r-lib / cli
1
#' Various handy symbols to use in a command line UI
2
#'
3
#' @usage
4
#' symbol
5
#'
6
#' @format A named list, see \code{names(symbol)} for all sign names.
7
#'
8
#' @details
9
#'
10
#' On Windows they have a fallback to less fancy symbols.
11
#'
12
#' `list_symbols()` prints a table with all symbols to the screen.
13
#'
14
#' @name symbol
15
#' @aliases symbol
16
#' @export symbol
17
#'
18
#' @examples
19
#' cat(symbol$tick, " SUCCESS\n", symbol$cross, " FAILURE\n", sep = "")
20
#'
21
#' ## All symbols
22
#' cat(paste(format(names(symbol), width = 20),
23
#'   unlist(symbol)), sep = "\n")
24
NULL
25

26
symbol_utf8 <- list(
27
  "tick" = '\u2714',
28
  "cross" = '\u2716',
29
  "star" = '\u2605',
30
  "square" = '\u2587',
31
  "square_small" = '\u25FB',
32
  "square_small_filled" = '\u25FC',
33
  "circle" = '\u25EF',
34
  "circle_filled" = '\u25C9',
35
  "circle_dotted" = '\u25CC',
36
  "circle_double" = '\u25CE',
37
  "circle_circle" = '\u24DE',
38
  "circle_cross" = '\u24E7',
39
  "circle_pipe" = '\u24be',
40
  "circle_question_mark" = '?\u20DD',
41
  "bullet" = '\u25CF',
42
  "dot" = '\u2024',
43
  "line" = '\u2500',
44
  "double_line" = "\u2550",
45
  "ellipsis" = '\u2026',
46
  "continue" = '\u2026',
47
  "pointer" = '\u276F',
48
  "info" = '\u2139',
49
  "warning" = '\u26A0',
50
  "menu" = '\u2630',
51
  "smiley" = '\u263A',
52
  "mustache" = '\u0DF4',
53
  "heart" = '\u2665',
54
  "arrow_up" = '\u2191',
55
  "arrow_down" = '\u2193',
56
  "arrow_left" = '\u2190',
57
  "arrow_right" = '\u2192',
58
  "radio_on" = '\u25C9',
59
  "radio_off" = '\u25EF',
60
  "checkbox_on" = '\u2612',
61
  "checkbox_off" = '\u2610',
62
  "checkbox_circle_on" = '\u24E7',
63
  "checkbox_circle_off" = '\u24BE',
64
  "fancy_question_mark" = '\u2753',
65
  "neq" = "\u2260",
66
  "geq" = "\u2265",
67
  "leq" = "\u2264",
68
  "times" = "\u00d7",
69

70
  "upper_block_1" = "\u2594",
71
  "upper_block_4" = "\u2580",
72

73
  "lower_block_1" = "\u2581",
74
  "lower_block_2" = "\u2582",
75
  "lower_block_3" = "\u2583",
76
  "lower_block_4" = "\u2584",
77
  "lower_block_5" = "\u2585",
78
  "lower_block_6" = "\u2586",
79
  "lower_block_7" = "\u2587",
80
  "lower_block_8" = "\u2588",
81

82
  "full_block" = "\u2588",
83

84
  "sup_0" = "\u2070",
85
  "sup_1" = "\u00b9",
86
  "sup_2" = "\u00b2",
87
  "sup_3" = "\u00b3",
88
  "sup_4" = "\u2074",
89
  "sup_5" = "\u2075",
90
  "sup_6" = "\u2076",
91
  "sup_7" = "\u2077",
92
  "sup_8" = "\u2078",
93
  "sup_9" = "\u2079",
94

95
  "sup_minus" = "\u207b",
96
  "sup_plus" = "\u207a",
97

98
  "play" = "\u25b6",
99
  "stop" = "\u25a0",
100
  "record" = "\u25cf",
101

102
  "figure_dash" = "\u2012",
103
  "en_dash" = "\u2013",
104
  "em_dash" = "\u2014",
105

106
  "dquote_left" = "\u201c",
107
  "dquote_right" = "\u201d",
108
  "squote_left" = "\u2018",
109
  "squote_right" = "\u2019"
110
)
111

