diff options
author | Wojciech Siewierski <wojciech.siewierski@onet.pl> | 2015-03-10 00:05:17 +0100 |
---|---|---|
committer | hut <hut@lepus.uberspace.de> | 2015-03-10 00:22:11 +0100 |
commit | a8d2b74b0ec86cfbf4ec872fb12a4768e65f7e67 (patch) | |
tree | 63d4edf5e0c09bb1b2f4daaa491ca9a45012c0dd /ranger | |
parent | f08fc58366502baf8cb6534c0e9b58cddec982f8 (diff) | |
download | ranger-a8d2b74b0ec86cfbf4ec872fb12a4768e65f7e67.tar.gz |
config.commands: :linemode and :default_linemode tab completion
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/config/commands.py | 31 | ||||
-rw-r--r-- | ranger/core/actions.py | 46 |
2 files changed, 31 insertions, 46 deletions
diff --git a/ranger/config/commands.py b/ranger/config/commands.py index a92dfa80..9bb203b9 100644 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -423,6 +423,11 @@ class default_linemode(Command): for col in self.fm.ui.browser.columns: col.need_redraw = True + def tab(self): + mode = self.arg(1) + return (self.arg(0) + " " + linemode + for linemode in self.fm.thisfile.linemode_dict.keys()) + class quit(Command): """:quit @@ -1416,3 +1421,29 @@ class meta(prompt_metadata): metadata = self.fm.metadata.get_metadata(self.fm.thisfile.path) if key in metadata and metadata[key]: return self.arg(0) + " " + metadata[key] + +class linemode(default_linemode): + """ + :linemode <mode> + + Change what is displayed as a filename. + + - "mode" may be any of the defined linemodes (see: ranger.core.linemode). + "normal" is mapped to "filename". + """ + + def execute(self): + mode = self.arg(1) + + if mode == "normal": + mode = DEFAULT_LINEMODE + + if mode not in self.fm.thisfile.linemode_dict: + self.notify("Unhandled linemode: `%s'" % mode, bad=True) + return + + self.fm.thisdir._set_linemode_of_children(mode) + + # Ask the browsercolumns to redraw + for col in self.fm.ui.browser.columns: + col.need_redraw = True diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 33903859..9c620f20 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -154,52 +154,6 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware): """Redraw the window""" self.ui.redraw_window() - def linemode(self, mode, directory=None, depth=0): - """ - Change what is displayed as a filename. - - - "mode" may be: "filename", "permissions", "metatitle", the mode - "normal" is mapped to "filename". - - "directory" specifies the directory. None means the current directory - - "depth" specifies the recursion depth - """ - - if mode == "normal": - mode = DEFAULT_LINEMODE - - if mode not in self.thisfile.linemode_dict: - self.notify("Unhandled linemode: `%s'" % mode, bad=True) - return - - if directory is None: - directory = self.fm.thisdir - - directories = set([directory]) - bucket = set() - - current_depth = 0 - - while True: - if current_depth >= depth: - for direct in directories: - direct._set_linemode_of_children(mode) - break - - else: - for direct in directories: - direct._set_linemode_of_children(mode) - for file_ in direct.files: - if file_.is_directory: - bucket.add(file_) - - directories, bucket = bucket, directories - bucket.clear() - current_depth += 1 - - # Ask the browsercolumns to redraw - for col in self.ui.browser.columns: - col.need_redraw = True - def open_console(self, string='', prompt=None, position=None): """Open the console""" self.change_mode('normal') |