From 4237ce33d7b7bb95bc0ed3536bb5e4fc1b9c8325 Mon Sep 17 00:00:00 2001 From: toonn Date: Sat, 26 May 2018 15:21:27 +0200 Subject: In terminals devoid of color cut items were invisible Since most people use dark background terminals - yes, I'm assuming because it's my preference - the black color for cut items is nearly invisible the intention was for bold to be interpreted as bright but that's a dirty dirty trick. Since dim white sounds like bright black that's what we fall back to now for terminals that don't support BRIGHT colors. The solarized theme remains unchanged, so still uses bold, because it looks like it knows what it's doing. Fixes #1185 --- ranger/colorschemes/default.py | 33 ++++++++++++++++++++------------- ranger/colorschemes/snow.py | 6 +++--- ranger/gui/color.py | 5 +++++ 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/ranger/colorschemes/default.py b/ranger/colorschemes/default.py index 350c8359..63f6f8c3 100644 --- a/ranger/colorschemes/default.py +++ b/ranger/colorschemes/default.py @@ -6,7 +6,7 @@ from __future__ import (absolute_import, division, print_function) from ranger.gui.colorscheme import ColorScheme from ranger.gui.color import ( black, blue, cyan, green, magenta, red, white, yellow, default, - normal, bold, reverse, + normal, bold, reverse, dim, BRIGHT, default_colors, ) @@ -37,37 +37,42 @@ class Default(ColorScheme): if context.container: fg = red if context.directory: - attr |= bold fg = blue + fg += BRIGHT elif context.executable and not \ any((context.media, context.container, context.fifo, context.socket)): - attr |= bold fg = green + fg += BRIGHT if context.socket: fg = magenta - attr |= bold + fg += BRIGHT if context.fifo or context.device: fg = yellow if context.device: - attr |= bold + fg += BRIGHT if context.link: fg = cyan if context.good else magenta if context.tag_marker and not context.selected: - attr |= bold if fg in (red, magenta): fg = white else: fg = red + fg += BRIGHT if not context.selected and (context.cut or context.copied): fg = black - attr |= bold + fg += BRIGHT + # If the terminal doesn't support bright colors, use dim white + # instead of black. + if BRIGHT == 0: + attr |= dim + fg = white if context.main_column: if context.selected: - attr |= bold + fg += BRIGHT if context.marked: - attr |= bold fg = yellow + fg += BRIGHT if context.badinfo: if attr & reverse: bg = magenta @@ -78,7 +83,6 @@ class Default(ColorScheme): fg = cyan elif context.in_titlebar: - attr |= bold if context.hostname: fg = red if context.bad else green elif context.directory: @@ -88,6 +92,7 @@ class Default(ColorScheme): bg = green elif context.link: fg = cyan + fg += BRIGHT elif context.in_statusbar: if context.permissions: @@ -96,15 +101,17 @@ class Default(ColorScheme): elif context.bad: fg = magenta if context.marked: - attr |= bold | reverse + attr |= reverse fg = yellow + fg += BRIGHT if context.frozen: - attr |= bold | reverse + attr |= reverse fg = cyan + fg += BRIGHT if context.message: if context.bad: - attr |= bold fg = red + fg += BRIGHT if context.loaded: bg = self.progress_bar_color if context.vcsinfo: diff --git a/ranger/colorschemes/snow.py b/ranger/colorschemes/snow.py index 8e9686a8..0370e46a 100644 --- a/ranger/colorschemes/snow.py +++ b/ranger/colorschemes/snow.py @@ -4,7 +4,7 @@ from __future__ import (absolute_import, division, print_function) from ranger.gui.colorscheme import ColorScheme -from ranger.gui.color import default_colors, reverse, bold +from ranger.gui.color import default_colors, reverse, BRIGHT class Snow(ColorScheme): @@ -19,7 +19,7 @@ class Snow(ColorScheme): if context.selected: attr = reverse if context.directory: - attr |= bold + fg += BRIGHT elif context.highlight: attr |= reverse @@ -35,7 +35,7 @@ class Snow(ColorScheme): elif context.in_taskview: if context.selected: - attr |= bold + fg += BRIGHT if context.loaded: attr |= reverse diff --git a/ranger/gui/color.py b/ranger/gui/color.py index 45f983e8..8f6439c7 100644 --- a/ranger/gui/color.py +++ b/ranger/gui/color.py @@ -66,6 +66,11 @@ blink = curses.A_BLINK reverse = curses.A_REVERSE underline = curses.A_UNDERLINE invisible = curses.A_INVIS +dim = curses.A_DIM default_colors = (default, default, normal) # pylint: enable=invalid-name,bad-whitespace + +curses.setupterm() +# Adding BRIGHT to a color achieves what `bold` was used for. +BRIGHT = 8 if curses.tigetnum('colors') >= 16 else 0 -- cgit 1.4.1-2-gfad0 From 18d424138fbf1e58b03786bb61a18c9951f0fe7c Mon Sep 17 00:00:00 2001 From: toonn Date: Fri, 7 Sep 2018 20:03:16 +0200 Subject: Restore the use of the bold attribute Brightness by itself is not always clear so in terminals that actually support boldface it can help to differentiate. Bright black can be hard to differentiate from white, this is the case in kitty's default colorscheme. It's still better than the bold black because while that was easily differentiated from white it was very hard to see. --- ranger/colorschemes/default.py | 14 ++++++++++++-- ranger/colorschemes/snow.py | 4 +++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ranger/colorschemes/default.py b/ranger/colorschemes/default.py index 63f6f8c3..e9c42513 100644 --- a/ranger/colorschemes/default.py +++ b/ranger/colorschemes/default.py @@ -37,29 +37,35 @@ class Default(ColorScheme): if context.container: fg = red if context.directory: + attr |= bold fg = blue fg += BRIGHT elif context.executable and not \ any((context.media, context.container, context.fifo, context.socket)): + attr |= bold fg = green fg += BRIGHT if context.socket: + attr |= bold fg = magenta fg += BRIGHT if context.fifo or context.device: fg = yellow if context.device: + attr |= bold fg += BRIGHT if context.link: fg = cyan if context.good else magenta if context.tag_marker and not context.selected: + attr |= bold if fg in (red, magenta): fg = white else: fg = red fg += BRIGHT if not context.selected and (context.cut or context.copied): + attr |= bold fg = black fg += BRIGHT # If the terminal doesn't support bright colors, use dim white @@ -69,8 +75,10 @@ class Default(ColorScheme): fg = white if context.main_column: if context.selected: + attr |= bold fg += BRIGHT if context.marked: + attr |= bold fg = yellow fg += BRIGHT if context.badinfo: @@ -92,6 +100,7 @@ class Default(ColorScheme): bg = green elif context.link: fg = cyan + attr |= bold fg += BRIGHT elif context.in_statusbar: @@ -101,15 +110,16 @@ class Default(ColorScheme): elif context.bad: fg = magenta if context.marked: - attr |= reverse + attr |= bold | reverse fg = yellow fg += BRIGHT if context.frozen: - attr |= reverse + attr |= bold | reverse fg = cyan fg += BRIGHT if context.message: if context.bad: + attr |= bold fg = red fg += BRIGHT if context.loaded: diff --git a/ranger/colorschemes/snow.py b/ranger/colorschemes/snow.py index 0370e46a..c5f23c1c 100644 --- a/ranger/colorschemes/snow.py +++ b/ranger/colorschemes/snow.py @@ -4,7 +4,7 @@ from __future__ import (absolute_import, division, print_function) from ranger.gui.colorscheme import ColorScheme -from ranger.gui.color import default_colors, reverse, BRIGHT +from ranger.gui.color import default_colors, reverse, bold, BRIGHT class Snow(ColorScheme): @@ -19,6 +19,7 @@ class Snow(ColorScheme): if context.selected: attr = reverse if context.directory: + attr |= bold fg += BRIGHT elif context.highlight: @@ -35,6 +36,7 @@ class Snow(ColorScheme): elif context.in_taskview: if context.selected: + attr |= bold fg += BRIGHT if context.loaded: attr |= reverse -- cgit 1.4.1-2-gfad0 From 60b566061fc9948a97735802fd637baddaced7b2 Mon Sep 17 00:00:00 2001 From: Toon Nolten Date: Sat, 8 Sep 2018 22:18:53 +0200 Subject: Fix unbrightened selection BRIGHT is additive, not idempotent like bold is. This caused what should be bright text to be "unbrightened" again. --- ranger/colorschemes/default.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ranger/colorschemes/default.py b/ranger/colorschemes/default.py index e9c42513..a9e01e0c 100644 --- a/ranger/colorschemes/default.py +++ b/ranger/colorschemes/default.py @@ -74,13 +74,13 @@ class Default(ColorScheme): attr |= dim fg = white if context.main_column: + # Doubling up with BRIGHT here causes issues because it's + # additive not idempotent. if context.selected: attr |= bold - fg += BRIGHT if context.marked: attr |= bold fg = yellow - fg += BRIGHT if context.badinfo: if attr & reverse: bg = magenta -- cgit 1.4.1-2-gfad0