From 48945a6d34cfd5ec9ca67be813b6fccfc0a1dfdf Mon Sep 17 00:00:00 2001 From: squigz Date: Wed, 3 Jan 2018 13:49:40 -0500 Subject: Add option to draw separators between columns instead of drawing boxes --- ranger/container/settings.py | 1 + ranger/gui/widgets/view_miller.py | 46 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/ranger/container/settings.py b/ranger/container/settings.py index 2f38a2b6..1dc61046 100644 --- a/ranger/container/settings.py +++ b/ranger/container/settings.py @@ -40,6 +40,7 @@ ALLOWED_SETTINGS = { 'display_size_in_status_bar': bool, 'display_tags_in_all_columns': bool, 'draw_borders': bool, + 'draw_separators': bool, 'draw_progress_bar_in_status_bar': bool, 'flushinput': bool, 'freeze_files': bool, diff --git a/ranger/gui/widgets/view_miller.py b/ranger/gui/widgets/view_miller.py index 1f08e1af..209978ec 100644 --- a/ranger/gui/widgets/view_miller.py +++ b/ranger/gui/widgets/view_miller.py @@ -100,6 +100,8 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta DisplayableContainer.draw(self) if self.settings.draw_borders: self._draw_borders() + if self.settings.draw_separators: + self._draw_separators() if self.draw_bookmarks: self._draw_bookmarks() elif self.draw_hints: @@ -173,6 +175,50 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta self.addch(self.hei - 1, right_end, curses.ACS_LRCORNER) # pylint: enable=no-member + def _draw_separators(self): + win = self.win + separators = self.settings.draw_separators + self.color('in_browser', 'border') + + left_start = 0 + right_end = self.wid - 1 + + for child in self.columns: + if not child.has_preview(): + left_start = child.x + child.wid + else: + break + + # Shift the rightmost vertical line to the left to create a padding, + # but only when padding_right is on, the preview column is collapsed + # and we did not open the pager to "zoom" in to the file. + if self.settings.padding_right and not self.pager.visible and self.is_collapsed: + right_end = self.columns[-1].x - 1 + if right_end < left_start: + right_end = self.wid - 1 + + + # Draw the vertical lines in the middle + for child in self.columns[:-1]: + if not child.has_preview(): + continue + if child.main_column and self.pager.visible: + # If we "zoom in" with the pager, we have to + # skip the between main_column and pager. + break + x = child.x + child.wid + y = self.hei - 1 + try: + # pylint: disable=no-member + win.vline(1, x, curses.ACS_VLINE, y - 1) + self.addch(0, x, curses.ACS_VLINE, 0) + self.addch(y, x, curses.ACS_VLINE, 0) + # pylint: enable=no-member + except curses.error: + # in case it's off the boundaries + pass + + def _collapse(self): # Should the last column be cut off? (Because there is no preview) if not self.settings.collapse_preview or not self.preview \ -- cgit 1.4.1-2-gfad0 From ab34ebb150b0741f52f7f84df08c10c3a2201f51 Mon Sep 17 00:00:00 2001 From: squigz Date: Thu, 4 Jan 2018 07:17:42 -0500 Subject: Add 'draw_separators' option to rc.conf --- ranger/config/rc.conf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index 6bb8f0d0..b6d4702c 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -126,6 +126,9 @@ set draw_progress_bar_in_status_bar true # Draw borders around columns? set draw_borders false +# Draw veritcal separators between columns? +set draw_borders false + # Display the directory name in tabs? set dirname_in_tabs false -- cgit 1.4.1-2-gfad0 From efbbdac00f1ca71615ae83e4f3a9899620454d07 Mon Sep 17 00:00:00 2001 From: squigz Date: Thu, 4 Jan 2018 07:19:44 -0500 Subject: Update manpage with 'draw_separator' setting --- doc/ranger.1 | 5 ++++- doc/ranger.pod | 4 ++++ doc/rifle.1 | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/doc/ranger.1 b/doc/ranger.1 index bb7114a2..39a9c051 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -129,7 +129,7 @@ .\" ======================================================================== .\" .IX Title "RANGER 1" -.TH RANGER 1 "ranger-1.9.0b6" "12/07/2017" "ranger manual" +.TH RANGER 1 "ranger-1.9.0b6" "01/04/2018" "ranger manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -769,6 +769,9 @@ Display tags in all columns? .IP "draw_borders [bool]" 4 .IX Item "draw_borders [bool]" Draw borders around columns? +.IP "draw_separators [bool]" 4 +.IX Item "draw_separators [bool]" +Draw vertical separators between columns? .IP "draw_progress_bar_in_status_bar [bool]" 4 .IX Item "draw_progress_bar_in_status_bar [bool]" Draw a progress bar in the status bar which displays the average state of all diff --git a/doc/ranger.pod b/doc/ranger.pod index 43926f46..76d879d4 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -759,6 +759,10 @@ Display tags in all columns? Draw borders around columns? +=item draw_separators [bool] + +Draw vertical separators between columns? + =item draw_progress_bar_in_status_bar [bool] Draw a progress bar in the status bar which displays the average state of all diff --git a/doc/rifle.1 b/doc/rifle.1 index 8531d69c..753b3c3c 100644 --- a/doc/rifle.1 +++ b/doc/rifle.1 @@ -129,7 +129,7 @@ .\" ======================================================================== .\" .IX Title "RIFLE 1" -.TH RIFLE 1 "rifle-1.9.0b6" "12/07/2017" "rifle manual" +.TH RIFLE 1 "rifle-1.9.0b6" "01/04/2018" "rifle manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l -- cgit 1.4.1-2-gfad0 From f8e37d8bc41b172d8d845cc7cca7a2d85109061c Mon Sep 17 00:00:00 2001 From: squigz Date: Thu, 4 Jan 2018 14:28:02 -0500 Subject: Fix draw_separators setting in rc.conf --- ranger/config/rc.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index b6d4702c..d5c4ba66 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -127,7 +127,7 @@ set draw_progress_bar_in_status_bar true set draw_borders false # Draw veritcal separators between columns? -set draw_borders false +set draw_separators false # Display the directory name in tabs? set dirname_in_tabs false -- cgit 1.4.1-2-gfad0 From 08fbe46b0237137d7c5aadead2882d6a826cddf7 Mon Sep 17 00:00:00 2001 From: squigz Date: Thu, 4 Jan 2018 14:36:22 -0500 Subject: Remove _draw_separators and integrate with _draw_borders with the `separators_only` argument --- ranger/gui/widgets/view_miller.py | 90 +++++++++++---------------------------- 1 file changed, 26 insertions(+), 64 deletions(-) diff --git a/ranger/gui/widgets/view_miller.py b/ranger/gui/widgets/view_miller.py index 209978ec..721f2d1f 100644 --- a/ranger/gui/widgets/view_miller.py +++ b/ranger/gui/widgets/view_miller.py @@ -101,7 +101,7 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta if self.settings.draw_borders: self._draw_borders() if self.settings.draw_separators: - self._draw_separators() + self._draw_borders(separators_only=True) if self.draw_bookmarks: self._draw_bookmarks() elif self.draw_hints: @@ -109,9 +109,10 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta elif self.draw_info: self._draw_info(self.draw_info) - def _draw_borders(self): + def _draw_borders(self, separators_only=False): win = self.win self.color('in_browser', 'border') + separators = separators_only left_start = 0 right_end = self.wid - 1 @@ -131,14 +132,15 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta right_end = self.wid - 1 # Draw horizontal lines and the leftmost vertical line - try: - # pylint: disable=no-member - win.hline(0, left_start, curses.ACS_HLINE, right_end - left_start) - win.hline(self.hei - 1, left_start, curses.ACS_HLINE, right_end - left_start) - win.vline(1, left_start, curses.ACS_VLINE, self.hei - 2) - # pylint: enable=no-member - except curses.error: - pass + if not separators: + try: + # pylint: disable=no-member + win.hline(0, left_start, curses.ACS_HLINE, right_end - left_start) + win.hline(self.hei - 1, left_start, curses.ACS_HLINE, right_end - left_start) + win.vline(1, left_start, curses.ACS_VLINE, self.hei - 2) + # pylint: enable=no-member + except curses.error: + pass # Draw the vertical lines in the middle for child in self.columns[:-1]: @@ -153,71 +155,31 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta try: # pylint: disable=no-member win.vline(1, x, curses.ACS_VLINE, y - 1) - self.addch(0, x, curses.ACS_TTEE, 0) - self.addch(y, x, curses.ACS_BTEE, 0) + char = curses.ACS_TTEE if not separators else curses.ACS_VLINE + self.addch(0, x, char, 0) + char = curses.ACS_BTEE if not separators else curses.ACS_VLINE + self.addch(y, x, char, 0) # pylint: enable=no-member except curses.error: # in case it's off the boundaries pass - # Draw the last vertical line - try: - # pylint: disable=no-member - win.vline(1, right_end, curses.ACS_VLINE, self.hei - 2) - # pylint: enable=no-member - except curses.error: - pass - - # pylint: disable=no-member - self.addch(0, left_start, curses.ACS_ULCORNER) - self.addch(self.hei - 1, left_start, curses.ACS_LLCORNER) - self.addch(0, right_end, curses.ACS_URCORNER) - self.addch(self.hei - 1, right_end, curses.ACS_LRCORNER) - # pylint: enable=no-member - - def _draw_separators(self): - win = self.win - separators = self.settings.draw_separators - self.color('in_browser', 'border') - - left_start = 0 - right_end = self.wid - 1 - - for child in self.columns: - if not child.has_preview(): - left_start = child.x + child.wid - else: - break - - # Shift the rightmost vertical line to the left to create a padding, - # but only when padding_right is on, the preview column is collapsed - # and we did not open the pager to "zoom" in to the file. - if self.settings.padding_right and not self.pager.visible and self.is_collapsed: - right_end = self.columns[-1].x - 1 - if right_end < left_start: - right_end = self.wid - 1 - - - # Draw the vertical lines in the middle - for child in self.columns[:-1]: - if not child.has_preview(): - continue - if child.main_column and self.pager.visible: - # If we "zoom in" with the pager, we have to - # skip the between main_column and pager. - break - x = child.x + child.wid - y = self.hei - 1 + if not separators: + # Draw the last vertical line try: # pylint: disable=no-member - win.vline(1, x, curses.ACS_VLINE, y - 1) - self.addch(0, x, curses.ACS_VLINE, 0) - self.addch(y, x, curses.ACS_VLINE, 0) + win.vline(1, right_end, curses.ACS_VLINE, self.hei - 2) # pylint: enable=no-member except curses.error: - # in case it's off the boundaries pass + if not separators: + # pylint: disable=no-member + self.addch(0, left_start, curses.ACS_ULCORNER) + self.addch(self.hei - 1, left_start, curses.ACS_LLCORNER) + self.addch(0, right_end, curses.ACS_URCORNER) + self.addch(self.hei - 1, right_end, curses.ACS_LRCORNER) + # pylint: enable=no-member def _collapse(self): # Should the last column be cut off? (Because there is no preview) -- cgit 1.4.1-2-gfad0 From bbb01f5e3e6bb86d4842db1e22f918dc0b06a40f Mon Sep 17 00:00:00 2001 From: squigz Date: Thu, 4 Jan 2018 16:05:44 -0500 Subject: Changes draw_borders setting to a string Allows drawing vertical separators between columns, borders around all the columns, both of the two, or none --- ranger/config/rc.conf | 7 ++--- ranger/container/settings.py | 3 +- ranger/gui/widgets/view_miller.py | 65 ++++++++++++++++++++------------------- 3 files changed, 37 insertions(+), 38 deletions(-) diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index d5c4ba66..5f5f182a 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -123,11 +123,8 @@ set status_bar_on_top false # currently running tasks which support progress bars? set draw_progress_bar_in_status_bar true -# Draw borders around columns? -set draw_borders false - -# Draw veritcal separators between columns? -set draw_separators false +# Draw borders around columns? (separators, borders, both, or none. Separators are vertical lines between columsn. Borders are around the entire columns. Both combines the two) +set draw_borders none # Display the directory name in tabs? set dirname_in_tabs false diff --git a/ranger/container/settings.py b/ranger/container/settings.py index 1dc61046..583616b5 100644 --- a/ranger/container/settings.py +++ b/ranger/container/settings.py @@ -39,7 +39,7 @@ ALLOWED_SETTINGS = { 'display_size_in_main_column': bool, 'display_size_in_status_bar': bool, 'display_tags_in_all_columns': bool, - 'draw_borders': bool, + 'draw_borders': str, 'draw_separators': bool, 'draw_progress_bar_in_status_bar': bool, 'flushinput': bool, @@ -97,6 +97,7 @@ ALLOWED_SETTINGS = { ALLOWED_VALUES = { 'cd_tab_case': ['sensitive', 'insensitive', 'smart'], 'confirm_on_delete': ['multiple', 'always', 'never'], + 'draw_borders': ['None', 'both', 'outline', 'separators'], 'line_numbers': ['false', 'absolute', 'relative'], 'one_indexed': [False, True], 'preview_images_method': ['w3m', 'iterm2', 'urxvt', 'urxvt-full'], diff --git a/ranger/gui/widgets/view_miller.py b/ranger/gui/widgets/view_miller.py index 721f2d1f..baf014af 100644 --- a/ranger/gui/widgets/view_miller.py +++ b/ranger/gui/widgets/view_miller.py @@ -99,9 +99,7 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta directory.use() DisplayableContainer.draw(self) if self.settings.draw_borders: - self._draw_borders() - if self.settings.draw_separators: - self._draw_borders(separators_only=True) + self._draw_borders(self.settings.draw_borders) if self.draw_bookmarks: self._draw_bookmarks() elif self.draw_hints: @@ -109,10 +107,13 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta elif self.draw_info: self._draw_info(self.draw_info) - def _draw_borders(self, separators_only=False): + def _draw_borders(self, string): win = self.win + + separators = 1 if string.lower() == "separators" else 0 + borders = 1 if string.lower() == "outline" else 0 + both = 1 if string.lower() == "both" else 0 self.color('in_browser', 'border') - separators = separators_only left_start = 0 right_end = self.wid - 1 @@ -132,7 +133,7 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta right_end = self.wid - 1 # Draw horizontal lines and the leftmost vertical line - if not separators: + if both or borders: try: # pylint: disable=no-member win.hline(0, left_start, curses.ACS_HLINE, right_end - left_start) @@ -143,28 +144,30 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta pass # Draw the vertical lines in the middle - for child in self.columns[:-1]: - if not child.has_preview(): - continue - if child.main_column and self.pager.visible: - # If we "zoom in" with the pager, we have to - # skip the between main_column and pager. - break - x = child.x + child.wid - y = self.hei - 1 - try: - # pylint: disable=no-member - win.vline(1, x, curses.ACS_VLINE, y - 1) - char = curses.ACS_TTEE if not separators else curses.ACS_VLINE - self.addch(0, x, char, 0) - char = curses.ACS_BTEE if not separators else curses.ACS_VLINE - self.addch(y, x, char, 0) - # pylint: enable=no-member - except curses.error: - # in case it's off the boundaries - pass - - if not separators: + if both or separators: + for child in self.columns[:-1]: + if not child.has_preview(): + continue + if child.main_column and self.pager.visible: + # If we "zoom in" with the pager, we have to + # skip the between main_column and pager. + break + x = child.x + child.wid + y = self.hei - 1 + try: + # pylint: disable=no-member + win.vline(1, x, curses.ACS_VLINE, y - 1) + char = curses.ACS_TTEE if both or borders else curses.ACS_VLINE + char = curses.ACS_TTEE if both or borders else curses.ACS_VLINE + self.addch(0, x, char, 0) + char = curses.ACS_BTEE if both or borders else curses.ACS_VLINE + self.addch(y, x, char, 0) + # pylint: enable=no-member + except curses.error: + # in case it's off the boundaries + pass + + if both or borders: # Draw the last vertical line try: # pylint: disable=no-member @@ -173,7 +176,7 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta except curses.error: pass - if not separators: + if both or borders: # pylint: disable=no-member self.addch(0, left_start, curses.ACS_ULCORNER) self.addch(self.hei - 1, left_start, curses.ACS_LLCORNER) @@ -203,10 +206,8 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta """Resize all the columns according to the given ratio""" ViewBase.resize(self, y, x, hei, wid) - borders = self.settings.draw_borders - pad = 1 if borders else 0 + pad = 1 if not self.settings.draw_borders.lower() == "none" else 0 left = pad - self.is_collapsed = self._collapse() if self.is_collapsed: generator = enumerate(self.stretch_ratios) -- cgit 1.4.1-2-gfad0 From 11ff0c35a1467e2fca59b9733acbe7b3b82045b8 Mon Sep 17 00:00:00 2001 From: squigz Date: Thu, 4 Jan 2018 16:08:42 -0500 Subject: Remove draw_separators from ALLOWED_SETTINGS --- ranger/container/settings.py | 1 - 1 file changed, 1 deletion(-) diff --git a/ranger/container/settings.py b/ranger/container/settings.py index 583616b5..f07c85a6 100644 --- a/ranger/container/settings.py +++ b/ranger/container/settings.py @@ -40,7 +40,6 @@ ALLOWED_SETTINGS = { 'display_size_in_status_bar': bool, 'display_tags_in_all_columns': bool, 'draw_borders': str, - 'draw_separators': bool, 'draw_progress_bar_in_status_bar': bool, 'flushinput': bool, 'freeze_files': bool, -- cgit 1.4.1-2-gfad0 From 8de67322c111e6e3c64cc2ddda829589e8c64bf9 Mon Sep 17 00:00:00 2001 From: squigz Date: Thu, 4 Jan 2018 20:09:10 -0500 Subject: Use True/False instead of 1/0 Update padding conditions to not show when draw_borders is set to separators or none --- ranger/gui/widgets/view_miller.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ranger/gui/widgets/view_miller.py b/ranger/gui/widgets/view_miller.py index baf014af..7cec3c21 100644 --- a/ranger/gui/widgets/view_miller.py +++ b/ranger/gui/widgets/view_miller.py @@ -110,9 +110,9 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta def _draw_borders(self, string): win = self.win - separators = 1 if string.lower() == "separators" else 0 - borders = 1 if string.lower() == "outline" else 0 - both = 1 if string.lower() == "both" else 0 + separators = True if string.lower() == "separators" else False + borders = True if string.lower() == "outline" else False + both = True if string.lower() == "both" else False self.color('in_browser', 'border') left_start = 0 @@ -206,7 +206,8 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta """Resize all the columns according to the given ratio""" ViewBase.resize(self, y, x, hei, wid) - pad = 1 if not self.settings.draw_borders.lower() == "none" else 0 + borders = self.settings.draw_borders.lower() + pad = 1 if borders == "outline" or borders == "both" else 0 left = pad self.is_collapsed = self._collapse() if self.is_collapsed: -- cgit 1.4.1-2-gfad0 From 16f6b5203f04e80275a0df717be70de93f1a6fb6 Mon Sep 17 00:00:00 2001 From: squigz Date: Thu, 4 Jan 2018 20:10:50 -0500 Subject: Fix rc.conf --- ranger/config/rc.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index 5f5f182a..3fd46d38 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -123,7 +123,7 @@ set status_bar_on_top false # currently running tasks which support progress bars? set draw_progress_bar_in_status_bar true -# Draw borders around columns? (separators, borders, both, or none. Separators are vertical lines between columsn. Borders are around the entire columns. Both combines the two) +# Draw borders around columns? (separators, outline, both, or none. Separators are vertical lines between columsn. Outline draws a box around all the columns. Both combines the two) set draw_borders none # Display the directory name in tabs? -- cgit 1.4.1-2-gfad0 From de45af6210e55e053504d734e058b9360e74762b Mon Sep 17 00:00:00 2001 From: squigz Date: Thu, 4 Jan 2018 20:16:37 -0500 Subject: Update manpage section on draw_borders --- doc/ranger.1 | 13 ++++++++++--- doc/ranger.pod | 9 +++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/doc/ranger.1 b/doc/ranger.1 index 39a9c051..21665bbf 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -766,9 +766,16 @@ Display the file size in the status bar? .IP "display_tags_in_all_columns [bool]" 4 .IX Item "display_tags_in_all_columns [bool]" Display tags in all columns? -.IP "draw_borders [bool]" 4 -.IX Item "draw_borders [bool]" -Draw borders around columns? +.IP "draw_borders [string]" 4 +.IX Item "draw_borders [string]" +Draw borders around or between the columns? Possible values are: +.Sp +.Vb 4 +\& none no borders of any sort +\& outline draw an outline around all the columns +\& separators draw only vertical lines between columns +\& both both of the above +.Ve .IP "draw_separators [bool]" 4 .IX Item "draw_separators [bool]" Draw vertical separators between columns? diff --git a/doc/ranger.pod b/doc/ranger.pod index 76d879d4..c54b6dfb 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -755,10 +755,15 @@ Display the file size in the status bar? Display tags in all columns? -=item draw_borders [bool] +=item draw_borders [string] -Draw borders around columns? +Draw borders around or between the columns? Possible values are: + none no borders of any sort + outline draw an outline around all the columns + separators draw only vertical lines between columns + both both of the above + =item draw_separators [bool] Draw vertical separators between columns? -- cgit 1.4.1-2-gfad0 From 50410a43f7f8d076bc6963dce0b21f8ce72955e0 Mon Sep 17 00:00:00 2001 From: squigz Date: Thu, 4 Jan 2018 20:18:49 -0500 Subject: Reduce calls to string.lower() --- ranger/gui/widgets/view_miller.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ranger/gui/widgets/view_miller.py b/ranger/gui/widgets/view_miller.py index 7cec3c21..795988cb 100644 --- a/ranger/gui/widgets/view_miller.py +++ b/ranger/gui/widgets/view_miller.py @@ -99,7 +99,7 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta directory.use() DisplayableContainer.draw(self) if self.settings.draw_borders: - self._draw_borders(self.settings.draw_borders) + self._draw_borders(self.settings.draw_borders.lower()) if self.draw_bookmarks: self._draw_bookmarks() elif self.draw_hints: @@ -110,9 +110,9 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta def _draw_borders(self, string): win = self.win - separators = True if string.lower() == "separators" else False - borders = True if string.lower() == "outline" else False - both = True if string.lower() == "both" else False + separators = True if string == "separators" else False + borders = True if string == "outline" else False + both = True if string == "both" else False self.color('in_browser', 'border') left_start = 0 @@ -158,7 +158,6 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta # pylint: disable=no-member win.vline(1, x, curses.ACS_VLINE, y - 1) char = curses.ACS_TTEE if both or borders else curses.ACS_VLINE - char = curses.ACS_TTEE if both or borders else curses.ACS_VLINE self.addch(0, x, char, 0) char = curses.ACS_BTEE if both or borders else curses.ACS_VLINE self.addch(y, x, char, 0) -- cgit 1.4.1-2-gfad0 From 4a1f382485894cfa9928ae734c93ba21dab888d1 Mon Sep 17 00:00:00 2001 From: squigz Date: Thu, 4 Jan 2018 20:43:48 -0500 Subject: remove unnecessary checks --- ranger/gui/widgets/view_miller.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ranger/gui/widgets/view_miller.py b/ranger/gui/widgets/view_miller.py index 795988cb..aa05260d 100644 --- a/ranger/gui/widgets/view_miller.py +++ b/ranger/gui/widgets/view_miller.py @@ -157,9 +157,9 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta try: # pylint: disable=no-member win.vline(1, x, curses.ACS_VLINE, y - 1) - char = curses.ACS_TTEE if both or borders else curses.ACS_VLINE + char = curses.ACS_TTEE if both else curses.ACS_VLINE self.addch(0, x, char, 0) - char = curses.ACS_BTEE if both or borders else curses.ACS_VLINE + char = curses.ACS_BTEE if both else curses.ACS_VLINE self.addch(y, x, char, 0) # pylint: enable=no-member except curses.error: -- cgit 1.4.1-2-gfad0 From 5a70e87c219c415bf9443cdf968e0e760d84ab12 Mon Sep 17 00:00:00 2001 From: squigz Date: Thu, 4 Jan 2018 20:52:06 -0500 Subject: draw_borders: treat true as both for backwards compatibility --- ranger/gui/widgets/view_miller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ranger/gui/widgets/view_miller.py b/ranger/gui/widgets/view_miller.py index aa05260d..39fe938e 100644 --- a/ranger/gui/widgets/view_miller.py +++ b/ranger/gui/widgets/view_miller.py @@ -112,7 +112,7 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta separators = True if string == "separators" else False borders = True if string == "outline" else False - both = True if string == "both" else False + both = True if string == "both" or string == "true" else False self.color('in_browser', 'border') left_start = 0 -- cgit 1.4.1-2-gfad0 From bb2956e755937b148496691ec746366cf65165be Mon Sep 17 00:00:00 2001 From: Wojciech Siewierski Date: Fri, 5 Jan 2018 02:55:54 +0100 Subject: Clean up the draw_borders code --- ranger/gui/widgets/view_miller.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/ranger/gui/widgets/view_miller.py b/ranger/gui/widgets/view_miller.py index 39fe938e..5ee266ae 100644 --- a/ranger/gui/widgets/view_miller.py +++ b/ranger/gui/widgets/view_miller.py @@ -107,12 +107,9 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta elif self.draw_info: self._draw_info(self.draw_info) - def _draw_borders(self, string): + def _draw_borders(self, border_type): win = self.win - separators = True if string == "separators" else False - borders = True if string == "outline" else False - both = True if string == "both" or string == "true" else False self.color('in_browser', 'border') left_start = 0 @@ -133,7 +130,7 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta right_end = self.wid - 1 # Draw horizontal lines and the leftmost vertical line - if both or borders: + if border_type in ['both', 'outline']: try: # pylint: disable=no-member win.hline(0, left_start, curses.ACS_HLINE, right_end - left_start) @@ -144,7 +141,7 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta pass # Draw the vertical lines in the middle - if both or separators: + if border_type in ['both', 'separators']: for child in self.columns[:-1]: if not child.has_preview(): continue @@ -157,16 +154,18 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta try: # pylint: disable=no-member win.vline(1, x, curses.ACS_VLINE, y - 1) - char = curses.ACS_TTEE if both else curses.ACS_VLINE - self.addch(0, x, char, 0) - char = curses.ACS_BTEE if both else curses.ACS_VLINE - self.addch(y, x, char, 0) + if border_type == 'both': + self.addch(0, x, curses.ACS_TTEE, 0) + self.addch(y, x, curses.ACS_BTEE, 0) + else: + self.addch(0, x, curses.ACS_VLINE, 0) + self.addch(y, x, curses.ACS_VLINE, 0) # pylint: enable=no-member except curses.error: # in case it's off the boundaries pass - if both or borders: + if border_type in ['both', 'outline']: # Draw the last vertical line try: # pylint: disable=no-member @@ -175,7 +174,7 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta except curses.error: pass - if both or borders: + if border_type in ['both', 'outline']: # pylint: disable=no-member self.addch(0, left_start, curses.ACS_ULCORNER) self.addch(self.hei - 1, left_start, curses.ACS_LLCORNER) -- cgit 1.4.1-2-gfad0 From b24a2246dc4c144e8589dbff03fd21301721c285 Mon Sep 17 00:00:00 2001 From: Wojciech Siewierski Date: Fri, 5 Jan 2018 03:18:12 +0100 Subject: Further draw_borders refactoring, "both" isn't now a distinct state --- ranger/gui/widgets/view_miller.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/ranger/gui/widgets/view_miller.py b/ranger/gui/widgets/view_miller.py index 5ee266ae..e207ab49 100644 --- a/ranger/gui/widgets/view_miller.py +++ b/ranger/gui/widgets/view_miller.py @@ -99,7 +99,12 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta directory.use() DisplayableContainer.draw(self) if self.settings.draw_borders: - self._draw_borders(self.settings.draw_borders.lower()) + draw_borders = self.settings.draw_borders.lower() + if draw_borders in ['both', 'true']: # 'true' for backwards compat. + border_types = ['separators', 'outline'] + else: + border_types = [draw_borders] + self._draw_borders(border_types) if self.draw_bookmarks: self._draw_bookmarks() elif self.draw_hints: @@ -107,7 +112,7 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta elif self.draw_info: self._draw_info(self.draw_info) - def _draw_borders(self, border_type): + def _draw_borders(self, border_types): win = self.win self.color('in_browser', 'border') @@ -130,7 +135,7 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta right_end = self.wid - 1 # Draw horizontal lines and the leftmost vertical line - if border_type in ['both', 'outline']: + if 'outline' in border_types: try: # pylint: disable=no-member win.hline(0, left_start, curses.ACS_HLINE, right_end - left_start) @@ -141,7 +146,7 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta pass # Draw the vertical lines in the middle - if border_type in ['both', 'separators']: + if 'separators' in border_types: for child in self.columns[:-1]: if not child.has_preview(): continue @@ -154,7 +159,7 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta try: # pylint: disable=no-member win.vline(1, x, curses.ACS_VLINE, y - 1) - if border_type == 'both': + if 'outline' in border_types: self.addch(0, x, curses.ACS_TTEE, 0) self.addch(y, x, curses.ACS_BTEE, 0) else: @@ -165,7 +170,7 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta # in case it's off the boundaries pass - if border_type in ['both', 'outline']: + if 'outline' in border_types: # Draw the last vertical line try: # pylint: disable=no-member @@ -174,7 +179,7 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta except curses.error: pass - if border_type in ['both', 'outline']: + if 'outline' in border_types: # pylint: disable=no-member self.addch(0, left_start, curses.ACS_ULCORNER) self.addch(self.hei - 1, left_start, curses.ACS_LLCORNER) @@ -204,8 +209,11 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta """Resize all the columns according to the given ratio""" ViewBase.resize(self, y, x, hei, wid) - borders = self.settings.draw_borders.lower() - pad = 1 if borders == "outline" or borders == "both" else 0 + border_type = self.settings.draw_borders.lower() + if border_type in ['outline', 'both', 'true']: + pad = 1 + else: + pad = 0 left = pad self.is_collapsed = self._collapse() if self.is_collapsed: -- cgit 1.4.1-2-gfad0 From 520e76e13f619715175b6ce83e22ad0e3e65b057 Mon Sep 17 00:00:00 2001 From: squigz Date: Fri, 5 Jan 2018 08:01:28 -0500 Subject: Disable pylint too-many-branches for _draw_borders --- ranger/gui/widgets/view_miller.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ranger/gui/widgets/view_miller.py b/ranger/gui/widgets/view_miller.py index e207ab49..0c3c47ba 100644 --- a/ranger/gui/widgets/view_miller.py +++ b/ranger/gui/widgets/view_miller.py @@ -113,6 +113,7 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta self._draw_info(self.draw_info) def _draw_borders(self, border_types): + # pylint: disable=too-many-branches win = self.win self.color('in_browser', 'border') -- cgit 1.4.1-2-gfad0 From 4e74225ee94b57524e5f8211419e4e8ce68ed694 Mon Sep 17 00:00:00 2001 From: squigz Date: Fri, 5 Jan 2018 08:14:36 -0500 Subject: Another pylint fix (2 spaces before in-line comment) --- ranger/gui/widgets/view_miller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ranger/gui/widgets/view_miller.py b/ranger/gui/widgets/view_miller.py index 0c3c47ba..54750e17 100644 --- a/ranger/gui/widgets/view_miller.py +++ b/ranger/gui/widgets/view_miller.py @@ -100,7 +100,7 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta DisplayableContainer.draw(self) if self.settings.draw_borders: draw_borders = self.settings.draw_borders.lower() - if draw_borders in ['both', 'true']: # 'true' for backwards compat. + if draw_borders in ['both', 'true']: # 'true' for backwards compat. border_types = ['separators', 'outline'] else: border_types = [draw_borders] -- cgit 1.4.1-2-gfad0 From d0afe4be708708d66d6505cbf10b271b0759bda2 Mon Sep 17 00:00:00 2001 From: squigz Date: Fri, 5 Jan 2018 08:18:38 -0500 Subject: Fix commit 520e76e --- ranger/gui/widgets/view_miller.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ranger/gui/widgets/view_miller.py b/ranger/gui/widgets/view_miller.py index 54750e17..ea2d26d6 100644 --- a/ranger/gui/widgets/view_miller.py +++ b/ranger/gui/widgets/view_miller.py @@ -112,8 +112,7 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta elif self.draw_info: self._draw_info(self.draw_info) - def _draw_borders(self, border_types): - # pylint: disable=too-many-branches + def _draw_borders(self, border_types): # pylint: disable=too-many-branches win = self.win self.color('in_browser', 'border') -- cgit 1.4.1-2-gfad0 From 5fc66210888db4d446989bab64eb5270d08b4bad Mon Sep 17 00:00:00 2001 From: guangzhi Date: Sun, 11 Mar 2018 08:52:23 +0800 Subject: Attempt to fix issue #1108 flag t problem issue #1108: Rifle's flag t only works with urxvt (and xterm) (because who cares about standards?). Urxvt passes any arguments after -e verbatim, most other terminals consume them as arguments. Some terminals use -e, others use -x. Fix: in rifle.py, if $TERMCMD is set to gnome-terminal, xfce4-terminal etc., give either -e or -x that pairs with the terminal. If $TERMCMD not found in executables, fall back to xterm and -e. --- ranger/ext/rifle.py | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/ranger/ext/rifle.py b/ranger/ext/rifle.py index 70215039..670d40a4 100755 --- a/ranger/ext/rifle.py +++ b/ranger/ext/rifle.py @@ -359,19 +359,34 @@ class Rifle(object): # pylint: disable=too-many-instance-attributes term = os.environ['TERM'] if term.startswith('rxvt-unicode'): term = 'urxvt' + cmdflag='-e' elif term.startswith('rxvt-'): # Sometimes urxvt calls itself "rxvt-256color" if 'rxvt' in get_executables(): term = 'rxvt' else: term = 'urxvt' - if term not in get_executables(): - self.hook_logger("Can not determine terminal command. " - "Please set $TERMCMD manually.") - # A fallback terminal that is likely installed: - term = 'xterm' - os.environ['TERMCMD'] = term - cmd = [os.environ['TERMCMD'], '-e'] + cmd + cmdflag='-e' + else: + term = os.environ['TERMCMD'] + if term in ['gnome-terminal', 'xfce4-terminal', 'mate-terminal',\ + 'terminator']: + cmdflag='-x' + elif term in ['lxterminal',]: + cmdflag='-e' + else: + cmdflag='-e' + + if term not in get_executables(): + self.hook_logger("Can not determine terminal command. " + "Please set $TERMCMD manually.") + # A fallback terminal that is likely installed: + term = 'xterm' + cmdflag='-e' + + os.environ['TERMCMD'] = term + cmd = [os.environ['TERMCMD'], cmdflag] + cmd + if 'f' in flags or 't' in flags: Popen_forked(cmd, env=self.hook_environment(os.environ)) else: -- cgit 1.4.1-2-gfad0 From 08774ba13f4c8d679dbabcd33f748b1002ee397b Mon Sep 17 00:00:00 2001 From: guangzhi Date: Sun, 11 Mar 2018 19:50:09 +0800 Subject: run test and fix some formatting --- ranger/ext/rifle.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ranger/ext/rifle.py b/ranger/ext/rifle.py index 670d40a4..8b1314c3 100755 --- a/ranger/ext/rifle.py +++ b/ranger/ext/rifle.py @@ -359,30 +359,30 @@ class Rifle(object): # pylint: disable=too-many-instance-attributes term = os.environ['TERM'] if term.startswith('rxvt-unicode'): term = 'urxvt' - cmdflag='-e' + cmdflag = '-e' elif term.startswith('rxvt-'): # Sometimes urxvt calls itself "rxvt-256color" if 'rxvt' in get_executables(): term = 'rxvt' else: term = 'urxvt' - cmdflag='-e' + cmdflag = '-e' else: term = os.environ['TERMCMD'] - if term in ['gnome-terminal', 'xfce4-terminal', 'mate-terminal',\ - 'terminator']: - cmdflag='-x' - elif term in ['lxterminal',]: - cmdflag='-e' + if term in ['gnome-terminal', 'xfce4-terminal', + 'mate-terminal', 'terminator']: + cmdflag = '-x' + elif term in ['lxterminal', ]: + cmdflag = '-e' else: - cmdflag='-e' + cmdflag = '-e' if term not in get_executables(): self.hook_logger("Can not determine terminal command. " "Please set $TERMCMD manually.") # A fallback terminal that is likely installed: term = 'xterm' - cmdflag='-e' + cmdflag = '-e' os.environ['TERMCMD'] = term cmd = [os.environ['TERMCMD'], cmdflag] + cmd -- cgit 1.4.1-2-gfad0 From 2b4984ecd0dccdf6fc1ddf1aa63725371e9234d2 Mon Sep 17 00:00:00 2001 From: guangzhi Date: Tue, 13 Mar 2018 16:14:14 +0800 Subject: re-organize block regarding flag t issue #1108 Changes made to rifle.py: * get `term` from `os.environ['TERMCMD']`, if failed, use `TERM` * if `term` not found in executables, fall back to `xterm` * choose `cmdflag` according to `term`, currently have 3 choices: * `-e`: tested terminals + versions: * xterm (331-1) * urxvt (9.22) * lxterminal (0.3.1-1) * konsole (17.12.2-1) * lilyterm (0.9.9.2-2) * cool-retro-term (1.0.1-1) * `-x`: * xfce4-terminal (0.8.7.1-1) * mate-terminal (1.20.0-1) * terminator (1.91-5) * gnome-terminal (3.26.2) * `--`: * gnome-terminal (3.26.2) * terminals that are found not working when tested: * pantheon-terminal (0.4.3-2): not -e or -x or --execute (people using elementary probably won't use ranger anyway). * terminology (1.1.1-1): not -e or -x * tilda (1.4.1-1): with -c tilda opens but not entering editor * kitty (0.8.0-1): don't think this has the functionality * terminals haven't tested: * st * termite (having conflicts on my system) * iterm2 --- ranger/ext/rifle.py | 48 +++++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/ranger/ext/rifle.py b/ranger/ext/rifle.py index 8b1314c3..f11f6f2c 100755 --- a/ranger/ext/rifle.py +++ b/ranger/ext/rifle.py @@ -355,33 +355,39 @@ class Rifle(object): # pylint: disable=too-many-instance-attributes cmd = prefix + [command] if 't' in flags: - if 'TERMCMD' not in os.environ: - term = os.environ['TERM'] - if term.startswith('rxvt-unicode'): - term = 'urxvt' - cmdflag = '-e' - elif term.startswith('rxvt-'): - # Sometimes urxvt calls itself "rxvt-256color" - if 'rxvt' in get_executables(): - term = 'rxvt' - else: - term = 'urxvt' - cmdflag = '-e' - else: - term = os.environ['TERMCMD'] - if term in ['gnome-terminal', 'xfce4-terminal', - 'mate-terminal', 'terminator']: - cmdflag = '-x' - elif term in ['lxterminal', ]: - cmdflag = '-e' - else: - cmdflag = '-e' + term = os.environ.get('TERMCMD', os.environ['TERM']) if term not in get_executables(): self.hook_logger("Can not determine terminal command. " "Please set $TERMCMD manually.") # A fallback terminal that is likely installed: term = 'xterm' + + # Choose correct cmdflag accordingly + if term.lower() in ['xfce4-terminal', 'mate-terminal', + 'terminator']: + cmdflag = '-x' + elif term.lower() in ['xterm', 'xterm-256color', 'urxvt', + 'rxvt', 'rxvt-256color', + 'rxvt-unicode', 'lxterminal', + 'konsole', 'lilyterm', + 'cool-retro-term']: + cmdflag = '-e' + elif term.lower() in ['gnome-terminal', ]: + cmdflag = '--' + # terminals that are found not working with -e or -x: + # consider uncomment the next 2 lines + #elif term.lower() in ['pantheon-terminal', 'terminology']: + #term = 'xterm' + #cmdflag = '-e' + # 'tilda opens with -c but doesn't go into editor. Not sure. + #elif term.lower() in ['tilda', ]: + #cmdflag = '-c' + # terminals not tested yet: + #elif term.lower() in ['st', 'stterm', 'termite', 'kitty', + #'iterm2']: + #pass + else: cmdflag = '-e' os.environ['TERMCMD'] = term -- cgit 1.4.1-2-gfad0 From b84444110868a3b4be4dea89a76aa86b883f151f Mon Sep 17 00:00:00 2001 From: guangzhi Date: Tue, 13 Mar 2018 20:32:12 +0800 Subject: Correct some formatting in fix of issue #1108. Remove some trailing whitespaces etc. Another note: regarding iterm2 or some other terminals on mac, it seems to be rather different to launch a new window in mac than in linux. Some search suggests that you need to issue open -a terminal -n to open a new terminal window. So that would probably involve other changes than simply getting a correct cmdflag. --- ranger/ext/rifle.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/ranger/ext/rifle.py b/ranger/ext/rifle.py index f11f6f2c..0fd8046f 100755 --- a/ranger/ext/rifle.py +++ b/ranger/ext/rifle.py @@ -370,23 +370,22 @@ class Rifle(object): # pylint: disable=too-many-instance-attributes elif term.lower() in ['xterm', 'xterm-256color', 'urxvt', 'rxvt', 'rxvt-256color', 'rxvt-unicode', 'lxterminal', - 'konsole', 'lilyterm', + 'konsole', 'lilyterm', 'cool-retro-term']: cmdflag = '-e' elif term.lower() in ['gnome-terminal', ]: cmdflag = '--' # terminals that are found not working with -e or -x: - # consider uncomment the next 2 lines - #elif term.lower() in ['pantheon-terminal', 'terminology']: - #term = 'xterm' - #cmdflag = '-e' + # consider uncomment the next 2 lines + # elif term.lower() in ['pantheon-terminal', 'terminology']: + # term = 'xterm' + # cmdflag = '-e' # 'tilda opens with -c but doesn't go into editor. Not sure. - #elif term.lower() in ['tilda', ]: - #cmdflag = '-c' + # elif term.lower() in ['tilda', ]: + # cmdflag = '-c' # terminals not tested yet: - #elif term.lower() in ['st', 'stterm', 'termite', 'kitty', - #'iterm2']: - #pass + # elif term.lower() in ['st', 'stterm', 'termite', 'kitty']: + # pass else: cmdflag = '-e' -- cgit 1.4.1-2-gfad0 From 7baa70ec2032e328439c286d0e671ef56be22e59 Mon Sep 17 00:00:00 2001 From: guangzhi Date: Fri, 16 Mar 2018 19:03:59 +0800 Subject: more terminals tested for fix of issue #1108 Handle aliases for 'xterm', 'xterm-256color' by using 'xterm' if $TERMCMD starts with 'xterm'. If $TERMCMD in ['urxvt', 'rxvt-unicode'], use 'urxvt'. If $TERMCMD in ['rxvt', 'rxvt-256color'], use 'rxvt' if found, otherwise 'urxvt'. Tested 'termite (13-1)', 'terminology (1.1.1-1)', 'pantheon-terminal (0.4.3-2)' and 'st (1:0.7.r38.g0ac685f-1)', these all use the -e flag. Tested 'tilda (1.4.1-1)', which uses -c flag. 'tilda', 'pantheon-terminal', 'terminology' and 'termite' don't work with the '/bin/sh --set' scheme. As a temp fix, get the application name and argument from `command` and compose the `cmd` list from these. See line 397--407 for details. Let's forget about mac users, shall we? --- ranger/ext/rifle.py | 56 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/ranger/ext/rifle.py b/ranger/ext/rifle.py index 0fd8046f..97dfb444 100755 --- a/ranger/ext/rifle.py +++ b/ranger/ext/rifle.py @@ -356,6 +356,20 @@ class Rifle(object): # pylint: disable=too-many-instance-attributes cmd = prefix + [command] if 't' in flags: term = os.environ.get('TERMCMD', os.environ['TERM']) + # we can do this, can't we? + term = term.lower() + + # handle aliases of xterm and urxvt, rxvt + # match 'xterm', 'xterm-256color' + if term.startswith('xterm'): + term = 'xterm' + if term in ['urxvt', 'rxvt-unicode']: + term = 'urxvt' + if term in ['rxvt', 'rxvt-256color']: + if 'rxvt 'in get_executables(): + term = 'rxvt' + else: + term = 'urxvt' if term not in get_executables(): self.hook_logger("Can not determine terminal command. " @@ -364,33 +378,35 @@ class Rifle(object): # pylint: disable=too-many-instance-attributes term = 'xterm' # Choose correct cmdflag accordingly - if term.lower() in ['xfce4-terminal', 'mate-terminal', - 'terminator']: + if term in ['xfce4-terminal', 'mate-terminal', 'terminator']: cmdflag = '-x' - elif term.lower() in ['xterm', 'xterm-256color', 'urxvt', - 'rxvt', 'rxvt-256color', - 'rxvt-unicode', 'lxterminal', - 'konsole', 'lilyterm', - 'cool-retro-term']: + elif term in ['xterm', 'urxvt', 'rxvt', 'lxterminal', + 'konsole', 'lilyterm', 'cool-retro-term', + 'terminology', 'pantheon-terminal', 'termite', + 'st', 'stterm']: cmdflag = '-e' - elif term.lower() in ['gnome-terminal', ]: + elif term in ['gnome-terminal', ]: cmdflag = '--' - # terminals that are found not working with -e or -x: - # consider uncomment the next 2 lines - # elif term.lower() in ['pantheon-terminal', 'terminology']: - # term = 'xterm' - # cmdflag = '-e' - # 'tilda opens with -c but doesn't go into editor. Not sure. - # elif term.lower() in ['tilda', ]: - # cmdflag = '-c' - # terminals not tested yet: - # elif term.lower() in ['st', 'stterm', 'termite', 'kitty']: - # pass + elif term in ['tilda', ]: + cmdflag = '-c' else: cmdflag = '-e' os.environ['TERMCMD'] = term - cmd = [os.environ['TERMCMD'], cmdflag] + cmd + + # These terms don't work with the '/bin/sh set --' scheme + # a temporary fix. + if term in ['tilda', 'pantheon-terminal', 'terminology', + 'termite']: + + target = command.split(';')[0].split('--')[1].strip() + app = command.split(';')[1].split('--')[0].strip() + cmd = [os.environ['TERMCMD'], cmdflag, '%s %s' + % (app, target)] + else: + cmd = [os.environ['TERMCMD'], cmdflag] + cmd + + # self.hook_logger('cmd: %s' %cmd) if 'f' in flags or 't' in flags: Popen_forked(cmd, env=self.hook_environment(os.environ)) -- cgit 1.4.1-2-gfad0 From 88b5a20142f3c7666a78ec86db667635681adc9f Mon Sep 17 00:00:00 2001 From: dbosst Date: Tue, 27 Mar 2018 21:41:12 -0400 Subject: Added: shift tabs right/left shift selected tab right/left with ALT-p or ALT-o --- ranger/config/rc.conf | 2 ++ ranger/core/actions.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index fe00c7c0..8ac83cd3 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -478,6 +478,8 @@ map tab_open 6 map tab_open 7 map tab_open 8 map tab_open 9 +map tab_shift 1 +map tab_shift -1 # Sorting map or set sort_reverse! diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 6bbb35aa..68551775 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -1191,6 +1191,34 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m return self.tab_open(i, path) return None + def tab_shift(self, offset): + """Shift the tab left/right + + Shift the current tab to the left or right + """ + assert isinstance(offset, int) + tablist = self.get_tab_list() + oldtab_index = self.current_tab + old_index = tablist.index(oldtab_index) + new_index = (old_index + offset) + if new_index < 0: + return None + if new_index > (len(tablist)-1): + return None + newtab_index = tablist[new_index] + if newtab_index != oldtab_index: + oldtab = self.tabs[oldtab_index] + newtab = self.tabs[newtab_index] + self.tabs[oldtab_index] = newtab + self.tabs[newtab_index] = oldtab + self.current_tab = newtab_index + self.thistab = oldtab + self.change_mode('normal') + self.signal_emit('tab.change', old=oldtab, new=newtab) + self.signal_emit('tab.change', old=newtab, new=oldtab) + self.signal_emit('tab.layoutchange') + return None + def tab_switch(self, path, create_directory=False): """Switches to tab of given path, opening a new tab as necessary. -- cgit 1.4.1-2-gfad0 From 5ed312402389b9882512f09a7a740e850ce446c3 Mon Sep 17 00:00:00 2001 From: dbosst Date: Wed, 28 Mar 2018 12:30:47 -0400 Subject: use offset and pos to shift tabs: offset will shift the tab number as seen pos will shift the tab to the tav number given preserves as much as possible the tab numbers --- ranger/config/rc.conf | 4 ++-- ranger/core/actions.py | 57 ++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 43 insertions(+), 18 deletions(-) diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index 8ac83cd3..53171112 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -478,8 +478,8 @@ map tab_open 6 map tab_open 7 map tab_open 8 map tab_open 9 -map tab_shift 1 -map tab_shift -1 +map tab_shift 1 +map tab_shift -1 # Sorting map or set sort_reverse! diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 68551775..55226434 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -1191,31 +1191,56 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m return self.tab_open(i, path) return None - def tab_shift(self, offset): + def tab_shift(self, offset=0, pos=None): """Shift the tab left/right - Shift the current tab to the left or right + Shift the current tab to the left or right by either: + offset - changes the tab number by offset + pos - shifts the tab to the specified tab number """ - assert isinstance(offset, int) - tablist = self.get_tab_list() + oldtab_index = self.current_tab - old_index = tablist.index(oldtab_index) - new_index = (old_index + offset) - if new_index < 0: - return None - if new_index > (len(tablist)-1): - return None - newtab_index = tablist[new_index] + if pos is None: + assert isinstance(offset, int) + # enumerated index (1 to 9) + newtab_index = oldtab_index + offset + if newtab_index < 1: + newtab_index = 1 + if newtab_index > 9: + newtab_index = 9 + else: + assert isinstance(pos, int) + if pos < 1 or pos > 9: + return None + newtab_index = pos + # shift tabs without enumerating, preserve tab numbers when can if newtab_index != oldtab_index: + # the other tabs shift in the opposite direction + if (newtab_index - oldtab_index) > 0: + direction = -1 + else: + direction = 1 + + def tabshiftreorder(source_index): + # shift the tabs to make source_index empty + if source_index in self.tabs: + target_index = source_index + direction + # make the target_index empty recursively + tabshiftreorder(target_index) + # shift the source to target + source_tab = self.tabs[source_index] + self.tabs[target_index] = source_tab + del self.tabs[source_index] + + # first remove the current tab from the dict oldtab = self.tabs[oldtab_index] - newtab = self.tabs[newtab_index] - self.tabs[oldtab_index] = newtab + del self.tabs[oldtab_index] + # make newtab_index empty by shifting + tabshiftreorder(newtab_index) self.tabs[newtab_index] = oldtab self.current_tab = newtab_index self.thistab = oldtab - self.change_mode('normal') - self.signal_emit('tab.change', old=oldtab, new=newtab) - self.signal_emit('tab.change', old=newtab, new=oldtab) + self.ui.titlebar.request_redraw() self.signal_emit('tab.layoutchange') return None -- cgit 1.4.1-2-gfad0 From 2bb4c49acd42058378da59cc8d580f9aab1a9f6f Mon Sep 17 00:00:00 2001 From: guangzhi Date: Sat, 19 May 2018 07:52:41 +0800 Subject: remove term=term.lower() --- ranger/ext/rifle.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/ranger/ext/rifle.py b/ranger/ext/rifle.py index 5c17839a..650b8796 100755 --- a/ranger/ext/rifle.py +++ b/ranger/ext/rifle.py @@ -364,17 +364,15 @@ class Rifle(object): # pylint: disable=too-many-instance-attributes cmd = prefix + [command] if 't' in flags: term = os.environ.get('TERMCMD', os.environ['TERM']) - # we can do this, can't we? - term = term.lower() - # handle aliases of xterm and urxvt, rxvt - # match 'xterm', 'xterm-256color' + # Handle aliases of xterm and urxvt, rxvt. + # Match 'xterm', 'xterm-256color' if term.startswith('xterm'): term = 'xterm' if term in ['urxvt', 'rxvt-unicode']: term = 'urxvt' if term in ['rxvt', 'rxvt-256color']: - if 'rxvt 'in get_executables(): + if 'rxvt' in get_executables(): term = 'rxvt' else: term = 'urxvt' @@ -402,8 +400,8 @@ class Rifle(object): # pylint: disable=too-many-instance-attributes os.environ['TERMCMD'] = term - # These terms don't work with the '/bin/sh set --' scheme - # a temporary fix. + # These terms don't work with the '/bin/sh set --' scheme. + # A temporary fix. if term in ['tilda', 'pantheon-terminal', 'terminology', 'termite']: -- cgit 1.4.1-2-gfad0 From 5def08ab1aa0231f174f1090fb26ddab20387a64 Mon Sep 17 00:00:00 2001 From: toonn Date: Sat, 23 Jun 2018 22:57:23 +0200 Subject: Change rifle fallback mechanism for flag t Rifle used to just fall back to using `xterm` when `flag t` was used and `TERMCMD` didn't yield a valid command or the terminal emulator couldn't be determined from the `TERM` variable. Now when the need to fallback occurs rifle uses its own rules with a custom mime type i.e. `ranger/x-terminal-emulator`. This way we can provide a default sequence from rarer to more common terminal emulators and users can change the fallback by editing `rifle.conf` Fixes #1108 --- ranger/config/rifle.conf | 28 ++++++++++++++++++++++++++++ ranger/ext/rifle.py | 35 ++++++++++++++++++++++++++--------- 2 files changed, 54 insertions(+), 9 deletions(-) diff --git a/ranger/config/rifle.conf b/ranger/config/rifle.conf index b1a9bb71..83254a87 100644 --- a/ranger/config/rifle.conf +++ b/ranger/config/rifle.conf @@ -210,6 +210,34 @@ ext ace, has unace = for file in "$@"; do unace e "$file"; done ext rar, has unrar = unrar l "$1" | less ext rar, has unrar = for file in "$@"; do unrar x "$file"; done +#------------------------------------------- +# Flag t fallback terminals +#------------------------------------------- +# Rarely installed terminal emulators get higher priority; It is assumed that +# if you install a rare terminal emulator, you probably use it. +# gnome-terminal/konsole/xterm on the other hand are often installed as part of +# a desktop environment or as fallback terminal emulators. +mime ^ranger/x-terminal-emulator, has terminology = terminology -e "$@" +mime ^ranger/x-terminal-emulator, has kitty = kitty -- "$@" +mime ^ranger/x-terminal-emulator, has alacritty = alacritty -e "$@" +mime ^ranger/x-terminal-emulator, has sakura = sakura -e "$@" +mime ^ranger/x-terminal-emulator, has lilyterm = lilyterm -e "$@" +#mime ^ranger/x-terminal-emulator, has cool-retro-term = cool-retro-term -e "$@" +mime ^ranger/x-terminal-emulator, has termite = termite -x '"$@"' +#mime ^ranger/x-terminal-emulator, has yakuake = yakuake -e "$@" +mime ^ranger/x-terminal-emulator, has guake = guake -ne "$@" +mime ^ranger/x-terminal-emulator, has tilda = tilda -c "$@" +mime ^ranger/x-terminal-emulator, has st = st -e "$@" +mime ^ranger/x-terminal-emulator, has terminator = terminator -x "$@" +mime ^ranger/x-terminal-emulator, has urxvt = urxvt -e "$@" +mime ^ranger/x-terminal-emulator, has pantheon-terminal = pantheon-terminal -e "$@" +mime ^ranger/x-terminal-emulator, has lxterminal = lxterminal -e "$@" +mime ^ranger/x-terminal-emulator, has mate-terminal = mate-terminal -x "$@" +mime ^ranger/x-terminal-emulator, has xfce4-terminal = xfce4-terminal -x "$@" +mime ^ranger/x-terminal-emulator, has konsole = konsole -e "$@" +mime ^ranger/x-terminal-emulator, has gnome-terminal = gnome-terminal -- "$@" +mime ^ranger/x-terminal-emulator, has xterm = xterm -e "$@" + #------------------------------------------- # Misc #------------------------------------------- diff --git a/ranger/ext/rifle.py b/ranger/ext/rifle.py index 650b8796..6106656e 100755 --- a/ranger/ext/rifle.py +++ b/ranger/ext/rifle.py @@ -365,11 +365,19 @@ class Rifle(object): # pylint: disable=too-many-instance-attributes if 't' in flags: term = os.environ.get('TERMCMD', os.environ['TERM']) - # Handle aliases of xterm and urxvt, rxvt. + # Handle aliases of xterm and urxvt, rxvt and st and + # termite # Match 'xterm', 'xterm-256color' - if term.startswith('xterm'): + if term in ['xterm', 'xterm-256color']: term = 'xterm' - if term in ['urxvt', 'rxvt-unicode']: + if term in ['xterm-kitty']: + term = 'kitty' + if term in ['xterm-termite']: + term = 'termite' + if term in ['st', 'st-256color']: + term = 'st' + if term in ['urxvt', 'rxvt-unicode', + 'rxvt-unicode-256color']: term = 'urxvt' if term in ['rxvt', 'rxvt-256color']: if 'rxvt' in get_executables(): @@ -378,20 +386,27 @@ class Rifle(object): # pylint: disable=too-many-instance-attributes term = 'urxvt' if term not in get_executables(): - self.hook_logger("Can not determine terminal command. " - "Please set $TERMCMD manually.") - # A fallback terminal that is likely installed: - term = 'xterm' + self.hook_logger("Can not determine terminal command, " + "using rifle to determine fallback. " + "Please set $TERMCMD manually or " + "change fallbacks in rifle.conf.") + self._mimetype = 'ranger/x-terminal-emulator' + self.execute( + files=[command.split(';')[1].split('--')[0].strip()] + + files, flags='f', + mimetype='ranger/x-terminal-emulator') + return None # Choose correct cmdflag accordingly - if term in ['xfce4-terminal', 'mate-terminal', 'terminator']: + if term in ['xfce4-terminal', 'mate-terminal', + 'terminator']: cmdflag = '-x' elif term in ['xterm', 'urxvt', 'rxvt', 'lxterminal', 'konsole', 'lilyterm', 'cool-retro-term', 'terminology', 'pantheon-terminal', 'termite', 'st', 'stterm']: cmdflag = '-e' - elif term in ['gnome-terminal', ]: + elif term in ['gnome-terminal', 'kitty']: cmdflag = '--' elif term in ['tilda', ]: cmdflag = '-c' @@ -409,6 +424,8 @@ class Rifle(object): # pylint: disable=too-many-instance-attributes app = command.split(';')[1].split('--')[0].strip() cmd = [os.environ['TERMCMD'], cmdflag, '%s %s' % (app, target)] + elif term in ['guake']: + cmd = [os.environ['TERMCMD'], '-n', '${PWD}', cmdflag] + cmd else: cmd = [os.environ['TERMCMD'], cmdflag] + cmd -- cgit 1.4.1-2-gfad0 From 970d2ae77f7988e4af0dc604ff6444306f5d9be4 Mon Sep 17 00:00:00 2001 From: Nathaniel Date: Sat, 7 Jul 2018 18:08:22 -0700 Subject: Update plugin_pmount.py Currently the pmount plugin uses static device letters and partition numbers. this change uses present devices and partitions. - Changes the binds to remove the need for uppercase device letters, if a device has no partitions mounts/unmounts the device. - With only one partition the same binds will handle it instead of the whole device. - With greater than one partitions, map for each. This is still not fully functional, devices not present when ranger is started *(usb drives)* won't have a map created unless ranger is restarted :| ... Is there a simple way to have ranger 'reload' this plugin, or use a different hook, etc.? --- examples/plugin_pmount.py | 67 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 20 deletions(-) diff --git a/examples/plugin_pmount.py b/examples/plugin_pmount.py index 38c4a17c..feb54c83 100644 --- a/examples/plugin_pmount.py +++ b/examples/plugin_pmount.py @@ -3,38 +3,65 @@ # This plugin creates a bunch of keybindings used to mount and unmount # the devices using pmount(1). # -# alt+m : mount /dev/sd -# alt+m : mount /dev/sd -# alt+shift+m : unmount /dev/sd -# alt+shift+m : unmount /dev/sd -# alt+shift+n : list the devices +# (multiple partitions): alt+m : mount /dev/sd +# (one partition): alt+m : mount /dev/sd1 +# (no partitions): alt+m : mount /dev/sd +# +# (multiple partitions): alt+M : unmount /dev/sd +# (one partition): alt+M : unmount /dev/sd1 +# (no partitions): alt+M : unmount /dev/sd +# +# alt+n : list the devices from __future__ import (absolute_import, division, print_function) import ranger.api +import subprocess MOUNT_KEY = 'm' UMOUNT_KEY = 'M' -LIST_MOUNTS_KEY = 'N' - - +LIST_MOUNTS_KEY = 'n' HOOK_INIT_OLD = ranger.api.hook_init - def hook_init(fm): fm.execute_console("map {key} shell -p lsblk".format(key=LIST_MOUNTS_KEY)) - for disk in "abcdefgh": - fm.execute_console("map {key}{0} chain shell pmount sd{1}; cd /media/sd{1}".format( - disk.upper(), disk, key=MOUNT_KEY)) - fm.execute_console("map {key}{0} chain cd; chain shell pumount sd{1}".format( - disk.upper(), disk, key=UMOUNT_KEY)) - for part in "123456789": + + diskcmd = "lsblk -lno NAME | grep -w 'sd[a-z]' | sed 's/sd//'" + disks = subprocess.check_output(diskcmd, + shell=True).decode('utf-8').replace('\r', '').replace('\n', '') + + for disk in disks: + partcmd = "lsblk -lno NAME /dev/sd{0} | sed 's/sd{0}//' | tail -n 1".format(disk) + + try: + numparts = int(subprocess.check_output(partcmd, + shell=True).decode('utf-8').replace('\r', '').replace('\n', '')) + except ValueError: + numparts = 0 + + if numparts == 0: + # no partition, mount the whole device + fm.execute_console("map {key}{0} chain shell pmount sd{0}; cd /media/sd{0}".format( + disk, key=MOUNT_KEY)) + fm.execute_console("map {key}{0} chain cd; chain shell pumount sd{0}".format( + disk, key=UMOUNT_KEY)) + + elif numparts == 1: + # only one partition, mount the partition fm.execute_console( - "map {key}{0}{1} chain shell pmount sd{0}{1}; cd /media/sd{0}{1}".format( - disk, part, key=MOUNT_KEY) - ) - fm.execute_console("map {key}{0}{1} chain cd; shell pumount sd{0}{1}".format( - disk, part, key=UMOUNT_KEY)) + "map {key}{0} chain shell pmount sd{0}1; cd /media/sd{0}1".format( + disk, key=MOUNT_KEY)) + fm.execute_console("map {key}{0} chain cd; shell pumount sd{0}1".format( + disk, key=UMOUNT_KEY)) + + else: + # use range start 1, /dev/sd{device}0 doesn't exist + for part in range(1, numparts + 1): + fm.execute_console( + "map {key}{0}{1} chain shell pmount sd{0}{1}; cd /media/sd{0}{1}".format( + disk, part, key=MOUNT_KEY)) + fm.execute_console("map {key}{0}{1} chain cd; shell pumount sd{0}{1}".format( + disk, part, key=UMOUNT_KEY)) return HOOK_INIT_OLD(fm) -- cgit 1.4.1-2-gfad0 From 58bcf8691d522d658e8b4a1c0389d5bb53c3d1aa Mon Sep 17 00:00:00 2001 From: Nathaniel Date: Sat, 7 Jul 2018 19:01:13 -0700 Subject: Indentation and whitespace cleanup --- examples/plugin_pmount.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/examples/plugin_pmount.py b/examples/plugin_pmount.py index feb54c83..f7e1bd3c 100644 --- a/examples/plugin_pmount.py +++ b/examples/plugin_pmount.py @@ -27,15 +27,13 @@ def hook_init(fm): fm.execute_console("map {key} shell -p lsblk".format(key=LIST_MOUNTS_KEY)) diskcmd = "lsblk -lno NAME | grep -w 'sd[a-z]' | sed 's/sd//'" - disks = subprocess.check_output(diskcmd, - shell=True).decode('utf-8').replace('\r', '').replace('\n', '') + disks = subprocess.check_output(diskcmd, shell=True).decode('utf-8').replace('\r', '').replace('\n', '') for disk in disks: partcmd = "lsblk -lno NAME /dev/sd{0} | sed 's/sd{0}//' | tail -n 1".format(disk) - + try: - numparts = int(subprocess.check_output(partcmd, - shell=True).decode('utf-8').replace('\r', '').replace('\n', '')) + numparts = int(subprocess.check_output(partcmd, shell=True).decode('utf-8').replace('\r', '').replace('\n', '')) except ValueError: numparts = 0 @@ -48,18 +46,16 @@ def hook_init(fm): elif numparts == 1: # only one partition, mount the partition - fm.execute_console( - "map {key}{0} chain shell pmount sd{0}1; cd /media/sd{0}1".format( - disk, key=MOUNT_KEY)) + fm.execute_console("map {key}{0} chain shell pmount sd{0}1; cd /media/sd{0}1".format( + disk, key=MOUNT_KEY)) fm.execute_console("map {key}{0} chain cd; shell pumount sd{0}1".format( disk, key=UMOUNT_KEY)) - + else: # use range start 1, /dev/sd{device}0 doesn't exist for part in range(1, numparts + 1): - fm.execute_console( - "map {key}{0}{1} chain shell pmount sd{0}{1}; cd /media/sd{0}{1}".format( - disk, part, key=MOUNT_KEY)) + fm.execute_console("map {key}{0}{1} chain shell pmount sd{0}{1}; cd /media/sd{0}{1}".format( + disk, part, key=MOUNT_KEY)) fm.execute_console("map {key}{0}{1} chain cd; shell pumount sd{0}{1}".format( disk, part, key=UMOUNT_KEY)) -- cgit 1.4.1-2-gfad0 From 0e4577ea8ac0ea99e2c44164e2e81182d1ec4d07 Mon Sep 17 00:00:00 2001 From: Nathaniel Date: Sat, 7 Jul 2018 19:07:30 -0700 Subject: import order and break long lines --- examples/plugin_pmount.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/examples/plugin_pmount.py b/examples/plugin_pmount.py index f7e1bd3c..3079b5a3 100644 --- a/examples/plugin_pmount.py +++ b/examples/plugin_pmount.py @@ -15,8 +15,8 @@ from __future__ import (absolute_import, division, print_function) -import ranger.api import subprocess +import ranger.api MOUNT_KEY = 'm' UMOUNT_KEY = 'M' @@ -27,13 +27,15 @@ def hook_init(fm): fm.execute_console("map {key} shell -p lsblk".format(key=LIST_MOUNTS_KEY)) diskcmd = "lsblk -lno NAME | grep -w 'sd[a-z]' | sed 's/sd//'" - disks = subprocess.check_output(diskcmd, shell=True).decode('utf-8').replace('\r', '').replace('\n', '') + disks = subprocess.check_output( + diskcmd, shell=True).decode('utf-8').replace('\r', '').replace('\n', '') for disk in disks: partcmd = "lsblk -lno NAME /dev/sd{0} | sed 's/sd{0}//' | tail -n 1".format(disk) try: - numparts = int(subprocess.check_output(partcmd, shell=True).decode('utf-8').replace('\r', '').replace('\n', '')) + numparts = int(subprocess.check_output( + partcmd, shell=True).decode('utf-8').replace('\r', '').replace('\n', '')) except ValueError: numparts = 0 @@ -43,19 +45,21 @@ def hook_init(fm): disk, key=MOUNT_KEY)) fm.execute_console("map {key}{0} chain cd; chain shell pumount sd{0}".format( disk, key=UMOUNT_KEY)) - + elif numparts == 1: # only one partition, mount the partition - fm.execute_console("map {key}{0} chain shell pmount sd{0}1; cd /media/sd{0}1".format( - disk, key=MOUNT_KEY)) + fm.execute_console( + "map {key}{0} chain shell pmount sd{0}1; cd /media/sd{0}1".format( + disk, key=MOUNT_KEY)) fm.execute_console("map {key}{0} chain cd; shell pumount sd{0}1".format( disk, key=UMOUNT_KEY)) else: # use range start 1, /dev/sd{device}0 doesn't exist for part in range(1, numparts + 1): - fm.execute_console("map {key}{0}{1} chain shell pmount sd{0}{1}; cd /media/sd{0}{1}".format( - disk, part, key=MOUNT_KEY)) + fm.execute_console( + "map {key}{0}{1} chain shell pmount sd{0}{1}; cd /media/sd{0}{1}".format( + disk, part, key=MOUNT_KEY)) fm.execute_console("map {key}{0}{1} chain cd; shell pumount sd{0}{1}".format( disk, part, key=UMOUNT_KEY)) -- cgit 1.4.1-2-gfad0 From d0f4e2c56af9e0e6452289fd136bb3c9934af225 Mon Sep 17 00:00:00 2001 From: Nathaniel Date: Sat, 7 Jul 2018 19:10:47 -0700 Subject: 2 lines around function definition --- examples/plugin_pmount.py | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/plugin_pmount.py b/examples/plugin_pmount.py index 3079b5a3..f5bd1c67 100644 --- a/examples/plugin_pmount.py +++ b/examples/plugin_pmount.py @@ -23,6 +23,7 @@ UMOUNT_KEY = 'M' LIST_MOUNTS_KEY = 'n' HOOK_INIT_OLD = ranger.api.hook_init + def hook_init(fm): fm.execute_console("map {key} shell -p lsblk".format(key=LIST_MOUNTS_KEY)) -- cgit 1.4.1-2-gfad0 From f1603478415f0981ee865ee7413255318a7d7d3e Mon Sep 17 00:00:00 2001 From: Toon Nolten Date: Tue, 21 Aug 2018 10:46:37 +0200 Subject: Add selection argument to move action If `selection == False` don't operate on the entire selection (the marked files) but only on the file under the cursor. Inconsistent, I noticed `move to=100 percentage=true` works as expected but `move right=1 selection=false` doesn't. You need to pass `False`, most other values test as `True` in python, so `true` works *but* surprisingly imo, `false == True`. Fixes #1233 --- ranger/core/actions.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 83cfcc08..1417ac96 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -489,7 +489,10 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m if narg is not None: mode = narg tfile = self.thisfile - selection = self.thistab.get_selection() + if not kw.get('selection', True): + selection = [tfile] + else: + selection = self.thistab.get_selection() if tfile.is_directory: self.thistab.enter_dir(tfile) elif selection: -- cgit 1.4.1-2-gfad0 From a78adddd9bc5cb919f0d903216415522fac8c19a Mon Sep 17 00:00:00 2001 From: Toon Nolten Date: Tue, 21 Aug 2018 10:55:53 +0200 Subject: Fix type in execute_file docstring --- ranger/core/actions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 1417ac96..e645e2f8 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -407,7 +407,7 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m are multiple choices label: a string to select an opening method by its label flags: a string specifying additional options, see `man rifle` - mimetyle: pass the mimetype to rifle, overriding its own guess + mimetype: pass the mimetype to rifle, overriding its own guess """ mode = kw['mode'] if 'mode' in kw else 0 -- cgit 1.4.1-2-gfad0 From 37d39a99185b2eb43c2c9a807a1c4ed4477ebac5 Mon Sep 17 00:00:00 2001 From: Toon Nolten Date: Tue, 21 Aug 2018 12:24:00 +0200 Subject: Switch if/else branches to minimize negation --- ranger/core/actions.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ranger/core/actions.py b/ranger/core/actions.py index e645e2f8..087758c5 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -489,10 +489,10 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m if narg is not None: mode = narg tfile = self.thisfile - if not kw.get('selection', True): - selection = [tfile] - else: + if kw.get('selection', True): selection = self.thistab.get_selection() + else: + selection = [tfile] if tfile.is_directory: self.thistab.enter_dir(tfile) elif selection: -- cgit 1.4.1-2-gfad0 From fe999acb75d2e5bf8bee401afb98589e530b57da Mon Sep 17 00:00:00 2001 From: dbosst Date: Tue, 27 Mar 2018 21:41:12 -0400 Subject: Added: shift tabs right/left shift selected tab right/left with ALT-p or ALT-o --- ranger/core/actions.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 55226434..5a1ea258 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -1244,6 +1244,34 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m self.signal_emit('tab.layoutchange') return None + def tab_shift(self, offset): + """Shift the tab left/right + + Shift the current tab to the left or right + """ + assert isinstance(offset, int) + tablist = self.get_tab_list() + oldtab_index = self.current_tab + old_index = tablist.index(oldtab_index) + new_index = (old_index + offset) + if new_index < 0: + return None + if new_index > (len(tablist)-1): + return None + newtab_index = tablist[new_index] + if newtab_index != oldtab_index: + oldtab = self.tabs[oldtab_index] + newtab = self.tabs[newtab_index] + self.tabs[oldtab_index] = newtab + self.tabs[newtab_index] = oldtab + self.current_tab = newtab_index + self.thistab = oldtab + self.change_mode('normal') + self.signal_emit('tab.change', old=oldtab, new=newtab) + self.signal_emit('tab.change', old=newtab, new=oldtab) + self.signal_emit('tab.layoutchange') + return None + def tab_switch(self, path, create_directory=False): """Switches to tab of given path, opening a new tab as necessary. -- cgit 1.4.1-2-gfad0 From c036ce360bc838f9a51f3f21d65e8add2a28b7fc Mon Sep 17 00:00:00 2001 From: dbosst Date: Wed, 28 Mar 2018 12:30:47 -0400 Subject: use offset and pos to shift tabs: offset will shift the tab number as seen pos will shift the tab to the tav number given preserves as much as possible the tab numbers --- ranger/core/actions.py | 57 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 16 deletions(-) diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 5a1ea258..b5a763f8 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -1244,31 +1244,56 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m self.signal_emit('tab.layoutchange') return None - def tab_shift(self, offset): + def tab_shift(self, offset=0, pos=None): """Shift the tab left/right - Shift the current tab to the left or right + Shift the current tab to the left or right by either: + offset - changes the tab number by offset + pos - shifts the tab to the specified tab number """ - assert isinstance(offset, int) - tablist = self.get_tab_list() + oldtab_index = self.current_tab - old_index = tablist.index(oldtab_index) - new_index = (old_index + offset) - if new_index < 0: - return None - if new_index > (len(tablist)-1): - return None - newtab_index = tablist[new_index] + if pos is None: + assert isinstance(offset, int) + # enumerated index (1 to 9) + newtab_index = oldtab_index + offset + if newtab_index < 1: + newtab_index = 1 + if newtab_index > 9: + newtab_index = 9 + else: + assert isinstance(pos, int) + if pos < 1 or pos > 9: + return None + newtab_index = pos + # shift tabs without enumerating, preserve tab numbers when can if newtab_index != oldtab_index: + # the other tabs shift in the opposite direction + if (newtab_index - oldtab_index) > 0: + direction = -1 + else: + direction = 1 + + def tabshiftreorder(source_index): + # shift the tabs to make source_index empty + if source_index in self.tabs: + target_index = source_index + direction + # make the target_index empty recursively + tabshiftreorder(target_index) + # shift the source to target + source_tab = self.tabs[source_index] + self.tabs[target_index] = source_tab + del self.tabs[source_index] + + # first remove the current tab from the dict oldtab = self.tabs[oldtab_index] - newtab = self.tabs[newtab_index] - self.tabs[oldtab_index] = newtab + del self.tabs[oldtab_index] + # make newtab_index empty by shifting + tabshiftreorder(newtab_index) self.tabs[newtab_index] = oldtab self.current_tab = newtab_index self.thistab = oldtab - self.change_mode('normal') - self.signal_emit('tab.change', old=oldtab, new=newtab) - self.signal_emit('tab.change', old=newtab, new=oldtab) + self.ui.titlebar.request_redraw() self.signal_emit('tab.layoutchange') return None -- cgit 1.4.1-2-gfad0 From b6497f5d1d7c03e121b1b68db256f551fc4ed14f Mon Sep 17 00:00:00 2001 From: toonn Date: Wed, 22 Aug 2018 18:36:40 +0200 Subject: Remove limit and change pos to to Let's have the users report how they want shifting to work. You can currently create tabs at negative indices so it feels wrong not to be able to shift tabs there or have shifts of tabs at negative indices have a weird result. --- ranger/core/actions.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/ranger/core/actions.py b/ranger/core/actions.py index b5a763f8..1d95a9b7 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -1244,28 +1244,22 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m self.signal_emit('tab.layoutchange') return None - def tab_shift(self, offset=0, pos=None): + def tab_shift(self, offset=0, to=None): # pylint: disable=invalid-name """Shift the tab left/right Shift the current tab to the left or right by either: offset - changes the tab number by offset - pos - shifts the tab to the specified tab number + to - shifts the tab to the specified tab number """ oldtab_index = self.current_tab - if pos is None: + if to is None: assert isinstance(offset, int) # enumerated index (1 to 9) newtab_index = oldtab_index + offset - if newtab_index < 1: - newtab_index = 1 - if newtab_index > 9: - newtab_index = 9 else: - assert isinstance(pos, int) - if pos < 1 or pos > 9: - return None - newtab_index = pos + assert isinstance(to, int) + newtab_index = to # shift tabs without enumerating, preserve tab numbers when can if newtab_index != oldtab_index: # the other tabs shift in the opposite direction -- cgit 1.4.1-2-gfad0 From 8fd92581dfcd126ce432b8832209f8cdf4a73ecd Mon Sep 17 00:00:00 2001 From: jakanakae-envangel Date: Wed, 22 Aug 2018 21:41:51 +0200 Subject: scope.sh: Implement image previews for archives Take the first alphabetically sorted png, jpg or gif image from the archive, or fallback to normal file listing if there are none. Supported formats: zip, cbz, rar, cbr, 7z, cb7, tar, cbt, txz, tgz, tbz2. Optional deps: tar or bsdtar (from libarchive) for cbt and t* formats, bsdtar or unzip for zip and cbz, bsdtar or unrar for rar and cbr, bsdtar for 7z and cb7. --- ranger/data/scope.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh index 25251533..ceb9e1ae 100755 --- a/ranger/data/scope.sh +++ b/ranger/data/scope.sh @@ -123,6 +123,53 @@ handle_image() { # -jpeg -tiffcompression jpeg \ # -- "${FILE_PATH}" "${IMAGE_CACHE_PATH%.*}" \ # && exit 6 || exit 1;; + + # Archive + application/zip|application/x-rar|application/x-7z-compressed|\ + application/x-xz|application/x-bzip2|application/x-gzip|application/x-tar) + local fn="" + local bsd="" + local zip=""; local rar=""; local z7=""; local tar="" + case "${MIMETYPE}" in + application/zip) zip=1 ;; + application/x-rar) rar=1 ;; + application/x-7z-compressed) z7=1 ;; + *) tar=1 ;; + esac + [ "$tar" ] && fn=$(tar --list --file "${FILE_PATH}") + [ $? != 0 ] && bsd=1 && fn=$(bsdtar --list --file "${FILE_PATH}") + [ $? != 0 ] && [ "$bsd" ] && bsd="" && [ "$tar" -o "$z7"] && return + if [ -z "$bsd" ] && [ -z "$tar" ]; then + if [ "$rar" ]; then + fn=$(unrar lb -p- -- "${FILE_PATH}") + elif [ "$zip" ]; then + fn=$(zipinfo -1 -- "${FILE_PATH}") + fi + [ $? != 0 ] && return + fi + + fn=$(echo -n "$fn" | grep '\.\(png\|jpe\?g\|gif\)$' | sort -V | head -n 1) + [ "$fn" = "" ] && return + [ "$bsd" ] && fn=$(printf '%b' "$fn") + + if [ "$tar" ] && [ -z "$bsd" ]; then + tar --extract --to-stdout --file "${FILE_PATH}" "$fn" > \ + "${IMAGE_CACHE_PATH}" && exit 6 + rm -- "${IMAGE_CACHE_PATH}" + return + fi + # bsdtar and unzip need escaiping + fne=$(echo -n "$fn" | sed 's/[][*?\]/\\\0/g') + bsdtar --extract --to-stdout --file "${FILE_PATH}" "$fne" > \ + "${IMAGE_CACHE_PATH}" && exit 6 + rm -- "${IMAGE_CACHE_PATH}" + if [ "$rar" ]; then + unrar p -p- -inul -- "${FILE_PATH}" "$fn" > "${IMAGE_CACHE_PATH}" && exit 6 + elif [ "$zip" ]; then + unzip -pP "" -- "${FILE_PATH}" "$fne" > "${IMAGE_CACHE_PATH}" && exit 6 + fi + rm -- "${IMAGE_CACHE_PATH}" + ;; esac } -- cgit 1.4.1-2-gfad0 From b9eacb84a1fc013ec3903d230d12f846041f8108 Mon Sep 17 00:00:00 2001 From: jakanakae-envangel Date: Thu, 23 Aug 2018 18:53:27 +0200 Subject: scope.sh: Comment archive previewing by default --- ranger/data/scope.sh | 90 ++++++++++++++++++++++++++-------------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh index ceb9e1ae..29f4d718 100755 --- a/ranger/data/scope.sh +++ b/ranger/data/scope.sh @@ -125,51 +125,51 @@ handle_image() { # && exit 6 || exit 1;; # Archive - application/zip|application/x-rar|application/x-7z-compressed|\ - application/x-xz|application/x-bzip2|application/x-gzip|application/x-tar) - local fn="" - local bsd="" - local zip=""; local rar=""; local z7=""; local tar="" - case "${MIMETYPE}" in - application/zip) zip=1 ;; - application/x-rar) rar=1 ;; - application/x-7z-compressed) z7=1 ;; - *) tar=1 ;; - esac - [ "$tar" ] && fn=$(tar --list --file "${FILE_PATH}") - [ $? != 0 ] && bsd=1 && fn=$(bsdtar --list --file "${FILE_PATH}") - [ $? != 0 ] && [ "$bsd" ] && bsd="" && [ "$tar" -o "$z7"] && return - if [ -z "$bsd" ] && [ -z "$tar" ]; then - if [ "$rar" ]; then - fn=$(unrar lb -p- -- "${FILE_PATH}") - elif [ "$zip" ]; then - fn=$(zipinfo -1 -- "${FILE_PATH}") - fi - [ $? != 0 ] && return - fi - - fn=$(echo -n "$fn" | grep '\.\(png\|jpe\?g\|gif\)$' | sort -V | head -n 1) - [ "$fn" = "" ] && return - [ "$bsd" ] && fn=$(printf '%b' "$fn") - - if [ "$tar" ] && [ -z "$bsd" ]; then - tar --extract --to-stdout --file "${FILE_PATH}" "$fn" > \ - "${IMAGE_CACHE_PATH}" && exit 6 - rm -- "${IMAGE_CACHE_PATH}" - return - fi - # bsdtar and unzip need escaiping - fne=$(echo -n "$fn" | sed 's/[][*?\]/\\\0/g') - bsdtar --extract --to-stdout --file "${FILE_PATH}" "$fne" > \ - "${IMAGE_CACHE_PATH}" && exit 6 - rm -- "${IMAGE_CACHE_PATH}" - if [ "$rar" ]; then - unrar p -p- -inul -- "${FILE_PATH}" "$fn" > "${IMAGE_CACHE_PATH}" && exit 6 - elif [ "$zip" ]; then - unzip -pP "" -- "${FILE_PATH}" "$fne" > "${IMAGE_CACHE_PATH}" && exit 6 - fi - rm -- "${IMAGE_CACHE_PATH}" - ;; + # application/zip|application/x-rar|application/x-7z-compressed|\ + # application/x-xz|application/x-bzip2|application/x-gzip|application/x-tar) + # local fn="" + # local bsd="" + # local zip=""; local rar=""; local z7=""; local tar="" + # case "${MIMETYPE}" in + # application/zip) zip=1 ;; + # application/x-rar) rar=1 ;; + # application/x-7z-compressed) z7=1 ;; + # *) tar=1 ;; + # esac + # [ "$tar" ] && fn=$(tar --list --file "${FILE_PATH}") + # [ $? != 0 ] && bsd=1 && fn=$(bsdtar --list --file "${FILE_PATH}") + # [ $? != 0 ] && [ "$bsd" ] && bsd="" && [ "$tar" -o "$z7"] && return + # if [ -z "$bsd" ] && [ -z "$tar" ]; then + # if [ "$rar" ]; then + # fn=$(unrar lb -p- -- "${FILE_PATH}") + # elif [ "$zip" ]; then + # fn=$(zipinfo -1 -- "${FILE_PATH}") + # fi + # [ $? != 0 ] && return + # fi + # + # fn=$(echo -n "$fn" | grep '\.\(png\|jpe\?g\|gif\)$' | sort -V | head -n 1) + # [ "$fn" = "" ] && return + # [ "$bsd" ] && fn=$(printf '%b' "$fn") + # + # if [ "$tar" ] && [ -z "$bsd" ]; then + # tar --extract --to-stdout --file "${FILE_PATH}" "$fn" > \ + # "${IMAGE_CACHE_PATH}" && exit 6 + # rm -- "${IMAGE_CACHE_PATH}" + # return + # fi + # # bsdtar and unzip need escaiping + # fne=$(echo -n "$fn" | sed 's/[][*?\]/\\\0/g') + # bsdtar --extract --to-stdout --file "${FILE_PATH}" "$fne" > \ + # "${IMAGE_CACHE_PATH}" && exit 6 + # rm -- "${IMAGE_CACHE_PATH}" + # if [ "$rar" ]; then + # unrar p -p- -inul -- "${FILE_PATH}" "$fn" > "${IMAGE_CACHE_PATH}" && exit 6 + # elif [ "$zip" ]; then + # unzip -pP "" -- "${FILE_PATH}" "$fne" > "${IMAGE_CACHE_PATH}" && exit 6 + # fi + # rm -- "${IMAGE_CACHE_PATH}" + # ;; esac } -- cgit 1.4.1-2-gfad0 From b3ac23bc6aba2bbcc82eeeb032928bd97bc87db5 Mon Sep 17 00:00:00 2001 From: jakanakae-envangel Date: Thu, 23 Aug 2018 20:41:58 +0200 Subject: scope.sh: Fix rm-ing a nonexistent file For archive previews, if bsdtar failed to extract a 7z file, it would attempt to rm the already removed IMAGE_CACHE_PATH file. --- ranger/data/scope.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh index 29f4d718..27a527ca 100755 --- a/ranger/data/scope.sh +++ b/ranger/data/scope.sh @@ -158,7 +158,7 @@ handle_image() { # rm -- "${IMAGE_CACHE_PATH}" # return # fi - # # bsdtar and unzip need escaiping + # # bsdtar and unzip need escaping. # fne=$(echo -n "$fn" | sed 's/[][*?\]/\\\0/g') # bsdtar --extract --to-stdout --file "${FILE_PATH}" "$fne" > \ # "${IMAGE_CACHE_PATH}" && exit 6 @@ -167,7 +167,7 @@ handle_image() { # unrar p -p- -inul -- "${FILE_PATH}" "$fn" > "${IMAGE_CACHE_PATH}" && exit 6 # elif [ "$zip" ]; then # unzip -pP "" -- "${FILE_PATH}" "$fne" > "${IMAGE_CACHE_PATH}" && exit 6 - # fi + # else return; fi # rm -- "${IMAGE_CACHE_PATH}" # ;; esac -- cgit 1.4.1-2-gfad0 From 2abdc70358dc7eefab81c436d5b09946964a148e Mon Sep 17 00:00:00 2001 From: jakanakae-envangel Date: Thu, 23 Aug 2018 20:59:02 +0200 Subject: scope.sh: Use python's mimetypes for finding imgs --- ranger/data/scope.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh index 27a527ca..d66f33a1 100755 --- a/ranger/data/scope.sh +++ b/ranger/data/scope.sh @@ -148,7 +148,10 @@ handle_image() { # [ $? != 0 ] && return # fi # - # fn=$(echo -n "$fn" | grep '\.\(png\|jpe\?g\|gif\)$' | sort -V | head -n 1) + # fn=$(echo "$fn" | python -c "import sys; import mimetypes as m; \ + # [ print(l, end='') for l in sys.stdin if \ + # (m.guess_type(l[:-1])[0] or '').startswith('image/') ]" |\ + # sort -V | head -n 1) # [ "$fn" = "" ] && return # [ "$bsd" ] && fn=$(printf '%b' "$fn") # -- cgit 1.4.1-2-gfad0 From 8b240933ab3b6f7a460d93d2da2e7be1acab8a5f Mon Sep 17 00:00:00 2001 From: toonn Date: Thu, 23 Aug 2018 21:15:30 +0200 Subject: Removed ghost of function definition --- ranger/core/actions.py | 53 -------------------------------------------------- 1 file changed, 53 deletions(-) diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 1d95a9b7..800226e1 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -1191,59 +1191,6 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m return self.tab_open(i, path) return None - def tab_shift(self, offset=0, pos=None): - """Shift the tab left/right - - Shift the current tab to the left or right by either: - offset - changes the tab number by offset - pos - shifts the tab to the specified tab number - """ - - oldtab_index = self.current_tab - if pos is None: - assert isinstance(offset, int) - # enumerated index (1 to 9) - newtab_index = oldtab_index + offset - if newtab_index < 1: - newtab_index = 1 - if newtab_index > 9: - newtab_index = 9 - else: - assert isinstance(pos, int) - if pos < 1 or pos > 9: - return None - newtab_index = pos - # shift tabs without enumerating, preserve tab numbers when can - if newtab_index != oldtab_index: - # the other tabs shift in the opposite direction - if (newtab_index - oldtab_index) > 0: - direction = -1 - else: - direction = 1 - - def tabshiftreorder(source_index): - # shift the tabs to make source_index empty - if source_index in self.tabs: - target_index = source_index + direction - # make the target_index empty recursively - tabshiftreorder(target_index) - # shift the source to target - source_tab = self.tabs[source_index] - self.tabs[target_index] = source_tab - del self.tabs[source_index] - - # first remove the current tab from the dict - oldtab = self.tabs[oldtab_index] - del self.tabs[oldtab_index] - # make newtab_index empty by shifting - tabshiftreorder(newtab_index) - self.tabs[newtab_index] = oldtab - self.current_tab = newtab_index - self.thistab = oldtab - self.ui.titlebar.request_redraw() - self.signal_emit('tab.layoutchange') - return None - def tab_shift(self, offset=0, to=None): # pylint: disable=invalid-name """Shift the tab left/right -- cgit 1.4.1-2-gfad0 From 1e8dbdea782bf4928f8df7ff1768b1fa646a3a5c Mon Sep 17 00:00:00 2001 From: jakanakae-envangel Date: Sat, 25 Aug 2018 09:25:44 +0200 Subject: scope.sh: Handle archive filenames starting with '-' --- ranger/data/scope.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh index d66f33a1..c0847551 100755 --- a/ranger/data/scope.sh +++ b/ranger/data/scope.sh @@ -156,14 +156,14 @@ handle_image() { # [ "$bsd" ] && fn=$(printf '%b' "$fn") # # if [ "$tar" ] && [ -z "$bsd" ]; then - # tar --extract --to-stdout --file "${FILE_PATH}" "$fn" > \ + # tar --extract --to-stdout --file "${FILE_PATH}" -- "$fn" > \ # "${IMAGE_CACHE_PATH}" && exit 6 # rm -- "${IMAGE_CACHE_PATH}" # return # fi # # bsdtar and unzip need escaping. # fne=$(echo -n "$fn" | sed 's/[][*?\]/\\\0/g') - # bsdtar --extract --to-stdout --file "${FILE_PATH}" "$fne" > \ + # bsdtar --extract --to-stdout --file "${FILE_PATH}" -- "$fne" > \ # "${IMAGE_CACHE_PATH}" && exit 6 # rm -- "${IMAGE_CACHE_PATH}" # if [ "$rar" ]; then -- cgit 1.4.1-2-gfad0 From d37e4b2c7f93ecb67527b57f2f4814788f5ec881 Mon Sep 17 00:00:00 2001 From: seebye Date: Sat, 25 Aug 2018 19:08:56 +0200 Subject: support ueberzug image displayer --- ranger/core/fm.py | 4 +++- ranger/ext/img_display.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/ranger/core/fm.py b/ranger/core/fm.py index 61b3cb11..46336e92 100644 --- a/ranger/core/fm.py +++ b/ranger/core/fm.py @@ -25,7 +25,7 @@ from ranger.core.runner import Runner from ranger.ext.img_display import (W3MImageDisplayer, ITerm2ImageDisplayer, TerminologyImageDisplayer, URXVTImageDisplayer, URXVTImageFSDisplayer, - KittyImageDisplayer, + KittyImageDisplayer, UeberzugImageDisplayer, ImageDisplayer) from ranger.core.metadata import MetadataManager from ranger.ext.rifle import Rifle @@ -238,6 +238,8 @@ class FM(Actions, # pylint: disable=too-many-instance-attributes return URXVTImageFSDisplayer() elif self.settings.preview_images_method == "kitty": return KittyImageDisplayer() + elif self.settings.preview_images_method == "ueberzug": + return UeberzugImageDisplayer() return ImageDisplayer() def _get_thisfile(self): diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py index f78e170b..4da745a5 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -20,6 +20,7 @@ import os import struct import sys import warnings +import json from subprocess import Popen, PIPE import termios @@ -664,3 +665,47 @@ class KittyImageDisplayer(ImageDisplayer): # os.remove(self.temp_paths[k]) # except (OSError, IOError): # continue + + +class UeberzugImageDisplayer(ImageDisplayer): + """Implementation of ImageDisplayer using ueberzug. + Ueberzug can display images in a Xorg session. + Does not work over ssh. + """ + IMAGE_ID = 'preview' + is_initialized = False + + def __init__(self): + self.process = None + + def initialize(self): + """start ueberzug""" + if self.is_initialized and self.process.poll() is None: + return + + self.process = Popen(['python3', '-m', 'ueberzug', 'layer'], + stdin=PIPE, universal_newlines=True) + self.is_initialized = True + + def _execute(self, **kwargs): + self.initialize() + self.process.stdin.write(json.dumps(kwargs) + '\n') + self.process.stdin.flush() + + def draw(self, path, start_x, start_y, width, height): + self._execute( + action='add', + identifier=self.IMAGE_ID, + x=start_x, + y=start_y, + max_width=width - 1, + max_height=height - 1, + path=path + ) + + def clear(self, start_x, start_y, width, height): + self._execute(action='remove', identifier=self.IMAGE_ID) + + def quit(self): + # ueberzug will terminate itself if stdin was closed + pass -- cgit 1.4.1-2-gfad0 From c0ecc9e71bbb40134c73cd1421b18785a0bd5ac3 Mon Sep 17 00:00:00 2001 From: seebye Date: Mon, 27 Aug 2018 00:52:50 +0200 Subject: ueberzug, remove hardcoded python version --- ranger/ext/img_display.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py index 4da745a5..23aa6bee 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -683,7 +683,7 @@ class UeberzugImageDisplayer(ImageDisplayer): if self.is_initialized and self.process.poll() is None: return - self.process = Popen(['python3', '-m', 'ueberzug', 'layer'], + self.process = Popen(['ueberzug', 'layer'], stdin=PIPE, universal_newlines=True) self.is_initialized = True -- cgit 1.4.1-2-gfad0 From d062ce4b0b4a8ca75c5bb7d27a35dc0471718d2c Mon Sep 17 00:00:00 2001 From: jakanakae-envangel Date: Tue, 28 Aug 2018 15:53:11 +0200 Subject: scope.sh: Simplify exit status checking --- ranger/data/scope.sh | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh index c0847551..b516904f 100755 --- a/ranger/data/scope.sh +++ b/ranger/data/scope.sh @@ -129,24 +129,17 @@ handle_image() { # application/x-xz|application/x-bzip2|application/x-gzip|application/x-tar) # local fn="" # local bsd="" - # local zip=""; local rar=""; local z7=""; local tar="" - # case "${MIMETYPE}" in + # local zip=""; local rar=""; local tar="" + # case "${mimetype}" in # application/zip) zip=1 ;; # application/x-rar) rar=1 ;; - # application/x-7z-compressed) z7=1 ;; + # application/x-7z-compressed) ;; # *) tar=1 ;; # esac - # [ "$tar" ] && fn=$(tar --list --file "${FILE_PATH}") - # [ $? != 0 ] && bsd=1 && fn=$(bsdtar --list --file "${FILE_PATH}") - # [ $? != 0 ] && [ "$bsd" ] && bsd="" && [ "$tar" -o "$z7"] && return - # if [ -z "$bsd" ] && [ -z "$tar" ]; then - # if [ "$rar" ]; then - # fn=$(unrar lb -p- -- "${FILE_PATH}") - # elif [ "$zip" ]; then - # fn=$(zipinfo -1 -- "${FILE_PATH}") - # fi - # [ $? != 0 ] && return - # fi + # { [ "$tar" ] && fn=$(tar --list --file "${FILE_PATH}"); } || \ + # { bsd=1 && fn=$(bsdtar --list --file "${FILE_PATH}"); } || \ + # { bsd="" && [ "$rar" ] && fn=$(unrar lb -p- -- "${FILE_PATH}"); } || \ + # { [ "$zip" ] && fn=$(zipinfo -1 -- "${FILE_PATH}"); } || return # # fn=$(echo "$fn" | python -c "import sys; import mimetypes as m; \ # [ print(l, end='') for l in sys.stdin if \ -- cgit 1.4.1-2-gfad0 From aa3033c287aa461a161782c07d508b946eac5ed7 Mon Sep 17 00:00:00 2001 From: seebye Date: Tue, 28 Aug 2018 21:20:43 +0200 Subject: quit image displayer on changing preview_images_method --- ranger/core/fm.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ranger/core/fm.py b/ranger/core/fm.py index 46336e92..43001e8b 100644 --- a/ranger/core/fm.py +++ b/ranger/core/fm.py @@ -102,6 +102,8 @@ class FM(Actions, # pylint: disable=too-many-instance-attributes self.rifle.reload_config() def set_image_displayer(): + if self.image_displayer: + self.image_displayer.quit() self.image_displayer = self._get_image_displayer() set_image_displayer() self.settings.signal_bind('setopt.preview_images_method', set_image_displayer, -- cgit 1.4.1-2-gfad0 From 87727172c18f7a3610137dfb89662964477333a5 Mon Sep 17 00:00:00 2001 From: seebye Date: Tue, 28 Aug 2018 21:22:39 +0200 Subject: quit image displayer on suspending ui --- ranger/gui/ui.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py index 4f76dfab..9a326956 100644 --- a/ranger/gui/ui.py +++ b/ranger/gui/ui.py @@ -136,6 +136,9 @@ class UI( # pylint: disable=too-many-instance-attributes,too-many-public-method self.vcsthread.pause() self.vcsthread.paused.wait() + if self.fm.image_displayer: + self.fm.image_displayer.quit() + self.win.keypad(0) curses.nocbreak() curses.echo() -- cgit 1.4.1-2-gfad0 From 8fd807244127463c4bce0316a2c32fa75c81a92b Mon Sep 17 00:00:00 2001 From: seebye Date: Tue, 28 Aug 2018 21:24:25 +0200 Subject: implement quit (ITerm2ImageDisplayer) --- ranger/ext/img_display.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py index 23aa6bee..d94cfdcd 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -252,6 +252,9 @@ class ITerm2ImageDisplayer(ImageDisplayer, FileManagerAware): self.fm.ui.win.redrawwin() self.fm.ui.win.refresh() + def quit(self): + self.clear(0, 0, 0, 0) + def _generate_iterm2_input(self, path, max_cols, max_rows): """Prepare the image content of path for image display in iTerm2""" image_width, image_height = self._get_image_dimensions(path) -- cgit 1.4.1-2-gfad0 From da41d7ba090bc1ad58fbbe64f8ace5ea2ff8ad6e Mon Sep 17 00:00:00 2001 From: seebye Date: Tue, 28 Aug 2018 21:25:57 +0200 Subject: implement quit (TerminologyImageDisplayer) --- ranger/ext/img_display.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py index d94cfdcd..7bc14b1b 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -380,6 +380,9 @@ class TerminologyImageDisplayer(ImageDisplayer, FileManagerAware): self.fm.ui.win.redrawwin() self.fm.ui.win.refresh() + def quit(self): + self.clear(0, 0, 0, 0) + class URXVTImageDisplayer(ImageDisplayer, FileManagerAware): """Implementation of ImageDisplayer working by setting the urxvt -- cgit 1.4.1-2-gfad0 From 4458f9e1e4aafbab2fafd46400dd3abf2762a421 Mon Sep 17 00:00:00 2001 From: seebye Date: Tue, 28 Aug 2018 21:28:55 +0200 Subject: implement quit (UeberzugImageDisplayer) --- ranger/ext/img_display.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py index 7bc14b1b..0ef45a4a 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -686,7 +686,8 @@ class UeberzugImageDisplayer(ImageDisplayer): def initialize(self): """start ueberzug""" - if self.is_initialized and self.process.poll() is None: + if (self.is_initialized and self.process.poll() is None and + not self.process.stdin.closed): return self.process = Popen(['ueberzug', 'layer'], @@ -710,8 +711,10 @@ class UeberzugImageDisplayer(ImageDisplayer): ) def clear(self, start_x, start_y, width, height): - self._execute(action='remove', identifier=self.IMAGE_ID) + if self.process and not self.process.stdin.closed: + self._execute(action='remove', identifier=self.IMAGE_ID) def quit(self): - # ueberzug will terminate itself if stdin was closed - pass + if (self.is_initialized and self.process.poll() is None and + not self.process.stdin.closed): + self.process.stdin.close() -- cgit 1.4.1-2-gfad0 From fff14e256398fab140054b8745e686bb8051aca1 Mon Sep 17 00:00:00 2001 From: seebye Date: Tue, 28 Aug 2018 23:34:54 +0200 Subject: ueberzug suppress stderr --- ranger/ext/img_display.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py index 0ef45a4a..45b43070 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -690,7 +690,7 @@ class UeberzugImageDisplayer(ImageDisplayer): not self.process.stdin.closed): return - self.process = Popen(['ueberzug', 'layer'], + self.process = Popen(['ueberzug', 'layer', '--silent'], stdin=PIPE, universal_newlines=True) self.is_initialized = True -- cgit 1.4.1-2-gfad0 From e8963cba55e2258061e97c4825f722848ab26f48 Mon Sep 17 00:00:00 2001 From: jakanakae-envangel Date: Thu, 30 Aug 2018 09:54:28 +0200 Subject: scope.sh: Simplify archive-img extraction code --- ranger/data/scope.sh | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh index b516904f..626d2395 100755 --- a/ranger/data/scope.sh +++ b/ranger/data/scope.sh @@ -127,9 +127,8 @@ handle_image() { # Archive # application/zip|application/x-rar|application/x-7z-compressed|\ # application/x-xz|application/x-bzip2|application/x-gzip|application/x-tar) - # local fn="" - # local bsd="" - # local zip=""; local rar=""; local tar="" + # local fn=""; local fe="" + # local zip=""; local rar=""; local tar=""; local bsd="" # case "${mimetype}" in # application/zip) zip=1 ;; # application/x-rar) rar=1 ;; @@ -137,8 +136,8 @@ handle_image() { # *) tar=1 ;; # esac # { [ "$tar" ] && fn=$(tar --list --file "${FILE_PATH}"); } || \ - # { bsd=1 && fn=$(bsdtar --list --file "${FILE_PATH}"); } || \ - # { bsd="" && [ "$rar" ] && fn=$(unrar lb -p- -- "${FILE_PATH}"); } || \ + # { fn=$(bsdtar --list --file "${FILE_PATH}") && bsd=1 && tar=""; } || \ + # { [ "$rar" ] && fn=$(unrar lb -p- -- "${FILE_PATH}"); } || \ # { [ "$zip" ] && fn=$(zipinfo -1 -- "${FILE_PATH}"); } || return # # fn=$(echo "$fn" | python -c "import sys; import mimetypes as m; \ @@ -148,23 +147,17 @@ handle_image() { # [ "$fn" = "" ] && return # [ "$bsd" ] && fn=$(printf '%b' "$fn") # - # if [ "$tar" ] && [ -z "$bsd" ]; then - # tar --extract --to-stdout --file "${FILE_PATH}" -- "$fn" > \ - # "${IMAGE_CACHE_PATH}" && exit 6 - # rm -- "${IMAGE_CACHE_PATH}" - # return - # fi - # # bsdtar and unzip need escaping. - # fne=$(echo -n "$fn" | sed 's/[][*?\]/\\\0/g') - # bsdtar --extract --to-stdout --file "${FILE_PATH}" -- "$fne" > \ + # [ "$tar" ] && tar --extract --to-stdout \ + # --file "${FILE_PATH}" -- "$fn" > "${IMAGE_CACHE_PATH}" && exit 6 + # fe=$(echo -n "$fn" | sed 's/[][*?\]/\\\0/g') + # [ "$bsd" ] && bsdtar --extract --to-stdout \ + # --file "${FILE_PATH}" -- "$fe" > "${IMAGE_CACHE_PATH}" && exit 6 + # [ "$bsd" ] || [ "$tar" ] && rm -- "${IMAGE_CACHE_PATH}" + # [ "$rar" ] && unrar p -p- -inul -- "${FILE_PATH}" "$fn" > \ # "${IMAGE_CACHE_PATH}" && exit 6 - # rm -- "${IMAGE_CACHE_PATH}" - # if [ "$rar" ]; then - # unrar p -p- -inul -- "${FILE_PATH}" "$fn" > "${IMAGE_CACHE_PATH}" && exit 6 - # elif [ "$zip" ]; then - # unzip -pP "" -- "${FILE_PATH}" "$fne" > "${IMAGE_CACHE_PATH}" && exit 6 - # else return; fi - # rm -- "${IMAGE_CACHE_PATH}" + # [ "$zip" ] && unzip -pP "" -- "${FILE_PATH}" "$fe" > \ + # "${IMAGE_CACHE_PATH}" && exit 6 + # [ "$rar" ] || [ "$zip" ] && rm -- "${IMAGE_CACHE_PATH}" # ;; esac } -- cgit 1.4.1-2-gfad0 From 573bc3aff2c6881928fae984280ff03ad5360fe7 Mon Sep 17 00:00:00 2001 From: natemaia Date: Wed, 5 Sep 2018 20:32:04 -0700 Subject: Remove extra pipe in subprocess call, rename plugin and add original --- examples/plugin_pmount.py | 66 +++++++++++------------------------- examples/plugin_pmount_dynamic.py | 70 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 47 deletions(-) create mode 100644 examples/plugin_pmount_dynamic.py diff --git a/examples/plugin_pmount.py b/examples/plugin_pmount.py index f5bd1c67..38c4a17c 100644 --- a/examples/plugin_pmount.py +++ b/examples/plugin_pmount.py @@ -3,66 +3,38 @@ # This plugin creates a bunch of keybindings used to mount and unmount # the devices using pmount(1). # -# (multiple partitions): alt+m : mount /dev/sd -# (one partition): alt+m : mount /dev/sd1 -# (no partitions): alt+m : mount /dev/sd -# -# (multiple partitions): alt+M : unmount /dev/sd -# (one partition): alt+M : unmount /dev/sd1 -# (no partitions): alt+M : unmount /dev/sd -# -# alt+n : list the devices +# alt+m : mount /dev/sd +# alt+m : mount /dev/sd +# alt+shift+m : unmount /dev/sd +# alt+shift+m : unmount /dev/sd +# alt+shift+n : list the devices from __future__ import (absolute_import, division, print_function) -import subprocess import ranger.api MOUNT_KEY = 'm' UMOUNT_KEY = 'M' -LIST_MOUNTS_KEY = 'n' +LIST_MOUNTS_KEY = 'N' + + HOOK_INIT_OLD = ranger.api.hook_init def hook_init(fm): fm.execute_console("map {key} shell -p lsblk".format(key=LIST_MOUNTS_KEY)) - - diskcmd = "lsblk -lno NAME | grep -w 'sd[a-z]' | sed 's/sd//'" - disks = subprocess.check_output( - diskcmd, shell=True).decode('utf-8').replace('\r', '').replace('\n', '') - - for disk in disks: - partcmd = "lsblk -lno NAME /dev/sd{0} | sed 's/sd{0}//' | tail -n 1".format(disk) - - try: - numparts = int(subprocess.check_output( - partcmd, shell=True).decode('utf-8').replace('\r', '').replace('\n', '')) - except ValueError: - numparts = 0 - - if numparts == 0: - # no partition, mount the whole device - fm.execute_console("map {key}{0} chain shell pmount sd{0}; cd /media/sd{0}".format( - disk, key=MOUNT_KEY)) - fm.execute_console("map {key}{0} chain cd; chain shell pumount sd{0}".format( - disk, key=UMOUNT_KEY)) - - elif numparts == 1: - # only one partition, mount the partition + for disk in "abcdefgh": + fm.execute_console("map {key}{0} chain shell pmount sd{1}; cd /media/sd{1}".format( + disk.upper(), disk, key=MOUNT_KEY)) + fm.execute_console("map {key}{0} chain cd; chain shell pumount sd{1}".format( + disk.upper(), disk, key=UMOUNT_KEY)) + for part in "123456789": fm.execute_console( - "map {key}{0} chain shell pmount sd{0}1; cd /media/sd{0}1".format( - disk, key=MOUNT_KEY)) - fm.execute_console("map {key}{0} chain cd; shell pumount sd{0}1".format( - disk, key=UMOUNT_KEY)) - - else: - # use range start 1, /dev/sd{device}0 doesn't exist - for part in range(1, numparts + 1): - fm.execute_console( - "map {key}{0}{1} chain shell pmount sd{0}{1}; cd /media/sd{0}{1}".format( - disk, part, key=MOUNT_KEY)) - fm.execute_console("map {key}{0}{1} chain cd; shell pumount sd{0}{1}".format( - disk, part, key=UMOUNT_KEY)) + "map {key}{0}{1} chain shell pmount sd{0}{1}; cd /media/sd{0}{1}".format( + disk, part, key=MOUNT_KEY) + ) + fm.execute_console("map {key}{0}{1} chain cd; shell pumount sd{0}{1}".format( + disk, part, key=UMOUNT_KEY)) return HOOK_INIT_OLD(fm) diff --git a/examples/plugin_pmount_dynamic.py b/examples/plugin_pmount_dynamic.py new file mode 100644 index 00000000..1448e15b --- /dev/null +++ b/examples/plugin_pmount_dynamic.py @@ -0,0 +1,70 @@ +# Tested with ranger 1.7.2 +# +# This plugin creates a bunch of keybindings used to mount and unmount +# the devices using pmount(1). +# +# (multiple partitions): alt+m : mount /dev/sd +# (one partition): alt+m : mount /dev/sd1 +# (no partitions): alt+m : mount /dev/sd +# +# (multiple partitions): alt+M : unmount /dev/sd +# (one partition): alt+M : unmount /dev/sd1 +# (no partitions): alt+M : unmount /dev/sd +# +# alt+n : list the devices + +from __future__ import (absolute_import, division, print_function) + +import subprocess +import ranger.api + +MOUNT_KEY = 'm' +UMOUNT_KEY = 'M' +LIST_MOUNTS_KEY = 'n' +HOOK_INIT_OLD = ranger.api.hook_init + + +def hook_init(fm): + fm.execute_console("map {key} shell -p lsblk".format(key=LIST_MOUNTS_KEY)) + + diskcmd = "lsblk -lno NAME | awk '!/[1-9]/ {sub(/sd/, \"\"); print}'" + disks = subprocess.check_output( + diskcmd, shell=True).decode('utf-8').replace('\r', '').replace('\n', '') + + for disk in disks: + partcmd = "lsblk -lno NAME /dev/sd{0} | sed 's/sd{0}//' | tail -n 1".format(disk) + + try: + numparts = int(subprocess.check_output( + partcmd, shell=True).decode('utf-8').replace('\r', '').replace('\n', '')) + except ValueError: + numparts = 0 + + if numparts == 0: + # no partition, mount the whole device + fm.execute_console("map {key}{0} chain shell pmount sd{0}; cd /media/sd{0}".format( + disk, key=MOUNT_KEY)) + fm.execute_console("map {key}{0} chain cd; chain shell pumount sd{0}".format( + disk, key=UMOUNT_KEY)) + + elif numparts == 1: + # only one partition, mount the partition + fm.execute_console( + "map {key}{0} chain shell pmount sd{0}1; cd /media/sd{0}1".format( + disk, key=MOUNT_KEY)) + fm.execute_console("map {key}{0} chain cd; shell pumount sd{0}1".format( + disk, key=UMOUNT_KEY)) + + else: + # use range start 1, /dev/sd{device}0 doesn't exist + for part in range(1, numparts + 1): + fm.execute_console( + "map {key}{0}{1} chain shell pmount sd{0}{1}; cd /media/sd{0}{1}".format( + disk, part, key=MOUNT_KEY)) + fm.execute_console("map {key}{0}{1} chain cd; shell pumount sd{0}{1}".format( + disk, part, key=UMOUNT_KEY)) + + return HOOK_INIT_OLD(fm) + + +ranger.api.hook_init = hook_init -- cgit 1.4.1-2-gfad0 From 180bd4ce0d1031a4a69a6197141964c34177b4f8 Mon Sep 17 00:00:00 2001 From: jakanakae-envangel Date: Fri, 7 Sep 2018 08:35:43 +0200 Subject: scope.sh: Explain what archive img-previewing does --- ranger/data/scope.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh index 626d2395..80185690 100755 --- a/ranger/data/scope.sh +++ b/ranger/data/scope.sh @@ -124,7 +124,7 @@ handle_image() { # -- "${FILE_PATH}" "${IMAGE_CACHE_PATH%.*}" \ # && exit 6 || exit 1;; - # Archive + # Preview archive files by showing their first containing image. # application/zip|application/x-rar|application/x-7z-compressed|\ # application/x-xz|application/x-bzip2|application/x-gzip|application/x-tar) # local fn=""; local fe="" -- cgit 1.4.1-2-gfad0 From 5b28572ed2e7b3339d04a6be8fa2d616d5d14857 Mon Sep 17 00:00:00 2001 From: seebye Date: Fri, 7 Sep 2018 13:03:21 +0200 Subject: 'ueberzug' added as allowed value to preview_images_method --- ranger/container/settings.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ranger/container/settings.py b/ranger/container/settings.py index 94e455a5..3f422256 100644 --- a/ranger/container/settings.py +++ b/ranger/container/settings.py @@ -104,7 +104,8 @@ ALLOWED_VALUES = { 'line_numbers': ['false', 'absolute', 'relative'], 'one_indexed': [False, True], 'preview_images_method': ['w3m', 'iterm2', 'terminology', - 'urxvt', 'urxvt-full', 'kitty'], + 'urxvt', 'urxvt-full', 'kitty', + 'ueberzug'], 'vcs_backend_bzr': ['disabled', 'local', 'enabled'], 'vcs_backend_git': ['enabled', 'disabled', 'local'], 'vcs_backend_hg': ['disabled', 'local', 'enabled'], -- cgit 1.4.1-2-gfad0 From e425d0a6bb65a9d2633eea55f13bc387628330bf Mon Sep 17 00:00:00 2001 From: seebye Date: Fri, 7 Sep 2018 13:06:53 +0200 Subject: ueberzug documentation updated --- ranger/config/rc.conf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index b112dc2c..7dccb20c 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -106,6 +106,10 @@ set preview_images false # while slower, this allows remote previews, # for example during an ssh session. # Tmux is unsupported. +# +# * ueberzug: +# Preview images in full color with the external command "ueberzug". +# Images are shown by using a child window. set preview_images_method w3m # Delay in seconds before displaying an image with the w3m method. -- cgit 1.4.1-2-gfad0 From a7258a2b18e3b29c5c5d24a496c7908f8ed23218 Mon Sep 17 00:00:00 2001 From: toonn Date: Fri, 7 Sep 2018 14:45:05 +0200 Subject: Change description comment I wanted to mention comic books explicitly because most people looking for comic book previews probably won't look for archive previews. --- ranger/data/scope.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh index 80185690..13a25b45 100755 --- a/ranger/data/scope.sh +++ b/ranger/data/scope.sh @@ -124,7 +124,8 @@ handle_image() { # -- "${FILE_PATH}" "${IMAGE_CACHE_PATH%.*}" \ # && exit 6 || exit 1;; - # Preview archive files by showing their first containing image. + # Preview archives using the first image inside. + # (Very useful for comic book collections for example.) # application/zip|application/x-rar|application/x-7z-compressed|\ # application/x-xz|application/x-bzip2|application/x-gzip|application/x-tar) # local fn=""; local fe="" -- cgit 1.4.1-2-gfad0 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 d9a8bb1cea1f42f694ef65877db73e1d80409846 Mon Sep 17 00:00:00 2001 From: toonn Date: Sat, 8 Sep 2018 14:37:46 +0200 Subject: Fix documentation Remove a setting that no longer exists from the man page. Reformat the comment in `rc.conf`. Use lower case `'none'` for consistency --- doc/ranger.1 | 31 ++++++++++++++++--------------- doc/ranger.pod | 4 ---- ranger/config/rc.conf | 5 ++++- ranger/container/settings.py | 2 +- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/doc/ranger.1 b/doc/ranger.1 index 21665bbf..052f06e9 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -1,4 +1,4 @@ -.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) +.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== @@ -54,16 +54,20 @@ .\" Avoid warning from groff about undefined register 'F'. .de IX .. -.if !\nF .nr F 0 -.if \nF>0 \{\ -. de IX -. tm Index:\\$1\t\\n%\t"\\$2" +.nr rF 0 +.if \n(.g .if rF .nr rF 1 +.if (\n(rF:(\n(.g==0)) \{\ +. if \nF \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" .. -. if !\nF==2 \{\ -. nr % 0 -. nr F 2 +. if !\nF==2 \{\ +. nr % 0 +. nr F 2 +. \} . \} .\} +.rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. @@ -129,7 +133,7 @@ .\" ======================================================================== .\" .IX Title "RANGER 1" -.TH RANGER 1 "ranger-1.9.0b6" "01/04/2018" "ranger manual" +.TH RANGER 1 "ranger-1.9.0b6" "2018-09-08" "ranger manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -169,7 +173,7 @@ plugins, sample configuration files and some programs for integrating ranger with other software. They are usually installed to \&\fI/usr/share/doc/ranger/examples\fR. .PP -The man page of \fIrifle\fR\|(1) describes the functions of the file opener +The man page of \fBrifle\fR\|(1) describes the functions of the file opener .PP The section \fI\s-1LINKS\s0\fR of this man page contains further resources. .SH "OPTIONS" @@ -599,7 +603,7 @@ Toggle the mark-status of all files .IP "V" 14 .IX Item "V" Starts the visual mode, which selects all files between the starting point and -the cursor until you press \s-1ESC. \s0 To unselect files in the same way, use \*(L"uV\*(R". +the cursor until you press \s-1ESC.\s0 To unselect files in the same way, use \*(L"uV\*(R". .IP "/" 14 Search for files in the current directory. .IP ":" 14 @@ -776,9 +780,6 @@ Draw borders around or between the columns? Possible values are: \& separators draw only vertical lines between columns \& both both of the above .Ve -.IP "draw_separators [bool]" 4 -.IX Item "draw_separators [bool]" -Draw vertical separators between columns? .IP "draw_progress_bar_in_status_bar [bool]" 4 .IX Item "draw_progress_bar_in_status_bar [bool]" Draw a progress bar in the status bar which displays the average state of all @@ -1524,7 +1525,7 @@ copy, run: .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" -\&\fIrifle\fR\|(1) +\&\fBrifle\fR\|(1) .SH "BUGS" .IX Header "BUGS" Report bugs here: diff --git a/doc/ranger.pod b/doc/ranger.pod index c54b6dfb..ff042fc7 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -764,10 +764,6 @@ Draw borders around or between the columns? Possible values are: separators draw only vertical lines between columns both both of the above -=item draw_separators [bool] - -Draw vertical separators between columns? - =item draw_progress_bar_in_status_bar [bool] Draw a progress bar in the status bar which displays the average state of all diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index 3fd46d38..cd0ac45b 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -123,7 +123,10 @@ set status_bar_on_top false # currently running tasks which support progress bars? set draw_progress_bar_in_status_bar true -# Draw borders around columns? (separators, outline, both, or none. Separators are vertical lines between columsn. Outline draws a box around all the columns. Both combines the two) +# Draw borders around columns? (separators, outline, both, or none) +# Separators are vertical lines between columns. +# Outline draws a box around all the columns. +# Both combines the two. set draw_borders none # Display the directory name in tabs? diff --git a/ranger/container/settings.py b/ranger/container/settings.py index f07c85a6..3e742926 100644 --- a/ranger/container/settings.py +++ b/ranger/container/settings.py @@ -96,7 +96,7 @@ ALLOWED_SETTINGS = { ALLOWED_VALUES = { 'cd_tab_case': ['sensitive', 'insensitive', 'smart'], 'confirm_on_delete': ['multiple', 'always', 'never'], - 'draw_borders': ['None', 'both', 'outline', 'separators'], + 'draw_borders': ['none', 'both', 'outline', 'separators'], 'line_numbers': ['false', 'absolute', 'relative'], 'one_indexed': [False, True], 'preview_images_method': ['w3m', 'iterm2', 'urxvt', 'urxvt-full'], -- 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 From 2485dd705e84fb64e3f04f5b4f6956968a5b9708 Mon Sep 17 00:00:00 2001 From: Wojciech Siewierski Date: Sat, 8 Sep 2018 23:33:01 +0200 Subject: New filter type for matching mimetypes --- doc/ranger.pod | 4 ++++ ranger/config/rc.conf | 1 + ranger/core/filter_stack.py | 17 +++++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/doc/ranger.pod b/doc/ranger.pod index 4fac5d50..772107e0 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -628,6 +628,10 @@ the current directory. For a more permanent solution, use the command Apply a new filename filter. +=item .m + +Apply a new mimetype filter. + =item .d Apply the typefilter "directory". diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index 4da1ffc0..a32ab494 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -566,6 +566,7 @@ copymap zf zz # Filter stack map .n console filter_stack add name%space +map .m console filter_stack add mime%space map .d filter_stack add type d map .f filter_stack add type f map .l filter_stack add type l diff --git a/ranger/core/filter_stack.py b/ranger/core/filter_stack.py index ff9f4080..2ca2b1c5 100644 --- a/ranger/core/filter_stack.py +++ b/ranger/core/filter_stack.py @@ -6,6 +6,7 @@ from __future__ import (absolute_import, division, print_function) import re +import mimetypes from ranger.container.directory import accept_file, InodeFilterConstants @@ -48,6 +49,22 @@ class NameFilter(BaseFilter): return "".format(self.pattern) +@stack_filter("mime") +class MimeFilter(BaseFilter): + def __init__(self, pattern): + self.pattern = pattern + self.regex = re.compile(pattern) + + def __call__(self, fobj): + mimetype, _ = mimetypes.guess_type(fobj.relative_path) + if mimetype is None: + return False + return self.regex.search(mimetype) + + def __str__(self): + return "".format(self.pattern) + + @stack_filter("type") class TypeFilter(BaseFilter): type_to_function = { -- cgit 1.4.1-2-gfad0 From d8047529f0ea0df007007ab5b3ef19363a6491e6 Mon Sep 17 00:00:00 2001 From: toonn Date: Sun, 9 Sep 2018 21:18:12 +0200 Subject: If you can read this on Debian, you're living in the future --- CHANGELOG.md | 39 +++++++++++++++++++++++++++++++++++++++ README.md | 2 +- doc/ranger.1 | 5 ++++- doc/rifle.1 | 2 +- ranger/__init__.py | 4 ++-- ranger/ext/rifle.py | 2 +- 6 files changed, 48 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 346b18dd..e8eb913c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,44 @@ This log documents changes between stable versions. +# 2018-09-09: version 1.9.2 +* Added a `hint_collapse_threshold` setting +* Added a `traverse_backwards` command analogous to `traverse` +* Added a command to shift tabs +* Added a normal mode mapping to quickly enter the console and scroll through + the history `C-p` +* Added a section to `scope.sh` for image previews of archives +* Added an avfs plugin +* Added an option to the move command to enable launching the selected file + instead of the marked files +* Added filtering functionality inspired by dired's filter stack, `.n, .| ...` +* Added image preview method for Kitty +* Added option to disable the display of free space for high latency situations +* Added section to `scope.sh` for pdf previews with mutool +* Added several emacs/readline-inspired keybindings, `C-g` for `ESC`, `alt-f/b` +* Added systemwide `rc.conf` and `commands.py` in `/etc/ranger` +* Added the `%any_path` macro to allow bookmarks to be used with commands that + need a path and are unaware of bookmarks +* Added versioning logic to include extra info in unreleased versions +* Change tab saving to save all tabs, not just the active tab +* Changed `draw_borders` setting to enable drawing only borders or seperators +* Changed behavior of positional arguments to the ranger command, if you + specify a path to a file ranger will open with that file selected +* Changed the `tilde_in_titlebar` setting to influence the window titlebar too +* Changed the default colorscheme to work properly in terminals that don't + equate bold and bright +* Fixed StopIteration errors +* Fixed embedded null errors +* Fixed issues reported by coverity scan +* Fixed running ranger as root on Mac OS +* Fixed unicode issue for python2 +* Fixed w3m preview issues with black stripes +* Improved PEP8 adherence +* Improved VCS symbols +* Improved `--cmd` functionality +* Improved file encoding detection by using chardet if it's available +* Rifle's flag t should now work with more terminals than xterm and urxvt +* Update colorscheme documentation + # 2018-02-22: version 1.9.1 * Fixed the rifle config backwards compatibility (regression in 1.9.0) * Fixed the POSIX compatibility of `Makefile` diff --git a/README.md b/README.md index e14bab46..d7ca0493 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -ranger 1.9.1 +ranger 1.9.2 ============ [![Build Status](https://travis-ci.org/ranger/ranger.svg?branch=master)](https://travis-ci.org/ranger/ranger) diff --git a/doc/ranger.1 b/doc/ranger.1 index acf3f29a..a33252e2 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -133,7 +133,7 @@ .\" ======================================================================== .\" .IX Title "RANGER 1" -.TH RANGER 1 "ranger-1.9.1" "2018-09-08" "ranger manual" +.TH RANGER 1 "ranger-1.9.2" "2018-09-09" "ranger manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -667,6 +667,9 @@ the current directory. For a more permanent solution, use the command .IP ".n" 14 .IX Item ".n" Apply a new filename filter. +.IP ".m" 14 +.IX Item ".m" +Apply a new mimetype filter. .IP ".d" 14 .IX Item ".d" Apply the typefilter \*(L"directory\*(R". diff --git a/doc/rifle.1 b/doc/rifle.1 index be605753..9ed1a145 100644 --- a/doc/rifle.1 +++ b/doc/rifle.1 @@ -133,7 +133,7 @@ .\" ======================================================================== .\" .IX Title "RIFLE 1" -.TH RIFLE 1 "rifle-1.9.1" "2018-09-08" "rifle manual" +.TH RIFLE 1 "rifle-1.9.2" "2018-09-09" "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/__init__.py b/ranger/__init__.py index ae1ecc48..b3bf61b2 100644 --- a/ranger/__init__.py +++ b/ranger/__init__.py @@ -32,8 +32,8 @@ def version_helper(): # Information __license__ = 'GPL3' -__version__ = '1.9.1' -__release__ = False +__version__ = '1.9.2' +__release__ = True __author__ = __maintainer__ = 'Roman Zimbelmann' __email__ = 'hut@hut.pm' diff --git a/ranger/ext/rifle.py b/ranger/ext/rifle.py index 6832e2cf..ee156d9a 100755 --- a/ranger/ext/rifle.py +++ b/ranger/ext/rifle.py @@ -21,7 +21,7 @@ import re from subprocess import Popen, PIPE import sys -__version__ = 'rifle 1.9.1' +__version__ = 'rifle 1.9.2' # Options and constants that a user might want to change: DEFAULT_PAGER = 'less' -- cgit 1.4.1-2-gfad0 From 7f6f6b13894be2f150f4789305e009b7b9f8df63 Mon Sep 17 00:00:00 2001 From: toonn Date: Mon, 10 Sep 2018 00:15:14 +0200 Subject: Business as usual --- ranger/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ranger/__init__.py b/ranger/__init__.py index b3bf61b2..2228d40e 100644 --- a/ranger/__init__.py +++ b/ranger/__init__.py @@ -33,7 +33,7 @@ def version_helper(): # Information __license__ = 'GPL3' __version__ = '1.9.2' -__release__ = True +__release__ = False __author__ = __maintainer__ = 'Roman Zimbelmann' __email__ = 'hut@hut.pm' -- cgit 1.4.1-2-gfad0 From 8e9451e6648c57d8016dad280132bf65a5d919cc Mon Sep 17 00:00:00 2001 From: toonn Date: Mon, 10 Sep 2018 00:32:49 +0200 Subject: Updated release doc The very last step changed. Also replaced a stale link in the man page. --- doc/howto-publish-a-release.md | 4 ++-- doc/ranger.1 | 4 ++-- doc/ranger.pod | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/howto-publish-a-release.md b/doc/howto-publish-a-release.md index e8d669ce..6bd70047 100644 --- a/doc/howto-publish-a-release.md +++ b/doc/howto-publish-a-release.md @@ -37,7 +37,7 @@ Make a release commit * [ ] Write changelog entry * [ ] Think of a witty commit message * [ ] Commit -* [ ] Tag the signed release with `git tag -a `, using the same +* [ ] Tag the signed release with `git tag -as vX.Y.Z`, using the same commit message as annotation * [ ] Push release and tag @@ -73,4 +73,4 @@ Announce the update Change back to before --------------------- -* [ ] Change `VERSION` in `ranger/__init__.py` back to `master` +* [ ] Change `__release__` in `ranger/__init__.py` back to `False` diff --git a/doc/ranger.1 b/doc/ranger.1 index a33252e2..4bbcc60c 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-09-09" "ranger manual" +.TH RANGER 1 "ranger-1.9.2" "2018-09-10" "ranger manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -1651,7 +1651,7 @@ ranger is maintained with the git version control system. To fetch a fresh copy, run: .PP .Vb 1 -\& git clone git://git.savannah.nongnu.org/ranger.git +\& git clone git@github.com:ranger/ranger.git .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" diff --git a/doc/ranger.pod b/doc/ranger.pod index 772107e0..637973ac 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -1812,7 +1812,7 @@ GNU General Public License 3 or (at your option) any later version. ranger is maintained with the git version control system. To fetch a fresh copy, run: - git clone git://git.savannah.nongnu.org/ranger.git + git clone git@github.com:ranger/ranger.git -- cgit 1.4.1-2-gfad0 From 7473c285fc3525aa70b684f3136b58e0352fe146 Mon Sep 17 00:00:00 2001 From: mark-dawn Date: Sun, 30 Sep 2018 18:37:16 +0200 Subject: Fix for issue #1312 (wrong color format) Moved the format conversion line from the stream section to the general one, as PIL does not autoconvert on save --- ranger/ext/img_display.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py index f78e170b..cd9b18d6 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -588,14 +588,14 @@ class KittyImageDisplayer(ImageDisplayer): image = image.resize((int(scale * image.width), int(scale * image.height)), self.backend.LANCZOS) + if image.mode != 'RGB' and image.mode != 'RGBA': + image = image.convert('RGB') # start_x += ((box[0] - image.width) // 2) // self.pix_row # start_y += ((box[1] - image.height) // 2) // self.pix_col if self.stream: # encode the whole image as base64 # TODO: implement z compression # to possibly increase resolution in sent image - if image.mode != 'RGB' and image.mode != 'RGBA': - image = image.convert('RGB') # t: transmissium medium, 'd' for embedded # f: size of a pixel fragment (8bytes per color) # s, v: size of the image to recompose the flattened data -- cgit 1.4.1-2-gfad0 From 05e3e3a9c03d684e1df8da6b1568f044e198df9f Mon Sep 17 00:00:00 2001 From: Wojciech Siewierski Date: Wed, 3 Oct 2018 20:48:36 +0200 Subject: Make sure Travis uses pipenv when testing --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0efd09fc..67873fc6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,4 +11,4 @@ install: - 'pipenv update --dev' script: - - 'make test' + - 'pipenv run make test' -- cgit 1.4.1-2-gfad0 From 908775cd3e7567e508074a4455ce620450846af9 Mon Sep 17 00:00:00 2001 From: Wojciech Siewierski Date: Wed, 3 Oct 2018 20:58:12 +0200 Subject: Travis: Update the checked python versions --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 67873fc6..fad40136 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,9 @@ dist: 'xenial' language: 'python' python: - '2.7' - - '3.4' - '3.5' + - '3.6' + - '3.7' install: - 'pip install pipenv' -- cgit 1.4.1-2-gfad0 From b8174684df603c6ea13483f9c035aed84b2977a7 Mon Sep 17 00:00:00 2001 From: Wojciech Siewierski Date: Wed, 3 Oct 2018 21:02:55 +0200 Subject: Travis: Python 3.7 seems to be broken on Travis, let's leave it for now --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fad40136..67613a84 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,6 @@ python: - '2.7' - '3.5' - '3.6' - - '3.7' install: - 'pip install pipenv' -- cgit 1.4.1-2-gfad0 From f848c140c381e8ac8f9e248e96d1d3df50258093 Mon Sep 17 00:00:00 2001 From: LeLobster Date: Thu, 4 Oct 2018 23:44:43 +0200 Subject: Add option to set a border value for use with st term --- ranger/config/rc.conf | 3 +++ ranger/container/settings.py | 1 + ranger/ext/img_display.py | 7 +++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index a32ab494..0e2af8cc 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -112,6 +112,9 @@ set preview_images_method w3m # Increase it in case of experiencing display corruption. set w3m_delay 0.02 +# Manually adjust the w3mimg offset when using a st terminal with a border value > 0 +set st_border_offset 0 + # Default iTerm2 font size (see: preview_images_method: iterm2) set iterm2_font_width 8 set iterm2_font_height 11 diff --git a/ranger/container/settings.py b/ranger/container/settings.py index 70a12b51..322bc11b 100644 --- a/ranger/container/settings.py +++ b/ranger/container/settings.py @@ -82,6 +82,7 @@ ALLOWED_SETTINGS = { 'sort': str, 'sort_unicode': bool, 'status_bar_on_top': bool, + 'st_border_offset': int, 'tilde_in_titlebar': bool, 'unicode_ellipsis': bool, 'update_title': bool, diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py index cd9b18d6..048775ef 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -219,9 +219,12 @@ class W3MImageDisplayer(ImageDisplayer, FileManagerAware): width = (width * max_height_pixels) // height height = max_height_pixels + posx=int(((start_x - 0.2) * fontw) + self.fm.settings.st_border_offset) + posy=(start_y * fonth) + self.fm.settings.st_border_offset + return "0;1;{x};{y};{w};{h};;;;;{filename}\n4;\n3;\n".format( - x=int((start_x - 0.2) * fontw), - y=start_y * fonth, + x=posx, + y=posy, # y = (start_y + 1) * fonth, # (for tmux top status bar) w=width, h=height, -- cgit 1.4.1-2-gfad0 From ea91c39a5b406366b80055f4570963a45335429d Mon Sep 17 00:00:00 2001 From: LeLobster Date: Thu, 4 Oct 2018 23:58:16 +0200 Subject: Fix ALLOWED_SETTINGS order --- ranger/container/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ranger/container/settings.py b/ranger/container/settings.py index 322bc11b..5e9c4ba2 100644 --- a/ranger/container/settings.py +++ b/ranger/container/settings.py @@ -81,8 +81,8 @@ ALLOWED_SETTINGS = { 'sort_reverse': bool, 'sort': str, 'sort_unicode': bool, - 'status_bar_on_top': bool, 'st_border_offset': int, + 'status_bar_on_top': bool, 'tilde_in_titlebar': bool, 'unicode_ellipsis': bool, 'update_title': bool, -- cgit 1.4.1-2-gfad0 From addcfa2823e994fbebf1a8740a9e986cc41fa340 Mon Sep 17 00:00:00 2001 From: LeLobster Date: Fri, 5 Oct 2018 00:00:32 +0200 Subject: Comply with pylint's complaint about > 15 local vars --- ranger/ext/img_display.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py index 048775ef..768cf651 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -219,12 +219,12 @@ class W3MImageDisplayer(ImageDisplayer, FileManagerAware): width = (width * max_height_pixels) // height height = max_height_pixels - posx=int(((start_x - 0.2) * fontw) + self.fm.settings.st_border_offset) - posy=(start_y * fonth) + self.fm.settings.st_border_offset + start_x = int(((start_x - 0.2) * fontw) + self.fm.settings.st_border_offset) + start_y = (start_y * fonth) + self.fm.settings.st_border_offset return "0;1;{x};{y};{w};{h};;;;;{filename}\n4;\n3;\n".format( - x=posx, - y=posy, + x=start_x, + y=start_y, # y = (start_y + 1) * fonth, # (for tmux top status bar) w=width, h=height, -- cgit 1.4.1-2-gfad0 From 2679b379d2ee9816ddd65d23f635663da61abe29 Mon Sep 17 00:00:00 2001 From: LeLobster Date: Fri, 5 Oct 2018 00:04:39 +0200 Subject: Add comment about st_border_offset in the man page --- doc/ranger.1 | 33 ++++++++++++++++----------------- doc/ranger.pod | 3 +++ doc/rifle.1 | 22 +++++++++------------- 3 files changed, 28 insertions(+), 30 deletions(-) diff --git a/doc/ranger.1 b/doc/ranger.1 index 4bbcc60c..24ae284c 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -1,4 +1,4 @@ -.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) +.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) .\" .\" Standard preamble: .\" ======================================================================== @@ -54,20 +54,16 @@ .\" Avoid warning from groff about undefined register 'F'. .de IX .. -.nr rF 0 -.if \n(.g .if rF .nr rF 1 -.if (\n(rF:(\n(.g==0)) \{\ -. if \nF \{\ -. de IX -. tm Index:\\$1\t\\n%\t"\\$2" +.if !\nF .nr F 0 +.if \nF>0 \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" .. -. if !\nF==2 \{\ -. nr % 0 -. nr F 2 -. \} +. if !\nF==2 \{\ +. nr % 0 +. nr F 2 . \} .\} -.rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. @@ -133,7 +129,7 @@ .\" ======================================================================== .\" .IX Title "RANGER 1" -.TH RANGER 1 "ranger-1.9.2" "2018-09-10" "ranger manual" +.TH RANGER 1 "ranger-1.9.2" "10/05/2018" "ranger manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -173,7 +169,7 @@ plugins, sample configuration files and some programs for integrating ranger with other software. They are usually installed to \&\fI/usr/share/doc/ranger/examples\fR. .PP -The man page of \fBrifle\fR\|(1) describes the functions of the file opener +The man page of \fIrifle\fR\|(1) describes the functions of the file opener .PP The section \fI\s-1LINKS\s0\fR of this man page contains further resources. .SH "POSITIONAL ARGUMENTS" @@ -299,6 +295,9 @@ This does not work over ssh, requires certain terminals (tested on \*(L"xterm\*( To enable this feature, install the program \*(L"w3m\*(R" and set the option \&\f(CW\*(C`preview_images_method\*(C'\fR to w3m. .PP +When using \*(L"st\*(R" with a compiled border larger than 0 the w3m preview will be misaligned. +Use the \f(CW\*(C`st_border_offset\*(C'\fR option to manually adjust the image offset. This should be the same value as st's borderpx. +.PP \fIiTerm2\fR .IX Subsection "iTerm2" .PP @@ -339,7 +338,7 @@ To enable this feature, set the option \f(CW\*(C`preview_images_method\*(C'\fR t \fIkitty\fR .IX Subsection "kitty" .PP -This only works on Kitty. It requires \s-1PIL\s0 (or pillow) to work. +This only works on Kitty. It requires \s-1PIL \s0(or pillow) to work. Allows remote image previews, for example in an ssh session. .PP To enable this feature, set the option \f(CW\*(C`preview_images_method\*(C'\fR to kitty. @@ -625,7 +624,7 @@ Toggle the mark-status of all files .IP "V" 14 .IX Item "V" Starts the visual mode, which selects all files between the starting point and -the cursor until you press \s-1ESC.\s0 To unselect files in the same way, use \*(L"uV\*(R". +the cursor until you press \s-1ESC. \s0 To unselect files in the same way, use \*(L"uV\*(R". .IP "/" 14 Search for files in the current directory. .IP ":" 14 @@ -1655,7 +1654,7 @@ copy, run: .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" -\&\fBrifle\fR\|(1) +\&\fIrifle\fR\|(1) .SH "BUGS" .IX Header "BUGS" Report bugs here: diff --git a/doc/ranger.pod b/doc/ranger.pod index 637973ac..77d1e18a 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -209,6 +209,9 @@ This does not work over ssh, requires certain terminals (tested on "xterm" and To enable this feature, install the program "w3m" and set the option C to w3m. +When using "st" with a compiled border larger than 0 the w3m preview will be misaligned. +Use the C option to manually adjust the image offset. This should be the same value as st's borderpx. + =head3 iTerm2 This only works in iTerm2 compiled with image preview support, but works over diff --git a/doc/rifle.1 b/doc/rifle.1 index 9ed1a145..bcd82df0 100644 --- a/doc/rifle.1 +++ b/doc/rifle.1 @@ -1,4 +1,4 @@ -.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) +.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) .\" .\" Standard preamble: .\" ======================================================================== @@ -54,20 +54,16 @@ .\" Avoid warning from groff about undefined register 'F'. .de IX .. -.nr rF 0 -.if \n(.g .if rF .nr rF 1 -.if (\n(rF:(\n(.g==0)) \{\ -. if \nF \{\ -. de IX -. tm Index:\\$1\t\\n%\t"\\$2" +.if !\nF .nr F 0 +.if \nF>0 \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" .. -. if !\nF==2 \{\ -. nr % 0 -. nr F 2 -. \} +. if !\nF==2 \{\ +. nr % 0 +. nr F 2 . \} .\} -.rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. @@ -133,7 +129,7 @@ .\" ======================================================================== .\" .IX Title "RIFLE 1" -.TH RIFLE 1 "rifle-1.9.2" "2018-09-09" "rifle manual" +.TH RIFLE 1 "rifle-1.9.2" "10/05/2018" "rifle manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l -- cgit 1.4.1-2-gfad0 From d5d668a62faeea07a7476a14fef0f63ea84a83e8 Mon Sep 17 00:00:00 2001 From: LeLobster Date: Fri, 5 Oct 2018 03:14:45 +0200 Subject: Check the env variable TERM before setting w3m offset --- ranger/ext/img_display.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py index 768cf651..5059c22e 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -219,8 +219,13 @@ class W3MImageDisplayer(ImageDisplayer, FileManagerAware): width = (width * max_height_pixels) // height height = max_height_pixels - start_x = int(((start_x - 0.2) * fontw) + self.fm.settings.st_border_offset) - start_y = (start_y * fonth) + self.fm.settings.st_border_offset + if os.getenv('TERM') in ['st-256color', 'st']: + start_x = int(((start_x - 0.2) * fontw) + self.fm.settings.st_border_offset) + start_y = (start_y * fonth) + self.fm.settings.st_border_offset + else: + start_x = int((start_x - 0.2) * fontw) + start_y = start_y * fonth + return "0;1;{x};{y};{w};{h};;;;;{filename}\n4;\n3;\n".format( x=start_x, -- cgit 1.4.1-2-gfad0 From 0b7aa9b797cb4a846183a22e4bbfc5cae70076db Mon Sep 17 00:00:00 2001 From: LeLobster Date: Fri, 5 Oct 2018 03:30:23 +0200 Subject: Update man pages and config opt name to be generic in stead of st --- doc/ranger.1 | 4 ++-- doc/ranger.pod | 4 ++-- ranger/config/rc.conf | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/ranger.1 b/doc/ranger.1 index 24ae284c..b942ab79 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -295,8 +295,8 @@ This does not work over ssh, requires certain terminals (tested on \*(L"xterm\*( To enable this feature, install the program \*(L"w3m\*(R" and set the option \&\f(CW\*(C`preview_images_method\*(C'\fR to w3m. .PP -When using \*(L"st\*(R" with a compiled border larger than 0 the w3m preview will be misaligned. -Use the \f(CW\*(C`st_border_offset\*(C'\fR option to manually adjust the image offset. This should be the same value as st's borderpx. +When using a terminal with a border larger than 0 which is not automatically detected the w3m preview will be misaligned. +Use the \f(CW\*(C`w3m_offset\*(C'\fR option to manually adjust the image offset. This should be the same value as the terminals' border value. .PP \fIiTerm2\fR .IX Subsection "iTerm2" diff --git a/doc/ranger.pod b/doc/ranger.pod index 77d1e18a..a9aaad2c 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -209,8 +209,8 @@ This does not work over ssh, requires certain terminals (tested on "xterm" and To enable this feature, install the program "w3m" and set the option C to w3m. -When using "st" with a compiled border larger than 0 the w3m preview will be misaligned. -Use the C option to manually adjust the image offset. This should be the same value as st's borderpx. +When using a terminal with a border larger than 0 which is not automatically detected the w3m preview will be misaligned. +Use the C option to manually adjust the image offset. This should be the same value as the terminals' border value. =head3 iTerm2 diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index 0e2af8cc..9963da2c 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -112,8 +112,8 @@ set preview_images_method w3m # Increase it in case of experiencing display corruption. set w3m_delay 0.02 -# Manually adjust the w3mimg offset when using a st terminal with a border value > 0 -set st_border_offset 0 +# Manually adjust the w3mimg offset when using a terminal which needs this +set w3m_offset 0 # Default iTerm2 font size (see: preview_images_method: iterm2) set iterm2_font_width 8 -- cgit 1.4.1-2-gfad0 From ea3a33be8be937fa92008cb2b89fe20279b572f9 Mon Sep 17 00:00:00 2001 From: LeLobster Date: Sat, 6 Oct 2018 01:53:03 +0200 Subject: Revert "Check the env variable TERM before setting w3m offset" This reverts commit d5d668a62faeea07a7476a14fef0f63ea84a83e8. --- ranger/ext/img_display.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py index 5059c22e..768cf651 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -219,13 +219,8 @@ class W3MImageDisplayer(ImageDisplayer, FileManagerAware): width = (width * max_height_pixels) // height height = max_height_pixels - if os.getenv('TERM') in ['st-256color', 'st']: - start_x = int(((start_x - 0.2) * fontw) + self.fm.settings.st_border_offset) - start_y = (start_y * fonth) + self.fm.settings.st_border_offset - else: - start_x = int((start_x - 0.2) * fontw) - start_y = start_y * fonth - + start_x = int(((start_x - 0.2) * fontw) + self.fm.settings.st_border_offset) + start_y = (start_y * fonth) + self.fm.settings.st_border_offset return "0;1;{x};{y};{w};{h};;;;;{filename}\n4;\n3;\n".format( x=start_x, -- cgit 1.4.1-2-gfad0 From 64a9f416cc6d6044ac6d3580da7536374459fc14 Mon Sep 17 00:00:00 2001 From: LeLobster Date: Sat, 6 Oct 2018 02:11:27 +0200 Subject: Rename setting st_* to w3m_*. Did I really forget to change this earlier? --- ranger/container/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ranger/container/settings.py b/ranger/container/settings.py index 5e9c4ba2..405aaa48 100644 --- a/ranger/container/settings.py +++ b/ranger/container/settings.py @@ -81,7 +81,6 @@ ALLOWED_SETTINGS = { 'sort_reverse': bool, 'sort': str, 'sort_unicode': bool, - 'st_border_offset': int, 'status_bar_on_top': bool, 'tilde_in_titlebar': bool, 'unicode_ellipsis': bool, @@ -95,6 +94,7 @@ ALLOWED_SETTINGS = { 'vcs_backend_svn': str, 'viewmode': str, 'w3m_delay': float, + 'w3m_offset': int, 'wrap_scroll': bool, 'xterm_alt_key': bool, } -- cgit 1.4.1-2-gfad0 From 41e19fd36aff34f3743d47345c5d83c247964fb3 Mon Sep 17 00:00:00 2001 From: pavel Date: Sun, 7 Oct 2018 12:20:43 -0400 Subject: initial mouse wheel scroll support --- ranger/gui/widgets/browsercolumn.py | 9 ++++++++- ranger/gui/widgets/pager.py | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py index bc6f7b1b..d5741d09 100644 --- a/ranger/gui/widgets/browsercolumn.py +++ b/ranger/gui/widgets/browsercolumn.py @@ -95,7 +95,13 @@ class BrowserColumn(Pager): # pylint: disable=too-many-instance-attributes elif self.level == 0: self.fm.thisdir.move_to_obj(clicked_file) self.fm.execute_file(clicked_file) - + elif self.target.is_file: ##scrolling through file preview? + if len(self.lines) > self.hei: ##is it longer than we can show? + if self.scrollbit > -1: ## have we reached the the top? + self.scrollbit += direction # influence the start point + if self.scrollbit < 0: #make sure we dont scroll before the file + self.scrollbit = 0 + self.need_redraw = True else: if self.level > 0 and not direction: self.fm.move(right=0) @@ -155,6 +161,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 if target: target.use() diff --git a/ranger/gui/widgets/pager.py b/ranger/gui/widgets/pager.py index d64d4ac1..f4555cf9 100644 --- a/ranger/gui/widgets/pager.py +++ b/ranger/gui/widgets/pager.py @@ -29,6 +29,7 @@ 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) @@ -39,6 +40,7 @@ class Pager(Widget): # pylint: disable=too-many-instance-attributes self.lines = [] self.image = None self.image_drawn = False + self.scrollbit = 0 def _close_source(self): if self.source and self.source_is_stream: @@ -95,7 +97,7 @@ class Pager(Widget): # pylint: disable=too-many-instance-attributes if not self.image: line_gen = self._generate_lines( - starty=self.scroll_begin, startx=self.startx) + starty=self.scrollbit, startx=self.startx) #updated for new scroll var for line, i in zip(line_gen, range(self.hei)): self._draw_line(i, line) -- cgit 1.4.1-2-gfad0 From 2ababc06081e69d1b2410d57e11a4efad53f6ed4 Mon Sep 17 00:00:00 2001 From: LeLobster Date: Sat, 6 Oct 2018 02:15:51 +0200 Subject: Rename st_* to w3m_* here as well, oops Undo 'changes' to rifle doc --- doc/rifle.1 | 22 +++++++++++++--------- ranger/ext/img_display.py | 4 ++-- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/doc/rifle.1 b/doc/rifle.1 index bcd82df0..9ed1a145 100644 --- a/doc/rifle.1 +++ b/doc/rifle.1 @@ -1,4 +1,4 @@ -.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) +.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== @@ -54,16 +54,20 @@ .\" Avoid warning from groff about undefined register 'F'. .de IX .. -.if !\nF .nr F 0 -.if \nF>0 \{\ -. de IX -. tm Index:\\$1\t\\n%\t"\\$2" +.nr rF 0 +.if \n(.g .if rF .nr rF 1 +.if (\n(rF:(\n(.g==0)) \{\ +. if \nF \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" .. -. if !\nF==2 \{\ -. nr % 0 -. nr F 2 +. if !\nF==2 \{\ +. nr % 0 +. nr F 2 +. \} . \} .\} +.rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. @@ -129,7 +133,7 @@ .\" ======================================================================== .\" .IX Title "RIFLE 1" -.TH RIFLE 1 "rifle-1.9.2" "10/05/2018" "rifle manual" +.TH RIFLE 1 "rifle-1.9.2" "2018-09-09" "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/ext/img_display.py b/ranger/ext/img_display.py index 768cf651..9fed512e 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -219,8 +219,8 @@ class W3MImageDisplayer(ImageDisplayer, FileManagerAware): width = (width * max_height_pixels) // height height = max_height_pixels - start_x = int(((start_x - 0.2) * fontw) + self.fm.settings.st_border_offset) - start_y = (start_y * fonth) + self.fm.settings.st_border_offset + start_x = int(((start_x - 0.2) * fontw) + self.fm.settings.w3m_offset) + start_y = (start_y * fonth) + self.fm.settings.w3m_offset return "0;1;{x};{y};{w};{h};;;;;{filename}\n4;\n3;\n".format( x=start_x, -- cgit 1.4.1-2-gfad0 From 10f4ddfc00ea9d4f6fb7b53bcb69e4613dc48d43 Mon Sep 17 00:00:00 2001 From: LeLobster Date: Sun, 7 Oct 2018 22:38:24 +0200 Subject: Resolve requested changes --- doc/ranger.1 | 6 +++--- doc/ranger.pod | 4 ++-- ranger/ext/img_display.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/ranger.1 b/doc/ranger.1 index b942ab79..069f56c9 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -129,7 +129,7 @@ .\" ======================================================================== .\" .IX Title "RANGER 1" -.TH RANGER 1 "ranger-1.9.2" "10/05/2018" "ranger manual" +.TH RANGER 1 "ranger-1.9.2" "10/07/2018" "ranger manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -295,8 +295,8 @@ This does not work over ssh, requires certain terminals (tested on \*(L"xterm\*( To enable this feature, install the program \*(L"w3m\*(R" and set the option \&\f(CW\*(C`preview_images_method\*(C'\fR to w3m. .PP -When using a terminal with a border larger than 0 which is not automatically detected the w3m preview will be misaligned. -Use the \f(CW\*(C`w3m_offset\*(C'\fR option to manually adjust the image offset. This should be the same value as the terminals' border value. +When using a terminal with a nonzero border which is not automatically detected, the w3m preview will be misaligned. +Use the \f(CW\*(C`w3m_offset\*(C'\fR option to manually adjust the image offset. This should be the same value as the terminal's border value. .PP \fIiTerm2\fR .IX Subsection "iTerm2" diff --git a/doc/ranger.pod b/doc/ranger.pod index a9aaad2c..d671ebbb 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -209,8 +209,8 @@ This does not work over ssh, requires certain terminals (tested on "xterm" and To enable this feature, install the program "w3m" and set the option C to w3m. -When using a terminal with a border larger than 0 which is not automatically detected the w3m preview will be misaligned. -Use the C option to manually adjust the image offset. This should be the same value as the terminals' border value. +When using a terminal with a nonzero border which is not automatically detected, the w3m preview will be misaligned. +Use the C option to manually adjust the image offset. This should be the same value as the terminal's border value. =head3 iTerm2 diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py index 9fed512e..3f5b5471 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -219,7 +219,7 @@ class W3MImageDisplayer(ImageDisplayer, FileManagerAware): width = (width * max_height_pixels) // height height = max_height_pixels - start_x = int(((start_x - 0.2) * fontw) + self.fm.settings.w3m_offset) + start_x = int((start_x - 0.2) * fontw) + self.fm.settings.w3m_offset start_y = (start_y * fonth) + self.fm.settings.w3m_offset return "0;1;{x};{y};{w};{h};;;;;{filename}\n4;\n3;\n".format( -- cgit 1.4.1-2-gfad0 From 3d8df486a82aca3945429df93f16fce75a498e02 Mon Sep 17 00:00:00 2001 From: Wojciech Siewierski Date: Sun, 7 Oct 2018 22:44:53 +0200 Subject: Fix a misnamed command in the documentation --- ranger/core/actions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 40fd52a3..2241bc5b 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -211,7 +211,7 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m self.ui.redraw_main_column() def redraw_window(self): - """:redraw + """:redraw_window Redraw the window. """ -- cgit 1.4.1-2-gfad0 From 40f13d845bd492003dce09277f006249f6aa628c Mon Sep 17 00:00:00 2001 From: pavel Date: Sun, 7 Oct 2018 17:59:33 -0400 Subject: limited scrolling to the end of the file --- ranger/gui/widgets/browsercolumn.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py index d5741d09..c0446995 100644 --- a/ranger/gui/widgets/browsercolumn.py +++ b/ranger/gui/widgets/browsercolumn.py @@ -96,11 +96,12 @@ 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: ##scrolling through file preview? - if len(self.lines) > self.hei: ##is it longer than we can show? - if self.scrollbit > -1: ## have we reached the the top? - self.scrollbit += direction # influence the start point - if self.scrollbit < 0: #make sure we dont scroll before the file - self.scrollbit = 0 + if direction > 0 and len(self.lines) > self.hei+self.scrollbit: ##is there more to show? + self.scrollbit += direction # influence the start point + if self.scrollbit < 0: #make sure we dont scroll before or after the file + self.scrollbit = 0 + if direction < 0 and self.scrollbit > 0: ## have we reached the the top + self.scrollbit += direction # influence the start point self.need_redraw = True else: if self.level > 0 and not direction: -- cgit 1.4.1-2-gfad0 From af80275d890f3d8cf1ebdeb60f55798fdc792440 Mon Sep 17 00:00:00 2001 From: pavel Date: Sun, 7 Oct 2018 18:27:50 -0400 Subject: fixed CI errors --- ranger/gui/widgets/browsercolumn.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py index c0446995..6f08f329 100644 --- a/ranger/gui/widgets/browsercolumn.py +++ b/ranger/gui/widgets/browsercolumn.py @@ -95,13 +95,14 @@ class BrowserColumn(Pager): # pylint: disable=too-many-instance-attributes elif self.level == 0: self.fm.thisdir.move_to_obj(clicked_file) self.fm.execute_file(clicked_file) - elif self.target.is_file: ##scrolling through file preview? - if direction > 0 and len(self.lines) > self.hei+self.scrollbit: ##is there more to show? - self.scrollbit += direction # influence the start point - if self.scrollbit < 0: #make sure we dont scroll before or after the file + elif self.target.is_file: # scrolling through file preview? + # Is there more to show? + if direction > 0 and len(self.lines) > self.hei + self.scrollbit: + self.scrollbit += direction # influence the start point + if self.scrollbit < 0: # make sure we dont scroll before or after the file self.scrollbit = 0 - if direction < 0 and self.scrollbit > 0: ## have we reached the the top - self.scrollbit += direction # influence the start point + if direction < 0 and self.scrollbit > 0: # have we reached the the top + self.scrollbit += direction # influence the start point self.need_redraw = True else: if self.level > 0 and not direction: @@ -162,7 +163,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.scrollbit = 0 # reset scroll start if target: target.use() -- cgit 1.4.1-2-gfad0 From 87855973952ea2d044826325dd96d869d4692a02 Mon Sep 17 00:00:00 2001 From: Wojciech Siewierski Date: Mon, 8 Oct 2018 00:55:11 +0200 Subject: Refactor the code and fix the coding style --- ranger/gui/widgets/browsercolumn.py | 12 +++--------- ranger/gui/widgets/pager.py | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py index 6f08f329..3845dc41 100644 --- a/ranger/gui/widgets/browsercolumn.py +++ b/ranger/gui/widgets/browsercolumn.py @@ -60,7 +60,7 @@ class BrowserColumn(Pager): # pylint: disable=too-many-instance-attributes def request_redraw(self): self.need_redraw = True - def click(self, event): + def click(self, event): # pylint: disable=too-many-branches """Handle a MouseEvent""" direction = event.mouse_wheel_direction() if not (event.pressed(1) or event.pressed(3) or direction): @@ -95,14 +95,8 @@ class BrowserColumn(Pager): # pylint: disable=too-many-instance-attributes elif self.level == 0: self.fm.thisdir.move_to_obj(clicked_file) self.fm.execute_file(clicked_file) - elif self.target.is_file: # scrolling through file preview? - # Is there more to show? - if direction > 0 and len(self.lines) > self.hei + self.scrollbit: - self.scrollbit += direction # influence the start point - if self.scrollbit < 0: # make sure we dont scroll before or after the file - self.scrollbit = 0 - if direction < 0 and self.scrollbit > 0: # have we reached the the top - self.scrollbit += direction # influence the start point + elif self.target.is_file: + self.scrollbit = max(0, self.scrollbit + direction) self.need_redraw = True else: if self.level > 0 and not direction: diff --git a/ranger/gui/widgets/pager.py b/ranger/gui/widgets/pager.py index f4555cf9..c88f5ff0 100644 --- a/ranger/gui/widgets/pager.py +++ b/ranger/gui/widgets/pager.py @@ -97,7 +97,7 @@ class Pager(Widget): # pylint: disable=too-many-instance-attributes if not self.image: line_gen = self._generate_lines( - starty=self.scrollbit, startx=self.startx) #updated for new scroll var + starty=self.scrollbit, startx=self.startx) for line, i in zip(line_gen, range(self.hei)): self._draw_line(i, line) -- cgit 1.4.1-2-gfad0 From 2af64f3a618cdb285fdf14b7ba5723fc4ff816a2 Mon Sep 17 00:00:00 2001 From: Wojciech Siewierski Date: Mon, 8 Oct 2018 01:36:47 +0200 Subject: Add a bindable action for scrolling the file preview --- doc/ranger.1 | 5 ++++- doc/ranger.pod | 4 ++++ ranger/config/rc.conf | 2 ++ ranger/core/actions.py | 11 +++++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/doc/ranger.1 b/doc/ranger.1 index 4bbcc60c..70bca73b 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-09-10" "ranger manual" +.TH RANGER 1 "ranger-1.9.2" "2018-10-08" "ranger manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -1473,6 +1473,9 @@ This can be used to re-evaluate the rc.conf file after changing it: .Vb 1 \& map X chain shell vim \-p %confdir/rc.conf %rangerdir/config/rc.conf; source %confdir/rc.conf .Ve +.IP "scroll_preview \fIvalue\fR" 2 +.IX Item "scroll_preview value" +Scroll the file preview by \fIvalue\fR lines. .IP "terminal" 2 .IX Item "terminal" Spawns the \fIx\-terminal-emulator\fR starting in the current directory. diff --git a/doc/ranger.pod b/doc/ranger.pod index 637973ac..0f1af58a 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -1572,6 +1572,10 @@ This can be used to re-evaluate the rc.conf file after changing it: map X chain shell vim -p %confdir/rc.conf %rangerdir/config/rc.conf; source %confdir/rc.conf +=item scroll_preview I + +Scroll the file preview by I lines. + =item terminal Spawns the I starting in the current directory. diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index a32ab494..1e28f1e6 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -337,6 +337,8 @@ map change_mode normal map ~ set viewmode! map i display_file +map scroll_preview 1 +map scroll_preview -1 map ? help map W display_log map w taskview_open diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 2241bc5b..89c5124b 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -995,6 +995,17 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m else: pager.set_source(fobj) + def scroll_preview(self, lines, narg=None): + """:scroll_preview + +Scroll the file preview by 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) + preview_column.request_redraw() + # -------------------------- # -- Previews # -------------------------- -- cgit 1.4.1-2-gfad0 From a9465fe0745d3713fe19c44188d8cd763ea4671e Mon Sep 17 00:00:00 2001 From: Wojciech Siewierski Date: Mon, 8 Oct 2018 01:47:51 +0200 Subject: Replace pipenv with a simple requirements.txt Motivations: - we do not want to pin a single Python version like Pipenv usually does - constant issues like https://github.com/pypa/pipenv/issues/2924 --- .travis.yml | 5 +- Pipfile | 15 ----- Pipfile.lock | 175 ------------------------------------------------------- requirements.txt | 3 + 4 files changed, 5 insertions(+), 193 deletions(-) delete mode 100644 Pipfile delete mode 100644 Pipfile.lock create mode 100644 requirements.txt diff --git a/.travis.yml b/.travis.yml index 67613a84..7a156b2b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,8 +7,7 @@ python: - '3.6' install: - - 'pip install pipenv' - - 'pipenv update --dev' + - 'pip install -r requirements.txt' script: - - 'pipenv run make test' + - 'make test' diff --git a/Pipfile b/Pipfile deleted file mode 100644 index a927408c..00000000 --- a/Pipfile +++ /dev/null @@ -1,15 +0,0 @@ -[[source]] -url = "https://pypi.org/simple" -verify_ssl = true -name = "pypi" - -[requires] -python_version = "3.5" - -[dev-packages] -pytest = "*" -"flake8" = "*" -pylint = "<2.0.0" -"enum34" = "*" - -[packages] diff --git a/Pipfile.lock b/Pipfile.lock deleted file mode 100644 index be0d4a62..00000000 --- a/Pipfile.lock +++ /dev/null @@ -1,175 +0,0 @@ -{ - "_meta": { - "hash": { - "sha256": "ccd51f0d238502cb3001a4b709d4455134eeaebb96800ebaad364567ba1ba784" - }, - "pipfile-spec": 6, - "requires": { - "python_version": "3.5" - }, - "sources": [ - { - "name": "pypi", - "url": "https://pypi.org/simple", - "verify_ssl": true - } - ] - }, - "default": {}, - "develop": { - "astroid": { - "hashes": [ - "sha256:0ef2bf9f07c3150929b25e8e61b5198c27b0dca195e156f0e4d5bdd89185ca1a", - "sha256:fc9b582dba0366e63540982c3944a9230cbc6f303641c51483fa547dcc22393a" - ], - "version": "==1.6.5" - }, - "atomicwrites": { - "hashes": [ - "sha256:240831ea22da9ab882b551b31d4225591e5e447a68c5e188db5b89ca1d487585", - "sha256:a24da68318b08ac9c9c45029f4a10371ab5b20e4226738e150e6e7c571630ae6" - ], - "version": "==1.1.5" - }, - "attrs": { - "hashes": [ - "sha256:4b90b09eeeb9b88c35bc642cbac057e45a5fd85367b985bd2809c62b7b939265", - "sha256:e0d0eb91441a3b53dab4d9b743eafc1ac44476296a2053b6ca3af0b139faf87b" - ], - "version": "==18.1.0" - }, - "enum34": { - "hashes": [ - "sha256:2d81cbbe0e73112bdfe6ef8576f2238f2ba27dd0d55752a776c41d38b7da2850", - "sha256:644837f692e5f550741432dd3f223bbb9852018674981b1664e5dc339387588a", - "sha256:6bd0f6ad48ec2aa117d3d141940d484deccda84d4fcd884f5c3d93c23ecd8c79", - "sha256:8ad8c4783bf61ded74527bffb48ed9b54166685e4230386a9ed9b1279e2df5b1" - ], - "index": "pypi", - "version": "==1.1.6" - }, - "flake8": { - "hashes": [ - "sha256:7253265f7abd8b313e3892944044a365e3f4ac3fcdcfb4298f55ee9ddf188ba0", - "sha256:c7841163e2b576d435799169b78703ad6ac1bbb0f199994fc05f700b2a90ea37" - ], - "index": "pypi", - "version": "==3.5.0" - }, - "isort": { - "hashes": [ - "sha256:1153601da39a25b14ddc54955dbbacbb6b2d19135386699e2ad58517953b34af", - "sha256:b9c40e9750f3d77e6e4d441d8b0266cf555e7cdabdcff33c4fd06366ca761ef8", - "sha256:ec9ef8f4a9bc6f71eec99e1806bfa2de401650d996c59330782b89a5555c1497" - ], - "version": "==4.3.4" - }, - "lazy-object-proxy": { - "hashes": [ - "sha256:0ce34342b419bd8f018e6666bfef729aec3edf62345a53b537a4dcc115746a33", - "sha256:1b668120716eb7ee21d8a38815e5eb3bb8211117d9a90b0f8e21722c0758cc39", - "sha256:209615b0fe4624d79e50220ce3310ca1a9445fd8e6d3572a896e7f9146bbf019", - "sha256:27bf62cb2b1a2068d443ff7097ee33393f8483b570b475db8ebf7e1cba64f088", - "sha256:27ea6fd1c02dcc78172a82fc37fcc0992a94e4cecf53cb6d73f11749825bd98b", - "sha256:2c1b21b44ac9beb0fc848d3993924147ba45c4ebc24be19825e57aabbe74a99e", - "sha256:2df72ab12046a3496a92476020a1a0abf78b2a7db9ff4dc2036b8dd980203ae6", - "sha256:320ffd3de9699d3892048baee45ebfbbf9388a7d65d832d7e580243ade426d2b", - "sha256:50e3b9a464d5d08cc5227413db0d1c4707b6172e4d4d915c1c70e4de0bbff1f5", - "sha256:5276db7ff62bb7b52f77f1f51ed58850e315154249aceb42e7f4c611f0f847ff", - "sha256:61a6cf00dcb1a7f0c773ed4acc509cb636af2d6337a08f362413c76b2b47a8dd", - "sha256:6ae6c4cb59f199d8827c5a07546b2ab7e85d262acaccaacd49b62f53f7c456f7", - "sha256:7661d401d60d8bf15bb5da39e4dd72f5d764c5aff5a86ef52a042506e3e970ff", - "sha256:7bd527f36a605c914efca5d3d014170b2cb184723e423d26b1fb2fd9108e264d", - "sha256:7cb54db3535c8686ea12e9535eb087d32421184eacc6939ef15ef50f83a5e7e2", - "sha256:7f3a2d740291f7f2c111d86a1c4851b70fb000a6c8883a59660d95ad57b9df35", - "sha256:81304b7d8e9c824d058087dcb89144842c8e0dea6d281c031f59f0acf66963d4", - "sha256:933947e8b4fbe617a51528b09851685138b49d511af0b6c0da2539115d6d4514", - "sha256:94223d7f060301b3a8c09c9b3bc3294b56b2188e7d8179c762a1cda72c979252", - "sha256:ab3ca49afcb47058393b0122428358d2fbe0408cf99f1b58b295cfeb4ed39109", - "sha256:bd6292f565ca46dee4e737ebcc20742e3b5be2b01556dafe169f6c65d088875f", - "sha256:cb924aa3e4a3fb644d0c463cad5bc2572649a6a3f68a7f8e4fbe44aaa6d77e4c", - "sha256:d0fc7a286feac9077ec52a927fc9fe8fe2fabab95426722be4c953c9a8bede92", - "sha256:ddc34786490a6e4ec0a855d401034cbd1242ef186c20d79d2166d6a4bd449577", - "sha256:e34b155e36fa9da7e1b7c738ed7767fc9491a62ec6af70fe9da4a057759edc2d", - "sha256:e5b9e8f6bda48460b7b143c3821b21b452cb3a835e6bbd5dd33aa0c8d3f5137d", - "sha256:e81ebf6c5ee9684be8f2c87563880f93eedd56dd2b6146d8a725b50b7e5adb0f", - "sha256:eb91be369f945f10d3a49f5f9be8b3d0b93a4c2be8f8a5b83b0571b8123e0a7a", - "sha256:f460d1ceb0e4a5dcb2a652db0904224f367c9b3c1470d5a7683c0480e582468b" - ], - "version": "==1.3.1" - }, - "mccabe": { - "hashes": [ - "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42", - "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f" - ], - "version": "==0.6.1" - }, - "more-itertools": { - "hashes": [ - "sha256:2b6b9893337bfd9166bee6a62c2b0c9fe7735dcf85948b387ec8cba30e85d8e8", - "sha256:6703844a52d3588f951883005efcf555e49566a48afd4db4e965d69b883980d3", - "sha256:a18d870ef2ffca2b8463c0070ad17b5978056f403fb64e3f15fe62a52db21cc0" - ], - "version": "==4.2.0" - }, - "pluggy": { - "hashes": [ - "sha256:7f8ae7f5bdf75671a718d2daf0a64b7885f74510bcd98b1a0bb420eb9a9d0cff", - "sha256:d345c8fe681115900d6da8d048ba67c25df42973bda370783cd58826442dcd7c", - "sha256:e160a7fcf25762bb60efc7e171d4497ff1d8d2d75a3d0df7a21b76821ecbf5c5" - ], - "version": "==0.6.0" - }, - "py": { - "hashes": [ - "sha256:3fd59af7435864e1a243790d322d763925431213b6b8529c6ca71081ace3bbf7", - "sha256:e31fb2767eb657cbde86c454f02e99cb846d3cd9d61b318525140214fdc0e98e" - ], - "version": "==1.5.4" - }, - "pycodestyle": { - "hashes": [ - "sha256:682256a5b318149ca0d2a9185d365d8864a768a28db66a84a2ea946bcc426766", - "sha256:6c4245ade1edfad79c3446fadfc96b0de2759662dc29d07d80a6f27ad1ca6ba9" - ], - "version": "==2.3.1" - }, - "pyflakes": { - "hashes": [ - "sha256:08bd6a50edf8cffa9fa09a463063c425ecaaf10d1eb0335a7e8b1401aef89e6f", - "sha256:8d616a382f243dbf19b54743f280b80198be0bca3a5396f1d2e1fca6223e8805" - ], - "version": "==1.6.0" - }, - "pylint": { - "hashes": [ - "sha256:a48070545c12430cfc4e865bf62f5ad367784765681b3db442d8230f0960aa3c", - "sha256:fff220bcb996b4f7e2b0f6812fd81507b72ca4d8c4d05daf2655c333800cb9b3" - ], - "index": "pypi", - "version": "==1.9.2" - }, - "pytest": { - "hashes": [ - "sha256:0453c8676c2bee6feb0434748b068d5510273a916295fd61d306c4f22fbfd752", - "sha256:4b208614ae6d98195430ad6bde03641c78553acee7c83cec2e85d613c0cd383d" - ], - "index": "pypi", - "version": "==3.6.3" - }, - "six": { - "hashes": [ - "sha256:70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9", - "sha256:832dc0e10feb1aa2c68dcc57dbb658f1c7e65b9b61af69048abc87a2db00a0eb" - ], - "version": "==1.11.0" - }, - "wrapt": { - "hashes": [ - "sha256:d4d560d479f2c21e1b5443bbd15fe7ec4b37fe7e53d335d3b9b0a7b1226fe3c6" - ], - "version": "==1.10.11" - } - } -} diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..411a2a97 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +flake8 +pylint<2 +pytest -- cgit 1.4.1-2-gfad0 From 3fe8814b435cff349686d87c7c7afef1bcc1f34d Mon Sep 17 00:00:00 2001 From: toonn Date: Tue, 9 Oct 2018 16:53:15 +0200 Subject: Document w3m_offset in Settings section of manpage --- doc/ranger.1 | 39 ++++++++++++++++++++++----------------- doc/ranger.pod | 6 ++++++ 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/doc/ranger.1 b/doc/ranger.1 index 0cb65d80..02fb8c15 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -1,4 +1,4 @@ -.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) +.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== @@ -54,16 +54,20 @@ .\" Avoid warning from groff about undefined register 'F'. .de IX .. -.if !\nF .nr F 0 -.if \nF>0 \{\ -. de IX -. tm Index:\\$1\t\\n%\t"\\$2" +.nr rF 0 +.if \n(.g .if rF .nr rF 1 +.if (\n(rF:(\n(.g==0)) \{\ +. if \nF \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" .. -. if !\nF==2 \{\ -. nr % 0 -. nr F 2 +. if !\nF==2 \{\ +. nr % 0 +. nr F 2 +. \} . \} .\} +.rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. @@ -129,11 +133,7 @@ .\" ======================================================================== .\" .IX Title "RANGER 1" -<<<<<<< HEAD -.TH RANGER 1 "ranger-1.9.2" "2018-10-08" "ranger manual" -======= -.TH RANGER 1 "ranger-1.9.2" "10/07/2018" "ranger manual" ->>>>>>> LeLobster-stborderw3mfix +.TH RANGER 1 "ranger-1.9.2" "2018-10-09" "ranger manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -173,7 +173,7 @@ plugins, sample configuration files and some programs for integrating ranger with other software. They are usually installed to \&\fI/usr/share/doc/ranger/examples\fR. .PP -The man page of \fIrifle\fR\|(1) describes the functions of the file opener +The man page of \fBrifle\fR\|(1) describes the functions of the file opener .PP The section \fI\s-1LINKS\s0\fR of this man page contains further resources. .SH "POSITIONAL ARGUMENTS" @@ -342,7 +342,7 @@ To enable this feature, set the option \f(CW\*(C`preview_images_method\*(C'\fR t \fIkitty\fR .IX Subsection "kitty" .PP -This only works on Kitty. It requires \s-1PIL \s0(or pillow) to work. +This only works on Kitty. It requires \s-1PIL\s0 (or pillow) to work. Allows remote image previews, for example in an ssh session. .PP To enable this feature, set the option \f(CW\*(C`preview_images_method\*(C'\fR to kitty. @@ -628,7 +628,7 @@ Toggle the mark-status of all files .IP "V" 14 .IX Item "V" Starts the visual mode, which selects all files between the starting point and -the cursor until you press \s-1ESC. \s0 To unselect files in the same way, use \*(L"uV\*(R". +the cursor until you press \s-1ESC.\s0 To unselect files in the same way, use \*(L"uV\*(R". .IP "/" 14 Search for files in the current directory. .IP ":" 14 @@ -1070,6 +1070,11 @@ traditional miller column view that shows multiple levels of the hierarchy, or .IX Item "w3m_delay [float]" Delay in seconds before displaying an image with the w3m method. Increase it in case of experiencing display corruption. +.IP "w3m_offset [int]" 4 +.IX Item "w3m_offset [int]" +Offset in pixels for the inner border of the terminal. Some terminals require +the offset to be specified explicitly, among others st and UXterm, some don't +like urxvt. .IP "wrap_scroll [bool]" 4 .IX Item "wrap_scroll [bool]" Enable scroll wrapping \- moving down while on the last item will wrap around to @@ -1661,7 +1666,7 @@ copy, run: .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" -\&\fIrifle\fR\|(1) +\&\fBrifle\fR\|(1) .SH "BUGS" .IX Header "BUGS" Report bugs here: diff --git a/doc/ranger.pod b/doc/ranger.pod index c68e7246..c319f785 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -1122,6 +1122,12 @@ B to use multiple panes (one per tab) similar to midnight-commander. Delay in seconds before displaying an image with the w3m method. Increase it in case of experiencing display corruption. +=item w3m_offset [int] + +Offset in pixels for the inner border of the terminal. Some terminals require +the offset to be specified explicitly, among others st and UXterm, some don't +like urxvt. + =item wrap_scroll [bool] Enable scroll wrapping - moving down while on the last item will wrap around to -- cgit 1.4.1-2-gfad0 From b0016cb93da5b65277403dd99c06d7f0a09dfbcc Mon Sep 17 00:00:00 2001 From: GermainZ Date: Sun, 14 Oct 2018 17:23:11 +0200 Subject: Do not allow scrolling beyond end of file preview --- ranger/core/actions.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 89c5124b..4e76df65 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 -Scroll the file preview by lines.""" + Scroll the file preview by 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.scrollbit + lines + max_scroll = len(preview_column.lines) - preview_column.hei + preview_column.scrollbit = max(0, min(target_scroll, max_scroll)) preview_column.request_redraw() # -------------------------- -- cgit 1.4.1-2-gfad0 From 6549b810ae108325fd1bf2634e10884c55413bc8 Mon Sep 17 00:00:00 2001 From: GermainZ Date: Sun, 14 Oct 2018 16:28:27 +0200 Subject: Add size_in_bytes setting to show all sizes in bytes --- doc/ranger.1 | 37 ++++++++++++++++++++----------------- doc/ranger.pod | 4 ++++ ranger/config/rc.conf | 3 +++ ranger/container/settings.py | 1 + ranger/ext/human_readable.py | 5 +++++ 5 files changed, 33 insertions(+), 17 deletions(-) diff --git a/doc/ranger.1 b/doc/ranger.1 index 0cb65d80..b7d70ae1 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -1,4 +1,4 @@ -.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) +.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== @@ -54,16 +54,20 @@ .\" Avoid warning from groff about undefined register 'F'. .de IX .. -.if !\nF .nr F 0 -.if \nF>0 \{\ -. de IX -. tm Index:\\$1\t\\n%\t"\\$2" +.nr rF 0 +.if \n(.g .if rF .nr rF 1 +.if (\n(rF:(\n(.g==0)) \{\ +. if \nF \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" .. -. if !\nF==2 \{\ -. nr % 0 -. nr F 2 +. if !\nF==2 \{\ +. nr % 0 +. nr F 2 +. \} . \} .\} +.rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. @@ -129,11 +133,7 @@ .\" ======================================================================== .\" .IX Title "RANGER 1" -<<<<<<< HEAD -.TH RANGER 1 "ranger-1.9.2" "2018-10-08" "ranger manual" -======= -.TH RANGER 1 "ranger-1.9.2" "10/07/2018" "ranger manual" ->>>>>>> LeLobster-stborderw3mfix +.TH RANGER 1 "ranger-1.9.2" "10/14/2018" "ranger manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -173,7 +173,7 @@ plugins, sample configuration files and some programs for integrating ranger with other software. They are usually installed to \&\fI/usr/share/doc/ranger/examples\fR. .PP -The man page of \fIrifle\fR\|(1) describes the functions of the file opener +The man page of \fBrifle\fR\|(1) describes the functions of the file opener .PP The section \fI\s-1LINKS\s0\fR of this man page contains further resources. .SH "POSITIONAL ARGUMENTS" @@ -342,7 +342,7 @@ To enable this feature, set the option \f(CW\*(C`preview_images_method\*(C'\fR t \fIkitty\fR .IX Subsection "kitty" .PP -This only works on Kitty. It requires \s-1PIL \s0(or pillow) to work. +This only works on Kitty. It requires \s-1PIL\s0 (or pillow) to work. Allows remote image previews, for example in an ssh session. .PP To enable this feature, set the option \f(CW\*(C`preview_images_method\*(C'\fR to kitty. @@ -628,7 +628,7 @@ Toggle the mark-status of all files .IP "V" 14 .IX Item "V" Starts the visual mode, which selects all files between the starting point and -the cursor until you press \s-1ESC. \s0 To unselect files in the same way, use \*(L"uV\*(R". +the cursor until you press \s-1ESC.\s0 To unselect files in the same way, use \*(L"uV\*(R". .IP "/" 14 Search for files in the current directory. .IP ":" 14 @@ -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 @@ -1661,7 +1664,7 @@ copy, run: .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" -\&\fIrifle\fR\|(1) +\&\fBrifle\fR\|(1) .SH "BUGS" .IX Header "BUGS" Report bugs here: diff --git a/doc/ranger.pod b/doc/ranger.pod index c68e7246..f822df39 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/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. -- cgit 1.4.1-2-gfad0 From 6002eedbb0bb497d7ca08278bf7b1c618314ae1b Mon Sep 17 00:00:00 2001 From: meruru Date: Thu, 25 Oct 2018 00:46:20 -0300 Subject: Delete unused variable --- ranger/ext/rifle.py | 2 -- 1 file changed, 2 deletions(-) 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 -- cgit 1.4.1-2-gfad0 From 22dcaf91e7ad5df0a0177ec5dd5e0b071c3deb51 Mon Sep 17 00:00:00 2001 From: Baranovskiy Konstantin Date: Thu, 25 Oct 2018 16:07:04 +0300 Subject: Restoration of scrolling in pager. Fixes #1347 --- ranger/core/actions.py | 4 ++-- ranger/gui/widgets/browsercolumn.py | 6 ++++-- ranger/gui/widgets/pager.py | 6 +++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 4e76df65..1b5d0028 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -1004,9 +1004,9 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m if preview_column.target and preview_column.target.is_file: if narg is not None: lines = narg - target_scroll = preview_column.scrollbit + lines + target_scroll = preview_column.scroll_extra + lines max_scroll = len(preview_column.lines) - preview_column.hei - preview_column.scrollbit = max(0, min(target_scroll, max_scroll)) + preview_column.scroll_extra = max(0, min(target_scroll, max_scroll)) preview_column.request_redraw() # -------------------------- 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) -- cgit 1.4.1-2-gfad0 From f750522ac0394b72e3dfd3e070685169f692094c Mon Sep 17 00:00:00 2001 From: seebye Date: Thu, 25 Oct 2018 15:43:30 +0200 Subject: ueberzug: ensure the process's death with rangers end Wait for ueberzug to finish within a second if the timeout occurs send a SIGKILL --- ranger/ext/img_display.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py index 2cbf2f94..cd6d6198 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -21,6 +21,7 @@ import struct import sys import warnings import json +import threading from subprocess import Popen, PIPE import termios @@ -720,4 +721,10 @@ class UeberzugImageDisplayer(ImageDisplayer): def quit(self): if (self.is_initialized and self.process.poll() is None and not self.process.stdin.closed): + timer = threading.Timer(1, self.process.kill, []) self.process.stdin.close() + try: + timer.start() + _ = self.process.communicate() + finally: + timer.cancel() -- cgit 1.4.1-2-gfad0 From 5be6c2bb191f4c38c6d3f639d096b43c5645ff47 Mon Sep 17 00:00:00 2001 From: seebye Date: Thu, 25 Oct 2018 15:50:44 +0200 Subject: ueberzug: update documentation Mention ueberzug requirements. --- ranger/config/rc.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index 57b798a1..bccf7c56 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -110,6 +110,7 @@ set preview_images false # * ueberzug: # Preview images in full color with the external command "ueberzug". # Images are shown by using a child window. +# Only for users who run X11 in GNU/Linux. set preview_images_method w3m # Delay in seconds before displaying an image with the w3m method. -- cgit 1.4.1-2-gfad0 From c67418c71dc7dc78ad20ae98775b8e320fd63e3d Mon Sep 17 00:00:00 2001 From: seebye Date: Thu, 25 Oct 2018 15:59:55 +0200 Subject: ueberzug: remove unused variable --- ranger/ext/img_display.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py index cd6d6198..cfb72639 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -725,6 +725,6 @@ class UeberzugImageDisplayer(ImageDisplayer): self.process.stdin.close() try: timer.start() - _ = self.process.communicate() + self.process.communicate() finally: timer.cancel() -- cgit 1.4.1-2-gfad0 From 6351c6cb904b28275b7da3a7d8d7484032887bc1 Mon Sep 17 00:00:00 2001 From: seebye Date: Thu, 25 Oct 2018 16:34:02 +0200 Subject: ueberzug: timeout: end process with SIGTERM, use SIGKILL as fallback --- ranger/ext/img_display.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py index cfb72639..4207b22e 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -721,10 +721,13 @@ class UeberzugImageDisplayer(ImageDisplayer): def quit(self): if (self.is_initialized and self.process.poll() is None and not self.process.stdin.closed): - timer = threading.Timer(1, self.process.kill, []) + timer_term = threading.Timer(1, self.process.terminate, []) + timer_kill = threading.Timer(2, self.process.kill, []) self.process.stdin.close() try: - timer.start() + timer_term.start() + timer_kill.start() self.process.communicate() finally: - timer.cancel() + timer_term.cancel() + timer_kill.cancel() -- cgit 1.4.1-2-gfad0 From f533187b735328956e0c57d7b39677441e1edc85 Mon Sep 17 00:00:00 2001 From: seebye Date: Thu, 25 Oct 2018 16:53:37 +0200 Subject: ueberzug: fix changed pep8 rules --- ranger/ext/img_display.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py index 4207b22e..eeddd609 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -690,8 +690,8 @@ class UeberzugImageDisplayer(ImageDisplayer): def initialize(self): """start ueberzug""" - if (self.is_initialized and self.process.poll() is None and - not self.process.stdin.closed): + if (self.is_initialized and self.process.poll() is None + and not self.process.stdin.closed): return self.process = Popen(['ueberzug', 'layer', '--silent'], @@ -719,8 +719,8 @@ class UeberzugImageDisplayer(ImageDisplayer): self._execute(action='remove', identifier=self.IMAGE_ID) def quit(self): - if (self.is_initialized and self.process.poll() is None and - not self.process.stdin.closed): + if (self.is_initialized and self.process.poll() is None + and not self.process.stdin.closed): timer_term = threading.Timer(1, self.process.terminate, []) timer_kill = threading.Timer(2, self.process.kill, []) self.process.stdin.close() -- cgit 1.4.1-2-gfad0 From 588c1856de9d91b64dde53034387770f5b7b9a22 Mon Sep 17 00:00:00 2001 From: seebye Date: Thu, 25 Oct 2018 17:38:38 +0200 Subject: ueberzug: end ueberzug by directly sending SIGTERM, fallback to SIGKILL --- ranger/ext/img_display.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py index eeddd609..2d5b20a0 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -719,15 +719,11 @@ class UeberzugImageDisplayer(ImageDisplayer): self._execute(action='remove', identifier=self.IMAGE_ID) def quit(self): - if (self.is_initialized and self.process.poll() is None - and not self.process.stdin.closed): - timer_term = threading.Timer(1, self.process.terminate, []) - timer_kill = threading.Timer(2, self.process.kill, []) - self.process.stdin.close() + if self.is_initialized and self.process.poll() is None: + timer_kill = threading.Timer(1, self.process.kill, []) try: - timer_term.start() + self.process.terminate() timer_kill.start() self.process.communicate() finally: - timer_term.cancel() timer_kill.cancel() -- cgit 1.4.1-2-gfad0 From d6ac6d04ee61dffae0df811d9f424508b87580ab Mon Sep 17 00:00:00 2001 From: Baranovskiy Konstantin Date: Thu, 25 Oct 2018 16:07:04 +0300 Subject: Restoration of scrolling in pager. Fixes #1347 --- ranger/core/actions.py | 5 +---- ranger/gui/widgets/browsercolumn.py | 5 +---- ranger/gui/widgets/pager.py | 6 ++++++ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 1b5d0028..20a180e9 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -1004,10 +1004,7 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m if preview_column.target and preview_column.target.is_file: if narg is not None: lines = narg - 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() + preview_column.scrollbit(lines) # -------------------------- # -- Previews diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py index 8d2e63eb..ecc66f44 100644 --- a/ranger/gui/widgets/browsercolumn.py +++ b/ranger/gui/widgets/browsercolumn.py @@ -96,10 +96,7 @@ 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: - 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 + self.scrollbit(direction) else: if self.level > 0 and not direction: self.fm.move(right=0) diff --git a/ranger/gui/widgets/pager.py b/ranger/gui/widgets/pager.py index 3bb52e3f..c1aa2765 100644 --- a/ranger/gui/widgets/pager.py +++ b/ranger/gui/widgets/pager.py @@ -75,6 +75,12 @@ class Pager(Widget): # pylint: disable=too-many-instance-attributes def finalize(self): self.fm.ui.win.move(self.y, self.x) + def scrollbit(self, lines): + target_scroll = self.scroll_extra + lines + max_scroll = len(self.lines) - self.hei + self.scroll_extra = max(0, min(target_scroll, max_scroll)) + self.need_redraw = True + def draw(self): if self.need_clear_image: self.need_redraw = True -- cgit 1.4.1-2-gfad0 From f9c49f9c2e7ec680f9a06685eba75787e7d2ed7b Mon Sep 17 00:00:00 2001 From: Baranovskiy Konstantin Date: Sat, 20 Oct 2018 20:01:02 +0300 Subject: Broken preview of highlighted text with Python3 ranger/core/loader.py: CommandLoader.generate() gets text for preview panel from scope.sh as the blocks of byrearray (max 512 bytes). This blocks immediately decoded to utf-8. But in case when muli-byte unicode characters is present they may be split and python will can't correctly to decode it. For example: b'abc\xd0', b'\x9a...' b'\xd0\x9a' - is cyrillic letter 'K' and it can't be decoded separately (UnicodeDecodeError occurs). So, received data blocks (bytearrays) must be collected and only after that decoded as one whole byrearray. Fixes #906 Fixes #967 Fixes #1166 --- ranger/core/loader.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/ranger/core/loader.py b/ranger/core/loader.py index 274dc610..9f32535f 100644 --- a/ranger/core/loader.py +++ b/ranger/core/loader.py @@ -194,6 +194,7 @@ class CommandLoader( # pylint: disable=too-many-instance-attributes selectlist.append(process.stdout) if not self.silent: selectlist.append(process.stderr) + read_stdout = None while process.poll() is None: yield if self.finished: @@ -210,10 +211,11 @@ class CommandLoader( # pylint: disable=too-many-instance-attributes self.fm.notify(read, bad=True) elif robjs == process.stdout: read = robjs.read(512) - if py3: - read = safe_decode(read) if read: - self.stdout_buffer += read + if read_stdout is None: + read_stdout = read + else: + read_stdout += read except select.error: sleep(0.03) if not self.silent: @@ -223,9 +225,12 @@ class CommandLoader( # pylint: disable=too-many-instance-attributes self.fm.notify(line, bad=True) if self.read: read = process.stdout.read() + if read: + read_stdout += read + if read_stdout: if py3: - read = safe_decode(read) - self.stdout_buffer += read + read_stdout = safe_decode(read_stdout) + self.stdout_buffer += read_stdout self.finished = True self.signal_emit('after', process=process, loader=self) -- cgit 1.4.1-2-gfad0 From ec17480833b7c3d968e73a72394c826823dbdfe9 Mon Sep 17 00:00:00 2001 From: Baranovskiy Konstantin Date: Wed, 24 Oct 2018 18:11:27 +0300 Subject: File encoding guessing order changed. Fixes #1350 --- ranger/core/actions.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 20a180e9..e4cc1ded 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -1170,24 +1170,27 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m try: import chardet except ImportError: - # Guess encoding ourselves. These should be the most frequently used ones. - encodings = ('utf-8', 'utf-16') - for encoding in encodings: - try: - with codecs.open(path, 'r', encoding=encoding) as fobj: - text = fobj.read(count) - except UnicodeDecodeError: - pass - else: - LOG.debug("guessed encoding of '%s' as %r", path, encoding) - return text + pass else: with open(path, 'rb') as fobj: data = fobj.read(count) result = chardet.detect(data) - LOG.debug("chardet guess for '%s': %s", path, result) guessed_encoding = result['encoding'] - return codecs.decode(data, guessed_encoding, 'replace') + if guessed_encoding is not None: + LOG.debug("chardet guess for '%s': %s", path, result) + return codecs.decode(data, guessed_encoding, 'replace') + + # Guess encoding ourselves. These should be the most frequently used ones. + encodings = ('utf-8', 'utf-16') + for encoding in encodings: + try: + with codecs.open(path, 'r', encoding=encoding) as fobj: + text = fobj.read(count) + except UnicodeDecodeError: + pass + else: + LOG.debug("guessed encoding of '%s' as %r", path, encoding) + return text # latin-1 as the last resort with codecs.open(path, 'r', encoding='latin-1', errors='replace') as fobj: -- cgit 1.4.1-2-gfad0 From 9b1af8452642267ae982853ba331bb8fd8f22320 Mon Sep 17 00:00:00 2001 From: toonn Date: Sun, 28 Oct 2018 13:11:28 +0100 Subject: Put our guesses back in the except clause --- ranger/core/actions.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/ranger/core/actions.py b/ranger/core/actions.py index e4cc1ded..7e5765b0 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -1170,7 +1170,18 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m try: import chardet except ImportError: - pass + # Guess encoding ourselves. + # These should be the most frequently used ones. + encodings = ('utf-8', 'utf-16') + for encoding in encodings: + try: + with codecs.open(path, 'r', encoding=encoding) as fobj: + text = fobj.read(count) + except UnicodeDecodeError: + pass + else: + LOG.debug("guessed encoding of '%s' as %r", path, encoding) + return text else: with open(path, 'rb') as fobj: data = fobj.read(count) @@ -1180,18 +1191,6 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m LOG.debug("chardet guess for '%s': %s", path, result) return codecs.decode(data, guessed_encoding, 'replace') - # Guess encoding ourselves. These should be the most frequently used ones. - encodings = ('utf-8', 'utf-16') - for encoding in encodings: - try: - with codecs.open(path, 'r', encoding=encoding) as fobj: - text = fobj.read(count) - except UnicodeDecodeError: - pass - else: - LOG.debug("guessed encoding of '%s' as %r", path, encoding) - return text - # latin-1 as the last resort with codecs.open(path, 'r', encoding='latin-1', errors='replace') as fobj: return fobj.read(count) -- cgit 1.4.1-2-gfad0 From 55099758427b04201510774b4526bd2b0d331b48 Mon Sep 17 00:00:00 2001 From: toonn Date: Sun, 28 Oct 2018 13:46:29 +0100 Subject: Refactor encoding detection --- ranger/core/actions.py | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 7e5765b0..5358a40f 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -1167,33 +1167,36 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m @staticmethod def read_text_file(path, count=None): """Encoding-aware reading of a text file.""" + # Guess encoding ourselves. + # These should be the most frequently used ones. + # latin-1 as the last resort + encodings = [ ('utf-8', 'strict') + , ('utf-16', 'strict') + , ('latin-1', 'replace') + ] + + with open(path, 'rb') as fobj: + data = fobj.read(count) + try: import chardet except ImportError: - # Guess encoding ourselves. - # These should be the most frequently used ones. - encodings = ('utf-8', 'utf-16') - for encoding in encodings: - try: - with codecs.open(path, 'r', encoding=encoding) as fobj: - text = fobj.read(count) - except UnicodeDecodeError: - pass - else: - LOG.debug("guessed encoding of '%s' as %r", path, encoding) - return text + pass else: - with open(path, 'rb') as fobj: - data = fobj.read(count) result = chardet.detect(data) guessed_encoding = result['encoding'] if guessed_encoding is not None: - LOG.debug("chardet guess for '%s': %s", path, result) - return codecs.decode(data, guessed_encoding, 'replace') + # Add chardet's guess before our own. + encodings.insert(0, (guessed_encoding, 'replace')) - # latin-1 as the last resort - with codecs.open(path, 'r', encoding='latin-1', errors='replace') as fobj: - return fobj.read(count) + for (encoding, error_scheme) in encodings: + try: + text = codecs.decode(data, encoding, error_scheme) + except UnicodeDecodeError: + pass + else: + LOG.debug("Guessed encoding of '%s' as %s", path, encoding) + return text # -------------------------- # -- Tabs -- cgit 1.4.1-2-gfad0 From 89b4b1290cd7ad43ce6452876117323f03616a39 Mon Sep 17 00:00:00 2001 From: toonn Date: Sun, 28 Oct 2018 14:02:07 +0100 Subject: Placate our pep 8 overlords --- ranger/core/actions.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 5358a40f..6cf376eb 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -1170,10 +1170,8 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m # Guess encoding ourselves. # These should be the most frequently used ones. # latin-1 as the last resort - encodings = [ ('utf-8', 'strict') - , ('utf-16', 'strict') - , ('latin-1', 'replace') - ] + encodings = [('utf-8', 'strict'), ('utf-16', 'strict'), + ('latin-1', 'replace')] with open(path, 'rb') as fobj: data = fobj.read(count) -- cgit 1.4.1-2-gfad0 From 8454fc4a67fe5dfacc721161b78bf0924a831958 Mon Sep 17 00:00:00 2001 From: seebye Date: Tue, 6 Nov 2018 23:35:58 +0100 Subject: ueberzug: remove margin --- ranger/ext/img_display.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py index 2d5b20a0..9c84ce5e 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -709,8 +709,8 @@ class UeberzugImageDisplayer(ImageDisplayer): identifier=self.IMAGE_ID, x=start_x, y=start_y, - max_width=width - 1, - max_height=height - 1, + max_width=width, + max_height=height, path=path ) -- cgit 1.4.1-2-gfad0 From bae44ae3c7440c00acf65ba4c26a0fd2a0f78c3a Mon Sep 17 00:00:00 2001 From: Wojciech Siewierski Date: Sat, 24 Nov 2018 15:37:23 +0100 Subject: scope.sh: Format JSON with either jq or json.tool Closes #1383. --- ranger/data/scope.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh index 13a25b45..8e0a0f6d 100755 --- a/ranger/data/scope.sh +++ b/ranger/data/scope.sh @@ -83,6 +83,11 @@ handle_extension() { lynx -dump -- "${FILE_PATH}" && exit 5 elinks -dump "${FILE_PATH}" && exit 5 ;; # Continue with next handler on failure + # JSON + json) + jq --color-output . "${FILE_PATH}" && exit 5 + python -m json.tool -- "${FILE_PATH}" && exit 5 + ;; esac } -- cgit 1.4.1-2-gfad0 From f7c9f837634738da105056a8b66457afa3ff8636 Mon Sep 17 00:00:00 2001 From: Jon Erling Hustadnes Date: Mon, 17 Dec 2018 18:30:52 +0100 Subject: Added check if bookmark file is a symlink. If it is, the os.rename is performed on the original file path instead of overwriting the symlink. --- ranger/container/bookmarks.py | 8 +++++++- tests/ranger/container/test_bookmarks.py | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/ranger/container/bookmarks.py b/ranger/container/bookmarks.py index 59838c00..846a6585 100644 --- a/ranger/container/bookmarks.py +++ b/ranger/container/bookmarks.py @@ -185,7 +185,13 @@ class Bookmarks(FileManagerAware): old_perms = os.stat(self.path) os.chown(path_new, old_perms.st_uid, old_perms.st_gid) os.chmod(path_new, old_perms.st_mode) - os.rename(path_new, self.path) + + if os.path.islink(self.path): + link_path = os.path.realpath(self.path) + os.rename(path_new, link_path) + else: + os.rename(path_new, self.path) + except OSError as ex: self.fm.notify('Bookmarks error: {0}'.format(str(ex)), bad=True) return diff --git a/tests/ranger/container/test_bookmarks.py b/tests/ranger/container/test_bookmarks.py index 6fba2a3d..7802bd5d 100644 --- a/tests/ranger/container/test_bookmarks.py +++ b/tests/ranger/container/test_bookmarks.py @@ -56,3 +56,20 @@ def testbookmarks(tmpdir): secondstore.update_if_outdated() secondstore.update = origupdate secondstore.update_if_outdated() + + +def test_bookmark_symlink(tmpdir): + # Initialize plain file and symlink paths + bookmarkfile_link = tmpdir.join("bookmarkfile") + bookmarkfile_orig = tmpdir.join("bookmarkfile.org") + + # Create symlink pointing towards the original plain file. + os.symlink(bookmarkfile_orig, bookmarkfile_link) + + # Initialize the bookmark file and save the file. + bmstore = Bookmarks(str(bookmarkfile_link)) + bmstore.save() + + # Once saved, the bookmark file should still be a symlink pointing towards the plain file. + assert os.path.islink(bookmarkfile_link) + assert not os.path.islink(bookmarkfile_orig) -- cgit 1.4.1-2-gfad0 From f6c7a281c1cde6d754811f64f3227d5623a4d096 Mon Sep 17 00:00:00 2001 From: Jon Erling Hustadnes Date: Mon, 17 Dec 2018 22:22:05 +0100 Subject: corrected for python 2.7 --- tests/ranger/container/test_bookmarks.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/ranger/container/test_bookmarks.py b/tests/ranger/container/test_bookmarks.py index 7802bd5d..e76aaaf2 100644 --- a/tests/ranger/container/test_bookmarks.py +++ b/tests/ranger/container/test_bookmarks.py @@ -64,12 +64,12 @@ def test_bookmark_symlink(tmpdir): bookmarkfile_orig = tmpdir.join("bookmarkfile.org") # Create symlink pointing towards the original plain file. - os.symlink(bookmarkfile_orig, bookmarkfile_link) + os.symlink(str(bookmarkfile_orig), str(bookmarkfile_link)) # Initialize the bookmark file and save the file. bmstore = Bookmarks(str(bookmarkfile_link)) bmstore.save() # Once saved, the bookmark file should still be a symlink pointing towards the plain file. - assert os.path.islink(bookmarkfile_link) - assert not os.path.islink(bookmarkfile_orig) + assert os.path.islink(str(bookmarkfile_link)) + assert not os.path.islink(str(bookmarkfile_orig)) -- cgit 1.4.1-2-gfad0 From 29222004d0baa6f19f9ecba1b03b218716a13cb3 Mon Sep 17 00:00:00 2001 From: Jon Erling Hustadnes Date: Tue, 18 Dec 2018 12:41:13 +0100 Subject: updated original filename --- tests/ranger/container/test_bookmarks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ranger/container/test_bookmarks.py b/tests/ranger/container/test_bookmarks.py index e76aaaf2..64192c06 100644 --- a/tests/ranger/container/test_bookmarks.py +++ b/tests/ranger/container/test_bookmarks.py @@ -61,7 +61,7 @@ def testbookmarks(tmpdir): def test_bookmark_symlink(tmpdir): # Initialize plain file and symlink paths bookmarkfile_link = tmpdir.join("bookmarkfile") - bookmarkfile_orig = tmpdir.join("bookmarkfile.org") + bookmarkfile_orig = tmpdir.join("bookmarkfile.orig") # Create symlink pointing towards the original plain file. os.symlink(str(bookmarkfile_orig), str(bookmarkfile_link)) -- cgit 1.4.1-2-gfad0 From ec048e93fe0a4b7d2079c0af1364574906da9e7f Mon Sep 17 00:00:00 2001 From: Jon Erling Hustadnes Date: Tue, 18 Dec 2018 21:22:14 +0100 Subject: updated variable name --- ranger/container/bookmarks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ranger/container/bookmarks.py b/ranger/container/bookmarks.py index 846a6585..cbfc541a 100644 --- a/ranger/container/bookmarks.py +++ b/ranger/container/bookmarks.py @@ -187,8 +187,8 @@ class Bookmarks(FileManagerAware): os.chmod(path_new, old_perms.st_mode) if os.path.islink(self.path): - link_path = os.path.realpath(self.path) - os.rename(path_new, link_path) + target_path = os.path.realpath(self.path) + os.rename(path_new, target_path) else: os.rename(path_new, self.path) -- cgit 1.4.1-2-gfad0