about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authortoonn <toonn@toonn.io>2020-04-09 21:57:16 +0200
committertoonn <toonn@toonn.io>2020-04-09 21:57:16 +0200
commit94a21ef35169737922d6b4e22fe1e82ea37679af (patch)
treefc89f88653f6df374e6e725d9c135e097bec36cc
parent081e73152a9391211770fab56676d7d974413ae6 (diff)
downloadranger-94a21ef35169737922d6b4e22fe1e82ea37679af.tar.gz
Implement a line_number context for colorschemes
Changes the default color for line numbers to differ from the file's
color to the terminal's base foreground color in the default theme.
Green in the jungle theme and bold and/or bright in the snow theme.

Fixes #1906
-rw-r--r--ranger/colorschemes/default.py3
-rw-r--r--ranger/colorschemes/jungle.py6
-rw-r--r--ranger/colorschemes/snow.py3
-rw-r--r--ranger/gui/context.py3
-rw-r--r--ranger/gui/widgets/browsercolumn.py6
5 files changed, 16 insertions, 5 deletions
diff --git a/ranger/colorschemes/default.py b/ranger/colorschemes/default.py
index 3d50e2e4..86d2fbba 100644
--- a/ranger/colorschemes/default.py
+++ b/ranger/colorschemes/default.py
@@ -64,6 +64,9 @@ class Default(ColorScheme):
                 else:
                     fg = red
                 fg += BRIGHT
+            if context.line_number and not context.selected:
+                fg = default
+                attr &= ~bold
             if not context.selected and (context.cut or context.copied):
                 attr |= bold
                 fg = black
diff --git a/ranger/colorschemes/jungle.py b/ranger/colorschemes/jungle.py
index a1fd768d..c11ce64a 100644
--- a/ranger/colorschemes/jungle.py
+++ b/ranger/colorschemes/jungle.py
@@ -4,7 +4,7 @@
 from __future__ import (absolute_import, division, print_function)
 
 from ranger.colorschemes.default import Default
-from ranger.gui.color import green, red, blue
+from ranger.gui.color import green, red, blue, bold
 
 
 class Scheme(Default):
@@ -17,6 +17,10 @@ class Scheme(Default):
                 and not context.inactive_pane:
             fg = self.progress_bar_color
 
+        if context.line_number and not context.selected:
+            fg = self.progress_bar_color
+            attr &= ~bold
+
         if context.in_titlebar and context.hostname:
             fg = red if context.bad else blue
 
diff --git a/ranger/colorschemes/snow.py b/ranger/colorschemes/snow.py
index c5f23c1c..354c2a47 100644
--- a/ranger/colorschemes/snow.py
+++ b/ranger/colorschemes/snow.py
@@ -21,6 +21,9 @@ class Snow(ColorScheme):
             if context.directory:
                 attr |= bold
                 fg += BRIGHT
+            if context.line_number and not context.selected:
+                attr |= bold
+                fg += BRIGHT
 
         elif context.highlight:
             attr |= reverse
diff --git a/ranger/gui/context.py b/ranger/gui/context.py
index 96849686..202d6a53 100644
--- a/ranger/gui/context.py
+++ b/ranger/gui/context.py
@@ -16,7 +16,8 @@ CONTEXT_KEYS = [
     'good', 'bad',
     'space', 'permissions', 'owner', 'group', 'mtime', 'nlink',
     'scroll', 'all', 'bot', 'top', 'percentage', 'filter',
-    'flat', 'marked', 'tagged', 'tag_marker', 'cut', 'copied', 'frozen',
+    'flat', 'marked', 'tagged', 'tag_marker', 'line_number',
+    'cut', 'copied', 'frozen',
     'help_markup',  # COMPAT
     'seperator', 'key', 'special', 'border',  # COMPAT
     'title', 'text', 'highlight', 'bars', 'quotes', 'tab', 'loaded',
diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py
index 1412ef6a..8632cc46 100644
--- a/ranger/gui/widgets/browsercolumn.py
+++ b/ranger/gui/widgets/browsercolumn.py
@@ -280,8 +280,6 @@ class BrowserColumn(Pager):  # pylint: disable=too-many-instance-attributes
         # visible files in directory.
         linum_text_len = len(str(self.scroll_begin + self.hei))
         linum_format = "{0:>" + str(linum_text_len) + "}"
-        # add separator between line number and tag
-        linum_format += " "
 
         selected_i = self._get_index_of_selected_file()
         for line in range(self.hei):
@@ -347,12 +345,14 @@ class BrowserColumn(Pager):  # pylint: disable=too-many-instance-attributes
                     line_number_text = self._format_line_number(linum_format,
                                                                 i,
                                                                 selected_i)
-                    predisplay_left.append([line_number_text, []])
+                    predisplay_left.append([line_number_text, ['line_number']])
                     space -= linum_text_len
 
                     # Delete one additional character for space separator
                     # between the line number and the tag
                     space -= 1
+                    # add separator between line number and tag
+                    predisplay_left.append([' ', []])
 
             # selection mark
             tagmark = self._draw_tagged_display(tagged, tagged_marker)