diff options
-rw-r--r-- | ranger/api/__init__.py | 8 | ||||
-rw-r--r-- | ranger/config/commands.py | 2 | ||||
-rw-r--r-- | ranger/config/rc.conf | 4 | ||||
-rw-r--r-- | ranger/core/linemode.py | 16 | ||||
-rw-r--r-- | ranger/gui/widgets/browsercolumn.py | 6 |
5 files changed, 21 insertions, 15 deletions
diff --git a/ranger/api/__init__.py b/ranger/api/__init__.py index cc0815c2..572cf1a4 100644 --- a/ranger/api/__init__.py +++ b/ranger/api/__init__.py @@ -29,8 +29,8 @@ def hook_ready(fm): from ranger.core.linemode import LinemodeBase -def register_linemode(*linemodes): - """Register the linemodes in a dictionary of the available linemodes.""" +def register_linemode(linemode_class): + """Add a custom linemode class. See ranger.core.linemode""" from ranger.container.fsobject import FileSystemObject - for linemode in linemodes: - FileSystemObject.linemode_dict[linemode.name] = linemode() + FileSystemObject.linemode_dict[linemode_class.name] = linemode_class() + return linemode_class diff --git a/ranger/config/commands.py b/ranger/config/commands.py index 9bb203b9..b47cb6ad 100644 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -1439,7 +1439,7 @@ class linemode(default_linemode): mode = DEFAULT_LINEMODE if mode not in self.fm.thisfile.linemode_dict: - self.notify("Unhandled linemode: `%s'" % mode, bad=True) + self.fm.notify("Unhandled linemode: `%s'" % mode, bad=True) return self.fm.thisdir._set_linemode_of_children(mode) diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index c6622845..21c685d5 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -273,7 +273,7 @@ map <END> move to=-1 map <PAGEDOWN> move down=1 pages=True map <PAGEUP> move up=1 pages=True map <CR> move right=1 -map <DELETE> console delete +#map <DELETE> console delete map <INSERT> console touch # VIM-like @@ -337,6 +337,8 @@ map pL paste_symlink relative=True map phl paste_hardlink map pht paste_hardlinked_subtree +map dD console delete + map dd cut map ud uncut map da cut mode=add diff --git a/ranger/core/linemode.py b/ranger/core/linemode.py index c394bc15..166829cf 100644 --- a/ranger/core/linemode.py +++ b/ranger/core/linemode.py @@ -29,9 +29,17 @@ class LinemodeBase(object): """The left-aligned part of the line.""" raise NotImplementedError - @abstractmethod def infostring(self, file, metadata): - """The right-aligned part of the line.""" + """The right-aligned part of the line. + + If `NotImplementedError' is raised (e.g. this method is just + not implemented in the actual linemode), the caller should + provide its own implementation, which in this case means + displaying the hardlink count of the directories. Useful + because only the caller (BrowserColumn) possesses the data + necessary to display that information. + + """ raise NotImplementedError @@ -41,10 +49,6 @@ class DefaultLinemode(LinemodeBase): def filetitle(self, file, metadata): return file.relative_path - def infostring(self, file, metadata): - # Should never be called for this linemode, implemented in BrowserColumn - raise NotImplementedError - class TitleLinemode(LinemodeBase): name = "metatitle" diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py index 2e9bf7a2..0340b565 100644 --- a/ranger/gui/widgets/browsercolumn.py +++ b/ranger/gui/widgets/browsercolumn.py @@ -301,13 +301,13 @@ class BrowserColumn(Pager): # info string infostring = [] infostringlen = 0 - if current_linemode.name == "filename": - infostring = self._draw_infostring_display(drawn, space) - else: + try: infostringdata = current_linemode.infostring(drawn, metadata) if infostringdata: infostring.append([" " + infostringdata + " ", ["infostring"]]) + except NotImplementedError: + infostring = self._draw_infostring_display(drawn, space) if infostring: infostringlen = self._total_len(infostring) if space - infostringlen > 2: |