diff options
-rw-r--r-- | ranger/core/linemode.py | 16 | ||||
-rw-r--r-- | ranger/gui/widgets/browsercolumn.py | 6 |
2 files changed, 13 insertions, 9 deletions
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: |