112
symbol_rstudio <- symbol_utf8
113
symbol_rstudio$tick <- "\u2713"
114
symbol_rstudio$cross <- "x"
115
symbol_rstudio$star <- "\u066d"
116
symbol_rstudio$square # ???
117
symbol_rstudio$square_small # ???
118
symbol_rstudio$suare_small_filled # ???
119
symbol_rstudio$circle_circle # ???
120
symbol_rstudio$circle_cross # ???
121
symbol_rstudio$circle_pipe # ???
122
symbol_rstudio$circle_question_mark # ???
123
symbol_rstudio$pointer <- ">"
124
symbol_rstudio$warning <- "!"
125
symbol_rstudio$menu # ???
126
symbol_rstudio$mustache # ???
127
symbol_rstudio$checkbox_circle_on # ???
128
symbol_rstudio$checkbox_circle_off # ???
129
symbol_rstudio$fancy_question_mark # ???
130

131
symbol_win <- list(
132
  "tick" = '\u221A',
133
  "cross" = 'x',
134
  "star" = '*',
135
  "square" = '\u2588',
136
  "square_small" = '[ ]',
137
  "square_small_filled" = '[\u2588]',
138
  "circle" = '( )',
139
  "circle_filled" = '(*)',
140
  "circle_dotted" = '( )',
141
  "circle_double" = '(o)',
142
  "circle_circle" = '(o)',
143
  "circle_cross" = '(x)',
144
  "circle_pipe" = '(|)',
145
  "circle_question_mark" = '(?)',
146
  "bullet" = '*',
147
  "dot" = '.',
148
  "line" = '-',
149
  "double_line" = "=",
150
  "ellipsis" = '...',
151
  "continue" = '~',
152
  "pointer" = '>',
153
  "info" = 'i',
154
  "warning" = '\u203C',
155
  "menu" = '\u2261',
156
  "smiley" = '\u263A',
157
  "mustache" = '\u250C\u2500\u2510',
158
  "heart" = '\u2665',
159
  "arrow_up" = '^',
160
  "arrow_down" = 'v',
161
  "arrow_left" = '<',
162
  "arrow_right" = '>',
163
  "radio_on" = '(*)',
164
  "radio_off" = '( )',
165
  "checkbox_on" = '[x]',
166
  "checkbox_off" = '[ ]',
167
  "checkbox_circle_on" = '(x)',
168
  "checkbox_circle_off" = '( )',
169
  "fancy_question_mark" = "(?)",
170
  "neq" = "!=",
171
  "geq" = ">=",
172
  "leq" = "<=",
173
  "times" = "x",
174

175
  "upper_block_1" = "^",
176
  "upper_block_4" = "^",
177

178
  "lower_block_1" = ".",
179
  "lower_block_2" = "_",
180
  "lower_block_3" = "_",
181
  "lower_block_4" = "=",
182
  "lower_block_5" = "=",
183
  "lower_block_6" = "*",
184
  "lower_block_7" = "\u2588",
185
  "lower_block_8" = "\u2588",
186

187
  "full_block" = "\u2588",
188

189
  "sup_0" = "0",
190
  "sup_1" = "1",
191
  "sup_2" = "2",
192
  "sup_3" = "3",
193
  "sup_4" = "4",
194
  "sup_5" = "5",
195
  "sup_6" = "6",
196
  "sup_7" = "7",
197
  "sup_8" = "8",
198
  "sup_9" = "9",
199

200
  "sup_minus" = "-",
201
  "sup_plus" = "+",
202

203
  "play" = ">",
204
  "stop" = "#",
205
  "record" = "o",
206

207
  "figure_dash" = "-",
208
  "en_dash" = "--",
209
  "em_dash" = "---",
210

211
  "dquote_left" = "\"",
212
  "dquote_right" = "\"",
213
  "squote_left" = "'",
214
  "squote_right" = "'"
215
)
216

