summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lepus.uberspace.de>2014-12-04 00:51:41 +0100
committerhut <hut@lepus.uberspace.de>2014-12-04 00:51:41 +0100
commitb132301bc72351ad0baad92650cfc040112cafee (patch)
treec08c7e92add118a2cdffb7f4a8ad67452479bd08
parent987d618504ead0a099160c14855d8181500f3463 (diff)
downloadranger-b132301bc72351ad0baad92650cfc040112cafee.tar.gz
ext.papermanager: redraw after using :paper* commands
-rw-r--r--ranger/config/commands.py3
-rw-r--r--ranger/ext/papermanager.py7
-rw-r--r--ranger/gui/widgets/browsercolumn.py22
3 files changed, 22 insertions, 10 deletions
diff --git a/ranger/config/commands.py b/ranger/config/commands.py
index 8145aadd..8485c784 100644
--- a/ranger/config/commands.py
+++ b/ranger/config/commands.py
@@ -1306,6 +1306,9 @@ class paper(Command):
         if paper._paper_console_chain:
             key = paper._paper_console_chain.pop()
             self._paper_fill_console(key)
+        else:
+            for col in self.fm.ui.browser.columns:
+                col.need_redraw = True
 
     def _paper_fill_console(self, key):
         paperinfo = self.fm.papermanager.get_paper_info(self.fm.thisfile.path)
diff --git a/ranger/ext/papermanager.py b/ranger/ext/papermanager.py
index 059f051f..366dd6fa 100644
--- a/ranger/ext/papermanager.py
+++ b/ranger/ext/papermanager.py
@@ -78,6 +78,7 @@ class PaperManager(object):
                     if name in valid:
                         return self._set_pager_info_raw(filename, update_dict,
                                 metafile)
+                self.metadata_cache[filename] = result
             finally:
                 if csvfile:
                     csvfile.close()
@@ -89,6 +90,8 @@ class PaperManager(object):
 
     def _set_pager_info_raw(self, filename, update_dict, metafile):
         valid = (filename, basename(filename))
+        paperinfo = OpenStruct(filename=filename, title=None, year=None,
+                authors=None, url=None)
 
         try:
             with open(metafile, "r") as infile:
@@ -107,6 +110,8 @@ class PaperManager(object):
                     # When finding the row that corresponds to the given filename,
                     # update the items with the information from update_dict.
                     self._fill_row_with_ostruct(row, update_dict)
+                    self._fill_ostruct_with_data(paperinfo, row)
+                    self.metadata_cache[filename] = paperinfo
                     found = True
                 writer.writerow(row)
 
@@ -114,6 +119,8 @@ class PaperManager(object):
             if not found:
                 row = [basename(filename), None, None, None, None]
                 self._fill_row_with_ostruct(row, update_dict)
+                self._fill_ostruct_with_data(paperinfo, row)
+                self.metadata_cache[filename] = paperinfo
                 writer.writerow(row)
 
     def _get_metafile_content(self, metafile):
diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py
index 12523648..b2159339 100644
--- a/ranger/gui/widgets/browsercolumn.py
+++ b/ranger/gui/widgets/browsercolumn.py
@@ -248,10 +248,18 @@ class BrowserColumn(Pager):
             else:
                 tagged_marker = " "
 
+            # Extract linemode-related information from the drawn object
+            paperinfo = None
+            use_linemode = drawn._linemode
+            if use_linemode == "papertitle":
+                paperinfo = self.fm.papermanager.get_paper_info(drawn.path)
+                if not paperinfo.title:
+                    use_linemode = "filename"
+
             key = (self.wid, selected_i == i, drawn.marked, self.main_column,
                     drawn.path in copied, tagged_marker, drawn.infostring,
                     drawn.vcsfilestatus, drawn.vcsremotestatus, self.fm.do_cut,
-                    drawn._linemode)
+                    use_linemode)
 
             if key in drawn.display_data:
                 self.execute_curses_batch(line, drawn.display_data[key])
@@ -260,17 +268,11 @@ class BrowserColumn(Pager):
 
 
             # Deal with the line mode
-            paperinfo = None
-            use_linemode = drawn._linemode
             if use_linemode == "papertitle":
-                paperinfo = self.fm.papermanager.get_paper_info(drawn.path)
-                if paperinfo.title:
-                    if paperinfo.year:
-                        text = "%s - %s" % (paperinfo.year, paperinfo.title)
-                    else:
-                        text = paperinfo.title
+                if paperinfo.year:
+                    text = "%s - %s" % (paperinfo.year, paperinfo.title)
                 else:
-                    use_linemode = "filename"
+                    text = paperinfo.title
             if use_linemode == "filename":
                 text = drawn.basename
             elif use_linemode == "permissions":