From b6c3bf3763242fade28661463623dc03337bc7be Mon Sep 17 00:00:00 2001 From: Rob Broadley Date: Mon, 6 Jan 2025 18:40:26 +0000 Subject: [PATCH] Fix highlighted text not readable with some color schemes Make the foreground (text) color be the usual background color, when highlighting text. This is done by setting the foreground color instead of the background color, then inverting (code 7) to swap the foreground and background colors. Previously, with some color schemes there was not enough contrast between the text and highlight color. Based on the assumption that there should be contrast between terminal colors and the background, this should make the text readable with a wider set of color schemes. --- pre_commit/color.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pre_commit/color.py b/pre_commit/color.py index 2d6f248b..00354df8 100644 --- a/pre_commit/color.py +++ b/pre_commit/color.py @@ -56,10 +56,10 @@ if sys.platform == 'win32': # pragma: no cover (windows) else: # pragma: win32 no cover terminal_supports_color = True -RED = '\033[41m' -GREEN = '\033[42m' -YELLOW = '\033[43;30m' -TURQUOISE = '\033[46;30m' +RED = '\033[31;7m' +GREEN = '\033[32;7m' +YELLOW = '\033[33;7m' +TURQUOISE = '\033[36;7m' SUBTLE = '\033[2m' NORMAL = '\033[m'