Skip to content

Commit

Permalink
Skip coverage of unused helper functions
Browse files Browse the repository at this point in the history
  • Loading branch information
edelarua committed Apr 16, 2024
1 parent 639ceda commit 80a9a0c
Showing 1 changed file with 33 additions and 33 deletions.
66 changes: 33 additions & 33 deletions R/decorate_grob.R
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ decorate_grob <- function(grob,
)
}

# nocov start
#' @importFrom grid validDetails
#' @noRd
validDetails.decoratedGrob <- function(x) {
Expand Down Expand Up @@ -266,38 +267,6 @@ heightDetails.decoratedGrob <- function(x) {
grid::unit(1, "null")
}

# Adapted from Paul Murell R Graphics 2nd Edition
# https://www.stat.auckland.ac.nz/~paul/RG2e/interactgrid-splittext.R
split_string <- function(text, width) {
strings <- strsplit(text, " ")
out_string <- NA
for (string_i in seq_along(strings)) {
newline_str <- strings[[string_i]]
if (length(newline_str) == 0) newline_str <- ""
if (is.na(out_string[string_i])) {
out_string[string_i] <- newline_str[[1]][[1]]
linewidth <- grid::stringWidth(out_string[string_i])
}
gapwidth <- grid::stringWidth(" ")
availwidth <- as.numeric(width)
if (length(newline_str) > 1) {
for (i in seq(2, length(newline_str))) {
width_i <- grid::stringWidth(newline_str[i])
if (grid::convertWidth(linewidth + gapwidth + width_i, grid::unitType(width), valueOnly = TRUE) < availwidth) {
sep <- " "
linewidth <- linewidth + gapwidth + width_i
} else {
sep <- "\n"
linewidth <- width_i
}
out_string[string_i] <- paste(out_string[string_i], newline_str[i], sep = sep)
}
}
}
paste(out_string, collapse = "\n")
}

# nocov start
#' Split text according to available text width
#'
#' Dynamically wrap text.
Expand Down Expand Up @@ -354,7 +323,6 @@ split_text_grob <- function(text,
draw = FALSE
)
}
# nocov end

#' @importFrom grid validDetails
#' @noRd
Expand Down Expand Up @@ -398,6 +366,38 @@ drawDetails.dynamicSplitText <- function(x, recording) {

grid::grid.draw(x)
}
# nocov end

# Adapted from Paul Murell R Graphics 2nd Edition
# https://www.stat.auckland.ac.nz/~paul/RG2e/interactgrid-splittext.R
split_string <- function(text, width) {
strings <- strsplit(text, " ")
out_string <- NA
for (string_i in seq_along(strings)) {
newline_str <- strings[[string_i]]
if (length(newline_str) == 0) newline_str <- ""
if (is.na(out_string[string_i])) {
out_string[string_i] <- newline_str[[1]][[1]]
linewidth <- grid::stringWidth(out_string[string_i])
}
gapwidth <- grid::stringWidth(" ")
availwidth <- as.numeric(width)
if (length(newline_str) > 1) {
for (i in seq(2, length(newline_str))) {
width_i <- grid::stringWidth(newline_str[i])
if (grid::convertWidth(linewidth + gapwidth + width_i, grid::unitType(width), valueOnly = TRUE) < availwidth) {
sep <- " "
linewidth <- linewidth + gapwidth + width_i
} else {
sep <- "\n"
linewidth <- width_i
}
out_string[string_i] <- paste(out_string[string_i], newline_str[i], sep = sep)
}
}
}
paste(out_string, collapse = "\n")
}

#' Update page number
#'
Expand Down

0 comments on commit 80a9a0c

Please sign in to comment.