diff --git a/R/progress.R b/R/progress.R index d72da62..84d54dd 100644 --- a/R/progress.R +++ b/R/progress.R @@ -246,9 +246,9 @@ pb_init <- function(self, private, format, total, width, stream, assert_character_scalar(format) assert_nonnegative_scalar(total <- as.numeric(total), na = TRUE) assert_nonzero_count(width) - assert_single_char(complete) - assert_single_char(incomplete) - assert_single_char(current) + assert_single_char(complete, strip_color = TRUE) + assert_single_char(incomplete, strip_color = TRUE) + assert_single_char(current, strip_color = TRUE) assert_function(callback) assert_flag(clear) assert_nonnegative_scalar(show_after) diff --git a/R/utils.R b/R/utils.R index ec41151..4ddc545 100644 --- a/R/utils.R +++ b/R/utils.R @@ -108,9 +108,14 @@ assert_connection <- function(x) { stopifnot(inherits(x, "connection")) } -assert_single_char <- function(x) { +#' @importFrom crayon col_nchar +assert_single_char <- function(x, strip_color = FALSE) { assert_character_scalar(x) - stopifnot(nchar(x) == 1) + if (strip_color) { + stopifnot(col_nchar(x) == 1) + } else { + stopifnot(nchar(x) == 1) + } } assert_function <- function(x) {