Add the package's contents. (#1)
diff --git a/README.md b/README.md index 44458b0..5459994 100644 --- a/README.md +++ b/README.md
@@ -1,3 +1,42 @@ -This library contains getters for useful semantic symbols. Because `cmd.exe` on -Windows can't display Unicode, it also provides a mode where the symbols are -replaced with plain-ASCII equivalents. +This library contains getters for useful Unicode glyphs as well as plain ASCII +alternatives. It's intended to be used in command-line applications that may run +on Windows and libraries that may be used by those applications. + +We recommend that you import this library with the prefix "glyph". For example: + +```dart +import 'package:term_glyph/term_glyph.dart' as glyph; + +/// Formats [items] into a bulleted list, with one item per line. +String bulletedList(List<String> items) => + items.map((item) => "${glyph.bullet} $item").join("\n"); +``` + +## ASCII Mode + +The default Windows `cmd.exe` shell is unable to display Unicode characters, so +this package is able to transparently switch its glyphs to ASCII alternatives by +setting [the `ascii` attribute][ascii]. When this attribute is `true`, all +glyphs use ASCII characters instead. It currently defaults to `false`, although +in the future it may default to `true` for applications running on the Dart VM +on Windows. For example: + +[ascii]: https://www.dartdocs.org/documentation/term_glyph/latest/term_glyph/ascii.html + +```dart +import 'dart:io'; + +import 'package:term_glyph/term_glyph.dart' as glyph; + +void main() { + glyph.ascii = Platform.isWindows; + + // Prints "Unicode => ASCII" on Windows, "Unicode ━▶ ASCII" everywhere else. + print("Unicode ${glyph.rightArrow} ASCII"); +} +``` + +All ASCII glyphs are guaranteed to be the same number of characters as the +corresponding Unicode glyphs, so that they line up properly when printed on a +terminal. The specific ASCII text for a given Unicode glyph may change over +time; this is not considered a breaking change.
diff --git a/data.csv b/data.csv new file mode 100644 index 0000000..92a72f7 --- /dev/null +++ b/data.csv
@@ -0,0 +1,85 @@ +# Miscellaneous +bullet,•,*,A bullet point. + +# Arrows +leftArrow,←,<,"A left-pointing arrow. + +Note that the Unicode arrow glyphs may overlap with adjacent characters in some +terminal fonts, and should generally be surrounding by spaces." +rightArrow,→,>,"A right-pointing arrow. + +Note that the Unicode arrow glyphs may overlap with adjacent characters in some +terminal fonts, and should generally be surrounding by spaces." +upArrow,↑,^,An upwards-pointing arrow. +downArrow,↓,v,A downwards-pointing arrow. +longLeftArrow,◀━,<=,A two-character left-pointing arrow. +longRightArrow,━▶,=>,A two-character right-pointing arrow. + +# Box drawing characters + +## Normal +horizontalLine,─,-,A horizontal line that can be used to draw a box. +verticalLine,│,|,A vertical line that can be used to draw a box. +topLeftCorner,┌,",",The upper left-hand corner of a box. +topRightCorner,┐,",",The upper right-hand corner of a box. +bottomLeftCorner,└,',The lower left-hand corner of a box. +bottomRightCorner,┘,',The lower right-hand corner of a box. +cross,┼,+,An intersection of vertical and horizontal box lines. +teeUp,┴,+,A horizontal box line with a vertical line going up from the middle. +teeDown,┬,+,A horizontal box line with a vertical line going down from the middle. +teeLeft,┤,+,A vertical box line with a horizontal line going left from the middle. +teeRight,├,+,A vertical box line with a horizontal line going right from the middle. +upEnd,╵,',The top half of a vertical box line. +downEnd,╷,",",The bottom half of a vertical box line. +leftEnd,╴,-,The left half of a horizontal box line. +rightEnd,╶,-,The right half of a horizontal box line. + +## Bold +horizontalLineBold,━,=,A bold horizontal line that can be used to draw a box. +verticalLineBold,┃,|,A bold vertical line that can be used to draw a box. +topLeftCornerBold,┏,",",The bold upper left-hand corner of a box. +topRightCornerBold,┓,",",The bold upper right-hand corner of a box. +bottomLeftCornerBold,┗,',The bold lower left-hand corner of a box. +bottomRightCornerBold,┛,',The bold lower right-hand corner of a box. +crossBold,╋,+,An intersection of bold vertical and horizontal box lines. +teeUpBold,┻,+,A bold horizontal box line with a vertical line going up from the middle. +teeDownBold,┳,+,A bold horizontal box line with a vertical line going down from the middle. +teeLeftBold,┫,+,A bold vertical box line with a horizontal line going left from the middle. +teeRightBold,┣,+,A bold vertical box line with a horizontal line going right from the middle. +upEndBold,╹,',The top half of a bold vertical box line. +downEndBold,╻,",",The bottom half of a bold vertical box line. +leftEndBold,╸,-,The left half of a bold horizontal box line. +rightEndBold,╺,-,The right half of a bold horizontal box line. + +## Double +horizontalLineDouble,═,=,A double horizontal line that can be used to draw a box. +verticalLineDouble,║,|,A double vertical line that can be used to draw a box. +topLeftCornerDouble,╔,",",The double upper left-hand corner of a box. +topRightCornerDouble,╗,",",The double upper right-hand corner of a box. +bottomLeftCornerDouble,╚,"""",The double lower left-hand corner of a box. +bottomRightCornerDouble,╝,"""",The double lower right-hand corner of a box. +crossDouble,╬,+,An intersection of double vertical and horizontal box lines. +teeUpDouble,╩,+,A double horizontal box line with a vertical line going up from the middle. +teeDownDouble,╦,+,A double horizontal box line with a vertical line going down from the middle. +teeLeftDouble,╣,+,A double vertical box line with a horizontal line going left from the middle. +teeRightDouble,╠,+,A double vertical box line with a horizontal line going right from the middle. + +## Dashed + +### Double +horizontalLineDoubleDash,╌,-,A dashed horizontal line that can be used to draw a box. +horizontalLineDoubleDashBold,╍,-,A bold dashed horizontal line that can be used to draw a box. +verticalLineDoubleDash,╎,|,A dashed vertical line that can be used to draw a box. +verticalLineDoubleDashBold,╏,|,A bold dashed vertical line that can be used to draw a box. + +### Triple +horizontalLineTripleDash,┄,-,A dashed horizontal line that can be used to draw a box. +horizontalLineTripleDashBold,┅,-,A bold dashed horizontal line that can be used to draw a box. +verticalLineTripleDash,┆,|,A dashed vertical line that can be used to draw a box. +verticalLineTripleDashBold,┇,|,A bold dashed vertical line that can be used to draw a box. + +### Quadruple +horizontalLineQuadrupleDash,┈,-,A dashed horizontal line that can be used to draw a box. +horizontalLineQuadrupleDashBold,┉,-,A bold dashed horizontal line that can be used to draw a box. +verticalLineQuadrupleDash,┊,|,A dashed vertical line that can be used to draw a box. +verticalLineQuadrupleDashBold,┋,|,A bold dashed vertical line that can be used to draw a box.
diff --git a/lib/src/generated.dart b/lib/src/generated.dart new file mode 100644 index 0000000..e1b83d1 --- /dev/null +++ b/lib/src/generated.dart
@@ -0,0 +1,564 @@ +// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Don't modify this file by hand! It's generated by tool/generate.dart. + +/// Whether the glyph getters return plain ASCII, as opposed to Unicode +/// characters or sequences. +/// +/// Defaults to `false`. +bool get ascii => _ascii; +var _ascii = false; +set ascii(bool value) { + _ascii = value; + if (value) { + _bullet = "*"; + _leftArrow = "<"; + _rightArrow = ">"; + _upArrow = "^"; + _downArrow = "v"; + _longLeftArrow = "<="; + _longRightArrow = "=>"; + _horizontalLine = "-"; + _verticalLine = "|"; + _topLeftCorner = ","; + _topRightCorner = ","; + _bottomLeftCorner = "'"; + _bottomRightCorner = "'"; + _cross = "+"; + _teeUp = "+"; + _teeDown = "+"; + _teeLeft = "+"; + _teeRight = "+"; + _upEnd = "'"; + _downEnd = ","; + _leftEnd = "-"; + _rightEnd = "-"; + _horizontalLineBold = "="; + _verticalLineBold = "|"; + _topLeftCornerBold = ","; + _topRightCornerBold = ","; + _bottomLeftCornerBold = "'"; + _bottomRightCornerBold = "'"; + _crossBold = "+"; + _teeUpBold = "+"; + _teeDownBold = "+"; + _teeLeftBold = "+"; + _teeRightBold = "+"; + _upEndBold = "'"; + _downEndBold = ","; + _leftEndBold = "-"; + _rightEndBold = "-"; + _horizontalLineDouble = "="; + _verticalLineDouble = "|"; + _topLeftCornerDouble = ","; + _topRightCornerDouble = ","; + _bottomLeftCornerDouble = '"'; + _bottomRightCornerDouble = '"'; + _crossDouble = "+"; + _teeUpDouble = "+"; + _teeDownDouble = "+"; + _teeLeftDouble = "+"; + _teeRightDouble = "+"; + _horizontalLineDoubleDash = "-"; + _horizontalLineDoubleDashBold = "-"; + _verticalLineDoubleDash = "|"; + _verticalLineDoubleDashBold = "|"; + _horizontalLineTripleDash = "-"; + _horizontalLineTripleDashBold = "-"; + _verticalLineTripleDash = "|"; + _verticalLineTripleDashBold = "|"; + _horizontalLineQuadrupleDash = "-"; + _horizontalLineQuadrupleDashBold = "-"; + _verticalLineQuadrupleDash = "|"; + _verticalLineQuadrupleDashBold = "|"; + } else { + _bullet = "•"; + _leftArrow = "←"; + _rightArrow = "→"; + _upArrow = "↑"; + _downArrow = "↓"; + _longLeftArrow = "◀━"; + _longRightArrow = "━▶"; + _horizontalLine = "─"; + _verticalLine = "│"; + _topLeftCorner = "┌"; + _topRightCorner = "┐"; + _bottomLeftCorner = "└"; + _bottomRightCorner = "┘"; + _cross = "┼"; + _teeUp = "┴"; + _teeDown = "┬"; + _teeLeft = "┤"; + _teeRight = "├"; + _upEnd = "╵"; + _downEnd = "╷"; + _leftEnd = "╴"; + _rightEnd = "╶"; + _horizontalLineBold = "━"; + _verticalLineBold = "┃"; + _topLeftCornerBold = "┏"; + _topRightCornerBold = "┓"; + _bottomLeftCornerBold = "┗"; + _bottomRightCornerBold = "┛"; + _crossBold = "╋"; + _teeUpBold = "┻"; + _teeDownBold = "┳"; + _teeLeftBold = "┫"; + _teeRightBold = "┣"; + _upEndBold = "╹"; + _downEndBold = "╻"; + _leftEndBold = "╸"; + _rightEndBold = "╺"; + _horizontalLineDouble = "═"; + _verticalLineDouble = "║"; + _topLeftCornerDouble = "╔"; + _topRightCornerDouble = "╗"; + _bottomLeftCornerDouble = "╚"; + _bottomRightCornerDouble = "╝"; + _crossDouble = "╬"; + _teeUpDouble = "╩"; + _teeDownDouble = "╦"; + _teeLeftDouble = "╣"; + _teeRightDouble = "╠"; + _horizontalLineDoubleDash = "╌"; + _horizontalLineDoubleDashBold = "╍"; + _verticalLineDoubleDash = "╎"; + _verticalLineDoubleDashBold = "╏"; + _horizontalLineTripleDash = "┄"; + _horizontalLineTripleDashBold = "┅"; + _verticalLineTripleDash = "┆"; + _verticalLineTripleDashBold = "┇"; + _horizontalLineQuadrupleDash = "┈"; + _horizontalLineQuadrupleDashBold = "┉"; + _verticalLineQuadrupleDash = "┊"; + _verticalLineQuadrupleDashBold = "┋"; + } +} + +/// A bullet point. +/// +/// If [ascii] is `false`, this is "•". If it's `true`, this is +/// "*" instead. +String get bullet => _bullet; +var _bullet = "•"; + +/// A left-pointing arrow. +/// +/// Note that the Unicode arrow glyphs may overlap with adjacent characters in some +/// terminal fonts, and should generally be surrounding by spaces. +/// +/// If [ascii] is `false`, this is "←". If it's `true`, this is +/// "<" instead. +String get leftArrow => _leftArrow; +var _leftArrow = "←"; + +/// A right-pointing arrow. +/// +/// Note that the Unicode arrow glyphs may overlap with adjacent characters in some +/// terminal fonts, and should generally be surrounding by spaces. +/// +/// If [ascii] is `false`, this is "→". If it's `true`, this is +/// ">" instead. +String get rightArrow => _rightArrow; +var _rightArrow = "→"; + +/// An upwards-pointing arrow. +/// +/// If [ascii] is `false`, this is "↑". If it's `true`, this is +/// "^" instead. +String get upArrow => _upArrow; +var _upArrow = "↑"; + +/// A downwards-pointing arrow. +/// +/// If [ascii] is `false`, this is "↓". If it's `true`, this is +/// "v" instead. +String get downArrow => _downArrow; +var _downArrow = "↓"; + +/// A two-character left-pointing arrow. +/// +/// If [ascii] is `false`, this is "◀━". If it's `true`, this is +/// "<=" instead. +String get longLeftArrow => _longLeftArrow; +var _longLeftArrow = "◀━"; + +/// A two-character right-pointing arrow. +/// +/// If [ascii] is `false`, this is "━▶". If it's `true`, this is +/// "=>" instead. +String get longRightArrow => _longRightArrow; +var _longRightArrow = "━▶"; + +/// A horizontal line that can be used to draw a box. +/// +/// If [ascii] is `false`, this is "─". If it's `true`, this is +/// "-" instead. +String get horizontalLine => _horizontalLine; +var _horizontalLine = "─"; + +/// A vertical line that can be used to draw a box. +/// +/// If [ascii] is `false`, this is "│". If it's `true`, this is +/// "|" instead. +String get verticalLine => _verticalLine; +var _verticalLine = "│"; + +/// The upper left-hand corner of a box. +/// +/// If [ascii] is `false`, this is "┌". If it's `true`, this is +/// "," instead. +String get topLeftCorner => _topLeftCorner; +var _topLeftCorner = "┌"; + +/// The upper right-hand corner of a box. +/// +/// If [ascii] is `false`, this is "┐". If it's `true`, this is +/// "," instead. +String get topRightCorner => _topRightCorner; +var _topRightCorner = "┐"; + +/// The lower left-hand corner of a box. +/// +/// If [ascii] is `false`, this is "└". If it's `true`, this is +/// "'" instead. +String get bottomLeftCorner => _bottomLeftCorner; +var _bottomLeftCorner = "└"; + +/// The lower right-hand corner of a box. +/// +/// If [ascii] is `false`, this is "┘". If it's `true`, this is +/// "'" instead. +String get bottomRightCorner => _bottomRightCorner; +var _bottomRightCorner = "┘"; + +/// An intersection of vertical and horizontal box lines. +/// +/// If [ascii] is `false`, this is "┼". If it's `true`, this is +/// "+" instead. +String get cross => _cross; +var _cross = "┼"; + +/// A horizontal box line with a vertical line going up from the middle. +/// +/// If [ascii] is `false`, this is "┴". If it's `true`, this is +/// "+" instead. +String get teeUp => _teeUp; +var _teeUp = "┴"; + +/// A horizontal box line with a vertical line going down from the middle. +/// +/// If [ascii] is `false`, this is "┬". If it's `true`, this is +/// "+" instead. +String get teeDown => _teeDown; +var _teeDown = "┬"; + +/// A vertical box line with a horizontal line going left from the middle. +/// +/// If [ascii] is `false`, this is "┤". If it's `true`, this is +/// "+" instead. +String get teeLeft => _teeLeft; +var _teeLeft = "┤"; + +/// A vertical box line with a horizontal line going right from the middle. +/// +/// If [ascii] is `false`, this is "├". If it's `true`, this is +/// "+" instead. +String get teeRight => _teeRight; +var _teeRight = "├"; + +/// The top half of a vertical box line. +/// +/// If [ascii] is `false`, this is "╵". If it's `true`, this is +/// "'" instead. +String get upEnd => _upEnd; +var _upEnd = "╵"; + +/// The bottom half of a vertical box line. +/// +/// If [ascii] is `false`, this is "╷". If it's `true`, this is +/// "," instead. +String get downEnd => _downEnd; +var _downEnd = "╷"; + +/// The left half of a horizontal box line. +/// +/// If [ascii] is `false`, this is "╴". If it's `true`, this is +/// "-" instead. +String get leftEnd => _leftEnd; +var _leftEnd = "╴"; + +/// The right half of a horizontal box line. +/// +/// If [ascii] is `false`, this is "╶". If it's `true`, this is +/// "-" instead. +String get rightEnd => _rightEnd; +var _rightEnd = "╶"; + +/// A bold horizontal line that can be used to draw a box. +/// +/// If [ascii] is `false`, this is "━". If it's `true`, this is +/// "=" instead. +String get horizontalLineBold => _horizontalLineBold; +var _horizontalLineBold = "━"; + +/// A bold vertical line that can be used to draw a box. +/// +/// If [ascii] is `false`, this is "┃". If it's `true`, this is +/// "|" instead. +String get verticalLineBold => _verticalLineBold; +var _verticalLineBold = "┃"; + +/// The bold upper left-hand corner of a box. +/// +/// If [ascii] is `false`, this is "┏". If it's `true`, this is +/// "," instead. +String get topLeftCornerBold => _topLeftCornerBold; +var _topLeftCornerBold = "┏"; + +/// The bold upper right-hand corner of a box. +/// +/// If [ascii] is `false`, this is "┓". If it's `true`, this is +/// "," instead. +String get topRightCornerBold => _topRightCornerBold; +var _topRightCornerBold = "┓"; + +/// The bold lower left-hand corner of a box. +/// +/// If [ascii] is `false`, this is "┗". If it's `true`, this is +/// "'" instead. +String get bottomLeftCornerBold => _bottomLeftCornerBold; +var _bottomLeftCornerBold = "┗"; + +/// The bold lower right-hand corner of a box. +/// +/// If [ascii] is `false`, this is "┛". If it's `true`, this is +/// "'" instead. +String get bottomRightCornerBold => _bottomRightCornerBold; +var _bottomRightCornerBold = "┛"; + +/// An intersection of bold vertical and horizontal box lines. +/// +/// If [ascii] is `false`, this is "╋". If it's `true`, this is +/// "+" instead. +String get crossBold => _crossBold; +var _crossBold = "╋"; + +/// A bold horizontal box line with a vertical line going up from the middle. +/// +/// If [ascii] is `false`, this is "┻". If it's `true`, this is +/// "+" instead. +String get teeUpBold => _teeUpBold; +var _teeUpBold = "┻"; + +/// A bold horizontal box line with a vertical line going down from the middle. +/// +/// If [ascii] is `false`, this is "┳". If it's `true`, this is +/// "+" instead. +String get teeDownBold => _teeDownBold; +var _teeDownBold = "┳"; + +/// A bold vertical box line with a horizontal line going left from the middle. +/// +/// If [ascii] is `false`, this is "┫". If it's `true`, this is +/// "+" instead. +String get teeLeftBold => _teeLeftBold; +var _teeLeftBold = "┫"; + +/// A bold vertical box line with a horizontal line going right from the middle. +/// +/// If [ascii] is `false`, this is "┣". If it's `true`, this is +/// "+" instead. +String get teeRightBold => _teeRightBold; +var _teeRightBold = "┣"; + +/// The top half of a bold vertical box line. +/// +/// If [ascii] is `false`, this is "╹". If it's `true`, this is +/// "'" instead. +String get upEndBold => _upEndBold; +var _upEndBold = "╹"; + +/// The bottom half of a bold vertical box line. +/// +/// If [ascii] is `false`, this is "╻". If it's `true`, this is +/// "," instead. +String get downEndBold => _downEndBold; +var _downEndBold = "╻"; + +/// The left half of a bold horizontal box line. +/// +/// If [ascii] is `false`, this is "╸". If it's `true`, this is +/// "-" instead. +String get leftEndBold => _leftEndBold; +var _leftEndBold = "╸"; + +/// The right half of a bold horizontal box line. +/// +/// If [ascii] is `false`, this is "╺". If it's `true`, this is +/// "-" instead. +String get rightEndBold => _rightEndBold; +var _rightEndBold = "╺"; + +/// A double horizontal line that can be used to draw a box. +/// +/// If [ascii] is `false`, this is "═". If it's `true`, this is +/// "=" instead. +String get horizontalLineDouble => _horizontalLineDouble; +var _horizontalLineDouble = "═"; + +/// A double vertical line that can be used to draw a box. +/// +/// If [ascii] is `false`, this is "║". If it's `true`, this is +/// "|" instead. +String get verticalLineDouble => _verticalLineDouble; +var _verticalLineDouble = "║"; + +/// The double upper left-hand corner of a box. +/// +/// If [ascii] is `false`, this is "╔". If it's `true`, this is +/// "," instead. +String get topLeftCornerDouble => _topLeftCornerDouble; +var _topLeftCornerDouble = "╔"; + +/// The double upper right-hand corner of a box. +/// +/// If [ascii] is `false`, this is "╗". If it's `true`, this is +/// "," instead. +String get topRightCornerDouble => _topRightCornerDouble; +var _topRightCornerDouble = "╗"; + +/// The double lower left-hand corner of a box. +/// +/// If [ascii] is `false`, this is "╚". If it's `true`, this is +/// """ instead. +String get bottomLeftCornerDouble => _bottomLeftCornerDouble; +var _bottomLeftCornerDouble = "╚"; + +/// The double lower right-hand corner of a box. +/// +/// If [ascii] is `false`, this is "╝". If it's `true`, this is +/// """ instead. +String get bottomRightCornerDouble => _bottomRightCornerDouble; +var _bottomRightCornerDouble = "╝"; + +/// An intersection of double vertical and horizontal box lines. +/// +/// If [ascii] is `false`, this is "╬". If it's `true`, this is +/// "+" instead. +String get crossDouble => _crossDouble; +var _crossDouble = "╬"; + +/// A double horizontal box line with a vertical line going up from the middle. +/// +/// If [ascii] is `false`, this is "╩". If it's `true`, this is +/// "+" instead. +String get teeUpDouble => _teeUpDouble; +var _teeUpDouble = "╩"; + +/// A double horizontal box line with a vertical line going down from the middle. +/// +/// If [ascii] is `false`, this is "╦". If it's `true`, this is +/// "+" instead. +String get teeDownDouble => _teeDownDouble; +var _teeDownDouble = "╦"; + +/// A double vertical box line with a horizontal line going left from the middle. +/// +/// If [ascii] is `false`, this is "╣". If it's `true`, this is +/// "+" instead. +String get teeLeftDouble => _teeLeftDouble; +var _teeLeftDouble = "╣"; + +/// A double vertical box line with a horizontal line going right from the middle. +/// +/// If [ascii] is `false`, this is "╠". If it's `true`, this is +/// "+" instead. +String get teeRightDouble => _teeRightDouble; +var _teeRightDouble = "╠"; + +/// A dashed horizontal line that can be used to draw a box. +/// +/// If [ascii] is `false`, this is "╌". If it's `true`, this is +/// "-" instead. +String get horizontalLineDoubleDash => _horizontalLineDoubleDash; +var _horizontalLineDoubleDash = "╌"; + +/// A bold dashed horizontal line that can be used to draw a box. +/// +/// If [ascii] is `false`, this is "╍". If it's `true`, this is +/// "-" instead. +String get horizontalLineDoubleDashBold => _horizontalLineDoubleDashBold; +var _horizontalLineDoubleDashBold = "╍"; + +/// A dashed vertical line that can be used to draw a box. +/// +/// If [ascii] is `false`, this is "╎". If it's `true`, this is +/// "|" instead. +String get verticalLineDoubleDash => _verticalLineDoubleDash; +var _verticalLineDoubleDash = "╎"; + +/// A bold dashed vertical line that can be used to draw a box. +/// +/// If [ascii] is `false`, this is "╏". If it's `true`, this is +/// "|" instead. +String get verticalLineDoubleDashBold => _verticalLineDoubleDashBold; +var _verticalLineDoubleDashBold = "╏"; + +/// A dashed horizontal line that can be used to draw a box. +/// +/// If [ascii] is `false`, this is "┄". If it's `true`, this is +/// "-" instead. +String get horizontalLineTripleDash => _horizontalLineTripleDash; +var _horizontalLineTripleDash = "┄"; + +/// A bold dashed horizontal line that can be used to draw a box. +/// +/// If [ascii] is `false`, this is "┅". If it's `true`, this is +/// "-" instead. +String get horizontalLineTripleDashBold => _horizontalLineTripleDashBold; +var _horizontalLineTripleDashBold = "┅"; + +/// A dashed vertical line that can be used to draw a box. +/// +/// If [ascii] is `false`, this is "┆". If it's `true`, this is +/// "|" instead. +String get verticalLineTripleDash => _verticalLineTripleDash; +var _verticalLineTripleDash = "┆"; + +/// A bold dashed vertical line that can be used to draw a box. +/// +/// If [ascii] is `false`, this is "┇". If it's `true`, this is +/// "|" instead. +String get verticalLineTripleDashBold => _verticalLineTripleDashBold; +var _verticalLineTripleDashBold = "┇"; + +/// A dashed horizontal line that can be used to draw a box. +/// +/// If [ascii] is `false`, this is "┈". If it's `true`, this is +/// "-" instead. +String get horizontalLineQuadrupleDash => _horizontalLineQuadrupleDash; +var _horizontalLineQuadrupleDash = "┈"; + +/// A bold dashed horizontal line that can be used to draw a box. +/// +/// If [ascii] is `false`, this is "┉". If it's `true`, this is +/// "-" instead. +String get horizontalLineQuadrupleDashBold => _horizontalLineQuadrupleDashBold; +var _horizontalLineQuadrupleDashBold = "┉"; + +/// A dashed vertical line that can be used to draw a box. +/// +/// If [ascii] is `false`, this is "┊". If it's `true`, this is +/// "|" instead. +String get verticalLineQuadrupleDash => _verticalLineQuadrupleDash; +var _verticalLineQuadrupleDash = "┊"; + +/// A bold dashed vertical line that can be used to draw a box. +/// +/// If [ascii] is `false`, this is "┋". If it's `true`, this is +/// "|" instead. +String get verticalLineQuadrupleDashBold => _verticalLineQuadrupleDashBold; +var _verticalLineQuadrupleDashBold = "┋";
diff --git a/lib/term_glyph.dart b/lib/term_glyph.dart new file mode 100644 index 0000000..8582175 --- /dev/null +++ b/lib/term_glyph.dart
@@ -0,0 +1,12 @@ +// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +export 'src/generated.dart'; + +import 'src/generated.dart'; + +/// Returns [glyph] if Unicode glyph are allowed, and [alternative] if they +/// aren't. +String glyphOrAscii(String glyph, String alternative) => + ascii ? alternative : glyph;
diff --git a/pubspec.yaml b/pubspec.yaml index 275c2bf..4ba1efb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml
@@ -1,8 +1,13 @@ -name: symbol -version: 1.0.0-dev -description: Useful symbols and Windows-safe equivalents. +name: term_glyph +version: 1.0.0 +description: Useful glyphs and Windows-safe equivalents. author: Dart Team <misc@dartlang.org> -homepage: https://github.com/dart-lang/symbol +homepage: https://github.com/dart-lang/term_glyph environment: sdk: '>=1.8.0 <2.0.0' + +dev_dependencies: + csv: '^3.0.0' + dart_style: '^0.2.0' + test: '^0.12.0'
diff --git a/test/symbol_test.dart b/test/symbol_test.dart new file mode 100644 index 0000000..e3f94e5 --- /dev/null +++ b/test/symbol_test.dart
@@ -0,0 +1,41 @@ +// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:test/test.dart'; + +import 'package:term_glyph/term_glyph.dart' as glyph; + +void main() { + group("with ascii = false", () { + setUpAll(() { + glyph.ascii = false; + }); + + test("glyphs return Unicode versions", () { + expect(glyph.topLeftCorner, equals("┌")); + expect(glyph.teeUpBold, equals("┻")); + expect(glyph.longLeftArrow, equals("◀━")); + }); + + test("glyphOrAscii returns the first argument", () { + expect(glyph.glyphOrAscii("A", "B"), equals("A")); + }); + }); + + group("with ascii = true", () { + setUpAll(() { + glyph.ascii = true; + }); + + test("glyphs return ASCII versions", () { + expect(glyph.topLeftCorner, equals(",")); + expect(glyph.teeUpBold, equals("+")); + expect(glyph.longLeftArrow, equals("<=")); + }); + + test("glyphOrAscii returns the second argument", () { + expect(glyph.glyphOrAscii("A", "B"), equals("B")); + }); + }); +}
diff --git a/tool/generate.dart b/tool/generate.dart new file mode 100644 index 0000000..2e94b4c --- /dev/null +++ b/tool/generate.dart
@@ -0,0 +1,67 @@ +// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:io'; + +import 'package:csv/csv.dart'; + +void main() { + var csv = new CsvCodec(eol: "\n"); + var data = csv.decode(new File("data.csv").readAsStringSync()); + + // Remove comments and empty lines. + data.removeWhere((row) => row.length < 3); + + var file = new File("lib/src/generated.dart").openSync(mode: FileMode.WRITE); + file.writeStringSync(""" + // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file + // for details. All rights reserved. Use of this source code is governed by a + // BSD-style license that can be found in the LICENSE file. + + // Don't modify this file by hand! It's generated by tool/generate.dart. + + /// Whether the glyph getters return plain ASCII, as opposed to Unicode + /// characters or sequences. + /// + /// Defaults to `false`. + bool get ascii => _ascii; + var _ascii = false; + set ascii(bool value) { + _ascii = value; + if (value) { + """); + + for (var glyph in data) { + file.writeStringSync("_${glyph[0]} = ${_quote(glyph[2])};"); + } + + file.writeStringSync("} else {"); + + for (var glyph in data) { + file.writeStringSync("_${glyph[0]} = ${_quote(glyph[1])};"); + } + + file.writeStringSync("}}"); + + for (var glyph in data) { + for (var line in glyph[3].split("\n")) { + file.writeStringSync("/// $line\n"); + } + + file.writeStringSync(""" + /// + /// If [ascii] is `false`, this is "${glyph[1]}". If it's `true`, this is + /// "${glyph[2]}" instead. + String get ${glyph[0]} => _${glyph[0]}; + var _${glyph[0]} = ${_quote(glyph[1])}; + """); + } + + var result = Process.runSync( + "pub", ["run", "dart_style:format", "-w", "lib/src/generated.dart"]); + print(result.stderr); + exit(result.exitCode); +} + +String _quote(String input) => input.contains('"') ? "'$input'" : '"$input"';