Skip to content
This repository was archived by the owner on Feb 20, 2026. It is now read-only.

Commit 7668590

Browse files
authored
Merge pull request #10 from TankerApp/dm/symbol
Add ui.Symbol class
2 parents ea15ecf + 6e3556c commit 7668590

3 files changed

Lines changed: 30 additions & 1 deletion

File tree

docs/changelog.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Changelog
22
==========
33

4+
v0.4.1
5+
------
6+
7+
* Export a ``Symbol`` class, to use when you do not want to force
8+
color as with ``UnicodeSequence``
9+
410
v0.4.0
511
------
612

docs/usage.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ You can use any of these constants as a ``token`` in the following functions:
7474
* ``cross``: ❌ (red, replaced by 'ko' on Windows)
7575
* ``ellipsis``: … (no color, replaced by '...' on Windows)
7676

77-
You can create your own sequences using :class:`UnicodeSequence`:
77+
You can create your own colored sequences using :class:`UnicodeSequence`:
7878

7979
.. autoclass:: UnicodeSequence
8080

@@ -85,6 +85,18 @@ You can use any of these constants as a ``token`` in the following functions:
8585
↑ 2 commits # on Linux
8686
+ 2 commits # on Windows
8787

88+
Alternatively, if you do not wont to force a color, you can use
89+
:class:`Symbol`:
90+
91+
.. autoclass:: Symbol
92+
93+
::
94+
95+
>>> heart = ui.Symbol("❤", "<3")
96+
>>> ui.info("Thanks for using python-cli-ui", heart)
97+
Thanks for using python-cli-ui ❤ # on Linux
98+
Thanks for using python-cli-ui <3 # on Windows
99+
88100

89101

90102
Informative messages

ui/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,14 @@ def tuple(self):
117117
cross = UnicodeSequence(red, "❌","ko")
118118

119119

120+
class Symbol(UnicodeSequence):
121+
def __init__(self, as_unicode, as_ascii):
122+
super().__init__(reset, as_unicode, as_ascii)
123+
124+
def tuple(self):
125+
return (self.as_string,)
126+
127+
120128
def using_colorama():
121129
if os.name == "nt":
122130
if "TERM" not in os.environ:
@@ -544,6 +552,9 @@ def did_you_mean(message, user_input, choices):
544552

545553

546554
if __name__ == "__main__":
555+
info("OK", check)
556+
up = Symbol("👍", "+1")
557+
info("I like it", blue, up)
547558
info_section(bold, "python-cli demo")
548559
# Monkey-patch message() so that we sleep after
549560
# each call

0 commit comments

Comments
 (0)