File tree 3 files changed +19
-2
lines changed 3 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ importFrom(purrr,pmap)
31
31
importFrom(purrr,pwalk)
32
32
importFrom(purrr,reduce)
33
33
importFrom(purrr,when)
34
+ importFrom(rlang,is_installed)
34
35
importFrom(rlang,seq2)
35
36
importFrom(utils,tail)
36
37
importFrom(utils,write.table)
Original file line number Diff line number Diff line change @@ -16,12 +16,20 @@ construct_vertical <- function(x) {
16
16
# ' @param colored Whether or not the output should be colored with
17
17
# ' `prettycode::highlight()`.
18
18
# ' @param style Passed to `prettycode::highlight()`.
19
+ # ' @importFrom rlang is_installed
19
20
# ' @export
20
21
print.vertical <- function (x , ... ,
21
- colored = TRUE ,
22
+ colored = getOption( " styler.colored_print.vertical " ) ,
22
23
style = prettycode :: default_style()) {
23
24
if (colored ) {
24
- x <- prettycode :: highlight(x , style = style )
25
+ if (is_installed(" prettycode" )) {
26
+ x <- prettycode :: highlight(x , style = style )
27
+ } else {
28
+ warn(c(
29
+ " Could not use colored = TRUE, as the package prettycode is not" ,
30
+ " installed. Please install it if you want to see colored output."
31
+ ))
32
+ }
25
33
}
26
34
cat(x , sep = " \n " )
27
35
}
Original file line number Diff line number Diff line change 1
1
.onLoad <- function (libname , pkgname ) {
2
2
backports :: import(pkgname , " trimws" )
3
+ op <- options()
4
+ op.styler <- list (
5
+ styler.colored_print.vertical = TRUE
6
+ )
7
+ toset <- ! (names(op.styler ) %in% names(op ))
8
+ if (any(toset )) options(op.styler [toset ])
9
+ invisible ()
3
10
}
11
+
You can’t perform that action at this time.
0 commit comments