From 6891ddc45b2cac79fdf51546b35167fe9fa0baa0 Mon Sep 17 00:00:00 2001 From: Adrià Farrés <14farresa@gmail.com> Date: Sun, 18 Mar 2018 02:39:27 +0100 Subject: Add delay after opening (quickly_executed) a file This is analogous to 6cae0ed but with files, not directories. --- ranger/config/commands.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ranger/config/commands.py b/ranger/config/commands.py index a3837d8e..97c42d74 100755 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -1393,6 +1393,8 @@ class scout(Command): self.fm.cd(pattern) else: self.fm.move(right=1) + if self.quickly_executed: + self.fm.block_input(0.5) if self.KEEP_OPEN in flags and thisdir != self.fm.thisdir: # reopen the console: -- cgit 1.4.1-2-gfad0 From 703a9a20a640ee53080c9b3c405ae55f652b70e5 Mon Sep 17 00:00:00 2001 From: Chuancong Gao Date: Tue, 27 Mar 2018 14:45:39 -0700 Subject: Update VCS symbols --- ranger/colorschemes/default.py | 2 ++ ranger/gui/widgets/__init__.py | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ranger/colorschemes/default.py b/ranger/colorschemes/default.py index c88cdc7c..350c8359 100644 --- a/ranger/colorschemes/default.py +++ b/ranger/colorschemes/default.py @@ -138,6 +138,8 @@ class Default(ColorScheme): attr &= ~bold if context.vcsconflict: fg = magenta + elif context.vcsuntracked: + fg = cyan elif context.vcschanged: fg = red elif context.vcsunknown: diff --git a/ranger/gui/widgets/__init__.py b/ranger/gui/widgets/__init__.py index 36292103..c8f1262b 100644 --- a/ranger/gui/widgets/__init__.py +++ b/ranger/gui/widgets/__init__.py @@ -12,11 +12,11 @@ class Widget(Displayable): 'conflict': ( 'X', ['vcsconflict']), 'untracked': ( - '+', ['vcschanged']), + '?', ['vcsuntracked']), 'deleted': ( '-', ['vcschanged']), 'changed': ( - '*', ['vcschanged']), + '+', ['vcschanged']), 'staged': ( '*', ['vcsstaged']), 'ignored': ( @@ -26,7 +26,7 @@ class Widget(Displayable): 'none': ( ' ', []), 'unknown': ( - '?', ['vcsunknown']), + '!', ['vcsunknown']), } vcsremotestatus_symb = { @@ -41,7 +41,7 @@ class Widget(Displayable): 'none': ( '⌂', ['vcsnone']), 'unknown': ( - '?', ['vcsunknown']), + '!', ['vcsunknown']), } ellipsis = {False: '~', True: '…'} -- cgit 1.4.1-2-gfad0 From ae7668078374a6ef30d3a45b29746d7315223761 Mon Sep 17 00:00:00 2001 From: toonn Date: Thu, 19 Apr 2018 09:04:04 +0200 Subject: Save all the tabs, including the active tab. Remove the check preventing the active tab from being saved. Fixes #883 --- ranger/core/fm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ranger/core/fm.py b/ranger/core/fm.py index c55a3922..d85dd48c 100644 --- a/ranger/core/fm.py +++ b/ranger/core/fm.py @@ -424,5 +424,5 @@ class FM(Actions, # pylint: disable=too-many-instance-attributes if not ranger.args.clean and self.settings.save_tabs_on_exit and len(self.tabs) > 1: with open(self.datapath('tabs'), 'a') as fobj: # Don't save active tab since launching ranger changes the active tab - fobj.write('\0'.join(v.path for t, v in self.tabs.items() - if t != self.current_tab) + '\0\0') + fobj.write('\0'.join(v.path for t, v in self.tabs.items()) + + '\0\0') -- cgit 1.4.1-2-gfad0 From ec825cb15005673b9f9092547dbc42bc35ae60bf Mon Sep 17 00:00:00 2001 From: toonn Date: Thu, 19 Apr 2018 12:51:58 +0200 Subject: Lift the limit on tabs for :tab_new --- ranger/core/actions.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 6bbb35aa..a3aad746 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -1186,10 +1186,10 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m def tab_new(self, path=None, narg=None): if narg: return self.tab_open(narg, path) - for i in range(1, 10): - if i not in self.tabs: - return self.tab_open(i, path) - return None + i = 1 + while i in self.tabs: + i += 1 + return self.tab_open(i, path) 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 a11c723d0ebc4152d0878a79df25c2282e70c6c5 Mon Sep 17 00:00:00 2001 From: toonn Date: Thu, 19 Apr 2018 12:52:47 +0200 Subject: Remove the implicit assumption tabs are numbers. Only get_tab_list() implicitly assumed that tab keys are numbers, or at least homogeneous. This assumption has now been removed by using a simple ordering class that orders numbers as expected but anything else lexically. --- ranger/core/actions.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ranger/core/actions.py b/ranger/core/actions.py index a3aad746..3e488159 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -1237,7 +1237,18 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m def get_tab_list(self): assert self.tabs, "There must be at least 1 tab at all times" - return sorted(self.tabs) + + class NaturalOrder(object): # pylint: disable=too-few-public-methods + def __init__(self, obj): + self.obj = obj + + def __lt__(self, other): + try: + return self.obj < other.obj + except TypeError: + return str(self.obj) < str(other.obj) + + return sorted(self.tabs, key=NaturalOrder) # -------------------------- # -- Overview of internals -- cgit 1.4.1-2-gfad0 From b1d93d5cfc8338a429d7af0b685199c0b0315854 Mon Sep 17 00:00:00 2001 From: toonn Date: Sat, 21 Apr 2018 19:17:46 +0200 Subject: MISSION CRITICAL update to adhere to pep8 Pep8 was changed to recommend breaking lines *before* rather than after binary operators. This patch makes everything right with the universe. Fixes #1145 --- ranger/container/directory.py | 5 +++-- ranger/core/main.py | 4 ++-- ranger/ext/direction.py | 4 ++-- ranger/ext/img_display.py | 16 ++++++++-------- ranger/gui/widgets/browsercolumn.py | 4 ++-- ranger/gui/widgets/view_base.py | 4 ++-- 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/ranger/container/directory.py b/ranger/container/directory.py index 18b1687c..e281e6c9 100644 --- a/ranger/container/directory.py +++ b/ranger/container/directory.py @@ -338,8 +338,9 @@ class Directory( # pylint: disable=too-many-instance-attributes,too-many-public dirlist = [ os.path.join("/", dirpath, d) for d in dirnames - if self.flat == -1 or - (dirpath.count(os.path.sep) - mypath.count(os.path.sep)) <= self.flat + if self.flat == -1 + or (dirpath.count(os.path.sep) + - mypath.count(os.path.sep)) <= self.flat ] filelist += dirlist filelist += [os.path.join("/", dirpath, f) for f in filenames] diff --git a/ranger/core/main.py b/ranger/core/main.py index 4adea918..9a7a554d 100644 --- a/ranger/core/main.py +++ b/ranger/core/main.py @@ -397,8 +397,8 @@ def load_settings( # pylint: disable=too-many-locals,too-many-branches,too-many default_conf = fm.relpath('config', 'rc.conf') custom_conf_is_readable = os.access(custom_conf, os.R_OK) - if (os.environ.get('RANGER_LOAD_DEFAULT_RC', 'TRUE').upper() != 'FALSE' or - not custom_conf_is_readable): + if (os.environ.get('RANGER_LOAD_DEFAULT_RC', 'TRUE').upper() != 'FALSE' + or not custom_conf_is_readable): fm.source(default_conf) if custom_conf_is_readable: fm.source(custom_conf) diff --git a/ranger/ext/direction.py b/ranger/ext/direction.py index 7df45556..33ebb604 100644 --- a/ranger/ext/direction.py +++ b/ranger/ext/direction.py @@ -97,8 +97,8 @@ class Direction(dict): return self.get('cycle') in (True, 'true', 'on', 'yes') def one_indexed(self): - return ('one_indexed' in self and - self.get('one_indexed') in (True, 'true', 'on', 'yes')) + return ('one_indexed' in self + and self.get('one_indexed') in (True, 'true', 'on', 'yes')) def multiply(self, n): for key in ('up', 'right', 'down', 'left'): diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py index 67941e27..78d71cb2 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -434,20 +434,20 @@ class URXVTImageDisplayer(ImageDisplayer, FileManagerAware): pct_width, pct_height = self._get_sizes() sys.stdout.write( - self.display_protocol + - path + - ";{pct_width}x{pct_height}+{pct_x}+{pct_y}:op=keep-aspect".format( + self.display_protocol + + path + + ";{pct_width}x{pct_height}+{pct_x}+{pct_y}:op=keep-aspect".format( pct_width=pct_width, pct_height=pct_height, pct_x=pct_x, pct_y=pct_y - ) + - self.close_protocol + ) + + self.close_protocol ) sys.stdout.flush() def clear(self, start_x, start_y, width, height): sys.stdout.write( - self.display_protocol + - ";100x100+1000+1000" + - self.close_protocol + self.display_protocol + + ";100x100+1000+1000" + + self.close_protocol ) sys.stdout.flush() diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py index b3272cbc..cf322409 100644 --- a/ranger/gui/widgets/browsercolumn.py +++ b/ranger/gui/widgets/browsercolumn.py @@ -318,8 +318,8 @@ class BrowserColumn(Pager): # pylint: disable=too-many-instance-attributes text = current_linemode.filetitle(drawn, metadata) - if drawn.marked and (self.main_column or - self.settings.display_tags_in_all_columns): + if drawn.marked and (self.main_column + or self.settings.display_tags_in_all_columns): text = " " + text # Computing predisplay data. predisplay contains a list of lists diff --git a/ranger/gui/widgets/view_base.py b/ranger/gui/widgets/view_base.py index 80061004..4493443e 100644 --- a/ranger/gui/widgets/view_base.py +++ b/ranger/gui/widgets/view_base.py @@ -72,8 +72,8 @@ class ViewBase(Widget, DisplayableContainer): # pylint: disable=too-many-instan sorted_bookmarks = sorted( ( item for item in self.fm.bookmarks - if self.fm.settings.show_hidden_bookmarks or - '/.' not in item[1].path + if self.fm.settings.show_hidden_bookmarks + or '/.' not in item[1].path ), key=lambda t: t[0].lower(), ) -- cgit 1.4.1-2-gfad0 From 0370e98e0df4286b8c87a2b4c0d0c35f83dad3e8 Mon Sep 17 00:00:00 2001 From: toonn Date: Mon, 14 May 2018 11:27:26 +0200 Subject: Add ignore for `W503` to `.flake8` to follow new pep8 --- .flake8 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.flake8 b/.flake8 index f5072c08..b77e4e6c 100644 --- a/.flake8 +++ b/.flake8 @@ -1,3 +1,3 @@ [flake8] max-line-length = 99 -ignore = E221 +ignore = E221,W503 -- cgit 1.4.1-2-gfad0 From 5fcaeafa4001584211c83c5a28dc3b4bd15bdb1f Mon Sep 17 00:00:00 2001 From: Rodrigo Stuchi Date: Mon, 14 May 2018 23:03:44 -0300 Subject: Yank name without extension yw map to yank a filename without extension closes #1162 removed unnecessary semicolon --- ranger/config/commands.py | 8 +++++++- ranger/config/rc.conf | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ranger/config/commands.py b/ranger/config/commands.py index 8d444dd6..63331c8c 100755 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -1725,6 +1725,7 @@ class yank(Command): modes = { '': 'basename', + 'name_no_ext': 'splitext', 'name': 'basename', 'dir': 'dirname', 'path': 'path', @@ -1757,7 +1758,12 @@ class yank(Command): clipboard_commands = clipboards() - selection = self.get_selection_attr(self.modes[self.arg(1)]) + mode = self.modes[self.arg(1)] + if mode == "splitext": + selection = [os.path.splitext(self.get_selection_attr('basename')[0])[0]] + else: + selection = self.get_selection_attr(mode) + new_clipboard_contents = "\n".join(selection) for command in clipboard_commands: process = subprocess.Popen(command, universal_newlines=True, diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index 342c22d9..f80f699b 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -413,6 +413,7 @@ map dU shell -p du --max-depth=1 -h --apparent-size | sort -rh map yp yank path map yd yank dir map yn yank name +map yw yank name_no_ext # Filesystem Operations map = chmod -- cgit 1.4.1-2-gfad0 From 81bd1f8a2cf8f072227162922a64a0b6c6b2d932 Mon Sep 17 00:00:00 2001 From: hut Date: Tue, 15 May 2018 22:56:13 +0200 Subject: rc.conf: rename `yank name_no_ext` command to `yank name_without_extension` --- ranger/config/commands.py | 2 +- ranger/config/rc.conf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ranger/config/commands.py b/ranger/config/commands.py index 63331c8c..dc987051 100755 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -1725,7 +1725,7 @@ class yank(Command): modes = { '': 'basename', - 'name_no_ext': 'splitext', + 'name_without_extension': 'splitext', 'name': 'basename', 'dir': 'dirname', 'path': 'path', diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index f80f699b..3725c400 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -413,7 +413,7 @@ map dU shell -p du --max-depth=1 -h --apparent-size | sort -rh map yp yank path map yd yank dir map yn yank name -map yw yank name_no_ext +map yw yank name_without_extension # Filesystem Operations map = chmod -- cgit 1.4.1-2-gfad0 From 8a8ad05bb64e595fe8ac0196e850445ea704f269 Mon Sep 17 00:00:00 2001 From: Rodrigo Stuchi Date: Tue, 15 May 2018 18:53:57 -0300 Subject: Fixed yank name without extension in multiple files changed map `yw` to `y.` ref.: #1174 --- ranger/config/commands.py | 3 ++- ranger/config/rc.conf | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ranger/config/commands.py b/ranger/config/commands.py index a2492369..bf03069f 100755 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -1762,7 +1762,8 @@ class yank(Command): mode = self.modes[self.arg(1)] if mode == "splitext": - selection = [os.path.splitext(self.get_selection_attr('basename')[0])[0]] + selection = [os.path.splitext(item)[0] for item in + self.get_selection_attr('basename')] else: selection = self.get_selection_attr(mode) diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index 3725c400..6b0802bb 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -413,7 +413,7 @@ map dU shell -p du --max-depth=1 -h --apparent-size | sort -rh map yp yank path map yd yank dir map yn yank name -map yw yank name_without_extension +map y. yank name_without_extension # Filesystem Operations map = chmod -- cgit 1.4.1-2-gfad0 From 6eae1e1480df9d66e7d851b332ce636a7d95af11 Mon Sep 17 00:00:00 2001 From: Chuancong Gao Date: Tue, 15 May 2018 15:06:15 -0700 Subject: Fix bug for "Improve VCS symbols" #1123 --- ranger/gui/context.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ranger/gui/context.py b/ranger/gui/context.py index d8d1957c..96849686 100644 --- a/ranger/gui/context.py +++ b/ranger/gui/context.py @@ -23,7 +23,7 @@ CONTEXT_KEYS = [ 'keybuffer', 'infostring', 'vcsfile', 'vcsremote', 'vcsinfo', 'vcscommit', 'vcsdate', - 'vcsconflict', 'vcschanged', 'vcsunknown', 'vcsignored', + 'vcsconflict', 'vcschanged', 'vcsunknown', 'vcsignored', 'vcsuntracked', 'vcsstaged', 'vcssync', 'vcsnone', 'vcsbehind', 'vcsahead', 'vcsdiverged' ] -- cgit 1.4.1-2-gfad0 From 591c7ce7c2d406e9e7de506c9ee49f8b6468539e Mon Sep 17 00:00:00 2001 From: Rodrigo Stuchi Date: Tue, 15 May 2018 21:51:20 -0300 Subject: remove unnecessary if statement, uses lazy_property --- ranger/config/commands.py | 8 ++------ ranger/container/fsobject.py | 6 +++++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ranger/config/commands.py b/ranger/config/commands.py index bf03069f..7f5fc764 100755 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -1727,7 +1727,7 @@ class yank(Command): modes = { '': 'basename', - 'name_without_extension': 'splitext', + 'name_without_extension': 'basename_without_extension', 'name': 'basename', 'dir': 'dirname', 'path': 'path', @@ -1761,11 +1761,7 @@ class yank(Command): clipboard_commands = clipboards() mode = self.modes[self.arg(1)] - if mode == "splitext": - selection = [os.path.splitext(item)[0] for item in - self.get_selection_attr('basename')] - else: - selection = self.get_selection_attr(mode) + selection = self.get_selection_attr(mode) new_clipboard_contents = "\n".join(selection) for command in clipboard_commands: diff --git a/ranger/container/fsobject.py b/ranger/container/fsobject.py index 0c9f70f6..37151ecf 100644 --- a/ranger/container/fsobject.py +++ b/ranger/container/fsobject.py @@ -6,7 +6,7 @@ from __future__ import (absolute_import, division, print_function) import re from grp import getgrgid from os import lstat, stat -from os.path import abspath, basename, dirname, realpath, relpath +from os.path import abspath, basename, dirname, realpath, relpath, splitext from pwd import getpwuid from time import time @@ -170,6 +170,10 @@ class FileSystemObject( # pylint: disable=too-many-instance-attributes,too-many basename_list += [(string, 0)] return basename_list + @lazy_property + def basename_without_extension(self): + return splitext(self.basename)[0] + @lazy_property def safe_basename(self): return self.basename.translate(_SAFE_STRING_TABLE) -- cgit 1.4.1-2-gfad0 From 11549e2c0c73a8a0bb543801af4e134b3e076095 Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 16 May 2018 11:57:15 +0200 Subject: Revert "ranger can select files" Due to this commit, pressing `` on a file does nothing. Normally it should open the file. Until this is fixed, I'll remove this commit to restore this basic functionality. Unfortunately, the revert makes ranger crash when run like `ranger `, but this is a much less frequent use case, so the revert is still warranted. This reverts commit 2288a40b45ccdc57d287648c96c5bbe378b95a6d. --- ranger/core/tab.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ranger/core/tab.py b/ranger/core/tab.py index 7bb45d75..1d5e69d4 100644 --- a/ranger/core/tab.py +++ b/ranger/core/tab.py @@ -4,7 +4,7 @@ from __future__ import (absolute_import, division, print_function) import os -from os.path import abspath, normpath, join, expanduser, isdir, dirname +from os.path import abspath, normpath, join, expanduser, isdir import sys from ranger.container import settings @@ -123,11 +123,9 @@ class Tab(FileManagerAware, SettingsAware): # pylint: disable=too-many-instance # get the absolute path path = normpath(join(self.path, expanduser(path))) - selectfile = None if not isdir(path): - selectfile = path - path = dirname(path) + return False new_thisdir = self.fm.get_directory(path) try: @@ -157,8 +155,6 @@ class Tab(FileManagerAware, SettingsAware): # pylint: disable=too-many-instance self.thisdir.sort_directories_first = self.fm.settings.sort_directories_first self.thisdir.sort_reverse = self.fm.settings.sort_reverse self.thisdir.sort_if_outdated() - if selectfile: - self.thisdir.move_to_obj(selectfile) if previous and previous.path != path: self.thisfile = self.thisdir.pointed_obj else: -- cgit 1.4.1-2-gfad0