summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2012-12-15 19:51:07 +0100
committerFlorent Le Coz <louiz@louiz.org>2012-12-15 19:51:07 +0100
commit266ba884e50b550122fefb568888fb5d1f91fba7 (patch)
treec5010fe95763c09017aa10ed0aa1dd852b98a873
parent4fe00ed0693340b4b76b563f6015120de25e2fe6 (diff)
downloadpoezio-266ba884e50b550122fefb568888fb5d1f91fba7.tar.gz
poezio-266ba884e50b550122fefb568888fb5d1f91fba7.tar.bz2
poezio-266ba884e50b550122fefb568888fb5d1f91fba7.tar.xz
poezio-266ba884e50b550122fefb568888fb5d1f91fba7.zip
Make /w command better.
fix #2185
-rw-r--r--src/core.py10
-rw-r--r--src/tabs.py22
-rw-r--r--src/windows.py1
3 files changed, 28 insertions, 5 deletions
diff --git a/src/core.py b/src/core.py
index da0585a4..e74ecd01 100644
--- a/src/core.py
+++ b/src/core.py
@@ -1509,15 +1509,17 @@ class Core(object):
self.current_tab_nb = nb
else:
for tab in self.tabs:
- if nb in safeJID(tab.get_name()).user:
- self.current_tab_nb = tab.nb
+ for name in tab.matching_names():
+ if nb in name:
+ self.current_tab_nb = tab.nb
self.current_tab().on_gain_focus()
self.refresh_window()
def completion_win(self, the_input):
"""Completion for /win"""
- l = [safeJID(tab.get_name()).user for tab in self.tabs]
- l.remove('')
+ l = []
+ for tab in self.tabs:
+ l.extend(tab.matching_names())
return the_input.auto_completion(l, ' ', quotify=False)
def command_move_tab(self, arg):
diff --git a/src/tabs.py b/src/tabs.py
index f604eca2..c9c5d153 100644
--- a/src/tabs.py
+++ b/src/tabs.py
@@ -366,6 +366,15 @@ class Tab(object):
if self.input:
self.input.on_delete()
+ def matching_names(self):
+ """
+ Returns a list of strings that are used to name a tab with the /win
+ command. For example you could switch to a tab that returns
+ ['hello', 'coucou'] using /win hel, or /win coucou
+ If not implemented in the tab, it just doesn’t match with anything.
+ """
+ return []
+
def __del__(self):
log.debug('------ Closing tab %s', self.__class__.__name__)
@@ -1632,6 +1641,9 @@ class MucTab(ChatTab):
self._text_buffer.add_message(txt, time, nickname, nick_color, history, user, highlight=highlight, identifier=identifier)
return highlight
+ def matching_names(self):
+ return [safeJID(self.get_name()).user]
+
class PrivateTab(ChatTab):
"""
The tab containg a private conversation (someone from a MUC)
@@ -1900,6 +1912,9 @@ class PrivateTab(ChatTab):
user=forced_user,
identifier=identifier)
+ def matching_names(self):
+ return [safeJID(self.get_name()).resource]
+
class RosterInfoTab(Tab):
"""
A tab, splitted in two, containing the roster and infos
@@ -2972,6 +2987,12 @@ class ConversationTab(ChatTab):
user=forced_user,
identifier=identifier)
+ def matching_names(self):
+ contact = roster[self.get_name()]
+ res = [contact.bare_jid if contact else safeJID(self.get_name()).bare]
+ if contact and contact.name:
+ res.append(contact.name)
+ return res
class MucListTab(Tab):
"""
@@ -3143,7 +3164,6 @@ class MucListTab(Tab):
self.core.doupdate()
class XMLTab(Tab):
-
def __init__(self):
Tab.__init__(self)
self.state = 'normal'
diff --git a/src/windows.py b/src/windows.py
index e8f4ce8f..bc697300 100644
--- a/src/windows.py
+++ b/src/windows.py
@@ -504,6 +504,7 @@ class ConversationInfoWin(InfoWin):
"""
for key in informations:
self.addstr(informations[key](jid), to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
+
def write_resource_information(self, resource):
"""
Write the informations about the resource