Skip to content

Commit

Permalink
ext.papermanager: redraw after using :paper* commands
Browse files Browse the repository at this point in the history
  • Loading branch information
hut committed Dec 3, 2014
1 parent 987d618 commit b132301
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
3 changes: 3 additions & 0 deletions ranger/config/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,9 @@ def _process_command_stack(self):
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)
Expand Down
7 changes: 7 additions & 0 deletions ranger/ext/papermanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def set_paper_info(self, filename, update_dict):
if name in valid:
return self._set_pager_info_raw(filename, update_dict,
metafile)
self.metadata_cache[filename] = result
finally:
if csvfile:
csvfile.close()
Expand All @@ -89,6 +90,8 @@ def set_paper_info(self, filename, update_dict):

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:
Expand All @@ -107,13 +110,17 @@ def _set_pager_info_raw(self, filename, update_dict, metafile):
# 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)

# If the row was never found, create a new one.
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):
Expand Down
22 changes: 12 additions & 10 deletions ranger/gui/widgets/browsercolumn.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,18 @@ def _draw_directory(self):
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])
Expand All @@ -260,17 +268,11 @@ def _draw_directory(self):


# 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":
Expand Down

0 comments on commit b132301

Please sign in to comment.