summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--doc/ranger.110
-rw-r--r--doc/ranger.pod7
-rw-r--r--doc/rifle.12
-rw-r--r--ranger/config/rc.conf3
-rw-r--r--ranger/container/settings.py2
-rw-r--r--ranger/core/actions.py1
-rw-r--r--ranger/ext/direction.py9
-rw-r--r--ranger/gui/widgets/browsercolumn.py7
8 files changed, 37 insertions, 4 deletions
diff --git a/doc/ranger.1 b/doc/ranger.1
index 3bf260f1..61bc31a3 100644
--- a/doc/ranger.1
+++ b/doc/ranger.1
@@ -129,7 +129,7 @@
 .\" ========================================================================
 .\"
 .IX Title "RANGER 1"
-.TH RANGER 1 "ranger-1.9.0b5" "07/16/2017" "ranger manual"
+.TH RANGER 1 "ranger-1.9.0b5" "09/17/2017" "ranger manual"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
@@ -816,6 +816,14 @@ all directories above the current one as well?
 .IP "mouse_enabled [bool] <zm>" 4
 .IX Item "mouse_enabled [bool] <zm>"
 Enable mouse input?
+.IP "one_indexed [bool]" 4
+.IX Item "one_indexed [bool]"
+Start line numbers from 1.  Possible values are:
+.Sp
+.Vb 2
+\& false      start line numbers from 0
+\& true       start line numbers from 1
+.Ve
 .IP "padding_right [bool]" 4
 .IX Item "padding_right [bool]"
 When collapse_preview is on and there is no preview, should there remain a
diff --git a/doc/ranger.pod b/doc/ranger.pod
index 9c91bd96..5d72ba1c 100644
--- a/doc/ranger.pod
+++ b/doc/ranger.pod
@@ -812,6 +812,13 @@ all directories above the current one as well?
 
 Enable mouse input?
 
+=item one_indexed [bool]
+
+Start line numbers from 1.  Possible values are:
+
+ false      start line numbers from 0
+ true       start line numbers from 1
+
 =item padding_right [bool]
 
 When collapse_preview is on and there is no preview, should there remain a
diff --git a/doc/rifle.1 b/doc/rifle.1
index aefc3979..4d112c6f 100644
--- a/doc/rifle.1
+++ b/doc/rifle.1
@@ -129,7 +129,7 @@
 .\" ========================================================================
 .\"
 .IX Title "RIFLE 1"
-.TH RIFLE 1 "rifle-1.9.0b5" "07/16/2017" "rifle manual"
+.TH RIFLE 1 "rifle-1.9.0b5" "09/17/2017" "rifle manual"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf
index 92428312..b4163083 100644
--- a/ranger/config/rc.conf
+++ b/ranger/config/rc.conf
@@ -221,6 +221,9 @@ set clear_filters_on_dir_change false
 # Disable displaying line numbers in main column
 set line_numbers false
 
+# Start line numbers from 1 instead of 0
+set one_indexed false
+
 # Save tabs on exit
 set save_tabs_on_exit false
 
diff --git a/ranger/container/settings.py b/ranger/container/settings.py
index 521583c4..a0e1ab10 100644
--- a/ranger/container/settings.py
+++ b/ranger/container/settings.py
@@ -50,6 +50,7 @@ ALLOWED_SETTINGS = {
     'max_history_size': (int, type(None)),
     'metadata_deep_search': bool,
     'mouse_enabled': bool,
+    'one_indexed': bool,
     'open_all_images': bool,
     'padding_right': bool,
     'preview_directories': bool,
@@ -93,6 +94,7 @@ ALLOWED_VALUES = {
     'cd_tab_case': ['sensitive', 'insensitive', 'smart'],
     'confirm_on_delete': ['multiple', 'always', 'never'],
     'line_numbers': ['false', 'absolute', 'relative'],
+    'one_indexed': [False, True],
     'preview_images_method': ['w3m', 'iterm2', 'urxvt', 'urxvt-full'],
     'vcs_backend_bzr': ['disabled', 'local', 'enabled'],
     'vcs_backend_git': ['enabled', 'disabled', 'local'],
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index eb091186..5f8f6c53 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -461,6 +461,7 @@ class Actions(  # pylint: disable=too-many-instance-attributes,too-many-public-m
         """
         cwd = self.thisdir
         kw.setdefault('cycle', self.fm.settings['wrap_scroll'])
+        kw.setdefault('one_indexed', self.fm.settings['one_indexed'])
         direction = Direction(kw)
         if 'left' in direction or direction.left() > 0:
             steps = direction.left()
diff --git a/ranger/ext/direction.py b/ranger/ext/direction.py
index e337c26e..7df45556 100644
--- a/ranger/ext/direction.py
+++ b/ranger/ext/direction.py
@@ -96,6 +96,10 @@ class Direction(dict):
     def cycle(self):
         return self.get('cycle') in (True, 'true', 'on', 'yes')
 
+    def one_indexed(self):
+        return ('one_indexed' in self and
+                self.get('one_indexed') in (True, 'true', 'on', 'yes'))
+
     def multiply(self, n):
         for key in ('up', 'right', 'down', 'left'):
             try:
@@ -129,7 +133,10 @@ class Direction(dict):
         pos = direction
         if override is not None:
             if self.absolute():
-                pos = override
+                if self.one_indexed():
+                    pos = override - 1
+                else:
+                    pos = override
             else:
                 pos *= override
         if self.pages():
diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py
index 14fde110..75559954 100644
--- a/ranger/gui/widgets/browsercolumn.py
+++ b/ranger/gui/widgets/browsercolumn.py
@@ -203,7 +203,12 @@ class BrowserColumn(Pager):  # pylint: disable=too-many-instance-attributes
         if self.settings.line_numbers == 'relative':
             line_number = abs(selected_i - i)
             if line_number == 0:
-                line_number = selected_i
+                if self.settings.one_indexed:
+                    line_number = selected_i + 1
+                else:
+                    line_number = selected_i
+        elif self.settings.one_indexed:
+            line_number += 1
 
         return linum_format.format(line_number)