Skip to content

Commit

Permalink
Use fansi::strip_ctl() instead of deprecated fansi::strip_sgr()
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy committed Jun 28, 2024
1 parent 7ccaec0 commit c8d22d8
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export(type_sum)
import(lifecycle)
import(rlang)
importFrom(cli,symbol)
importFrom(fansi,strip_sgr)
importFrom(fansi,strip_ctl)
importFrom(fansi,substr2_ctl)
importFrom(glue,as_glue)
importFrom(utf8,utf8_width)
Expand Down
4 changes: 2 additions & 2 deletions R/extent.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
#'
#' @param x A character vector.
#' @export
#' @importFrom fansi strip_sgr
#' @importFrom fansi strip_ctl
#' @importFrom utf8 utf8_width
#' @examples
#' get_extent(c("abc", "de"))
#' get_extent("\u904b\u6c23")
get_extent <- function(x) {
force(x)
x <- strip_sgr(x, warn = FALSE)
x <- strip_ctl(x, warn = FALSE)
width <- utf8_width(x, encode = FALSE, utf8 = TRUE)
if (anyNA(width)) {
is_na <- which(is.na(width))
Expand Down
2 changes: 1 addition & 1 deletion R/ggplot2.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ MakeScaleContinuousPositionNum <- function() {
},
get_labels = function(self, breaks = self$get_breaks()) {
out <- ggplot2::ggproto_parent(ggplot2::ScaleContinuousPosition, self)$get_labels(breaks)
fansi::strip_sgr(out)
fansi::strip_ctl(out)
},
make_title = function(self, title) {
out <- ggplot2::ggproto_parent(ggplot2::ScaleContinuousPosition, self)$make_title(title)
Expand Down
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cat_line <- function(...) {
}

#' @importFrom utf8 utf8_width
#' @importFrom fansi strip_sgr substr2_ctl
#' @importFrom fansi strip_ctl substr2_ctl
str_trunc <- function(x, width, shorten = NULL) {
if (all(is.infinite(width))) {
return(x)
Expand Down
2 changes: 1 addition & 1 deletion R/vctr.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ obj_print_data.pillar_vctr <- function(x, ..., .size) {
}

# FIXME: base::print.default() can't use color, roll own implementation?
out <- stats::setNames(strip_sgr(format(x), warn = FALSE), names(x))
out <- stats::setNames(strip_ctl(format(x), warn = FALSE), names(x))
print(out, quote = FALSE, max = vec_size(x))
invisible(x)
}
Expand Down

0 comments on commit c8d22d8

Please sign in to comment.