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
//! Glyph configuration for scrollbar rendering.
/// Glyphs used to render the track, arrows, and thumb.
///
/// Arrays use indices 0..=7 to represent 1/8th through full coverage.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct GlyphSet {
/// Track glyph for vertical scrollbars.
pub track_vertical: char,
/// Track glyph for horizontal scrollbars.
pub track_horizontal: char,
/// Arrow glyph for the start of a vertical scrollbar (top).
pub arrow_vertical_start: char,
/// Arrow glyph for the end of a vertical scrollbar (bottom).
pub arrow_vertical_end: char,
/// Arrow glyph for the start of a horizontal scrollbar (left).
pub arrow_horizontal_start: char,
/// Arrow glyph for the end of a horizontal scrollbar (right).
pub arrow_horizontal_end: char,
/// Thumb glyphs for vertical lower fills (1/8th through full).
pub thumb_vertical_lower: [char; 8],
/// Thumb glyphs for vertical upper fills (1/8th through full).
pub thumb_vertical_upper: [char; 8],
/// Thumb glyphs for horizontal left fills (1/8th through full).
pub thumb_horizontal_left: [char; 8],
/// Thumb glyphs for horizontal right fills (1/8th through full).
pub thumb_horizontal_right: [char; 8],
}
impl GlyphSet {
/// Minimal glyphs: no visible track by default.
///
/// Choose this when the thumb should stand out by color against a filled background instead of
/// a visible line.
///
/// This uses a space character for the track so the scrollbar is "all thumb", with the
/// background color coming from `track_style`.
///
/// ```plain
/// [██ ]
/// [🮋█▏ ]
/// [🮊█▎ ]
/// [🮉█▍ ]
/// [▐█▌ ]
/// [🮈█▋ ]
/// [🮇█▊ ]
/// [▕█▉ ]
/// [ ██ ]
/// ```
pub const fn minimal() -> Self {
let mut glyphs = Self::symbols_for_legacy_computing();
glyphs.track_vertical = ' ';
glyphs.track_horizontal = ' ';
glyphs
}
/// Glyphs that include box-drawing line symbols for the track.
///
/// Choose this when callers should see a visible track line behind the thumb.
///
/// ```plain
/// [██──────]
/// [🮋█▏─────]
/// [🮊█▎─────]
/// [🮉█▍─────]
/// [▐█▌─────]
/// [🮈█▋─────]
/// [🮇█▊─────]
/// [▕█▉─────]
/// [─██─────]
/// ```
pub const fn box_drawing() -> Self {
Self::symbols_for_legacy_computing()
}
/// Glyphs that mix standard block elements with legacy supplement glyphs.
///
/// Choose this when the terminal font supports [Symbols for Legacy Computing] and you want
/// precise 1/8th-cell rendering on every thumb edge.
///
/// Use this to get full 1/8th coverage for upper and right edges that the standard block set
/// lacks; these glyphs come from [Symbols for Legacy Computing].
///
/// ```plain
/// [██──────]
/// [🮋█▏─────]
/// [🮊█▎─────]
/// [🮉█▍─────]
/// [▐█▌─────]
/// [🮈█▋─────]
/// [🮇█▊─────]
/// [▕█▉─────]
/// [─██─────]
/// ```
///
/// [Symbols for Legacy Computing]: https://en.wikipedia.org/wiki/Symbols_for_Legacy_Computing
pub const fn symbols_for_legacy_computing() -> Self {
let vertical_lower = ['▁', '▂', '▃', '▄', '▅', '▆', '▇', '█'];
let vertical_upper = ['▔', '🮂', '🮃', '▀', '🮄', '🮅', '🮆', '█'];
let horizontal_left = ['▏', '▎', '▍', '▌', '▋', '▊', '▉', '█'];
let horizontal_right = ['▕', '🮇', '🮈', '▐', '🮉', '🮊', '🮋', '█'];
Self {
track_vertical: '│',
track_horizontal: '─',
arrow_vertical_start: '▲',
arrow_vertical_end: '▼',
arrow_horizontal_start: '◀',
arrow_horizontal_end: '▶',
thumb_vertical_lower: vertical_lower,
thumb_vertical_upper: vertical_upper,
thumb_horizontal_left: horizontal_left,
thumb_horizontal_right: horizontal_right,
}
}
/// Glyphs using only standard Unicode block elements.
///
/// Choose this if your font lacks the legacy glyphs.
///
/// The standard block set does not include 1/8th upper or right fills (those come from
/// [Symbols for Legacy Computing]), so this set approximates upper and right partials by
/// rounding to coarse blocks:
///
/// - ~1/4: `▔` / `▕`
/// - ~1/2 and ~3/4: `▀` / `▐`
/// - ~7/8 and full: `█`
///
/// ```plain
/// [██──────]
/// [██▏─────]
/// [▐█▎─────]
/// [▐█▍─────]
/// [▐█▌─────]
/// [▐█▋─────]
/// [▕█▊─────]
/// [▕█▉─────]
/// [─██─────]
/// ```
///
/// [Symbols for Legacy Computing]: https://en.wikipedia.org/wiki/Symbols_for_Legacy_Computing
pub const fn unicode() -> Self {
let vertical_lower = ['▁', '▂', '▃', '▄', '▅', '▆', '▇', '█'];
let vertical_upper = ['▔', '▔', '▀', '▀', '▀', '▀', '█', '█'];
let horizontal_left = ['▏', '▎', '▍', '▌', '▋', '▊', '▉', '█'];
let horizontal_right = ['▕', '▕', '▐', '▐', '▐', '▐', '█', '█'];
Self {
track_vertical: '│',
track_horizontal: '─',
arrow_vertical_start: '▲',
arrow_vertical_end: '▼',
arrow_horizontal_start: '◀',
arrow_horizontal_end: '▶',
thumb_vertical_lower: vertical_lower,
thumb_vertical_upper: vertical_upper,
thumb_horizontal_left: horizontal_left,
thumb_horizontal_right: horizontal_right,
}
}
}
impl Default for GlyphSet {
fn default() -> Self {
Self::minimal()
}
}