-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathboxcat.R
55 lines (49 loc) · 1.31 KB
/
boxcat.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# boxcat.R
# ::rtemis::
# 2019 E.D. Gennatas rtemis.org
#' Box cat
#'
#' `cat` with a box; a boxed cat
#'
#' @param x Character: Text to be output to console
#' @param style Integer: {1, 2}: 1: vintage style, 2: modern style. Default = 2
#' @param col Color: Any color fn
#' @param newline.pre Logical: If TRUE, start with a new line. Default = TRUE
#' @param newline Logical: If TRUE, end with a new (empty) line. Default = FALSE
#' @param pad Integer: Pad message with this many spaces on the left. Default = 0
#'
#' @author E.D. Gennatas
#' @keywords internal
#' @noRd
boxcat <- function(x,
col = NULL,
newline.pre = TRUE,
newline = FALSE,
pad = 0) {
x <- as.character(x)
if (newline.pre) cat("\n")
cat(rep(" ", pad), sep = "")
cat(gray(".:"))
if (!is.null(col)) {
cat(col(x, TRUE))
} else {
cat(bold(x))
}
cat("\n")
if (newline) cat("\n")
} # rtemis::boxcat
pastebox <- function(x, pad = 0) {
paste0(paste0(rep(" ", pad), collapse = ""), ".:", x)
}
# objcat.R
# ::rtemis::
# 2019 E.D. Gennatas rtemis.org
#' `rtemis-internal`: Object cat
#'
#' @param x Character: Object description
#' @author E.D. Gennatas
#' @keywords internal
#' @noRd
objcat <- function(x) {
cat(".:rtemis", orange(x, bold = TRUE), "\n")
} # rtemis::boxcat