-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1660 from dart-lang/merge-term_glyph-package
Merge `package:term_glyph`
Showing
19 changed files
with
1,461 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
name: "package:term_glyph" | ||
about: "Create a bug or file a feature request against package:term_glyph." | ||
labels: "package:term_glyph" | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: package:term_glyph | ||
|
||
on: | ||
# Run on PRs and pushes to the default branch. | ||
push: | ||
branches: [ main ] | ||
paths: | ||
- '.github/workflows/term_glyph.yaml' | ||
- 'pkgs/term_glyph/**' | ||
pull_request: | ||
branches: [ main ] | ||
paths: | ||
- '.github/workflows/term_glyph.yaml' | ||
- 'pkgs/term_glyph/**' | ||
schedule: | ||
- cron: "0 0 * * 0" | ||
|
||
env: | ||
PUB_ENVIRONMENT: bot.github | ||
|
||
|
||
defaults: | ||
run: | ||
working-directory: pkgs/term_glyph/ | ||
|
||
jobs: | ||
# Check code formatting and static analysis on a single OS (linux) | ||
# against Dart dev. | ||
analyze: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
sdk: [dev] | ||
steps: | ||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | ||
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94 | ||
with: | ||
sdk: ${{ matrix.sdk }} | ||
- id: install | ||
name: Install dependencies | ||
run: dart pub get | ||
- name: Check formatting | ||
run: dart format --output=none --set-exit-if-changed . | ||
if: always() && steps.install.outcome == 'success' | ||
- name: Analyze code | ||
run: dart analyze --fatal-infos | ||
if: always() && steps.install.outcome == 'success' | ||
|
||
# Run tests on a matrix consisting of two dimensions: | ||
# 1. OS: ubuntu-latest, (macos-latest, windows-latest) | ||
# 2. release channel: dev | ||
test: | ||
needs: analyze | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
# Add macos-latest and/or windows-latest if relevant for this package. | ||
os: [ubuntu-latest] | ||
sdk: [3.1, dev] | ||
steps: | ||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | ||
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94 | ||
with: | ||
sdk: ${{ matrix.sdk }} | ||
- id: install | ||
name: Install dependencies | ||
run: dart pub get | ||
- name: Run VM tests | ||
run: dart test --platform vm | ||
if: always() && steps.install.outcome == 'success' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.dart_tool/ | ||
.pub/ | ||
.packages | ||
pubspec.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Below is a list of people and organizations that have contributed | ||
# to the project. Names should be added to the list like so: | ||
# | ||
# Name/Organization <email address> | ||
|
||
Google Inc. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
## 1.2.2 | ||
|
||
* Require Dart 3.1 | ||
* Move to `dart-lang/tools` monorepo. | ||
|
||
## 1.2.1 | ||
|
||
* Migrate to `package:lints`. | ||
* Populate the pubspec `repository` field. | ||
|
||
## 1.2.0 | ||
|
||
* Stable release for null safety. | ||
* Update SDK constraints to `>=2.12.0-0 <3.0.0` based on beta release | ||
guidelines. | ||
|
||
## 1.1.0 | ||
|
||
* Add a `GlyphSet` class that can be used to easily choose which set of glyphs | ||
to use for a particular chunk of code. | ||
|
||
* Add `asciiGlyphs`, `unicodeGlyphs`, and `glyphs` getters that provide access | ||
to `GlyphSet`s. | ||
|
||
## 1.0.1 | ||
|
||
* Set max SDK version to `<3.0.0`. | ||
|
||
## 1.0.0 | ||
|
||
* Initial version. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Copyright 2017, the Dart project authors. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are | ||
met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above | ||
copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided | ||
with the distribution. | ||
* Neither the name of Google LLC nor the names of its | ||
contributors may be used to endorse or promote products derived | ||
from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
[![Build Status](https://github.com/dart-lang/tools/actions/workflows/term_glyph.yaml/badge.svg)](https://github.com/dart-lang/tools/actions/workflows/term_glyph.yaml) | ||
[![pub package](https://img.shields.io/pub/v/term_glyph.svg)](https://pub.dev/packages/term_glyph) | ||
[![package publisher](https://img.shields.io/pub/publisher/term_glyph.svg)](https://pub.dev/packages/term_glyph/publisher) | ||
|
||
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 | ||
in places where Unicode isn't well-supported 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 | ||
|
||
Some shells are 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://pub.dev/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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# https://dart.dev/guides/language/analysis-options | ||
include: package:dart_flutter_team_lints/analysis_options.yaml | ||
|
||
analyzer: | ||
language: | ||
strict-casts: true | ||
strict-inference: true | ||
strict-raw-types: true | ||
|
||
linter: | ||
rules: | ||
- avoid_bool_literals_in_conditional_expressions | ||
- avoid_classes_with_only_static_members | ||
- avoid_private_typedef_functions | ||
- avoid_redundant_argument_values | ||
- avoid_returning_this | ||
- avoid_unused_constructor_parameters | ||
- avoid_void_async | ||
- cancel_subscriptions | ||
- join_return_with_assignment | ||
- literal_only_boolean_expressions | ||
- missing_whitespace_between_adjacent_strings | ||
- no_adjacent_strings_in_list | ||
- no_runtimeType_toString | ||
- prefer_const_declarations | ||
- prefer_expression_function_bodies | ||
- prefer_final_locals | ||
- unnecessary_await_in_return | ||
- unnecessary_breaks | ||
- use_if_null_to_convert_nulls_to_bools | ||
- use_raw_strings | ||
- use_string_buffers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
// Copyright (c) 2018, 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. | ||
|
||
import 'glyph_set.dart'; | ||
|
||
/// A [GlyphSet] that includes only ASCII glyphs. | ||
class AsciiGlyphSet implements GlyphSet { | ||
const AsciiGlyphSet(); | ||
|
||
/// Returns [glyph] if `this` supports Unicode glyphs and [alternative] | ||
/// otherwise. | ||
@override | ||
String glyphOrAscii(String glyph, String alternative) => alternative; | ||
@override | ||
String get bullet => '*'; | ||
@override | ||
String get leftArrow => '<'; | ||
@override | ||
String get rightArrow => '>'; | ||
@override | ||
String get upArrow => '^'; | ||
@override | ||
String get downArrow => 'v'; | ||
@override | ||
String get longLeftArrow => '<='; | ||
@override | ||
String get longRightArrow => '=>'; | ||
@override | ||
String get horizontalLine => '-'; | ||
@override | ||
String get verticalLine => '|'; | ||
@override | ||
String get topLeftCorner => ','; | ||
@override | ||
String get topRightCorner => ','; | ||
@override | ||
String get bottomLeftCorner => "'"; | ||
@override | ||
String get bottomRightCorner => "'"; | ||
@override | ||
String get cross => '+'; | ||
@override | ||
String get teeUp => '+'; | ||
@override | ||
String get teeDown => '+'; | ||
@override | ||
String get teeLeft => '+'; | ||
@override | ||
String get teeRight => '+'; | ||
@override | ||
String get upEnd => "'"; | ||
@override | ||
String get downEnd => ','; | ||
@override | ||
String get leftEnd => '-'; | ||
@override | ||
String get rightEnd => '-'; | ||
@override | ||
String get horizontalLineBold => '='; | ||
@override | ||
String get verticalLineBold => '|'; | ||
@override | ||
String get topLeftCornerBold => ','; | ||
@override | ||
String get topRightCornerBold => ','; | ||
@override | ||
String get bottomLeftCornerBold => "'"; | ||
@override | ||
String get bottomRightCornerBold => "'"; | ||
@override | ||
String get crossBold => '+'; | ||
@override | ||
String get teeUpBold => '+'; | ||
@override | ||
String get teeDownBold => '+'; | ||
@override | ||
String get teeLeftBold => '+'; | ||
@override | ||
String get teeRightBold => '+'; | ||
@override | ||
String get upEndBold => "'"; | ||
@override | ||
String get downEndBold => ','; | ||
@override | ||
String get leftEndBold => '-'; | ||
@override | ||
String get rightEndBold => '-'; | ||
@override | ||
String get horizontalLineDouble => '='; | ||
@override | ||
String get verticalLineDouble => '|'; | ||
@override | ||
String get topLeftCornerDouble => ','; | ||
@override | ||
String get topRightCornerDouble => ','; | ||
@override | ||
String get bottomLeftCornerDouble => '"'; | ||
@override | ||
String get bottomRightCornerDouble => '"'; | ||
@override | ||
String get crossDouble => '+'; | ||
@override | ||
String get teeUpDouble => '+'; | ||
@override | ||
String get teeDownDouble => '+'; | ||
@override | ||
String get teeLeftDouble => '+'; | ||
@override | ||
String get teeRightDouble => '+'; | ||
@override | ||
String get horizontalLineDoubleDash => '-'; | ||
@override | ||
String get horizontalLineDoubleDashBold => '-'; | ||
@override | ||
String get verticalLineDoubleDash => '|'; | ||
@override | ||
String get verticalLineDoubleDashBold => '|'; | ||
@override | ||
String get horizontalLineTripleDash => '-'; | ||
@override | ||
String get horizontalLineTripleDashBold => '-'; | ||
@override | ||
String get verticalLineTripleDash => '|'; | ||
@override | ||
String get verticalLineTripleDashBold => '|'; | ||
@override | ||
String get horizontalLineQuadrupleDash => '-'; | ||
@override | ||
String get horizontalLineQuadrupleDashBold => '-'; | ||
@override | ||
String get verticalLineQuadrupleDash => '|'; | ||
@override | ||
String get verticalLineQuadrupleDashBold => '|'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,227 @@ | ||
// Copyright (c) 2018, 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. | ||
|
||
/// A class that provides access to every configurable glyph. | ||
/// | ||
/// This is provided as a class so that individual chunks of code can choose | ||
/// between `ascii` and `unicode` glyphs. For example: | ||
/// | ||
/// ```dart | ||
/// import 'package:term_glyph/term_glyph.dart' as glyph; | ||
/// | ||
/// /// Adds a vertical line to the left of [text]. | ||
/// /// | ||
/// /// If [unicode] is `true`, this uses Unicode for the line. If it's | ||
/// /// `false`, this uses plain ASCII characters. If it's `null`, it | ||
/// /// defaults to [glyph.ascii]. | ||
/// void addVerticalLine(String text, {bool unicode}) { | ||
/// var glyphs = | ||
/// (unicode ?? !glyph.ascii) ? glyph.unicodeGlyphs : glyph.asciiGlyphs; | ||
/// | ||
/// return text | ||
/// .split('\n') | ||
/// .map((line) => '${glyphs.verticalLine} $line') | ||
/// .join('\n'); | ||
/// } | ||
/// ``` | ||
abstract class GlyphSet { | ||
/// Returns [glyph] if `this` supports Unicode glyphs and [alternative] | ||
/// otherwise. | ||
String glyphOrAscii(String glyph, String alternative); | ||
|
||
/// A bullet point. | ||
String get 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. | ||
String get 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. | ||
String get rightArrow; | ||
|
||
/// An upwards-pointing arrow. | ||
String get upArrow; | ||
|
||
/// A downwards-pointing arrow. | ||
String get downArrow; | ||
|
||
/// A two-character left-pointing arrow. | ||
String get longLeftArrow; | ||
|
||
/// A two-character right-pointing arrow. | ||
String get longRightArrow; | ||
|
||
/// A horizontal line that can be used to draw a box. | ||
String get horizontalLine; | ||
|
||
/// A vertical line that can be used to draw a box. | ||
String get verticalLine; | ||
|
||
/// The upper left-hand corner of a box. | ||
String get topLeftCorner; | ||
|
||
/// The upper right-hand corner of a box. | ||
String get topRightCorner; | ||
|
||
/// The lower left-hand corner of a box. | ||
String get bottomLeftCorner; | ||
|
||
/// The lower right-hand corner of a box. | ||
String get bottomRightCorner; | ||
|
||
/// An intersection of vertical and horizontal box lines. | ||
String get cross; | ||
|
||
/// A horizontal box line with a vertical line going up from the middle. | ||
String get teeUp; | ||
|
||
/// A horizontal box line with a vertical line going down from the middle. | ||
String get teeDown; | ||
|
||
/// A vertical box line with a horizontal line going left from the middle. | ||
String get teeLeft; | ||
|
||
/// A vertical box line with a horizontal line going right from the middle. | ||
String get teeRight; | ||
|
||
/// The top half of a vertical box line. | ||
String get upEnd; | ||
|
||
/// The bottom half of a vertical box line. | ||
String get downEnd; | ||
|
||
/// The left half of a horizontal box line. | ||
String get leftEnd; | ||
|
||
/// The right half of a horizontal box line. | ||
String get rightEnd; | ||
|
||
/// A bold horizontal line that can be used to draw a box. | ||
String get horizontalLineBold; | ||
|
||
/// A bold vertical line that can be used to draw a box. | ||
String get verticalLineBold; | ||
|
||
/// The bold upper left-hand corner of a box. | ||
String get topLeftCornerBold; | ||
|
||
/// The bold upper right-hand corner of a box. | ||
String get topRightCornerBold; | ||
|
||
/// The bold lower left-hand corner of a box. | ||
String get bottomLeftCornerBold; | ||
|
||
/// The bold lower right-hand corner of a box. | ||
String get bottomRightCornerBold; | ||
|
||
/// An intersection of bold vertical and horizontal box lines. | ||
String get crossBold; | ||
|
||
/// A bold horizontal box line with a vertical line going up from the middle. | ||
String get teeUpBold; | ||
|
||
/// A bold horizontal box line with a vertical line going down from the | ||
/// middle. | ||
String get teeDownBold; | ||
|
||
/// A bold vertical box line with a horizontal line going left from the | ||
/// middle. | ||
String get teeLeftBold; | ||
|
||
/// A bold vertical box line with a horizontal line going right from the | ||
/// middle. | ||
String get teeRightBold; | ||
|
||
/// The top half of a bold vertical box line. | ||
String get upEndBold; | ||
|
||
/// The bottom half of a bold vertical box line. | ||
String get downEndBold; | ||
|
||
/// The left half of a bold horizontal box line. | ||
String get leftEndBold; | ||
|
||
/// The right half of a bold horizontal box line. | ||
String get rightEndBold; | ||
|
||
/// A double horizontal line that can be used to draw a box. | ||
String get horizontalLineDouble; | ||
|
||
/// A double vertical line that can be used to draw a box. | ||
String get verticalLineDouble; | ||
|
||
/// The double upper left-hand corner of a box. | ||
String get topLeftCornerDouble; | ||
|
||
/// The double upper right-hand corner of a box. | ||
String get topRightCornerDouble; | ||
|
||
/// The double lower left-hand corner of a box. | ||
String get bottomLeftCornerDouble; | ||
|
||
/// The double lower right-hand corner of a box. | ||
String get bottomRightCornerDouble; | ||
|
||
/// An intersection of double vertical and horizontal box lines. | ||
String get crossDouble; | ||
|
||
/// A double horizontal box line with a vertical line going up from the | ||
/// middle. | ||
String get teeUpDouble; | ||
|
||
/// A double horizontal box line with a vertical line going down from the | ||
/// middle. | ||
String get teeDownDouble; | ||
|
||
/// A double vertical box line with a horizontal line going left from the | ||
/// middle. | ||
String get teeLeftDouble; | ||
|
||
/// A double vertical box line with a horizontal line going right from the | ||
/// middle. | ||
String get teeRightDouble; | ||
|
||
/// A dashed horizontal line that can be used to draw a box. | ||
String get horizontalLineDoubleDash; | ||
|
||
/// A bold dashed horizontal line that can be used to draw a box. | ||
String get horizontalLineDoubleDashBold; | ||
|
||
/// A dashed vertical line that can be used to draw a box. | ||
String get verticalLineDoubleDash; | ||
|
||
/// A bold dashed vertical line that can be used to draw a box. | ||
String get verticalLineDoubleDashBold; | ||
|
||
/// A dashed horizontal line that can be used to draw a box. | ||
String get horizontalLineTripleDash; | ||
|
||
/// A bold dashed horizontal line that can be used to draw a box. | ||
String get horizontalLineTripleDashBold; | ||
|
||
/// A dashed vertical line that can be used to draw a box. | ||
String get verticalLineTripleDash; | ||
|
||
/// A bold dashed vertical line that can be used to draw a box. | ||
String get verticalLineTripleDashBold; | ||
|
||
/// A dashed horizontal line that can be used to draw a box. | ||
String get horizontalLineQuadrupleDash; | ||
|
||
/// A bold dashed horizontal line that can be used to draw a box. | ||
String get horizontalLineQuadrupleDashBold; | ||
|
||
/// A dashed vertical line that can be used to draw a box. | ||
String get verticalLineQuadrupleDash; | ||
|
||
/// A bold dashed vertical line that can be used to draw a box. | ||
String get verticalLineQuadrupleDashBold; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,383 @@ | ||
// Copyright (c) 2018, 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. | ||
|
||
import '../../term_glyph.dart' as glyph; | ||
|
||
/// A bullet point. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "•". If it's `true`, this is | ||
/// "*" instead. | ||
String get bullet => glyph.glyphs.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 [glyph.ascii] is `false`, this is "←". If it's `true`, this is | ||
/// "<" instead. | ||
String get leftArrow => glyph.glyphs.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 [glyph.ascii] is `false`, this is "→". If it's `true`, this is | ||
/// ">" instead. | ||
String get rightArrow => glyph.glyphs.rightArrow; | ||
|
||
/// An upwards-pointing arrow. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "↑". If it's `true`, this is | ||
/// "^" instead. | ||
String get upArrow => glyph.glyphs.upArrow; | ||
|
||
/// A downwards-pointing arrow. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "↓". If it's `true`, this is | ||
/// "v" instead. | ||
String get downArrow => glyph.glyphs.downArrow; | ||
|
||
/// A two-character left-pointing arrow. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "◀━". If it's `true`, this is | ||
/// "<=" instead. | ||
String get longLeftArrow => glyph.glyphs.longLeftArrow; | ||
|
||
/// A two-character right-pointing arrow. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "━▶". If it's `true`, this is | ||
/// "=>" instead. | ||
String get longRightArrow => glyph.glyphs.longRightArrow; | ||
|
||
/// A horizontal line that can be used to draw a box. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "─". If it's `true`, this is | ||
/// "-" instead. | ||
String get horizontalLine => glyph.glyphs.horizontalLine; | ||
|
||
/// A vertical line that can be used to draw a box. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "│". If it's `true`, this is | ||
/// "|" instead. | ||
String get verticalLine => glyph.glyphs.verticalLine; | ||
|
||
/// The upper left-hand corner of a box. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "┌". If it's `true`, this is | ||
/// "," instead. | ||
String get topLeftCorner => glyph.glyphs.topLeftCorner; | ||
|
||
/// The upper right-hand corner of a box. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "┐". If it's `true`, this is | ||
/// "," instead. | ||
String get topRightCorner => glyph.glyphs.topRightCorner; | ||
|
||
/// The lower left-hand corner of a box. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "└". If it's `true`, this is | ||
/// "'" instead. | ||
String get bottomLeftCorner => glyph.glyphs.bottomLeftCorner; | ||
|
||
/// The lower right-hand corner of a box. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "┘". If it's `true`, this is | ||
/// "'" instead. | ||
String get bottomRightCorner => glyph.glyphs.bottomRightCorner; | ||
|
||
/// An intersection of vertical and horizontal box lines. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "┼". If it's `true`, this is | ||
/// "+" instead. | ||
String get cross => glyph.glyphs.cross; | ||
|
||
/// A horizontal box line with a vertical line going up from the middle. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "┴". If it's `true`, this is | ||
/// "+" instead. | ||
String get teeUp => glyph.glyphs.teeUp; | ||
|
||
/// A horizontal box line with a vertical line going down from the middle. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "┬". If it's `true`, this is | ||
/// "+" instead. | ||
String get teeDown => glyph.glyphs.teeDown; | ||
|
||
/// A vertical box line with a horizontal line going left from the middle. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "┤". If it's `true`, this is | ||
/// "+" instead. | ||
String get teeLeft => glyph.glyphs.teeLeft; | ||
|
||
/// A vertical box line with a horizontal line going right from the middle. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "├". If it's `true`, this is | ||
/// "+" instead. | ||
String get teeRight => glyph.glyphs.teeRight; | ||
|
||
/// The top half of a vertical box line. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "╵". If it's `true`, this is | ||
/// "'" instead. | ||
String get upEnd => glyph.glyphs.upEnd; | ||
|
||
/// The bottom half of a vertical box line. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "╷". If it's `true`, this is | ||
/// "," instead. | ||
String get downEnd => glyph.glyphs.downEnd; | ||
|
||
/// The left half of a horizontal box line. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "╴". If it's `true`, this is | ||
/// "-" instead. | ||
String get leftEnd => glyph.glyphs.leftEnd; | ||
|
||
/// The right half of a horizontal box line. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "╶". If it's `true`, this is | ||
/// "-" instead. | ||
String get rightEnd => glyph.glyphs.rightEnd; | ||
|
||
/// A bold horizontal line that can be used to draw a box. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "━". If it's `true`, this is | ||
/// "=" instead. | ||
String get horizontalLineBold => glyph.glyphs.horizontalLineBold; | ||
|
||
/// A bold vertical line that can be used to draw a box. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "┃". If it's `true`, this is | ||
/// "|" instead. | ||
String get verticalLineBold => glyph.glyphs.verticalLineBold; | ||
|
||
/// The bold upper left-hand corner of a box. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "┏". If it's `true`, this is | ||
/// "," instead. | ||
String get topLeftCornerBold => glyph.glyphs.topLeftCornerBold; | ||
|
||
/// The bold upper right-hand corner of a box. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "┓". If it's `true`, this is | ||
/// "," instead. | ||
String get topRightCornerBold => glyph.glyphs.topRightCornerBold; | ||
|
||
/// The bold lower left-hand corner of a box. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "┗". If it's `true`, this is | ||
/// "'" instead. | ||
String get bottomLeftCornerBold => glyph.glyphs.bottomLeftCornerBold; | ||
|
||
/// The bold lower right-hand corner of a box. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "┛". If it's `true`, this is | ||
/// "'" instead. | ||
String get bottomRightCornerBold => glyph.glyphs.bottomRightCornerBold; | ||
|
||
/// An intersection of bold vertical and horizontal box lines. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "╋". If it's `true`, this is | ||
/// "+" instead. | ||
String get crossBold => glyph.glyphs.crossBold; | ||
|
||
/// A bold horizontal box line with a vertical line going up from the middle. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "┻". If it's `true`, this is | ||
/// "+" instead. | ||
String get teeUpBold => glyph.glyphs.teeUpBold; | ||
|
||
/// A bold horizontal box line with a vertical line going down from the middle. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "┳". If it's `true`, this is | ||
/// "+" instead. | ||
String get teeDownBold => glyph.glyphs.teeDownBold; | ||
|
||
/// A bold vertical box line with a horizontal line going left from the middle. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "┫". If it's `true`, this is | ||
/// "+" instead. | ||
String get teeLeftBold => glyph.glyphs.teeLeftBold; | ||
|
||
/// A bold vertical box line with a horizontal line going right from the middle. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "┣". If it's `true`, this is | ||
/// "+" instead. | ||
String get teeRightBold => glyph.glyphs.teeRightBold; | ||
|
||
/// The top half of a bold vertical box line. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "╹". If it's `true`, this is | ||
/// "'" instead. | ||
String get upEndBold => glyph.glyphs.upEndBold; | ||
|
||
/// The bottom half of a bold vertical box line. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "╻". If it's `true`, this is | ||
/// "," instead. | ||
String get downEndBold => glyph.glyphs.downEndBold; | ||
|
||
/// The left half of a bold horizontal box line. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "╸". If it's `true`, this is | ||
/// "-" instead. | ||
String get leftEndBold => glyph.glyphs.leftEndBold; | ||
|
||
/// The right half of a bold horizontal box line. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "╺". If it's `true`, this is | ||
/// "-" instead. | ||
String get rightEndBold => glyph.glyphs.rightEndBold; | ||
|
||
/// A double horizontal line that can be used to draw a box. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "═". If it's `true`, this is | ||
/// "=" instead. | ||
String get horizontalLineDouble => glyph.glyphs.horizontalLineDouble; | ||
|
||
/// A double vertical line that can be used to draw a box. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "║". If it's `true`, this is | ||
/// "|" instead. | ||
String get verticalLineDouble => glyph.glyphs.verticalLineDouble; | ||
|
||
/// The double upper left-hand corner of a box. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "╔". If it's `true`, this is | ||
/// "," instead. | ||
String get topLeftCornerDouble => glyph.glyphs.topLeftCornerDouble; | ||
|
||
/// The double upper right-hand corner of a box. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "╗". If it's `true`, this is | ||
/// "," instead. | ||
String get topRightCornerDouble => glyph.glyphs.topRightCornerDouble; | ||
|
||
/// The double lower left-hand corner of a box. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "╚". If it's `true`, this is | ||
/// """ instead. | ||
String get bottomLeftCornerDouble => glyph.glyphs.bottomLeftCornerDouble; | ||
|
||
/// The double lower right-hand corner of a box. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "╝". If it's `true`, this is | ||
/// """ instead. | ||
String get bottomRightCornerDouble => glyph.glyphs.bottomRightCornerDouble; | ||
|
||
/// An intersection of double vertical and horizontal box lines. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "╬". If it's `true`, this is | ||
/// "+" instead. | ||
String get crossDouble => glyph.glyphs.crossDouble; | ||
|
||
/// A double horizontal box line with a vertical line going up from the middle. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "╩". If it's `true`, this is | ||
/// "+" instead. | ||
String get teeUpDouble => glyph.glyphs.teeUpDouble; | ||
|
||
/// A double horizontal box line with a vertical line going down from the | ||
/// middle. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "╦". If it's `true`, this is | ||
/// "+" instead. | ||
String get teeDownDouble => glyph.glyphs.teeDownDouble; | ||
|
||
/// A double vertical box line with a horizontal line going left from the | ||
/// middle. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "╣". If it's `true`, this is | ||
/// "+" instead. | ||
String get teeLeftDouble => glyph.glyphs.teeLeftDouble; | ||
|
||
/// A double vertical box line with a horizontal line going right from the | ||
/// middle. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "╠". If it's `true`, this is | ||
/// "+" instead. | ||
String get teeRightDouble => glyph.glyphs.teeRightDouble; | ||
|
||
/// A dashed horizontal line that can be used to draw a box. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "╌". If it's `true`, this is | ||
/// "-" instead. | ||
String get horizontalLineDoubleDash => glyph.glyphs.horizontalLineDoubleDash; | ||
|
||
/// A bold dashed horizontal line that can be used to draw a box. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "╍". If it's `true`, this is | ||
/// "-" instead. | ||
String get horizontalLineDoubleDashBold => | ||
glyph.glyphs.horizontalLineDoubleDashBold; | ||
|
||
/// A dashed vertical line that can be used to draw a box. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "╎". If it's `true`, this is | ||
/// "|" instead. | ||
String get verticalLineDoubleDash => glyph.glyphs.verticalLineDoubleDash; | ||
|
||
/// A bold dashed vertical line that can be used to draw a box. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "╏". If it's `true`, this is | ||
/// "|" instead. | ||
String get verticalLineDoubleDashBold => | ||
glyph.glyphs.verticalLineDoubleDashBold; | ||
|
||
/// A dashed horizontal line that can be used to draw a box. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "┄". If it's `true`, this is | ||
/// "-" instead. | ||
String get horizontalLineTripleDash => glyph.glyphs.horizontalLineTripleDash; | ||
|
||
/// A bold dashed horizontal line that can be used to draw a box. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "┅". If it's `true`, this is | ||
/// "-" instead. | ||
String get horizontalLineTripleDashBold => | ||
glyph.glyphs.horizontalLineTripleDashBold; | ||
|
||
/// A dashed vertical line that can be used to draw a box. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "┆". If it's `true`, this is | ||
/// "|" instead. | ||
String get verticalLineTripleDash => glyph.glyphs.verticalLineTripleDash; | ||
|
||
/// A bold dashed vertical line that can be used to draw a box. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "┇". If it's `true`, this is | ||
/// "|" instead. | ||
String get verticalLineTripleDashBold => | ||
glyph.glyphs.verticalLineTripleDashBold; | ||
|
||
/// A dashed horizontal line that can be used to draw a box. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "┈". If it's `true`, this is | ||
/// "-" instead. | ||
String get horizontalLineQuadrupleDash => | ||
glyph.glyphs.horizontalLineQuadrupleDash; | ||
|
||
/// A bold dashed horizontal line that can be used to draw a box. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "┉". If it's `true`, this is | ||
/// "-" instead. | ||
String get horizontalLineQuadrupleDashBold => | ||
glyph.glyphs.horizontalLineQuadrupleDashBold; | ||
|
||
/// A dashed vertical line that can be used to draw a box. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "┊". If it's `true`, this is | ||
/// "|" instead. | ||
String get verticalLineQuadrupleDash => glyph.glyphs.verticalLineQuadrupleDash; | ||
|
||
/// A bold dashed vertical line that can be used to draw a box. | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "┋". If it's `true`, this is | ||
/// "|" instead. | ||
String get verticalLineQuadrupleDashBold => | ||
glyph.glyphs.verticalLineQuadrupleDashBold; |
137 changes: 137 additions & 0 deletions
137
pkgs/term_glyph/lib/src/generated/unicode_glyph_set.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
// Copyright (c) 2018, 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. | ||
|
||
import 'glyph_set.dart'; | ||
|
||
/// A [GlyphSet] that includes only Unicode glyphs. | ||
class UnicodeGlyphSet implements GlyphSet { | ||
const UnicodeGlyphSet(); | ||
|
||
/// Returns [glyph] if `this` supports Unicode glyphs and [alternative] | ||
/// otherwise. | ||
@override | ||
String glyphOrAscii(String glyph, String alternative) => glyph; | ||
@override | ||
String get bullet => '•'; | ||
@override | ||
String get leftArrow => '←'; | ||
@override | ||
String get rightArrow => '→'; | ||
@override | ||
String get upArrow => '↑'; | ||
@override | ||
String get downArrow => '↓'; | ||
@override | ||
String get longLeftArrow => '◀━'; | ||
@override | ||
String get longRightArrow => '━▶'; | ||
@override | ||
String get horizontalLine => '─'; | ||
@override | ||
String get verticalLine => '│'; | ||
@override | ||
String get topLeftCorner => '┌'; | ||
@override | ||
String get topRightCorner => '┐'; | ||
@override | ||
String get bottomLeftCorner => '└'; | ||
@override | ||
String get bottomRightCorner => '┘'; | ||
@override | ||
String get cross => '┼'; | ||
@override | ||
String get teeUp => '┴'; | ||
@override | ||
String get teeDown => '┬'; | ||
@override | ||
String get teeLeft => '┤'; | ||
@override | ||
String get teeRight => '├'; | ||
@override | ||
String get upEnd => '╵'; | ||
@override | ||
String get downEnd => '╷'; | ||
@override | ||
String get leftEnd => '╴'; | ||
@override | ||
String get rightEnd => '╶'; | ||
@override | ||
String get horizontalLineBold => '━'; | ||
@override | ||
String get verticalLineBold => '┃'; | ||
@override | ||
String get topLeftCornerBold => '┏'; | ||
@override | ||
String get topRightCornerBold => '┓'; | ||
@override | ||
String get bottomLeftCornerBold => '┗'; | ||
@override | ||
String get bottomRightCornerBold => '┛'; | ||
@override | ||
String get crossBold => '╋'; | ||
@override | ||
String get teeUpBold => '┻'; | ||
@override | ||
String get teeDownBold => '┳'; | ||
@override | ||
String get teeLeftBold => '┫'; | ||
@override | ||
String get teeRightBold => '┣'; | ||
@override | ||
String get upEndBold => '╹'; | ||
@override | ||
String get downEndBold => '╻'; | ||
@override | ||
String get leftEndBold => '╸'; | ||
@override | ||
String get rightEndBold => '╺'; | ||
@override | ||
String get horizontalLineDouble => '═'; | ||
@override | ||
String get verticalLineDouble => '║'; | ||
@override | ||
String get topLeftCornerDouble => '╔'; | ||
@override | ||
String get topRightCornerDouble => '╗'; | ||
@override | ||
String get bottomLeftCornerDouble => '╚'; | ||
@override | ||
String get bottomRightCornerDouble => '╝'; | ||
@override | ||
String get crossDouble => '╬'; | ||
@override | ||
String get teeUpDouble => '╩'; | ||
@override | ||
String get teeDownDouble => '╦'; | ||
@override | ||
String get teeLeftDouble => '╣'; | ||
@override | ||
String get teeRightDouble => '╠'; | ||
@override | ||
String get horizontalLineDoubleDash => '╌'; | ||
@override | ||
String get horizontalLineDoubleDashBold => '╍'; | ||
@override | ||
String get verticalLineDoubleDash => '╎'; | ||
@override | ||
String get verticalLineDoubleDashBold => '╏'; | ||
@override | ||
String get horizontalLineTripleDash => '┄'; | ||
@override | ||
String get horizontalLineTripleDashBold => '┅'; | ||
@override | ||
String get verticalLineTripleDash => '┆'; | ||
@override | ||
String get verticalLineTripleDashBold => '┇'; | ||
@override | ||
String get horizontalLineQuadrupleDash => '┈'; | ||
@override | ||
String get horizontalLineQuadrupleDashBold => '┉'; | ||
@override | ||
String get verticalLineQuadrupleDash => '┊'; | ||
@override | ||
String get verticalLineQuadrupleDashBold => '┋'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// 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 'src/generated/ascii_glyph_set.dart'; | ||
import 'src/generated/glyph_set.dart'; | ||
import 'src/generated/unicode_glyph_set.dart'; | ||
|
||
export 'src/generated/glyph_set.dart'; | ||
export 'src/generated/top_level.dart'; | ||
|
||
/// A [GlyphSet] that always returns ASCII glyphs. | ||
const GlyphSet asciiGlyphs = AsciiGlyphSet(); | ||
|
||
/// A [GlyphSet] that always returns Unicode glyphs. | ||
const GlyphSet unicodeGlyphs = UnicodeGlyphSet(); | ||
|
||
/// Returns [asciiGlyphs] if [ascii] is `true` or [unicodeGlyphs] otherwise. | ||
/// | ||
/// Returns [unicodeGlyphs] by default. | ||
GlyphSet get glyphs => _glyphs; | ||
GlyphSet _glyphs = unicodeGlyphs; | ||
|
||
/// Whether the glyph getters return plain ASCII, as opposed to Unicode | ||
/// characters or sequences. | ||
/// | ||
/// Defaults to `false`. | ||
bool get ascii => glyphs == asciiGlyphs; | ||
|
||
set ascii(bool value) { | ||
_glyphs = value ? asciiGlyphs : unicodeGlyphs; | ||
} | ||
|
||
/// Returns [glyph] if Unicode glyph are allowed, and [alternative] if they | ||
/// aren't. | ||
String glyphOrAscii(String glyph, String alternative) => | ||
glyphs.glyphOrAscii(glyph, alternative); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: term_glyph | ||
version: 1.2.2 | ||
description: Useful Unicode glyphs and ASCII substitutes. | ||
repository: https://github.com/dart-lang/tools/tree/main/pkgs/term_glyph | ||
|
||
environment: | ||
sdk: ^3.1.0 | ||
|
||
dev_dependencies: | ||
csv: ^6.0.0 | ||
dart_flutter_team_lints: ^3.0.0 | ||
dart_style: ^2.0.0 | ||
test: ^1.16.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// 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:term_glyph/term_glyph.dart' as glyph; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group('with ascii = false', () { | ||
setUpAll(() { | ||
glyph.ascii = false; | ||
}); | ||
|
||
test('glyph getters 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')); | ||
}); | ||
|
||
test('glyphs returns unicodeGlyphs', () { | ||
expect(glyph.glyphs, equals(glyph.unicodeGlyphs)); | ||
}); | ||
|
||
test('asciiGlyphs still returns ASCII characters', () { | ||
expect(glyph.asciiGlyphs.topLeftCorner, equals(',')); | ||
expect(glyph.asciiGlyphs.teeUpBold, equals('+')); | ||
expect(glyph.asciiGlyphs.longLeftArrow, equals('<=')); | ||
}); | ||
}); | ||
|
||
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')); | ||
}); | ||
|
||
test('glyphs returns asciiGlyphs', () { | ||
expect(glyph.glyphs, equals(glyph.asciiGlyphs)); | ||
}); | ||
|
||
test('unicodeGlyphs still returns Unicode characters', () { | ||
expect(glyph.unicodeGlyphs.topLeftCorner, equals('┌')); | ||
expect(glyph.unicodeGlyphs.teeUpBold, equals('┻')); | ||
expect(glyph.unicodeGlyphs.longLeftArrow, equals('◀━')); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
// 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() { | ||
final csv = CsvCodec(eol: '\n'); | ||
final data = csv.decoder.convert(File('data.csv').readAsStringSync()); | ||
|
||
// Remove comments and empty lines. | ||
data.removeWhere((row) => row.length < 3); | ||
|
||
Directory('lib/src/generated').createSync(recursive: true); | ||
|
||
_writeGlyphSetInterface(data); | ||
_writeGlyphSet(data, ascii: false); | ||
_writeGlyphSet(data, ascii: true); | ||
_writeTopLevel(data); | ||
|
||
final result = Process.runSync( | ||
'pub', ['run', 'dart_style:format', '-w', 'lib/src/generated']); | ||
print(result.stderr); | ||
exit(result.exitCode); | ||
} | ||
|
||
/// Writes `lib/src/generated/glyph_set.dart`. | ||
void _writeGlyphSetInterface(List<List<dynamic>> data) { | ||
final file = | ||
File('lib/src/generated/glyph_set.dart').openSync(mode: FileMode.write); | ||
file.writeStringSync(r''' | ||
// Copyright (c) 2018, 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. | ||
/// A class that provides access to every configurable glyph. | ||
/// | ||
/// This is provided as a class so that individual chunks of code can choose | ||
/// between `ascii` and `unicode` glyphs. For example: | ||
/// | ||
/// ```dart | ||
/// import 'package:term_glyph/term_glyph.dart' as glyph; | ||
/// | ||
/// /// Adds a vertical line to the left of [text]. | ||
/// /// | ||
/// /// If [unicode] is `true`, this uses Unicode for the line. If it's | ||
/// /// `false`, this uses plain ASCII characters. If it's `null`, it | ||
/// /// defaults to [glyph.ascii]. | ||
/// void addVerticalLine(String text, {bool unicode}) { | ||
/// var glyphs = | ||
/// (unicode ?? !glyph.ascii) ? glyph.unicodeGlyphs : glyph.asciiGlyphs; | ||
/// | ||
/// return text | ||
/// .split('\n') | ||
/// .map((line) => '${glyphs.verticalLine} $line') | ||
/// .join('\n'); | ||
/// } | ||
/// ``` | ||
abstract class GlyphSet { | ||
/// Returns [glyph] if `this` supports Unicode glyphs and [alternative] | ||
/// otherwise. | ||
String glyphOrAscii(String glyph, String alternative); | ||
'''); | ||
|
||
for (var glyph in data) { | ||
for (var line in (glyph[3] as String).split('\n')) { | ||
file.writeStringSync('/// $line\n'); | ||
} | ||
|
||
file.writeStringSync('String get ${glyph[0]};'); | ||
} | ||
|
||
file.writeStringSync('}'); | ||
file.closeSync(); | ||
} | ||
|
||
/// Writes `lib/src/generated/${prefix.toLowerCase()}_glyph_set.dart`. | ||
/// | ||
/// If [ascii] is `true`, this writes the ASCII glyph set. Otherwise it writes | ||
/// the Unicode glyph set. | ||
void _writeGlyphSet(List<List<dynamic>> data, {required bool ascii}) { | ||
final file = | ||
File('lib/src/generated/${ascii ? "ascii" : "unicode"}_glyph_set.dart') | ||
.openSync(mode: FileMode.write); | ||
|
||
final className = '${ascii ? "Ascii" : "Unicode"}GlyphSet'; | ||
file.writeStringSync(''' | ||
// Copyright (c) 2018, 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. | ||
import 'glyph_set.dart'; | ||
/// A [GlyphSet] that includes only ${ascii ? "ASCII" : "Unicode"} glyphs. | ||
class $className implements GlyphSet { | ||
const $className(); | ||
/// Returns [glyph] if `this` supports Unicode glyphs and [alternative] | ||
/// otherwise. | ||
@override | ||
String glyphOrAscii(String glyph, String alternative) => | ||
${ascii ? "alternative" : "glyph"}; | ||
'''); | ||
|
||
final index = ascii ? 2 : 1; | ||
for (var glyph in data) { | ||
file.writeStringSync(''' | ||
@override | ||
String get ${glyph[0]} => ${_quote(glyph[index] as String)}; | ||
'''); | ||
} | ||
|
||
file.writeStringSync('}'); | ||
file.closeSync(); | ||
} | ||
|
||
/// Writes `lib/src/generated/top_level.dart`. | ||
void _writeTopLevel(List<List<dynamic>> data) { | ||
final file = | ||
File('lib/src/generated/top_level.dart').openSync(mode: FileMode.write); | ||
|
||
file.writeStringSync(''' | ||
// Copyright (c) 2018, 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. | ||
import '../../term_glyph.dart' as glyph; | ||
'''); | ||
|
||
for (var glyph in data) { | ||
for (var line in (glyph[3] as String).split('\n')) { | ||
file.writeStringSync('/// $line\n'); | ||
} | ||
|
||
file.writeStringSync(''' | ||
/// | ||
/// If [glyph.ascii] is `false`, this is "${glyph[1]}". If it's `true`, this is | ||
/// "${glyph[2]}" instead. | ||
String get ${glyph[0]} => glyph.glyphs.${glyph[0]}; | ||
'''); | ||
} | ||
|
||
file.closeSync(); | ||
} | ||
|
||
String _quote(String input) => input.contains("'") ? '"$input"' : "'$input'"; |