diff options
author | hut <hut@lavabit.com> | 2009-12-25 03:33:07 +0100 |
---|---|---|
committer | hut <hut@lavabit.com> | 2009-12-25 03:33:07 +0100 |
commit | 586f0006dd6e9c5a6477bcbf87130638cf5a4154 (patch) | |
tree | 892cd35c2ece2c76a5fddf65d1bcaa5c9626b616 | |
parent | ddf828fb5ce5a539e01d968aee5817ad1c921a01 (diff) | |
download | ranger-586f0006dd6e9c5a6477bcbf87130638cf5a4154.tar.gz |
can now (re)move processes in pman
-rw-r--r-- | ranger/defaults/keys.py | 8 | ||||
-rw-r--r-- | ranger/fm.py | 11 | ||||
-rw-r--r-- | ranger/fsobject/directory.py | 14 | ||||
-rw-r--r-- | ranger/fsobject/loader.py | 31 | ||||
-rw-r--r-- | ranger/gui/widgets/process_manager.py | 12 |
5 files changed, 65 insertions, 11 deletions
diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py index 2a775ab9..fe657fdd 100644 --- a/ranger/defaults/keys.py +++ b/ranger/defaults/keys.py @@ -193,14 +193,20 @@ def initialize_process_manager_commands(command_list): def bind(*args): command_list.bind(args[-1], *args[:-1]) + def do(method, *args, **kw): + return lambda widget, n: getattr(widget, method)(*args, **kw) + def do_fm(method, *args, **kw): - return lambda con: getattr(con.fm, method)(*args, **kw) + return lambda widget, n: getattr(con.fm, method)(*args, **kw) bind('j', KEY_DOWN, wdg.move(relative=1)) bind('k', KEY_UP, wdg.move(relative=-1)) bind('gg', wdg.move(absolute=0)) bind('G', wdg.move(absolute=-1)) + bind('K', lambda wdg, n: wdg.process_move(0)) + bind('J', lambda wdg, n: wdg.process_move(-1)) + bind('dd', do('process_remove')) bind('P', ESC, ctrl('d'), lambda wdg, n: wdg.fm.ui.close_pman()) command_list.rebuild_paths() diff --git a/ranger/fm.py b/ranger/fm.py index ce62e94c..a1b1339a 100644 --- a/ranger/fm.py +++ b/ranger/fm.py @@ -75,11 +75,12 @@ class FM(Actions): key = self.ui.get_next_key() - if self.input_blocked and \ - time() > self.input_blocked_until: - self.input_blocked = False - if not self.input_blocked: - self.ui.handle_key(key) + if key > 0: + if self.input_blocked and \ + time() > self.input_blocked_until: + self.input_blocked = False + if not self.input_blocked: + self.ui.handle_key(key) gc_tick += 1 if gc_tick > TICKS_BEFORE_COLLECTING_GARBAGE: diff --git a/ranger/fsobject/directory.py b/ranger/fsobject/directory.py index 8fb4d0ac..f5aeade4 100644 --- a/ranger/fsobject/directory.py +++ b/ranger/fsobject/directory.py @@ -165,8 +165,10 @@ class Directory(FileSystemObject, SettingsAware): self.content_loaded = True self.loading = False -# yield -# yield + + def unload(self): + self.loading = False + self.load_generator = None def load_content(self, schedule=False): """ @@ -175,7 +177,7 @@ class Directory(FileSystemObject, SettingsAware): """ self.load_once() - + if schedule is None: schedule = self.size > 30 @@ -319,8 +321,9 @@ class Directory(FileSystemObject, SettingsAware): def load_content_once(self, *a, **k): """Load the contents of the directory if not done yet""" - if not self.content_loaded and not self.loading: - self.load_content(*a, **k) + if not self.content_loaded: + if not self.loading: + self.load_content(*a, **k) return True return False @@ -329,6 +332,7 @@ class Directory(FileSystemObject, SettingsAware): Load the contents of the directory if it's outdated or not done yet """ + if self.load_content_once(*a, **k): return True if self.old_show_hidden != self.settings.show_hidden: diff --git a/ranger/fsobject/loader.py b/ranger/fsobject/loader.py index 5923ff95..7b051d53 100644 --- a/ranger/fsobject/loader.py +++ b/ranger/fsobject/loader.py @@ -35,6 +35,37 @@ class Loader(object): while obj in self.queue: self.queue.remove(obj) self.queue.appendleft(obj) + + def move(self, _from, to): + try: + item = self.queue[_from] + except IndexError: + return + + del self.queue[_from] + + if to == 0: + self.queue.appendleft(item) + elif to == -1: + self.queue.append(item) + else: + raise NotImplementedError + + def remove(self, item=None, index=None): + if item is not None and index is None: + for test, i in zip(self.queue, range(len(self.queue))): + if test == item: + index = i + break + else: + return + + if index is not None: + if item is None: + item = self.queue[index] + if hasattr(item, 'unload'): + item.unload() + del self.queue[index] def work(self): """ diff --git a/ranger/gui/widgets/process_manager.py b/ranger/gui/widgets/process_manager.py index ae372112..7a0f8357 100644 --- a/ranger/gui/widgets/process_manager.py +++ b/ranger/gui/widgets/process_manager.py @@ -73,6 +73,18 @@ class ProcessManager(Widget, Accumulator): self.color_reset() + def process_remove(self, i=None): + if i is None: + i = self.pointer + + self.fm.loader.remove(index=i) + + def process_move(self, absolute, i=None): + if i is None: + i = self.pointer + + self.fm.loader.move(_from=i, to=absolute) + def press(self, key): try: tup = self.env.keybuffer.tuple_without_numbers() |