diff options
author | toonn <toonn@toonn.io> | 2018-05-26 15:21:27 +0200 |
---|---|---|
committer | toonn <toonn@toonn.io> | 2018-09-07 22:39:50 +0200 |
commit | 4237ce33d7b7bb95bc0ed3536bb5e4fc1b9c8325 (patch) | |
tree | 63a0eb7d3dfdcdd9d7f6cb1a32818f5c13c7faae /ranger | |
parent | fa1d88115ba3a75cc2ea6d64b15553d30255e6aa (diff) | |
download | ranger-4237ce33d7b7bb95bc0ed3536bb5e4fc1b9c8325.tar.gz |
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
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/colorschemes/default.py | 33 | ||||
-rw-r--r-- | ranger/colorschemes/snow.py | 6 | ||||
-rw-r--r-- | 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 |