diff options
author | toonn <toonn@toonn.io> | 2021-01-05 18:52:25 +0100 |
---|---|---|
committer | toonn <toonn@toonn.io> | 2021-01-05 18:52:25 +0100 |
commit | 790d90853504f62e9449844a6481f3955190e35d (patch) | |
tree | baf6c8c4eca175ab0da304c840285bfdbaa4ee09 /ranger | |
parent | 7a0d077e4545f18d30488122fee80ba4df1c7b52 (diff) | |
parent | 6fd49695111232df31358a67b11dc5ee3b8dbcfc (diff) | |
download | ranger-790d90853504f62e9449844a6481f3955190e35d.tar.gz |
Merge branch 'chu4ng-fix-files-index' into fix-files-none
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/config/.pylintrc | 2 | ||||
-rwxr-xr-x | ranger/config/commands.py | 31 | ||||
-rw-r--r-- | ranger/config/rc.conf | 4 | ||||
-rw-r--r-- | ranger/config/rifle.conf | 47 | ||||
-rw-r--r-- | ranger/container/settings.py | 13 | ||||
-rw-r--r-- | ranger/core/actions.py | 2 | ||||
-rw-r--r-- | ranger/core/tab.py | 2 | ||||
-rw-r--r-- | ranger/ext/img_display.py | 2 | ||||
-rw-r--r-- | ranger/gui/color.py | 36 | ||||
-rw-r--r-- | ranger/gui/widgets/statusbar.py | 8 | ||||
-rw-r--r-- | ranger/gui/widgets/view_multipane.py | 102 |
11 files changed, 182 insertions, 67 deletions
diff --git a/ranger/config/.pylintrc b/ranger/config/.pylintrc index cc79f97c..316bf189 100644 --- a/ranger/config/.pylintrc +++ b/ranger/config/.pylintrc @@ -5,4 +5,4 @@ class-rgx=[a-z][a-z0-9_]{1,30}$ [FORMAT] max-line-length = 99 max-module-lines=3000 -disable=duplicate-code,fixme,import-outside-toplevel,locally-disabled,locally-enabled,missing-docstring,no-else-return +disable=duplicate-code,fixme,import-outside-toplevel,locally-disabled,locally-enabled,missing-docstring,no-else-return,super-with-arguments diff --git a/ranger/config/commands.py b/ranger/config/commands.py index b7b02e73..9031e7a2 100755 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -1465,22 +1465,21 @@ class scout(Command): Multiple flags can be combined. For example, ":scout -gpt" would create a :filter-like command using globbing. """ - # pylint: disable=bad-whitespace - AUTO_OPEN = 'a' - OPEN_ON_ENTER = 'e' - FILTER = 'f' - SM_GLOB = 'g' - IGNORE_CASE = 'i' - KEEP_OPEN = 'k' - SM_LETTERSKIP = 'l' - MARK = 'm' - UNMARK = 'M' - PERM_FILTER = 'p' - SM_REGEX = 'r' - SMART_CASE = 's' - AS_YOU_TYPE = 't' - INVERT = 'v' - # pylint: enable=bad-whitespace + + AUTO_OPEN = "a" + OPEN_ON_ENTER = "e" + FILTER = "f" + SM_GLOB = "g" + IGNORE_CASE = "i" + KEEP_OPEN = "k" + SM_LETTERSKIP = "l" + MARK = "m" + UNMARK = "M" + PERM_FILTER = "p" + SM_REGEX = "r" + SMART_CASE = "s" + AS_YOU_TYPE = "t" + INVERT = "v" def __init__(self, *args, **kwargs): super(scout, self).__init__(*args, **kwargs) diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index e1ed1b73..d7d79f97 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -627,13 +627,13 @@ eval for arg in "rwxXst": cmd("map +u{0} shell -f chmod u+{0} %s".format(arg)) eval for arg in "rwxXst": cmd("map +g{0} shell -f chmod g+{0} %s".format(arg)) eval for arg in "rwxXst": cmd("map +o{0} shell -f chmod o+{0} %s".format(arg)) eval for arg in "rwxXst": cmd("map +a{0} shell -f chmod a+{0} %s".format(arg)) -eval for arg in "rwxXst": cmd("map +{0} shell -f chmod u+{0} %s".format(arg)) +eval for arg in "rwxXst": cmd("map +{0} shell -f chmod +{0} %s".format(arg)) eval for arg in "rwxXst": cmd("map -u{0} shell -f chmod u-{0} %s".format(arg)) eval for arg in "rwxXst": cmd("map -g{0} shell -f chmod g-{0} %s".format(arg)) eval for arg in "rwxXst": cmd("map -o{0} shell -f chmod o-{0} %s".format(arg)) eval for arg in "rwxXst": cmd("map -a{0} shell -f chmod a-{0} %s".format(arg)) -eval for arg in "rwxXst": cmd("map -{0} shell -f chmod u-{0} %s".format(arg)) +eval for arg in "rwxXst": cmd("map -{0} shell -f chmod -{0} %s".format(arg)) # =================================================================== # == Define keys for the console diff --git a/ranger/config/rifle.conf b/ranger/config/rifle.conf index 8e2a7a40..c9834224 100644 --- a/ranger/config/rifle.conf +++ b/ranger/config/rifle.conf @@ -86,15 +86,15 @@ ext x?html?, has w3m, terminal = w3m "$@" #------------------------------------------- # Define the "editor" for text files as first action mime ^text, label editor = ${VISUAL:-$EDITOR} -- "$@" -mime ^text, label pager = "$PAGER" -- "$@" +mime ^text, label pager = $PAGER -- "$@" !mime ^text, label editor, ext xml|json|csv|tex|py|pl|rb|rs|js|sh|php = ${VISUAL:-$EDITOR} -- "$@" -!mime ^text, label pager, ext xml|json|csv|tex|py|pl|rb|rs|js|sh|php = "$PAGER" -- "$@" +!mime ^text, label pager, ext xml|json|csv|tex|py|pl|rb|rs|js|sh|php = $PAGER -- "$@" ext 1 = man "$1" ext s[wmf]c, has zsnes, X = zsnes "$1" ext s[wmf]c, has snes9x-gtk,X = snes9x-gtk "$1" ext nes, has fceux, X = fceux "$1" -ext exe = wine "$1" +ext exe, has wine = wine "$1" name ^[mM]akefile$ = make #-------------------------------------------- @@ -118,17 +118,19 @@ ext midi?, terminal, has wildmidi = wildmidi -- "$@" #-------------------------------------------- # Video/Audio with a GUI #------------------------------------------- -mime ^video|audio, has gmplayer, X, flag f = gmplayer -- "$@" -mime ^video|audio, has smplayer, X, flag f = smplayer "$@" -mime ^video, has mpv, X, flag f = mpv -- "$@" -mime ^video, has mpv, X, flag f = mpv --fs -- "$@" -mime ^video, has mplayer2, X, flag f = mplayer2 -- "$@" -mime ^video, has mplayer2, X, flag f = mplayer2 -fs -- "$@" -mime ^video, has mplayer, X, flag f = mplayer -- "$@" -mime ^video, has mplayer, X, flag f = mplayer -fs -- "$@" -mime ^video|audio, has vlc, X, flag f = vlc -- "$@" -mime ^video|audio, has totem, X, flag f = totem -- "$@" -mime ^video|audio, has totem, X, flag f = totem --fullscreen -- "$@" +mime ^video|^audio, has gmplayer, X, flag f = gmplayer -- "$@" +mime ^video|^audio, has smplayer, X, flag f = smplayer "$@" +mime ^video, has mpv, X, flag f = mpv -- "$@" +mime ^video, has mpv, X, flag f = mpv --fs -- "$@" +mime ^video, has mplayer2, X, flag f = mplayer2 -- "$@" +mime ^video, has mplayer2, X, flag f = mplayer2 -fs -- "$@" +mime ^video, has mplayer, X, flag f = mplayer -- "$@" +mime ^video, has mplayer, X, flag f = mplayer -fs -- "$@" +mime ^video|^audio, has vlc, X, flag f = vlc -- "$@" +mime ^video|^audio, has totem, X, flag f = totem -- "$@" +mime ^video|^audio, has totem, X, flag f = totem --fullscreen -- "$@" +mime ^audio, has audacity, X, flag f = audacity -- "$@" +ext aup, has audacity, X, flag f = audacity -- "$@" #-------------------------------------------- # Video without X @@ -153,7 +155,8 @@ ext pdf, has epdfview, X, flag f = epdfview -- "$@" ext pdf, has qpdfview, X, flag f = qpdfview "$@" ext pdf, has open, X, flag f = open "$@" -ext docx?, has catdoc, terminal = catdoc -- "$@" | "$PAGER" +ext sc, has sc, = sc -- "$@" +ext docx?, has catdoc, terminal = catdoc -- "$@" | $PAGER ext sxc|xlsx?|xlt|xlw|gnm|gnumeric, has gnumeric, X, flag f = gnumeric -- "$@" ext sxc|xlsx?|xlt|xlw|gnm|gnumeric, has kspread, X, flag f = kspread -- "$@" @@ -174,6 +177,8 @@ ext mobi, has ebook-viewer, X, flag f = ebook-viewer -- "$@" ext cbr, has zathura, X, flag f = zathura -- "$@" ext cbz, has zathura, X, flag f = zathura -- "$@" +ext sla, has scribus, X, flag f = scribus -- "$@" + #------------------------------------------- # Images #------------------------------------------- @@ -193,6 +198,8 @@ mime ^image, has geeqie, X, flag f = geeqie -- "$@" mime ^image, has gpicview, X, flag f = gpicview -- "$@" mime ^image, has gwenview, X, flag f = gwenview -- "$@" mime ^image, has gimp, X, flag f = gimp -- "$@" +mime ^image, has krita, X, flag f = krita -- "$@" +ext kra, has krita, X, flag f = krita -- "$@" ext xcf, X, flag f = gimp -- "$@" #------------------------------------------- @@ -200,15 +207,15 @@ ext xcf, X, flag f = gimp -- "$@" #------------------------------------------- # avoid password prompt by providing empty password -ext 7z, has 7z = 7z -p l "$@" | "$PAGER" +ext 7z, has 7z = 7z -p l "$@" | $PAGER # This requires atool -ext ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has atool = atool --list --each -- "$@" | "$PAGER" -ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has atool = atool --list --each -- "$@" | "$PAGER" +ext ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has atool = atool --list --each -- "$@" | $PAGER +ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has atool = atool --list --each -- "$@" | $PAGER ext 7z|ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has atool = atool --extract --each -- "$@" ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has atool = atool --extract --each -- "$@" # Listing and extracting archives without atool: -ext tar|gz|bz2|xz, has tar = tar vvtf "$1" | "$PAGER" +ext tar|gz|bz2|xz, has tar = tar vvtf "$1" | $PAGER ext tar|gz|bz2|xz, has tar = for file in "$@"; do tar vvxf "$file"; done ext bz2, has bzip2 = for file in "$@"; do bzip2 -dk "$file"; done ext zip, has unzip = unzip -l "$1" | less @@ -268,7 +275,7 @@ label open, has open = open -- "$@" # Define the editor for non-text files + pager as last action !mime ^text, !ext xml|json|csv|tex|py|pl|rb|rs|js|sh|php = ask label editor, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|rs|js|sh|php = ${VISUAL:-$EDITOR} -- "$@" -label pager, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|rs|js|sh|php = "$PAGER" -- "$@" +label pager, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|rs|js|sh|php = $PAGER -- "$@" ###################################################################### diff --git a/ranger/container/settings.py b/ranger/container/settings.py index 7549325a..e7d6775d 100644 --- a/ranger/container/settings.py +++ b/ranger/container/settings.py @@ -14,13 +14,11 @@ from ranger.gui.colorscheme import _colorscheme_name_to_class # Use these priority constants to trigger events at specific points in time # during processing of the signals "setopt" and "setopt.<some_setting_name>" -# pylint: disable=bad-whitespace -SIGNAL_PRIORITY_RAW = 2.0 # signal.value will be raw -SIGNAL_PRIORITY_SANITIZE = 1.0 # (Internal) post-processing signal.value -SIGNAL_PRIORITY_BETWEEN = 0.6 # sanitized signal.value, old fm.settings.XYZ -SIGNAL_PRIORITY_SYNC = 0.2 # (Internal) updating fm.settings.XYZ +SIGNAL_PRIORITY_RAW = 2.0 # signal.value will be raw +SIGNAL_PRIORITY_SANITIZE = 1.0 # (Internal) post-processing signal.value +SIGNAL_PRIORITY_BETWEEN = 0.6 # sanitized signal.value, old fm.settings.XYZ +SIGNAL_PRIORITY_SYNC = 0.2 # (Internal) updating fm.settings.XYZ SIGNAL_PRIORITY_AFTER_SYNC = 0.1 # after fm.settings.XYZ was updated -# pylint: enable=bad-whitespace ALLOWED_SETTINGS = { @@ -42,6 +40,7 @@ ALLOWED_SETTINGS = { "display_free_space_in_status_bar": bool, 'display_tags_in_all_columns': bool, 'draw_borders': str, + 'draw_borders_multipane': str, 'draw_progress_bar_in_status_bar': bool, 'flushinput': bool, 'freeze_files': bool, @@ -107,6 +106,8 @@ ALLOWED_VALUES = { 'cd_tab_case': ['sensitive', 'insensitive', 'smart'], 'confirm_on_delete': ['multiple', 'always', 'never'], 'draw_borders': ['none', 'both', 'outline', 'separators'], + 'draw_borders_multipane': [None, 'none', 'both', 'outline', + 'separators', 'active-pane'], 'line_numbers': ['false', 'absolute', 'relative'], 'nested_ranger_warning': ['true', 'false', 'error'], 'one_indexed': [False, True], diff --git a/ranger/core/actions.py b/ranger/core/actions.py index ba31db58..adfbe94d 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -1025,7 +1025,7 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m inode = stat(path).st_ino inode_path = "{0}{1}".format(str(inode), path) if PY3: - inode_path = inode_path.encode('utf-8', 'backslashescape') + inode_path = inode_path.encode('utf-8', 'backslashreplace') return '{0}.jpg'.format(sha512(inode_path).hexdigest()) def get_preview(self, fobj, width, height): diff --git a/ranger/core/tab.py b/ranger/core/tab.py index 1771ffa2..b61a77cc 100644 --- a/ranger/core/tab.py +++ b/ranger/core/tab.py @@ -73,6 +73,8 @@ class Tab(FileManagerAware, SettingsAware): # pylint: disable=too-many-instance self._pointed_obj = self.thisdir.files[self._pointer] except TypeError: pass + except IndexError: + pass pointer = property(_get_pointer, _set_pointer) diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py index f056db3b..b738f458 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -683,7 +683,7 @@ class KittyImageDisplayer(ImageDisplayer, FileManagerAware): self.stdbout.flush() # kitty doesn't seem to reply on deletes, checking like we do in draw() # will slows down scrolling with timeouts from select - self.image_id -= 1 + self.image_id = max(0, self.image_id - 1) self.fm.ui.win.redrawwin() self.fm.ui.win.refresh() diff --git a/ranger/gui/color.py b/ranger/gui/color.py index 8f6439c7..81d8b44b 100644 --- a/ranger/gui/color.py +++ b/ranger/gui/color.py @@ -49,27 +49,27 @@ def get_color(fg, bg): return COLOR_PAIRS[key] -# pylint: disable=invalid-name,bad-whitespace -black = curses.COLOR_BLACK -blue = curses.COLOR_BLUE -cyan = curses.COLOR_CYAN -green = curses.COLOR_GREEN -magenta = curses.COLOR_MAGENTA -red = curses.COLOR_RED -white = curses.COLOR_WHITE -yellow = curses.COLOR_YELLOW -default = -1 - -normal = curses.A_NORMAL -bold = curses.A_BOLD -blink = curses.A_BLINK -reverse = curses.A_REVERSE -underline = curses.A_UNDERLINE -invisible = curses.A_INVIS +# pylint: disable=invalid-name +black = curses.COLOR_BLACK +blue = curses.COLOR_BLUE +cyan = curses.COLOR_CYAN +green = curses.COLOR_GREEN +magenta = curses.COLOR_MAGENTA +red = curses.COLOR_RED +white = curses.COLOR_WHITE +yellow = curses.COLOR_YELLOW +default = -1 + +normal = curses.A_NORMAL +bold = curses.A_BOLD +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 +# pylint: enable=invalid-name curses.setupterm() # Adding BRIGHT to a color achieves what `bold` was used for. diff --git a/ranger/gui/widgets/statusbar.py b/ranger/gui/widgets/statusbar.py index fd44613e..4873c07a 100644 --- a/ranger/gui/widgets/statusbar.py +++ b/ranger/gui/widgets/statusbar.py @@ -42,6 +42,8 @@ class StatusBar(Widget): # pylint: disable=too-many-instance-attributes self.column = column self.settings.signal_bind('setopt.display_size_in_status_bar', self.request_redraw, weak=True) + self.fm.signal_bind('tab.layoutchange', self.request_redraw, weak=True) + self.fm.signal_bind('setop.viewmode', self.request_redraw, weak=True) def request_redraw(self): self.need_redraw = True @@ -52,9 +54,13 @@ class StatusBar(Widget): # pylint: disable=too-many-instance-attributes def clear_message(self): self.msg = None - def draw(self): + def draw(self): # pylint: disable=too-many-branches """Draw the statusbar""" + if self.column != self.fm.ui.browser.main_column: + self.column = self.fm.ui.browser.main_column + self.need_redraw = True + if self.hint and isinstance(self.hint, str): if self.old_hint != self.hint: self.need_redraw = True diff --git a/ranger/gui/widgets/view_multipane.py b/ranger/gui/widgets/view_multipane.py index 9661d31e..cef8d9a8 100644 --- a/ranger/gui/widgets/view_multipane.py +++ b/ranger/gui/widgets/view_multipane.py @@ -3,6 +3,7 @@ from __future__ import (absolute_import, division, print_function) +import curses from ranger.gui.widgets.view_base import ViewBase from ranger.gui.widgets.browsercolumn import BrowserColumn @@ -16,6 +17,17 @@ class ViewMultipane(ViewBase): # pylint: disable=too-many-ancestors self.fm.signal_bind('tab.change', self._tabchange_handler) self.rebuild() + self.old_draw_borders = self._draw_borders_setting() + + def _draw_borders_setting(self): + # If draw_borders_multipane has not been set, it defaults to `None` + # and we fallback to using draw_borders. Important to note: + # `None` is different from the string "none" referring to no borders + if self.settings.draw_borders_multipane is not None: + return self.settings.draw_borders_multipane + else: + return self.settings.draw_borders + def _layoutchange_handler(self): if self.fm.ui.browser == self: self.rebuild() @@ -43,13 +55,101 @@ class ViewMultipane(ViewBase): # pylint: disable=too-many-ancestors self.add_child(column) self.resize(self.y, self.x, self.hei, self.wid) + def draw(self): + if self.need_clear: + self.win.erase() + self.need_redraw = True + self.need_clear = False + + ViewBase.draw(self) + + if self._draw_borders_setting(): + draw_borders = self._draw_borders_setting() + 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: + self._draw_hints() + elif self.draw_info: + self._draw_info(self.draw_info) + + def _draw_border_rectangle(self, left_start, right_end): + win = self.win + 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) + win.vline(1, right_end, curses.ACS_VLINE, self.hei - 2) + # Draw the four corners + 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) + + def _draw_borders(self, border_types): + # Referenced from ranger.gui.widgets.view_miller + win = self.win + self.color('in_browser', 'border') + + left_start = 0 + right_end = self.wid - 1 + + # Draw the outline borders + if 'active-pane' not in border_types: + if 'outline' in border_types: + try: + self._draw_border_rectangle(left_start, right_end) + except curses.error: + pass + + # Draw the column separators + if 'separators' in border_types: + for child in self.columns[:-1]: + x = child.x + child.wid + y = self.hei - 1 + try: + win.vline(1, x, curses.ACS_VLINE, y - 1) + if 'outline' in border_types: + 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) + except curses.error: + pass + else: + bordered_column = self.main_column + left_start = max(bordered_column.x, 0) + right_end = min(left_start + bordered_column.wid, self.wid - 1) + try: + self._draw_border_rectangle(left_start, right_end) + except curses.error: + pass + def resize(self, y, x, hei=None, wid=None): ViewBase.resize(self, y, x, hei, wid) + + border_type = self._draw_borders_setting() + if border_type in ['outline', 'both', 'true', 'active-pane']: + # 'true' for backwards compat., no height pad needed for 'separators' + pad = 1 + else: + pad = 0 column_width = int((wid - len(self.columns) + 1) / len(self.columns)) left = 0 top = 0 for column in self.columns: - column.resize(top, left, hei, max(1, column_width)) + column.resize(top + pad, left, hei - pad * 2, max(1, column_width)) left += column_width + 1 column.need_redraw = True self.need_redraw = True + + def poke(self): + ViewBase.poke(self) + + if self.old_draw_borders != self._draw_borders_setting(): + self.resize(self.y, self.x, self.hei, self.wid) + self.old_draw_borders = self._draw_borders_setting() |