Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change ANSI color code 3 mapping from brown to gold and set bold format processing enabled by default #611

Merged
merged 9 commits into from
Jul 18, 2024
2 changes: 1 addition & 1 deletion qtconsole/ansi_code_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ class QtAnsiCodeProcessor(AnsiCodeProcessor):
0 : 'black', # black
1 : 'darkred', # red
2 : 'darkgreen', # green
3 : 'brown', # yellow
3 : 'gold', # yellow
4 : 'darkblue', # blue
5 : 'darkviolet', # magenta
6 : 'steelblue', # cyan
Expand Down
14 changes: 11 additions & 3 deletions qtconsole/tests/test_ansi_code_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
import unittest

# Local imports
from qtconsole.ansi_code_processor import AnsiCodeProcessor
from qtconsole.ansi_code_processor import AnsiCodeProcessor, QtAnsiCodeProcessor


class TestAnsiCodeProcessor(unittest.TestCase):

def setUp(self):
self.processor = AnsiCodeProcessor()
self.qt_processor = QtAnsiCodeProcessor()

def test_clear(self):
""" Do control sequences for clearing the console work?
Expand Down Expand Up @@ -37,7 +38,7 @@ def test_clear(self):
def test_colors(self):
""" Do basic controls sequences for colors work?
"""
string = 'first\x1b[34mblue\x1b[0mlast'
string = 'first\x1b[34mblue\x1b[0mlast\033[33mYellow'
i = -1
for i, substring in enumerate(self.processor.split_string(string)):
if i == 0:
Expand All @@ -49,9 +50,16 @@ def test_colors(self):
elif i == 2:
self.assertEqual(substring, 'last')
self.assertEqual(self.processor.foreground_color, None)
elif i == 3:
foreground_color = self.processor.foreground_color
self.assertEqual(substring, 'Yellow')
self.assertEqual(foreground_color, 3)
self.assertEqual(self.qt_processor.get_color(foreground_color).name(), '#ffd700')


jsbautista marked this conversation as resolved.
Show resolved Hide resolved
else:
self.fail('Too many substrings.')
self.assertEqual(i, 2, 'Too few substrings.')
self.assertEqual(i, 3, 'Too few substrings.')

def test_colors_xterm(self):
""" Do xterm-specific control sequences for colors work?
Expand Down
Loading