r-lib / cli
1

2
box_styles <- function() {
3

4 1
  styles <- list(
5 1
    single = list(
6 1
      top_left     = "\u250c",
7 1
      top_right    = "\u2510",
8 1
      bottom_right = "\u2518",
9 1
      bottom_left  = "\u2514",
10 1
      vertical    = "\u2502",
11 1
      horizontal  = "\u2500"
12
    ),
13 1
    double = list(
14 1
      top_left = "\u2554",
15 1
      top_right = "\u2557",
16 1
      bottom_right = "\u255d",
17 1
      bottom_left = "\u255a",
18 1
      vertical = "\u2551",
19 1
      horizontal = "\u2550"
20
    ),
21 1
    round= list(
22 1
      top_left = "\u256d",
23 1
      top_right = "\u256e",
24 1
      bottom_right = "\u256f",
25 1
      bottom_left = "\u2570",
26 1
      vertical = "\u2502",
27 1
      horizontal = "\u2500"
28
    ),
29 1
    "single-double" = list(
30 1
      top_left = "\u2553",
31 1
      top_right = "\u2556",
32 1
      bottom_right = "\u255c",
33 1
      bottom_left = "\u2559",
34 1
      vertical = "\u2551",
35 1
      horizontal = "\u2500"
36
    ),
37 1
    "double-single" = list(
38 1
      top_left = "\u2552",
39 1
      top_right = "\u2555",
40 1
      bottom_right = "\u255b",
41 1
      bottom_left = "\u2558",
42 1
      vertical = "\u2502",
43 1
      horizontal = "\u2550"
44
    ),
45 1
    classic = list(
46 1
      top_left = "+",
47 1
      top_right = "+",
48 1
      bottom_right = "+",
49 1
      bottom_left = "+",
50 1
      vertical = "|",
51 1
      horizontal = "-"
52
    ),
53 1
    none = list(
54 1
      top_left = " ",
55 1
      top_right = " ",
56 1
      bottom_right = " ",
57 1
      bottom_left = " ",
58 1
      vertical = " ",
59 1
      horizontal = " "
60
    )
61
  )
62

63
  ## If the platform is not UTF-8, then we replace the styles that have
64
  ## Unicode characters, with the classic style.
65

66 1
  if (!is_utf8_output()) {
67 1
    for (n in setdiff(names(styles), c("classic", "none"))) {
68 1
      styles[[n]] <- styles[["classic"]]
69
    }
70
  }
71

72 1
  do.call(rbind, styles)
73
}
74

75
#' @export
76
#' @rdname boxx
77

78
list_border_styles <- function() {
79 1
  rownames(box_styles())
80
}

Read our documentation on viewing source code .

Loading