Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document and export ansi_string #574

Merged
merged 5 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export(ansi_palettes)
export(ansi_regex)
export(ansi_show_cursor)
export(ansi_simplify)
export(ansi_string)
export(ansi_strip)
export(ansi_strsplit)
export(ansi_strtrim)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* `ansi_collapse(x, trunc = 1, style = "head")` now indeed show one element
if `length(x) == 2`, as documented (@salim-b, #572).

* `ansi_string()` is now an exported function (@multimeric, #573).

# cli 3.6.1

* ANSI hyperlinks are now turned off on the RStudio render plane (#581).
Expand Down
13 changes: 12 additions & 1 deletion R/ansiex.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@

#' Labels a character vector as containing ANSI control codes.
#'
#' This function sets the class of its argument, activating
#' ANSI-string-specific methods such as for printing.
#'
#' @param x A character vector or something that can be
#' coerced into one.
#' @return A `cli_ansi_string` object, a subclass of
#' `character`, with the same length and contents
#' as `x`.
#' @family low level ANSI functions
#' @export
ansi_string <- function(x) {
if (!is.character(x)) x <- as.character(x)
x <- enc2utf8(x)
Expand Down
1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ reference:
- ansi_nzchar
- ansi_regex
- ansi_simplify
- ansi_string
- ansi_strip
- ansi_strsplit
- ansi_strtrim
Expand Down
1 change: 1 addition & 0 deletions man/ansi_has_any.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/ansi_hide_cursor.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/ansi_regex.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions man/ansi_string.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/ansi_strip.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.