Skip to content

Commit 9d1ad40

Browse files
authored
Add a GlyphSet class (flutter#7)
This makes it easier for a class or function to control whether it individually uses ASCII or Unicode glyphs.
1 parent b90cdca commit 9d1ad40

File tree

10 files changed

+1113
-287
lines changed

10 files changed

+1113
-287
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## 1.1.0
2+
3+
* Add a `GlyphSet` class that can be used to easily choose which set of glyphs
4+
to use for a particular chunk of code.
5+
6+
* Add `asciiGlyphs`, `unicodeGlyphs`, and `glyphs` getters that provide access
7+
to `GlyphSet`s.
8+
19
## 1.0.1
210

311
* Set max SDK version to `<3.0.0`.

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
This library contains getters for useful Unicode glyphs as well as plain ASCII
22
alternatives. It's intended to be used in command-line applications that may run
3-
on Windows and libraries that may be used by those applications.
3+
in places where Unicode isn't well-supported and libraries that may be used by
4+
those applications.
45

56
We recommend that you import this library with the prefix "glyph". For example:
67

@@ -14,12 +15,12 @@ String bulletedList(List<String> items) =>
1415

1516
## ASCII Mode
1617

17-
The default Windows `cmd.exe` shell is unable to display Unicode characters, so
18-
this package is able to transparently switch its glyphs to ASCII alternatives by
19-
setting [the `ascii` attribute][ascii]. When this attribute is `true`, all
20-
glyphs use ASCII characters instead. It currently defaults to `false`, although
21-
in the future it may default to `true` for applications running on the Dart VM
22-
on Windows. For example:
18+
Some shells are unable to display Unicode characters, so this package is able to
19+
transparently switch its glyphs to ASCII alternatives by setting [the `ascii`
20+
attribute][ascii]. When this attribute is `true`, all glyphs use ASCII
21+
characters instead. It currently defaults to `false`, although in the future it
22+
may default to `true` for applications running on the Dart VM on Windows. For
23+
example:
2324

2425
[ascii]: https://www.dartdocs.org/documentation/term_glyph/latest/term_glyph/ascii.html
2526

Lines changed: 322 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,322 @@
1+
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// Don't modify this file by hand! It's generated by tool/generate.dart.
6+
7+
import 'glyph_set.dart';
8+
9+
/// A [GlyphSet] that includes only ASCII glyphs.
10+
class AsciiGlyphSet implements GlyphSet {
11+
const AsciiGlyphSet();
12+
13+
/// Returns [glyph] if [this] supports Unicode glyphs and [alternative]
14+
/// otherwise.
15+
String glyphOrAscii(String glyph, String alternative) => alternative;
16+
17+
/// A bullet point.
18+
///
19+
/// Always "*" for [this].
20+
String get bullet => "*";
21+
22+
/// A left-pointing arrow.
23+
///
24+
/// Note that the Unicode arrow glyphs may overlap with adjacent characters in some
25+
/// terminal fonts, and should generally be surrounding by spaces.
26+
///
27+
/// Always "<" for [this].
28+
String get leftArrow => "<";
29+
30+
/// A right-pointing arrow.
31+
///
32+
/// Note that the Unicode arrow glyphs may overlap with adjacent characters in some
33+
/// terminal fonts, and should generally be surrounding by spaces.
34+
///
35+
/// Always ">" for [this].
36+
String get rightArrow => ">";
37+
38+
/// An upwards-pointing arrow.
39+
///
40+
/// Always "^" for [this].
41+
String get upArrow => "^";
42+
43+
/// A downwards-pointing arrow.
44+
///
45+
/// Always "v" for [this].
46+
String get downArrow => "v";
47+
48+
/// A two-character left-pointing arrow.
49+
///
50+
/// Always "<=" for [this].
51+
String get longLeftArrow => "<=";
52+
53+
/// A two-character right-pointing arrow.
54+
///
55+
/// Always "=>" for [this].
56+
String get longRightArrow => "=>";
57+
58+
/// A horizontal line that can be used to draw a box.
59+
///
60+
/// Always "-" for [this].
61+
String get horizontalLine => "-";
62+
63+
/// A vertical line that can be used to draw a box.
64+
///
65+
/// Always "|" for [this].
66+
String get verticalLine => "|";
67+
68+
/// The upper left-hand corner of a box.
69+
///
70+
/// Always "," for [this].
71+
String get topLeftCorner => ",";
72+
73+
/// The upper right-hand corner of a box.
74+
///
75+
/// Always "," for [this].
76+
String get topRightCorner => ",";
77+
78+
/// The lower left-hand corner of a box.
79+
///
80+
/// Always "'" for [this].
81+
String get bottomLeftCorner => "'";
82+
83+
/// The lower right-hand corner of a box.
84+
///
85+
/// Always "'" for [this].
86+
String get bottomRightCorner => "'";
87+
88+
/// An intersection of vertical and horizontal box lines.
89+
///
90+
/// Always "+" for [this].
91+
String get cross => "+";
92+
93+
/// A horizontal box line with a vertical line going up from the middle.
94+
///
95+
/// Always "+" for [this].
96+
String get teeUp => "+";
97+
98+
/// A horizontal box line with a vertical line going down from the middle.
99+
///
100+
/// Always "+" for [this].
101+
String get teeDown => "+";
102+
103+
/// A vertical box line with a horizontal line going left from the middle.
104+
///
105+
/// Always "+" for [this].
106+
String get teeLeft => "+";
107+
108+
/// A vertical box line with a horizontal line going right from the middle.
109+
///
110+
/// Always "+" for [this].
111+
String get teeRight => "+";
112+
113+
/// The top half of a vertical box line.
114+
///
115+
/// Always "'" for [this].
116+
String get upEnd => "'";
117+
118+
/// The bottom half of a vertical box line.
119+
///
120+
/// Always "," for [this].
121+
String get downEnd => ",";
122+
123+
/// The left half of a horizontal box line.
124+
///
125+
/// Always "-" for [this].
126+
String get leftEnd => "-";
127+
128+
/// The right half of a horizontal box line.
129+
///
130+
/// Always "-" for [this].
131+
String get rightEnd => "-";
132+
133+
/// A bold horizontal line that can be used to draw a box.
134+
///
135+
/// Always "=" for [this].
136+
String get horizontalLineBold => "=";
137+
138+
/// A bold vertical line that can be used to draw a box.
139+
///
140+
/// Always "|" for [this].
141+
String get verticalLineBold => "|";
142+
143+
/// The bold upper left-hand corner of a box.
144+
///
145+
/// Always "," for [this].
146+
String get topLeftCornerBold => ",";
147+
148+
/// The bold upper right-hand corner of a box.
149+
///
150+
/// Always "," for [this].
151+
String get topRightCornerBold => ",";
152+
153+
/// The bold lower left-hand corner of a box.
154+
///
155+
/// Always "'" for [this].
156+
String get bottomLeftCornerBold => "'";
157+
158+
/// The bold lower right-hand corner of a box.
159+
///
160+
/// Always "'" for [this].
161+
String get bottomRightCornerBold => "'";
162+
163+
/// An intersection of bold vertical and horizontal box lines.
164+
///
165+
/// Always "+" for [this].
166+
String get crossBold => "+";
167+
168+
/// A bold horizontal box line with a vertical line going up from the middle.
169+
///
170+
/// Always "+" for [this].
171+
String get teeUpBold => "+";
172+
173+
/// A bold horizontal box line with a vertical line going down from the middle.
174+
///
175+
/// Always "+" for [this].
176+
String get teeDownBold => "+";
177+
178+
/// A bold vertical box line with a horizontal line going left from the middle.
179+
///
180+
/// Always "+" for [this].
181+
String get teeLeftBold => "+";
182+
183+
/// A bold vertical box line with a horizontal line going right from the middle.
184+
///
185+
/// Always "+" for [this].
186+
String get teeRightBold => "+";
187+
188+
/// The top half of a bold vertical box line.
189+
///
190+
/// Always "'" for [this].
191+
String get upEndBold => "'";
192+
193+
/// The bottom half of a bold vertical box line.
194+
///
195+
/// Always "," for [this].
196+
String get downEndBold => ",";
197+
198+
/// The left half of a bold horizontal box line.
199+
///
200+
/// Always "-" for [this].
201+
String get leftEndBold => "-";
202+
203+
/// The right half of a bold horizontal box line.
204+
///
205+
/// Always "-" for [this].
206+
String get rightEndBold => "-";
207+
208+
/// A double horizontal line that can be used to draw a box.
209+
///
210+
/// Always "=" for [this].
211+
String get horizontalLineDouble => "=";
212+
213+
/// A double vertical line that can be used to draw a box.
214+
///
215+
/// Always "|" for [this].
216+
String get verticalLineDouble => "|";
217+
218+
/// The double upper left-hand corner of a box.
219+
///
220+
/// Always "," for [this].
221+
String get topLeftCornerDouble => ",";
222+
223+
/// The double upper right-hand corner of a box.
224+
///
225+
/// Always "," for [this].
226+
String get topRightCornerDouble => ",";
227+
228+
/// The double lower left-hand corner of a box.
229+
///
230+
/// Always '"' for [this].
231+
String get bottomLeftCornerDouble => '"';
232+
233+
/// The double lower right-hand corner of a box.
234+
///
235+
/// Always '"' for [this].
236+
String get bottomRightCornerDouble => '"';
237+
238+
/// An intersection of double vertical and horizontal box lines.
239+
///
240+
/// Always "+" for [this].
241+
String get crossDouble => "+";
242+
243+
/// A double horizontal box line with a vertical line going up from the middle.
244+
///
245+
/// Always "+" for [this].
246+
String get teeUpDouble => "+";
247+
248+
/// A double horizontal box line with a vertical line going down from the middle.
249+
///
250+
/// Always "+" for [this].
251+
String get teeDownDouble => "+";
252+
253+
/// A double vertical box line with a horizontal line going left from the middle.
254+
///
255+
/// Always "+" for [this].
256+
String get teeLeftDouble => "+";
257+
258+
/// A double vertical box line with a horizontal line going right from the middle.
259+
///
260+
/// Always "+" for [this].
261+
String get teeRightDouble => "+";
262+
263+
/// A dashed horizontal line that can be used to draw a box.
264+
///
265+
/// Always "-" for [this].
266+
String get horizontalLineDoubleDash => "-";
267+
268+
/// A bold dashed horizontal line that can be used to draw a box.
269+
///
270+
/// Always "-" for [this].
271+
String get horizontalLineDoubleDashBold => "-";
272+
273+
/// A dashed vertical line that can be used to draw a box.
274+
///
275+
/// Always "|" for [this].
276+
String get verticalLineDoubleDash => "|";
277+
278+
/// A bold dashed vertical line that can be used to draw a box.
279+
///
280+
/// Always "|" for [this].
281+
String get verticalLineDoubleDashBold => "|";
282+
283+
/// A dashed horizontal line that can be used to draw a box.
284+
///
285+
/// Always "-" for [this].
286+
String get horizontalLineTripleDash => "-";
287+
288+
/// A bold dashed horizontal line that can be used to draw a box.
289+
///
290+
/// Always "-" for [this].
291+
String get horizontalLineTripleDashBold => "-";
292+
293+
/// A dashed vertical line that can be used to draw a box.
294+
///
295+
/// Always "|" for [this].
296+
String get verticalLineTripleDash => "|";
297+
298+
/// A bold dashed vertical line that can be used to draw a box.
299+
///
300+
/// Always "|" for [this].
301+
String get verticalLineTripleDashBold => "|";
302+
303+
/// A dashed horizontal line that can be used to draw a box.
304+
///
305+
/// Always "-" for [this].
306+
String get horizontalLineQuadrupleDash => "-";
307+
308+
/// A bold dashed horizontal line that can be used to draw a box.
309+
///
310+
/// Always "-" for [this].
311+
String get horizontalLineQuadrupleDashBold => "-";
312+
313+
/// A dashed vertical line that can be used to draw a box.
314+
///
315+
/// Always "|" for [this].
316+
String get verticalLineQuadrupleDash => "|";
317+
318+
/// A bold dashed vertical line that can be used to draw a box.
319+
///
320+
/// Always "|" for [this].
321+
String get verticalLineQuadrupleDashBold => "|";
322+
}

0 commit comments

Comments
 (0)