diff options
-rw-r--r-- | doc/ranger.1 | 5 | ||||
-rw-r--r-- | doc/ranger.pod | 4 | ||||
-rw-r--r-- | ranger/config/rc.conf | 3 | ||||
-rw-r--r-- | ranger/container/settings.py | 1 | ||||
-rw-r--r-- | ranger/core/actions.py | 7 | ||||
-rw-r--r-- | ranger/ext/human_readable.py | 5 | ||||
-rwxr-xr-x | ranger/ext/rifle.py | 2 | ||||
-rw-r--r-- | ranger/gui/widgets/browsercolumn.py | 6 | ||||
-rw-r--r-- | ranger/gui/widgets/pager.py | 6 |
9 files changed, 29 insertions, 10 deletions
diff --git a/doc/ranger.1 b/doc/ranger.1 index 02fb8c15..5a159e12 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -133,7 +133,7 @@ .\" ======================================================================== .\" .IX Title "RANGER 1" -.TH RANGER 1 "ranger-1.9.2" "2018-10-09" "ranger manual" +.TH RANGER 1 "ranger-1.9.2" "2018-10-26" "ranger manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -893,6 +893,9 @@ Otherwise the submaps are replaced with \*(L"...\*(R". .IP "hostname_in_titlebar [bool]" 4 .IX Item "hostname_in_titlebar [bool]" Show hostname in titlebar? +.IP "size_in_bytes [bool]" 4 +.IX Item "size_in_bytes [bool]" +Print file sizes in bytes instead of the default human-readable format. .IP "idle_delay [integer]" 4 .IX Item "idle_delay [integer]" The delay that ranger idly waits for user input, in milliseconds, with a diff --git a/doc/ranger.pod b/doc/ranger.pod index c319f785..8fbc8826 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -908,6 +908,10 @@ Otherwise the submaps are replaced with "...". Show hostname in titlebar? +=item size_in_bytes [bool] + +Print file sizes in bytes instead of the default human-readable format. + =item idle_delay [integer] The delay that ranger idly waits for user input, in milliseconds, with a diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index b69e3949..6867ce4a 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -293,6 +293,9 @@ set global_inode_type_filter # should be 'false' during start-up, but you can toggle it by pressing F. set freeze_files false +# Print file sizes in bytes instead of the default human-readable format. +set size_in_bytes false + # =================================================================== # == Local Options # =================================================================== diff --git a/ranger/container/settings.py b/ranger/container/settings.py index 405aaa48..22562c10 100644 --- a/ranger/container/settings.py +++ b/ranger/container/settings.py @@ -49,6 +49,7 @@ ALLOWED_SETTINGS = { 'hidden_filter': str, 'hint_collapse_threshold': int, 'hostname_in_titlebar': bool, + 'size_in_bytes': bool, 'idle_delay': int, 'iterm2_font_width': int, 'iterm2_font_height': int, diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 89c5124b..1b5d0028 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -998,12 +998,15 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m def scroll_preview(self, lines, narg=None): """:scroll_preview <lines> -Scroll the file preview by <lines> lines.""" + Scroll the file preview by <lines> lines. + """ preview_column = self.ui.browser.columns[-1] if preview_column.target and preview_column.target.is_file: if narg is not None: lines = narg - preview_column.scrollbit = max(0, preview_column.scrollbit + lines) + target_scroll = preview_column.scroll_extra + lines + max_scroll = len(preview_column.lines) - preview_column.hei + preview_column.scroll_extra = max(0, min(target_scroll, max_scroll)) preview_column.request_redraw() # -------------------------- diff --git a/ranger/ext/human_readable.py b/ranger/ext/human_readable.py index f365e594..385e56f4 100644 --- a/ranger/ext/human_readable.py +++ b/ranger/ext/human_readable.py @@ -3,6 +3,8 @@ from __future__ import (absolute_import, division, print_function) +from ranger.core.shared import SettingsAware + def human_readable(byte, separator=' '): # pylint: disable=too-many-return-statements """Convert a large number of bytes to an easily readable format. @@ -19,6 +21,9 @@ def human_readable(byte, separator=' '): # pylint: disable=too-many-return-stat if byte is None: return '' + if SettingsAware.settings.size_in_bytes: + return format(byte, 'n') # 'n' = locale-aware separator. + # I know this can be written much shorter, but this long version # performs much better than what I had before. If you attempt to # shorten this code, take performance into consideration. diff --git a/ranger/ext/rifle.py b/ranger/ext/rifle.py index ee156d9a..377f9b8a 100755 --- a/ranger/ext/rifle.py +++ b/ranger/ext/rifle.py @@ -162,9 +162,7 @@ class Rifle(object): # pylint: disable=too-many-instance-attributes config_file = self.config_file fobj = open(config_file, 'r') self.rules = [] - lineno = 0 for line in fobj: - lineno += 1 line = line.strip() if line.startswith('#') or line == '': continue diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py index 3845dc41..8d2e63eb 100644 --- a/ranger/gui/widgets/browsercolumn.py +++ b/ranger/gui/widgets/browsercolumn.py @@ -96,7 +96,9 @@ class BrowserColumn(Pager): # pylint: disable=too-many-instance-attributes self.fm.thisdir.move_to_obj(clicked_file) self.fm.execute_file(clicked_file) elif self.target.is_file: - self.scrollbit = max(0, self.scrollbit + direction) + target_scroll = self.scroll_extra + direction + max_scroll = len(self.lines) - self.hei + self.scroll_extra = max(0, min(target_scroll, max_scroll)) self.need_redraw = True else: if self.level > 0 and not direction: @@ -157,7 +159,7 @@ class BrowserColumn(Pager): # pylint: disable=too-many-instance-attributes if target != self.old_dir: self.need_redraw = True self.old_dir = target - self.scrollbit = 0 # reset scroll start + self.scroll_extra = 0 # reset scroll start if target: target.use() diff --git a/ranger/gui/widgets/pager.py b/ranger/gui/widgets/pager.py index c88f5ff0..3bb52e3f 100644 --- a/ranger/gui/widgets/pager.py +++ b/ranger/gui/widgets/pager.py @@ -29,18 +29,17 @@ class Pager(Widget): # pylint: disable=too-many-instance-attributes need_clear_image = False need_redraw_image = False max_width = None - scrollbit = 0 def __init__(self, win, embedded=False): Widget.__init__(self, win) self.embedded = embedded self.scroll_begin = 0 + self.scroll_extra = 0 self.startx = 0 self.markup = None self.lines = [] self.image = None self.image_drawn = False - self.scrollbit = 0 def _close_source(self): if self.source and self.source_is_stream: @@ -96,8 +95,9 @@ class Pager(Widget): # pylint: disable=too-many-instance-attributes self.clear_image() if not self.image: + scroll_pos = self.scroll_begin + self.scroll_extra line_gen = self._generate_lines( - starty=self.scrollbit, startx=self.startx) + starty=scroll_pos, startx=self.startx) for line, i in zip(line_gen, range(self.hei)): self._draw_line(i, line) |