summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lepus.uberspace.de>2014-12-04 00:27:36 +0100
committerhut <hut@lepus.uberspace.de>2014-12-04 00:27:36 +0100
commit2d7dc04212c5e9afa06257dc28f7b45f13dcbebd (patch)
tree992797b5743311e5156b9896a039826d906290a0 /ranger
parent90f9bac4803325270f13e7ab5a53bfe8221809b1 (diff)
downloadranger-2d7dc04212c5e9afa06257dc28f7b45f13dcbebd.tar.gz
config/commands.py: added :paper command
This uses a hacky workaround for command chaining using global varibales
which should be turned into proper OOP code at some point.  I don't have
the time to redesign ranger/gui/widgets/console.py at this point.
Diffstat (limited to 'ranger')
-rw-r--r--ranger/config/commands.py31
1 files changed, 30 insertions, 1 deletions
diff --git a/ranger/config/commands.py b/ranger/config/commands.py
index 39334659..1685898b 100644
--- a/ranger/config/commands.py
+++ b/ranger/config/commands.py
@@ -1284,7 +1284,35 @@ class flat(Command):
 
 # Papermanager commands
 # --------------------------------
-class paper_title(Command):
+class paper(Command):
+    """
+    :paper
+
+    This command opens a series of commands on the console that will ask the
+    user to input metadata about the current file.  This is used by the paper
+    manager module of ranger and can be later displayed in ranger, for example
+    by setting the option "linemode" to "papertitle".
+    """
+    def execute(self):
+        # TODO: This sets a pseudo-global variable containing a stack of
+        # commands that should be opened in the console next.  It's a
+        # work-around for ranger's lack of inherent console command chaining
+        # and will hopefully be implemented properly in the future.
+        paper._paper_console_chain = ["url", "year", "authors", "title"]
+
+        self._process_command_stack()
+
+    def _process_command_stack(self):
+        if paper._paper_console_chain:
+            key = paper._paper_console_chain.pop()
+            self._paper_fill_console(key)
+
+    def _paper_fill_console(self, key):
+        text = "paper_%s %s" % (key, "foo")
+        self.fm.open_console(text, position=len(text))
+
+
+class paper_title(paper):
     """
     :paper_title <title>
 
@@ -1296,6 +1324,7 @@ class paper_title(Command):
         update_dict = dict()
         update_dict[self._key] = self.rest(1)
         self.fm.papermanager.set_paper_info(self.fm.thisfile.path, update_dict)
+        self._process_command_stack()
 
     def tab(self):
         paperinfo = self.fm.papermanager.get_paper_info(self.fm.thisfile.path)