217
symbol_ascii <- list(
218
  "tick" = 'v',
219
  "cross" = 'x',
220
  "star" = '*',
221
  "square" = '[ ]',
222
  "square_small" = '[ ]',
223
  "square_small_filled" = '[x]',
224
  "circle" = '( )',
225
  "circle_filled" = '(*)',
226
  "circle_dotted" = '( )',
227
  "circle_double" = '(o)',
228
  "circle_circle" = '(o)',
229
  "circle_cross" = '(x)',
230
  "circle_pipe" = '(|)',
231
  "circle_question_mark" = '(?)',
232
  "bullet" = '*',
233
  "dot" = '.',
234
  "line" = '-',
235
  "double_line" = "=",
236
  "ellipsis" = '...',
237
  "continue" = '~',
238
  "pointer" = '>',
239
  "info" = 'i',
240
  "warning" = '!',
241
  "menu" = '=',
242
  "smiley" = ':)',
243
  "mustache" = '/\\/',
244
  "heart" = '<3',
245
  "arrow_up" = '^',
246
  "arrow_down" = 'v',
247
  "arrow_left" = '<',
248
  "arrow_right" = '>',
249
  "radio_on" = '(*)',
250
  "radio_off" = '( )',
251
  "checkbox_on" = '[x]',
252
  "checkbox_off" = '[ ]',
253
  "checkbox_circle_on" = '(x)',
254
  "checkbox_circle_off" = '( )',
255
  "fancy_question_mark" = "(?)",
256
  "neq" = "!=",
257
  "geq" = ">=",
258
  "leq" = "<=",
259
  "times" = "x",
260

261
  "upper_block_1" = "^",
262
  "upper_block_4" = "^",
263

264
  "lower_block_1" = ".",
265
  "lower_block_2" = "_",
266
  "lower_block_3" = "_",
267
  "lower_block_4" = "=",
268
  "lower_block_5" = "=",
269
  "lower_block_6" = "*",
270
  "lower_block_7" = "#",
271
  "lower_block_8" = "#",
272

273
  "full_block" = "#",
274

275
  "sup_0" = "0",
276
  "sup_1" = "1",
277
  "sup_2" = "2",
278
  "sup_3" = "3",
279
  "sup_4" = "4",
280
  "sup_5" = "5",
281
  "sup_6" = "6",
282
  "sup_7" = "7",
283
  "sup_8" = "8",
284
  "sup_9" = "9",
285

286
  "sup_minus" = "-",
287
  "sup_plus" = "+",
288

289
  "play" = ">",
290
  "stop" = "#",
291
  "record" = "o",
292

293
  "figure_dash" = "-",
294
  "en_dash" = "--",
295
  "em_dash" = "---",
296

297
  "dquote_left" = "\"",
298
  "dquote_right" = "\"",
299
  "squote_left" = "'",
300
  "squote_right" = "'"
301
)
302

303
#' @export
304
#' @rdname symbol
305

306
list_symbols <- function() {
307 0
  rpad <- function(x, width) {
308 0
    w <- nchar(x, type = "width")
309 0
    paste0(x, strrep(" ", width - w))
310
  }
311 0
  chars <- rpad(paste0(symbol, "\t", names(symbol)), 25)
312 0
  if (length(chars) %% 2) chars <- c(chars, "")
313 0
  chars <- paste(
314 0
  sep = "   ",
315 0
  chars[1:(length(chars)/2)],
316 0
  chars[(length(chars)/2 + 1):length(chars)])
317 0
  cat(chars, sep = "\n")
318
}

Read our documentation on viewing source code .

Loading