Skip to content

Commit

Permalink
Merge pull request #1660 from dart-lang/merge-term_glyph-package
Browse files Browse the repository at this point in the history
Merge `package:term_glyph`
  • Loading branch information
mosuem authored Dec 17, 2024
2 parents 4dcd4d9 + 983e272 commit c90e95b
Show file tree
Hide file tree
Showing 19 changed files with 1,461 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/term_glyph.md
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"
---
4 changes: 4 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@
- changed-files:
- any-glob-to-any-file: 'pkgs/sse/**'

'package:term_glyph':
- changed-files:
- any-glob-to-any-file: 'pkgs/term_glyph/**'

'package:test_reflective_loader':
- changed-files:
- any-glob-to-any-file: 'pkgs/test_reflective_loader/**'
Expand Down
72 changes: 72 additions & 0 deletions .github/workflows/term_glyph.yaml
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'
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ don't naturally belong to other topic monorepos (like
| [source_maps](pkgs/source_maps/) | A library to programmatically manipulate source map files. | [![package issues](https://img.shields.io/badge/package:source_maps-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Asource_maps) | [![pub package](https://img.shields.io/pub/v/source_maps.svg)](https://pub.dev/packages/source_maps) |
| [source_span](pkgs/source_span/) | Provides a standard representation for source code locations and spans. | [![package issues](https://img.shields.io/badge/package:source_span-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Asource_span) | [![pub package](https://img.shields.io/pub/v/source_span.svg)](https://pub.dev/packages/source_span) |
| [sse](pkgs/sse/) | Provides client and server functionality for setting up bi-directional communication through Server Sent Events (SSE) and corresponding POST requests. | [![package issues](https://img.shields.io/badge/package:sse-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Asse) | [![pub package](https://img.shields.io/pub/v/sse.svg)](https://pub.dev/packages/sse) |
| [term_glyph](pkgs/term_glyph/) | Useful Unicode glyphs and ASCII substitutes. | [![package issues](https://img.shields.io/badge/package:term_glyph-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aterm_glyph) | [![pub package](https://img.shields.io/pub/v/term_glyph.svg)](https://pub.dev/packages/term_glyph) |
| [test_reflective_loader](pkgs/test_reflective_loader/) | Support for discovering tests and test suites using reflection. | [![package issues](https://img.shields.io/badge/package:test_reflective_loader-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Atest_reflective_loader) | [![pub package](https://img.shields.io/pub/v/test_reflective_loader.svg)](https://pub.dev/packages/test_reflective_loader) |
| [timing](pkgs/timing/) | A simple package for tracking the performance of synchronous and asynchronous actions. | [![package issues](https://img.shields.io/badge/package:timing-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Atiming) | [![pub package](https://img.shields.io/pub/v/timing.svg)](https://pub.dev/packages/timing) |
| [unified_analytics](pkgs/unified_analytics/) | A package for logging analytics for all Dart and Flutter related tooling to Google Analytics. | [![package issues](https://img.shields.io/badge/package:unified_analytics-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aunified_analytics) | [![pub package](https://img.shields.io/pub/v/unified_analytics.svg)](https://pub.dev/packages/unified_analytics) |
Expand Down
4 changes: 4 additions & 0 deletions pkgs/term_glyph/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.dart_tool/
.pub/
.packages
pubspec.lock
6 changes: 6 additions & 0 deletions pkgs/term_glyph/AUTHORS
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.
31 changes: 31 additions & 0 deletions pkgs/term_glyph/CHANGELOG.md
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.
27 changes: 27 additions & 0 deletions pkgs/term_glyph/LICENSE
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.
47 changes: 47 additions & 0 deletions pkgs/term_glyph/README.md
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.
32 changes: 32 additions & 0 deletions pkgs/term_glyph/analysis_options.yaml
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
85 changes: 85 additions & 0 deletions pkgs/term_glyph/data.csv
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.
Loading

0 comments on commit c90e95b

Please sign in to comment.