From b5393406cbe86bce437a32787181fb0515dd0d21 Mon Sep 17 00:00:00 2001 From: hut Date: Thu, 31 Dec 2009 20:18:04 +0100 Subject: removed ProcessManager to TaskView --- ranger/colorschemes/default.py | 2 +- ranger/defaults/keys.py | 14 ++--- ranger/gui/colorscheme.py | 2 +- ranger/gui/defaultui.py | 22 +++---- ranger/gui/widgets/process_manager.py | 107 ---------------------------------- ranger/gui/widgets/taskview.py | 88 ++++++++++++++++++++++++++++ 6 files changed, 108 insertions(+), 127 deletions(-) delete mode 100644 ranger/gui/widgets/process_manager.py create mode 100644 ranger/gui/widgets/taskview.py diff --git a/ranger/colorschemes/default.py b/ranger/colorschemes/default.py index 367445cb..c92e1635 100644 --- a/ranger/colorschemes/default.py +++ b/ranger/colorschemes/default.py @@ -90,7 +90,7 @@ class Default(ColorScheme): if context.highlight: attr |= reverse - if context.in_pman: + if context.in_taskview: if context.title: fg = blue diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py index 652e7c42..7d1db7d2 100644 --- a/ranger/defaults/keys.py +++ b/ranger/defaults/keys.py @@ -169,7 +169,7 @@ def initialize_commands(command_list): bind('h', KEY_LEFT, KEY_BACKSPACE, DEL, lambda arg: \ arg.fm.move_left(arg.n or 1)) - bind('w', lambda arg: arg.fm.ui.open_pman()) + bind('w', lambda arg: arg.fm.ui.open_taskview()) command_list.rebuild_paths() @@ -210,8 +210,8 @@ def initialize_console_commands(command_list): command_list.rebuild_paths() -def initialize_process_manager_commands(command_list): - """Initialize the commands for the process manager widget""" +def initialize_taskview_commands(command_list): + """Initialize the commands for the TaskView widget""" system_functions(command_list) bind, hint = make_abbreviations(command_list) @@ -220,12 +220,12 @@ def initialize_process_manager_commands(command_list): bind('k', KEY_UP, nwrap.move(relative=-1)) bind('gg', nwrap.move(absolute=0)) bind('G', nwrap.move(absolute=-1)) - bind('K', wdg.process_move(0)) - bind('J', wdg.process_move(-1)) + bind('K', wdg.task_move(0)) + bind('J', wdg.task_move(-1)) - bind('dd', wdg.process_remove()) + bind('dd', wdg.task_remove()) bind('w', ESC, ctrl('d'), ctrl('c'), - lambda arg: arg.fm.ui.close_pman()) + lambda arg: arg.fm.ui.close_taskview()) command_list.rebuild_paths() diff --git a/ranger/gui/colorscheme.py b/ranger/gui/colorscheme.py index bf8194ea..7db72d0a 100644 --- a/ranger/gui/colorscheme.py +++ b/ranger/gui/colorscheme.py @@ -1,6 +1,6 @@ CONTEXT_KEYS = [ 'reset', 'error', 'in_display', 'in_statusbar', 'in_titlebar', 'in_console', - 'in_notify', 'in_pman', + 'in_notify', 'in_taskview', 'directory', 'file', 'hostname', 'executable', 'media', 'link', 'video', 'audio', 'image', 'media', 'document', 'container', diff --git a/ranger/gui/defaultui.py b/ranger/gui/defaultui.py index 3985b1cc..ccbe2578 100644 --- a/ranger/gui/defaultui.py +++ b/ranger/gui/defaultui.py @@ -9,7 +9,7 @@ class DefaultUI(UI): from ranger.gui.widgets.titlebar import TitleBar from ranger.gui.widgets.console import Console from ranger.gui.widgets.statusbar import StatusBar - from ranger.gui.widgets.process_manager import ProcessManager + from ranger.gui.widgets.taskview import TaskView from ranger.gui.widgets.notify import Notify from ranger.gui.widgets.pager import Pager @@ -23,9 +23,9 @@ class DefaultUI(UI): self.main_column = self.browser.main_column # Create the process manager - self.pman = ProcessManager(self.win) - self.pman.visible = False - self.add_child(self.pman) + self.taskview = TaskView(self.win) + self.taskview.visible = False + self.add_child(self.taskview) # Create the (initially hidden) notify bar self.notify = Notify(self.win) @@ -53,7 +53,7 @@ class DefaultUI(UI): notify_hei = min(max(1, y - 4), self.notify.requested_height) self.browser.resize(1, 0, y - 1 - notify_hei, x) - self.pman.resize(1, 0, y - 1 - notify_hei, x) + self.taskview.resize(1, 0, y - 1 - notify_hei, x) self.pager.resize(1, 0, y - 1 - notify_hei, x) self.notify.resize(y - notify_hei, 0, notify_hei, x) self.titlebar.resize(0, 0, 1, x) @@ -101,15 +101,15 @@ class DefaultUI(UI): self.status.visible = True self.close_pager() - def open_pman(self): + def open_taskview(self): self.browser.visible = False - self.pman.visible = True - self.pman.focused = True + self.taskview.visible = True + self.taskview.focused = True - def close_pman(self): - self.pman.visible = False + def close_taskview(self): + self.taskview.visible = False self.browser.visible = True - self.pman.focused = False + self.taskview.focused = False def scroll(self, relative): if self.browser and self.browser.main_column: diff --git a/ranger/gui/widgets/process_manager.py b/ranger/gui/widgets/process_manager.py deleted file mode 100644 index 08f390b5..00000000 --- a/ranger/gui/widgets/process_manager.py +++ /dev/null @@ -1,107 +0,0 @@ -""" -The process manager allows you to modify what the loader is doing. -""" - -import curses - -from . import Widget -from ranger.ext.accumulator import Accumulator -from ranger.container import CommandList -from collections import deque - -class DummyLoadObject(object): - def __init__(self, txt): - self.get_description = lambda: txt - self.load_generator = range(100) - - -class DummyLoader(object): - def __init__(self): - self.queue = deque() - self.queue.append(DummyLoadObject("blub")) - self.queue.append(DummyLoadObject("foo")) - self.queue.append(DummyLoadObject("asfkljflk")) - self.queue.append(DummyLoadObject("g$%GKSERJgsldflj")) - - -class ProcessManager(Widget, Accumulator): - def __init__(self, win): - Widget.__init__(self, win) - Accumulator.__init__(self) - self.scroll_begin = 0 - self.commandlist = CommandList() - self.settings.keys.initialize_process_manager_commands( \ - self.commandlist) - - # ---- dummy loader for testing purposes - self.loader = DummyLoader() - - def draw(self): - base_clr = deque() - base_clr.append('in_pman') - lst = self.get_list() - - if not self.pointer_is_synced(): - self.sync_index() - - if self.hei <= 0: - return - - self.addstr(0, 0, "Process Manager") - self.color_at(0, 0, self.wid, base_clr, 'title') - - if lst: - for i in range(self.hei - 1): - i += self.scroll_begin - try: - obj = lst[i] - except IndexError: - break - - y = i + 1 - clr = deque(base_clr) - - if self.pointer == i: - clr.append('selected') - - descr = obj.get_description() - self.addstr(y, 0, descr, self.wid) - self.color_at(y, 0, self.wid, clr) - - else: - if self.hei > 1: - self.addstr(1, 0, "No processes running") - self.color_at(1, 0, self.wid, base_clr, 'error') - - 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() - if tup: - cmd = self.commandlist[tup] - else: - return - - except KeyError: - self.env.key_clear() - else: - if hasattr(cmd, 'execute'): - cmd.execute_wrap(self) - self.env.key_clear() - - def get_list(self): - return self.fm.loader.queue - return self.loader.queue diff --git a/ranger/gui/widgets/taskview.py b/ranger/gui/widgets/taskview.py new file mode 100644 index 00000000..a7f90dff --- /dev/null +++ b/ranger/gui/widgets/taskview.py @@ -0,0 +1,88 @@ +""" +The TaskView allows you to modify what the loader is doing. +""" + +import curses + +from . import Widget +from ranger.ext.accumulator import Accumulator +from ranger.container import CommandList +from collections import deque + +class TaskView(Widget, Accumulator): + def __init__(self, win): + Widget.__init__(self, win) + Accumulator.__init__(self) + self.scroll_begin = 0 + self.commandlist = CommandList() + self.settings.keys.initialize_taskview_commands(self.commandlist) + + def draw(self): + base_clr = deque() + base_clr.append('in_taskview') + lst = self.get_list() + + if not self.pointer_is_synced(): + self.sync_index() + + if self.hei <= 0: + return + + self.addstr(0, 0, "Task View") + self.color_at(0, 0, self.wid, base_clr, 'title') + + if lst: + for i in range(self.hei - 1): + i += self.scroll_begin + try: + obj = lst[i] + except IndexError: + break + + y = i + 1 + clr = deque(base_clr) + + if self.pointer == i: + clr.append('selected') + + descr = obj.get_description() + self.addstr(y, 0, descr, self.wid) + self.color_at(y, 0, self.wid, clr) + + else: + if self.hei > 1: + self.addstr(1, 0, "No task in the queue.") + self.color_at(1, 0, self.wid, base_clr, 'error') + + self.color_reset() + + def task_remove(self, i=None): + if i is None: + i = self.pointer + + self.fm.loader.remove(index=i) + + def task_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() + if tup: + cmd = self.commandlist[tup] + else: + return + + except KeyError: + self.env.key_clear() + else: + if hasattr(cmd, 'execute'): + cmd.execute_wrap(self) + self.env.key_clear() + + def get_list(self): + return self.fm.loader.queue + return self.loader.queue -- cgit 1.4.1-2-gfad0