diff options
author | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2010-12-26 20:51:14 +0000 |
---|---|---|
committer | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2010-12-26 20:51:14 +0000 |
commit | cdb8128d321c16bf526afdbd7d790fc6189239b3 (patch) | |
tree | 731f205c25b6ae1dfe2069216ecd103a2dcee7cf /src/tabs.py | |
parent | 133cda19128b80cf52bcf3c9b16c467d30a56c7c (diff) | |
download | poezio-cdb8128d321c16bf526afdbd7d790fc6189239b3.tar.gz poezio-cdb8128d321c16bf526afdbd7d790fc6189239b3.tar.bz2 poezio-cdb8128d321c16bf526afdbd7d790fc6189239b3.tar.xz poezio-cdb8128d321c16bf526afdbd7d790fc6189239b3.zip |
fixed #1988 Traceback handler
Diffstat (limited to 'src/tabs.py')
-rw-r--r-- | src/tabs.py | 78 |
1 files changed, 58 insertions, 20 deletions
diff --git a/src/tabs.py b/src/tabs.py index c9707996..8016f86e 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -110,19 +110,19 @@ class Tab(object): """ returns the color that should be used in the GlobalInfoBar """ - raise NotImplementedError + return theme.COLOR_TAB_NORMAL def set_color_state(self, color): """ set the color state """ - raise NotImplementedError + pass def get_name(self): """ get the name of the tab """ - raise NotImplementedError + return self.__class__.__name__ def get_text_window(self): """ @@ -1039,14 +1039,51 @@ class MucListTab(Tab): self.core.execute(txt) return self.reset_help_message() + def get_name(self): + return self.name + + def on_input(self, key): + res = self.input.do_command(key) + if res: + return True + if key in self.key_func: + return self.key_func[key]() + + def on_lose_focus(self): + self._color_state = theme.COLOR_TAB_NORMAL + + def on_gain_focus(self): + self._color_state = theme.COLOR_TAB_CURRENT + curses.curs_set(0) + def get_color_state(self): - return theme.COLOR_TAB_NORMAL + return self._color_state - def set_color_state(self, color): - pass +class SimpleTextTab(Tab): + """ + A very simple tab, with just a text displaying some + information or whatever. + For example used to display tracebacks + """ + def __init__(self, core, text): + Tab.__init__(self, core) + self._color_state = theme.COLOR_TAB_NORMAL + self.text_win = windows.SimpleTextWin(text) + self.tab_win = windows.GlobalInfoBar() + self.default_help_message = windows.HelpText("“Ctrl+q”: close") + self.input = self.default_help_message + self.key_func['^T'] = self.close + self.key_func["/"] = self.on_slash + self.resize() - def get_name(self): - return self.name + def on_slash(self): + """ + '/' is pressed, activate the input + """ + curses.curs_set(1) + self.input = windows.CommandInput("", self.reset_help_message, self.execute_slash_command) + self.input.resize(1, self.width, self.height-1, 0, self.core.stdscr) + self.input.do_command("/") # we add the slash def on_input(self, key): res = self.input.do_command(key) @@ -1055,6 +1092,19 @@ class MucListTab(Tab): if key in self.key_func: return self.key_func[key]() + def close(self): + self.core.close_tab() + + def resize(self): + self.text_win.resize(self.height-2, self.width, 0, 0, self.core.stdscr) + self.tab_win.resize(1, self.width, self.height-2, 0, self.core.stdscr) + self.input.resize(1, self.width, self.height-1, 0, self.core.stdscr) + + def refresh(self, tabs, information, roster): + self.text_win.refresh() + self.tab_win.refresh(tabs, tabs[0]) + self.input.refresh() + def on_lose_focus(self): self._color_state = theme.COLOR_TAB_NORMAL @@ -1065,18 +1115,6 @@ class MucListTab(Tab): def get_color_state(self): return self._color_state -# class SimpleTextTab(Tab): -# """ -# A very simple tab, with just a text displaying some -# information or whatever -# """ -# def __init__(self, core, text): -# Tab.__init__(self, core) -# self.text = text -# self.text_win = - -# def resize(self): -# pass def diffmatch(search, string): """ Use difflib and a loop to check if search_pattern can |