Skip to content
This repository has been archived by the owner on Nov 29, 2022. It is now read-only.

Commit

Permalink
Detect bright background and foreground color versions
Browse files Browse the repository at this point in the history
  • Loading branch information
hSaria committed May 17, 2020
1 parent 2c545a8 commit 7f0de18
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions chromaterm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
COLOR_TYPES = {
'fg': {
'reset': '\x1b[39m',
're': re.compile(r'\x1b\[3(?:[0-79]|8;[0-9;]+)m')
're': re.compile(r'\x1b\[(?:3[0-79]|9[0-7]|38;[0-9;]+)m')
},
'bg': {
'reset': '\x1b[49m',
're': re.compile(r'\x1b\[4(?:[0-79]|8;[0-9;]+)m')
're': re.compile(r'\x1b\[(?:4[0-79]|10[0-7]|48;[0-9;]+)m')
},
'blink': {
'code': '\x1b[5m',
Expand Down
4 changes: 2 additions & 2 deletions chromaterm/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def test_baseline_tty_test_code_ttyname_different():

def test_config_decode_sgr_bg():
"""Background colors and reset are being detected."""
for code in ['\x1b[48;5;123m', '\x1b[48;2;1;1;1m', '\x1b[49m']:
for code in ['\x1b[48;5;12m', '\x1b[48;2;1;1;1m', '\x1b[49m', '\x1b[101m']:
colors = chromaterm.cli.Config.decode_sgr(code)
assert len(colors) == 1

Expand All @@ -117,7 +117,7 @@ def test_config_decode_sgr_bg():

def test_config_decode_sgr_fg():
"""Foreground colors and reset are being detected."""
for code in ['\x1b[38;5;123m', '\x1b[38;2;1;1;1m', '\x1b[39m']:
for code in ['\x1b[38;5;12m', '\x1b[38;2;1;1;1m', '\x1b[39m', '\x1b[91m']:
colors = chromaterm.cli.Config.decode_sgr(code)
assert len(colors) == 1

Expand Down
6 changes: 6 additions & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## ChromaTerm v0.6

### v0.6.2 – under development

* Detect bright background and foreground colors that may exist in the input of `ct`.

---

### v0.6.1 – 2020-05-02

* Fixed a rare bug that caused `ct` to wait on a key stroke after the program it spawned got closed.
Expand Down

0 comments on commit 7f0de18

Please sign in to comment.