fast-rich 0.3.2

A Rust port of Python's Rich library for beautiful terminal formatting
Documentation
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
//! Emoji name to Unicode character mapping.
//!
//! Maps shortcodes like `:smile:` to their Unicode equivalents.

use std::collections::HashMap;
use std::sync::LazyLock;

/// Static emoji map.
static EMOJI_MAP: LazyLock<HashMap<&'static str, &'static str>> = LazyLock::new(|| {
    let mut m = HashMap::new();

    // Smileys & Emotion
    m.insert("smile", "๐Ÿ˜„");
    m.insert("smiley", "๐Ÿ˜ƒ");
    m.insert("grinning", "๐Ÿ˜€");
    m.insert("grin", "๐Ÿ˜");
    m.insert("joy", "๐Ÿ˜‚");
    m.insert("laughing", "๐Ÿ˜†");
    m.insert("sweat_smile", "๐Ÿ˜…");
    m.insert("rofl", "๐Ÿคฃ");
    m.insert("wink", "๐Ÿ˜‰");
    m.insert("blush", "๐Ÿ˜Š");
    m.insert("innocent", "๐Ÿ˜‡");
    m.insert("heart_eyes", "๐Ÿ˜");
    m.insert("kissing_heart", "๐Ÿ˜˜");
    m.insert("yum", "๐Ÿ˜‹");
    m.insert("stuck_out_tongue", "๐Ÿ˜›");
    m.insert("thinking", "๐Ÿค”");
    m.insert("shushing_face", "๐Ÿคซ");
    m.insert("raised_eyebrow", "๐Ÿคจ");
    m.insert("neutral_face", "๐Ÿ˜");
    m.insert("expressionless", "๐Ÿ˜‘");
    m.insert("no_mouth", "๐Ÿ˜ถ");
    m.insert("smirk", "๐Ÿ˜");
    m.insert("unamused", "๐Ÿ˜’");
    m.insert("roll_eyes", "๐Ÿ™„");
    m.insert("grimacing", "๐Ÿ˜ฌ");
    m.insert("relieved", "๐Ÿ˜Œ");
    m.insert("pensive", "๐Ÿ˜”");
    m.insert("sleepy", "๐Ÿ˜ช");
    m.insert("sleeping", "๐Ÿ˜ด");
    m.insert("drooling", "๐Ÿคค");
    m.insert("mask", "๐Ÿ˜ท");
    m.insert("nerd", "๐Ÿค“");
    m.insert("sunglasses", "๐Ÿ˜Ž");
    m.insert("confused", "๐Ÿ˜•");
    m.insert("worried", "๐Ÿ˜Ÿ");
    m.insert("frowning", "โ˜น๏ธ");
    m.insert("open_mouth", "๐Ÿ˜ฎ");
    m.insert("hushed", "๐Ÿ˜ฏ");
    m.insert("astonished", "๐Ÿ˜ฒ");
    m.insert("flushed", "๐Ÿ˜ณ");
    m.insert("pleading", "๐Ÿฅบ");
    m.insert("cry", "๐Ÿ˜ข");
    m.insert("sob", "๐Ÿ˜ญ");
    m.insert("scream", "๐Ÿ˜ฑ");
    m.insert("angry", "๐Ÿ˜ ");
    m.insert("rage", "๐Ÿ˜ก");
    m.insert("skull", "๐Ÿ’€");
    m.insert("poop", "๐Ÿ’ฉ");
    m.insert("pile_of_poo", "๐Ÿ’ฉ");
    m.insert("clown", "๐Ÿคก");
    m.insert("ghost", "๐Ÿ‘ป");
    m.insert("alien", "๐Ÿ‘ฝ");
    m.insert("robot", "๐Ÿค–");

    // People & Body
    m.insert("wave", "๐Ÿ‘‹");
    m.insert("raised_hand", "โœ‹");
    m.insert("ok_hand", "๐Ÿ‘Œ");
    m.insert("thumbs_up", "๐Ÿ‘");
    m.insert("thumbsup", "๐Ÿ‘");
    m.insert("+1", "๐Ÿ‘");
    m.insert("thumbs_down", "๐Ÿ‘Ž");
    m.insert("thumbsdown", "๐Ÿ‘Ž");
    m.insert("-1", "๐Ÿ‘Ž");
    m.insert("fist", "โœŠ");
    m.insert("punch", "๐Ÿ‘Š");
    m.insert("clap", "๐Ÿ‘");
    m.insert("raised_hands", "๐Ÿ™Œ");
    m.insert("open_hands", "๐Ÿ‘");
    m.insert("palms_up", "๐Ÿคฒ");
    m.insert("handshake", "๐Ÿค");
    m.insert("pray", "๐Ÿ™");
    m.insert("point_up", "โ˜๏ธ");
    m.insert("point_up_2", "๐Ÿ‘†");
    m.insert("point_down", "๐Ÿ‘‡");
    m.insert("point_left", "๐Ÿ‘ˆ");
    m.insert("point_right", "๐Ÿ‘‰");
    m.insert("middle_finger", "๐Ÿ–•");
    m.insert("hand", "โœ‹");
    m.insert("v", "โœŒ๏ธ");
    m.insert("pinched_fingers", "๐ŸคŒ");
    m.insert("love_you", "๐ŸคŸ");
    m.insert("metal", "๐Ÿค˜");
    m.insert("call_me", "๐Ÿค™");
    m.insert("muscle", "๐Ÿ’ช");
    m.insert("brain", "๐Ÿง ");
    m.insert("eyes", "๐Ÿ‘€");
    m.insert("eye", "๐Ÿ‘๏ธ");
    m.insert("tongue", "๐Ÿ‘…");
    m.insert("lips", "๐Ÿ‘„");
    m.insert("baby", "๐Ÿ‘ถ");
    m.insert("boy", "๐Ÿ‘ฆ");
    m.insert("girl", "๐Ÿ‘ง");
    m.insert("man", "๐Ÿ‘จ");
    m.insert("woman", "๐Ÿ‘ฉ");
    m.insert("older_man", "๐Ÿ‘ด");
    m.insert("older_woman", "๐Ÿ‘ต");

    // Animals & Nature
    m.insert("dog", "๐Ÿถ");
    m.insert("cat", "๐Ÿฑ");
    m.insert("mouse", "๐Ÿญ");
    m.insert("hamster", "๐Ÿน");
    m.insert("rabbit", "๐Ÿฐ");
    m.insert("fox", "๐ŸฆŠ");
    m.insert("bear", "๐Ÿป");
    m.insert("panda", "๐Ÿผ");
    m.insert("koala", "๐Ÿจ");
    m.insert("tiger", "๐Ÿฏ");
    m.insert("lion", "๐Ÿฆ");
    m.insert("cow", "๐Ÿฎ");
    m.insert("pig", "๐Ÿท");
    m.insert("frog", "๐Ÿธ");
    m.insert("monkey", "๐Ÿต");
    m.insert("see_no_evil", "๐Ÿ™ˆ");
    m.insert("hear_no_evil", "๐Ÿ™‰");
    m.insert("speak_no_evil", "๐Ÿ™Š");
    m.insert("chicken", "๐Ÿ”");
    m.insert("penguin", "๐Ÿง");
    m.insert("bird", "๐Ÿฆ");
    m.insert("eagle", "๐Ÿฆ…");
    m.insert("duck", "๐Ÿฆ†");
    m.insert("owl", "๐Ÿฆ‰");
    m.insert("bat", "๐Ÿฆ‡");
    m.insert("wolf", "๐Ÿบ");
    m.insert("horse", "๐Ÿด");
    m.insert("unicorn", "๐Ÿฆ„");
    m.insert("bee", "๐Ÿ");
    m.insert("bug", "๐Ÿ›");
    m.insert("butterfly", "๐Ÿฆ‹");
    m.insert("snail", "๐ŸŒ");
    m.insert("ladybug", "๐Ÿž");
    m.insert("ant", "๐Ÿœ");
    m.insert("spider", "๐Ÿ•ท๏ธ");
    m.insert("scorpion", "๐Ÿฆ‚");
    m.insert("crab", "๐Ÿฆ€");
    m.insert("snake", "๐Ÿ");
    m.insert("turtle", "๐Ÿข");
    m.insert("fish", "๐ŸŸ");
    m.insert("octopus", "๐Ÿ™");
    m.insert("whale", "๐Ÿณ");
    m.insert("dolphin", "๐Ÿฌ");
    m.insert("shark", "๐Ÿฆˆ");
    m.insert("crocodile", "๐ŸŠ");
    m.insert("dragon", "๐Ÿ‰");
    m.insert("dinosaur", "๐Ÿฆ•");
    m.insert("t_rex", "๐Ÿฆ–");
    m.insert("raccoon", "๐Ÿฆ");
    m.insert("vampire", "๐Ÿง›");

    // Food & Drink
    m.insert("apple", "๐ŸŽ");
    m.insert("green_apple", "๐Ÿ");
    m.insert("pear", "๐Ÿ");
    m.insert("orange", "๐ŸŠ");
    m.insert("lemon", "๐Ÿ‹");
    m.insert("banana", "๐ŸŒ");
    m.insert("watermelon", "๐Ÿ‰");
    m.insert("grapes", "๐Ÿ‡");
    m.insert("strawberry", "๐Ÿ“");
    m.insert("cherry", "๐Ÿ’");
    m.insert("peach", "๐Ÿ‘");
    m.insert("mango", "๐Ÿฅญ");
    m.insert("pineapple", "๐Ÿ");
    m.insert("coconut", "๐Ÿฅฅ");
    m.insert("avocado", "๐Ÿฅ‘");
    m.insert("eggplant", "๐Ÿ†");
    m.insert("potato", "๐Ÿฅ”");
    m.insert("carrot", "๐Ÿฅ•");
    m.insert("corn", "๐ŸŒฝ");
    m.insert("hot_pepper", "๐ŸŒถ๏ธ");
    m.insert("bread", "๐Ÿž");
    m.insert("croissant", "๐Ÿฅ");
    m.insert("pizza", "๐Ÿ•");
    m.insert("hamburger", "๐Ÿ”");
    m.insert("fries", "๐ŸŸ");
    m.insert("hotdog", "๐ŸŒญ");
    m.insert("taco", "๐ŸŒฎ");
    m.insert("burrito", "๐ŸŒฏ");
    m.insert("egg", "๐Ÿฅš");
    m.insert("cooking", "๐Ÿณ");
    m.insert("pancakes", "๐Ÿฅž");
    m.insert("bacon", "๐Ÿฅ“");
    m.insert("steak", "๐Ÿฅฉ");
    m.insert("poultry_leg", "๐Ÿ—");
    m.insert("sushi", "๐Ÿฃ");
    m.insert("ramen", "๐Ÿœ");
    m.insert("cake", "๐ŸŽ‚");
    m.insert("cookie", "๐Ÿช");
    m.insert("chocolate", "๐Ÿซ");
    m.insert("candy", "๐Ÿฌ");
    m.insert("lollipop", "๐Ÿญ");
    m.insert("icecream", "๐Ÿฆ");
    m.insert("donut", "๐Ÿฉ");
    m.insert("coffee", "โ˜•");
    m.insert("tea", "๐Ÿต");
    m.insert("beer", "๐Ÿบ");
    m.insert("beers", "๐Ÿป");
    m.insert("wine", "๐Ÿท");
    m.insert("cocktail", "๐Ÿธ");
    m.insert("champagne", "๐Ÿพ");

    // Objects & Symbols
    m.insert("heart", "โค");
    m.insert("red_heart", "โค");
    m.insert("orange_heart", "๐Ÿงก");
    m.insert("yellow_heart", "๐Ÿ’›");
    m.insert("green_heart", "๐Ÿ’š");
    m.insert("blue_heart", "๐Ÿ’™");
    m.insert("purple_heart", "๐Ÿ’œ");
    m.insert("black_heart", "๐Ÿ–ค");
    m.insert("white_heart", "๐Ÿค");
    m.insert("broken_heart", "๐Ÿ’”");
    m.insert("sparkling_heart", "๐Ÿ’–");
    m.insert("fire", "๐Ÿ”ฅ");
    m.insert("sparkles", "โœจ");
    m.insert("star", "โญ");
    m.insert("glowing_star", "๐ŸŒŸ");
    m.insert("sparkle", "โ‡๏ธ");
    m.insert("zap", "โšก");
    m.insert("boom", "๐Ÿ’ฅ");
    m.insert("sun", "โ˜€๏ธ");
    m.insert("moon", "๐ŸŒ™");
    m.insert("cloud", "โ˜๏ธ");
    m.insert("rainbow", "๐ŸŒˆ");
    m.insert("umbrella", "โ˜‚๏ธ");
    m.insert("snowflake", "โ„๏ธ");
    m.insert("snowman", "โ›„");
    m.insert("gift", "๐ŸŽ");
    m.insert("balloon", "๐ŸŽˆ");
    m.insert("tada", "๐ŸŽ‰");
    m.insert("party_popper", "๐ŸŽ‰");
    m.insert("confetti", "๐ŸŽŠ");
    m.insert("trophy", "๐Ÿ†");
    m.insert("medal", "๐Ÿ…");
    m.insert("first_place", "๐Ÿฅ‡");
    m.insert("second_place", "๐Ÿฅˆ");
    m.insert("third_place", "๐Ÿฅ‰");
    m.insert("soccer", "โšฝ");
    m.insert("basketball", "๐Ÿ€");
    m.insert("football", "๐Ÿˆ");
    m.insert("baseball", "โšพ");
    m.insert("tennis", "๐ŸŽพ");
    m.insert("guitar", "๐ŸŽธ");
    m.insert("microphone", "๐ŸŽค");
    m.insert("headphones", "๐ŸŽง");
    m.insert("video_game", "๐ŸŽฎ");
    m.insert("dice", "๐ŸŽฒ");
    m.insert("dart", "๐ŸŽฏ");
    m.insert("phone", "๐Ÿ“ฑ");
    m.insert("computer", "๐Ÿ’ป");
    m.insert("keyboard", "โŒจ๏ธ");
    m.insert("printer", "๐Ÿ–จ๏ธ");
    m.insert("mouse_pc", "๐Ÿ–ฑ๏ธ");
    m.insert("light_bulb", "๐Ÿ’ก");
    m.insert("bulb", "๐Ÿ’ก");
    m.insert("battery", "๐Ÿ”‹");
    m.insert("electric_plug", "๐Ÿ”Œ");
    m.insert("money", "๐Ÿ’ฐ");
    m.insert("dollar", "๐Ÿ’ต");
    m.insert("credit_card", "๐Ÿ’ณ");
    m.insert("gem", "๐Ÿ’Ž");
    m.insert("wrench", "๐Ÿ”ง");
    m.insert("hammer", "๐Ÿ”จ");
    m.insert("gear", "โš™๏ธ");
    m.insert("link", "๐Ÿ”—");
    m.insert("lock", "๐Ÿ”’");
    m.insert("unlock", "๐Ÿ”“");
    m.insert("key", "๐Ÿ”‘");
    m.insert("bell", "๐Ÿ””");
    m.insert("bookmark", "๐Ÿ”–");
    m.insert("flag", "๐Ÿšฉ");
    m.insert("triangular_flag", "๐Ÿšฉ");
    m.insert("checkered_flag", "๐Ÿ");
    m.insert("clock", "๐Ÿ•");
    m.insert("hourglass", "โณ");
    m.insert("watch", "โŒš");
    m.insert("alarm_clock", "โฐ");
    m.insert("stopwatch", "โฑ๏ธ");
    m.insert("calendar", "๐Ÿ“…");
    m.insert("memo", "๐Ÿ“");
    m.insert("pencil", "โœ๏ธ");
    m.insert("pen", "๐Ÿ–Š๏ธ");
    m.insert("book", "๐Ÿ“–");
    m.insert("books", "๐Ÿ“š");
    m.insert("newspaper", "๐Ÿ“ฐ");
    m.insert("folder", "๐Ÿ“");
    m.insert("inbox_tray", "๐Ÿ“ฅ");
    m.insert("outbox_tray", "๐Ÿ“ค");
    m.insert("envelope", "โœ‰๏ธ");
    m.insert("email", "๐Ÿ“ง");
    m.insert("package", "๐Ÿ“ฆ");
    m.insert("clipboard", "๐Ÿ“‹");
    m.insert("pushpin", "๐Ÿ“Œ");
    m.insert("paperclip", "๐Ÿ“Ž");
    m.insert("scissors", "โœ‚๏ธ");
    m.insert("wastebasket", "๐Ÿ—‘๏ธ");

    // Status & Indicators
    m.insert("check", "โœ“");
    m.insert("checkmark", "โœ“");
    m.insert("check_mark", "โœ”๏ธ");
    m.insert("white_check_mark", "โœ…");
    m.insert("x", "โŒ");
    m.insert("cross", "โŒ");
    m.insert("cross_mark", "โŒ");
    m.insert("negative_squared_cross_mark", "โŽ");
    m.insert("question", "โ“");
    m.insert("grey_question", "โ”");
    m.insert("exclamation", "โ—");
    m.insert("grey_exclamation", "โ•");
    m.insert("warning", "โš ๏ธ");
    m.insert("no_entry", "โ›”");
    m.insert("prohibited", "๐Ÿšซ");
    m.insert("sos", "๐Ÿ†˜");
    m.insert("info", "โ„น๏ธ");
    m.insert("ok", "๐Ÿ†—");
    m.insert("new", "๐Ÿ†•");
    m.insert("free", "๐Ÿ†“");
    m.insert("up", "๐Ÿ†™");
    m.insert("cool", "๐Ÿ†’");
    m.insert("vs", "๐Ÿ†š");
    m.insert("100", "๐Ÿ’ฏ");
    m.insert("arrow_up", "โฌ†๏ธ");
    m.insert("arrow_down", "โฌ‡๏ธ");
    m.insert("arrow_left", "โฌ…๏ธ");
    m.insert("arrow_right", "โžก๏ธ");
    m.insert("arrow_upper_right", "โ†—๏ธ");
    m.insert("arrow_lower_right", "โ†˜๏ธ");
    m.insert("arrow_lower_left", "โ†™๏ธ");
    m.insert("arrow_upper_left", "โ†–๏ธ");
    m.insert("arrows_counterclockwise", "๐Ÿ”„");
    m.insert("back", "๐Ÿ”™");
    m.insert("end", "๐Ÿ”š");
    m.insert("on", "๐Ÿ”›");
    m.insert("soon", "๐Ÿ”œ");
    m.insert("top", "๐Ÿ”");
    m.insert("arrow_forward", "โ–ถ๏ธ");
    m.insert("arrow_backward", "โ—€๏ธ");
    m.insert("play_pause", "โฏ๏ธ");
    m.insert("stop_button", "โน๏ธ");
    m.insert("record_button", "โบ๏ธ");
    m.insert("fast_forward", "โฉ");
    m.insert("rewind", "โช");
    m.insert("repeat", "๐Ÿ”");
    m.insert("shuffle", "๐Ÿ”€");
    m.insert("radio_button", "๐Ÿ”˜");
    m.insert("white_circle", "โšช");
    m.insert("black_circle", "โšซ");
    m.insert("red_circle", "๐Ÿ”ด");
    m.insert("blue_circle", "๐Ÿ”ต");
    m.insert("green_circle", "๐ŸŸข");
    m.insert("yellow_circle", "๐ŸŸก");
    m.insert("orange_circle", "๐ŸŸ ");
    m.insert("purple_circle", "๐ŸŸฃ");
    m.insert("brown_circle", "๐ŸŸค");
    m.insert("white_square", "โฌœ");
    m.insert("black_square", "โฌ›");
    m.insert("red_square", "๐ŸŸฅ");
    m.insert("blue_square", "๐ŸŸฆ");
    m.insert("green_square", "๐ŸŸฉ");
    m.insert("yellow_square", "๐ŸŸจ");
    m.insert("orange_square", "๐ŸŸง");
    m.insert("purple_square", "๐ŸŸช");
    m.insert("brown_square", "๐ŸŸซ");

    // Development
    m.insert("rocket", "๐Ÿš€");
    m.insert("construction", "๐Ÿšง");
    m.insert("mag", "๐Ÿ”");
    m.insert("search", "๐Ÿ”");
    m.insert("mag_right", "๐Ÿ”Ž");
    m.insert("speech_balloon", "๐Ÿ’ฌ");
    m.insert("thought_balloon", "๐Ÿ’ญ");
    m.insert("nail_care", "๐Ÿ’…");
    m.insert("zany_face", "๐Ÿคช");
    m.insert("monocle", "๐Ÿง");
    m.insert("nerd_face", "๐Ÿค“");
    m.insert("partying_face", "๐Ÿฅณ");
    m.insert("mechanical_arm", "๐Ÿฆพ");
    m.insert("mechanical_leg", "๐Ÿฆฟ");

    m
});

