diff options
author | hut <hut@lepus.uberspace.de> | 2016-02-29 20:08:29 +0100 |
---|---|---|
committer | hut <hut@lepus.uberspace.de> | 2016-02-29 20:08:29 +0100 |
commit | 9c585e48e14525f11d2405ea0bb9b5eba92e63e9 (patch) | |
tree | f0ce49821383fa9b4116d4ecf0f36ff26a49fd4d | |
parent | 2de7ea308fb88f34a181de34c35c1f18fbd5c7aa (diff) | |
parent | d599ab1580d307e4a83f6a55eb4cba70a63e1a2f (diff) | |
download | ranger-9c585e48e14525f11d2405ea0bb9b5eba92e63e9.tar.gz |
Merge branch 'master' of https://github.com/nfnty/ranger
-rwxr-xr-x | ranger/config/commands.py | 4 | ||||
-rw-r--r-- | ranger/container/directory.py | 2 | ||||
-rw-r--r-- | ranger/ext/vcs/vcs.py | 20 | ||||
-rw-r--r-- | ranger/gui/ui.py | 7 |
4 files changed, 28 insertions, 5 deletions
diff --git a/ranger/config/commands.py b/ranger/config/commands.py index 3e7af7b5..c41bfcb6 100755 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -1360,7 +1360,7 @@ class stage(Command): self.fm.thisdir.vcs.action_add(filelist) except VcsError as error: self.fm.notify('Unable to stage files: {0:s}'.format(str(error))) - self.fm.ui.vcsthread.wakeup(self.fm.thisdir) + self.fm.ui.vcsthread.process(self.fm.thisdir) else: self.fm.notify('Unable to stage files: Not in repository') @@ -1379,7 +1379,7 @@ class unstage(Command): self.fm.thisdir.vcs.action_reset(filelist) except VcsError as error: self.fm.notify('Unable to unstage files: {0:s}'.format(str(error))) - self.fm.ui.vcsthread.wakeup(self.fm.thisdir) + self.fm.ui.vcsthread.process(self.fm.thisdir) else: self.fm.notify('Unable to unstage files: Not in repository') diff --git a/ranger/container/directory.py b/ranger/container/directory.py index 8ace0d85..e7c2b4b6 100644 --- a/ranger/container/directory.py +++ b/ranger/container/directory.py @@ -386,7 +386,7 @@ class Directory(FileSystemObject, Accumulator, Loadable): self.loading = False self.fm.signal_emit("finished_loading_dir", directory=self) if self.vcs: - self.fm.ui.vcsthread.wakeup(self) + self.fm.ui.vcsthread.process(self) def unload(self): self.loading = False diff --git a/ranger/ext/vcs/vcs.py b/ranger/ext/vcs/vcs.py index fd34c3fe..487c9405 100644 --- a/ranger/ext/vcs/vcs.py +++ b/ranger/ext/vcs/vcs.py @@ -370,6 +370,9 @@ class VcsThread(threading.Thread): # pylint: disable=too-many-instance-attribut self.daemon = True self.ui = ui # pylint: disable=invalid-name self.queue = queue.Queue() + self.advance = threading.Event() + self.advance.set() + self.paused = threading.Event() self.awoken = threading.Event() self.timestamp = time.time() self.redraw = False @@ -442,7 +445,12 @@ class VcsThread(threading.Thread): # pylint: disable=too-many-instance-attribut def run(self): while True: + self.paused.set() + self.advance.wait() self.awoken.wait() + if not self.advance.isSet(): + continue + self.paused.clear() self.awoken.clear() self._queue_process() @@ -455,8 +463,16 @@ class VcsThread(threading.Thread): # pylint: disable=too-many-instance-attribut self.ui.status.need_redraw = True self.ui.redraw() - def wakeup(self, dirobj): - """Wakeup thread""" + def pause(self): + """Pause thread""" + self.advance.clear() + + def unpause(self): + """Unpause thread""" + self.advance.set() + + def process(self, dirobj): + """Process dirobj""" self.queue.put(dirobj) self.awoken.set() diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py index 41b57c2c..ad95d754 100644 --- a/ranger/gui/ui.py +++ b/ranger/gui/ui.py @@ -94,8 +94,15 @@ class UI(DisplayableContainer): sys.stdout.write("\033kranger\033\\") sys.stdout.flush() + if 'vcsthread' in self.__dict__: + self.vcsthread.unpause() + def suspend(self): """Turn off curses""" + if 'vcsthread' in self.__dict__: + self.vcsthread.pause() + self.vcsthread.paused.wait() + self.win.keypad(0) curses.nocbreak() curses.echo() |