Fix add_tab_command (and remove)

This commit is contained in:
mathieui 2011-11-13 00:25:30 +01:00
parent cc4f6c8b4c
commit 4b02b1a812
2 changed files with 5 additions and 9 deletions

View file

@ -99,12 +99,15 @@ class PluginManager(object):
def add_tab_command(self, module_name, tab_type, name, handler, help, completion=None):
commands = self.tab_commands[module_name]
t = tab_type.__name__
if name in tab_type.plugin_commands:
return
if not t in commands:
commands[t] = []
commands[t].append((name, handler, help, completion))
tab_type.plugin_commands[name] = (handler, help, completion)
for tab in self.core.tabs:
if isinstance(tab, tab_type):
tab.add_plugin_command(name, handler, help, completion)
tab.update_commands()
def del_tab_command(self, module_name, tab_type, name):
commands = self.tab_commands[module_name]

View file

@ -222,17 +222,10 @@ class Tab(object):
def on_input(self, key):
pass
def add_plugin_command(self, name, handler, help, completion=None):
if name in self.plugin_commands or name in self.commands:
return
self.plugin_commands[name] = (handler, help, completion)
self.commands[name] = (handler, help, completion)
self.update_commands()
def update_commands(self):
for c in self.plugin_commands:
if not c in self.commands:
self.commands[name] = self.plugin_commands[c]
self.commands[c] = self.plugin_commands[c]
def on_lose_focus(self):
"""