/// Get the emoji character for a given name.
///
/// Returns `None` if the emoji is not found.
pub fn get_emoji(name: &str) -> Option<&'static str> {
    EMOJI_MAP.get(name).copied()
}

/// Check if an emoji name is valid.
pub fn is_valid_emoji(name: &str) -> bool {
    EMOJI_MAP.contains_key(name)
}

/// Get all available emoji names.
pub fn all_emoji_names() -> impl Iterator<Item = &'static str> {
    EMOJI_MAP.keys().copied()
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_get_emoji() {
        assert_eq!(get_emoji("smile"), Some("๐Ÿ˜„"));
        assert_eq!(get_emoji("thumbs_up"), Some("๐Ÿ‘"));
        assert_eq!(get_emoji("heart"), Some("โค")); // heart emoji without variation selector
        assert_eq!(get_emoji("rocket"), Some("๐Ÿš€"));
    }

    #[test]
    fn test_unknown_emoji() {
        assert_eq!(get_emoji("nonexistent"), None);
    }

    #[test]
    fn test_is_valid_emoji() {
        assert!(is_valid_emoji("smile"));
        assert!(!is_valid_emoji("unknown"));
    }

    #[test]
    fn test_all_emoji_names() {
        let names: Vec<_> = all_emoji_names().collect();
        assert!(names.contains(&"smile"));
        assert!(names.contains(&"heart"));
        assert!(names.len() > 100); // We should have at least 100 emojis
    }
}