summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-11-11 03:39:39 +0000
committerlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-11-11 03:39:39 +0000
commit58a82f170b01994be304283b2b195ea010b561e6 (patch)
tree97b3e00431ab1617c24607023f5f7634f2c7e44c /src
parentf729e79aade7a1c1e2978dcf3822647351d58204 (diff)
downloadpoezio-58a82f170b01994be304283b2b195ea010b561e6.tar.gz
poezio-58a82f170b01994be304283b2b195ea010b561e6.tar.bz2
poezio-58a82f170b01994be304283b2b195ea010b561e6.tar.xz
poezio-58a82f170b01994be304283b2b195ea010b561e6.zip
fix some issues with recent-words completion, make the ConversationTabs closable with /unquery and ignore the keyboard shortcuts not handled. fixed #1941
Diffstat (limited to 'src')
-rw-r--r--src/core.py3
-rw-r--r--src/tab.py37
-rw-r--r--src/user.py2
-rw-r--r--src/window.py4
4 files changed, 34 insertions, 12 deletions
diff --git a/src/core.py b/src/core.py
index 01770a49..6a23a3a6 100644
--- a/src/core.py
+++ b/src/core.py
@@ -1207,6 +1207,9 @@ class Core(object):
if isinstance(tab, PrivateTab):
self.tabs.remove(tab)
self.refresh_window()
+ if isinstance(tab, ConversationTab):
+ self.tabs.remove(tab)
+ self.refresh_window()
def command_query(self, arg):
"""
diff --git a/src/tab.py b/src/tab.py
index 03509de3..cf93b2e4 100644
--- a/src/tab.py
+++ b/src/tab.py
@@ -25,6 +25,9 @@ Window are displayed, etc
MIN_WIDTH = 50
MIN_HEIGHT = 16
+import logging
+log = logging.getLogger(__name__)
+
import window
import theme
import curses
@@ -126,6 +129,12 @@ class Tab(object):
"""
raise NotImplementedError
+ def on_close(self):
+ """
+ Called when the tab is to be closed
+ """
+ raise NotImplementedError
+
class InfoTab(Tab):
"""
The information tab, used to display global informations
@@ -181,6 +190,9 @@ class InfoTab(Tab):
def just_before_refresh(self):
return
+ def on_close(self):
+ return
+
class MucTab(Tab):
"""
The tab containing a multi-user-chat room.
@@ -251,31 +263,26 @@ class MucTab(Tab):
Complete the input with words recently said
"""
# build the list of the recent words
- char_we_dont_want = [',', '(', ')', '.']
+ char_we_dont_want = [',', '(', ')', '.', '"', '\'', ' '] # The last one is nbsp
words = list()
for msg in self._room.messages[:-40:-1]:
if not msg:
continue
+ log.debug('line: %s\n'%msg)
for char in char_we_dont_want:
- msg.txt.replace(char, ' ')
+ msg.txt = msg.txt.replace(char, ' ')
for word in msg.txt.split():
- if len(word) > 5:
+ if len(word) >= 5 and word not in words:
words.append(word)
self.input.auto_completion(words, False)
def get_color_state(self):
- """
- """
return self._room.color_state
def set_color_state(self, color):
- """
- """
self._room.set_color_state(color)
def get_name(self):
- """
- """
return self._room.name
def get_room(self):
@@ -305,6 +312,9 @@ class MucTab(Tab):
def just_before_refresh(self):
self.input.move_cursor_to_pos()
+ def on_close(self):
+ return
+
class PrivateTab(Tab):
"""
The tab containg a private conversation (someone from a MUC)
@@ -374,6 +384,9 @@ class PrivateTab(Tab):
def just_before_refresh(self):
return
+ def on_close(self):
+ return
+
class RosterInfoTab(Tab):
"""
A tab, splitted in two, containing the roster and infos
@@ -523,6 +536,9 @@ class RosterInfoTab(Tab):
def just_before_refresh(self):
return
+ def on_close(self):
+ return
+
class ConversationTab(Tab):
"""
The tab containg a normal conversation (someone from our roster)
@@ -597,6 +613,9 @@ class ConversationTab(Tab):
def just_before_refresh(self):
return
+ def on_close(self):
+ return
+
def jid_and_name_match(contact, txt):
"""
A function used to know if a contact in the roster should
diff --git a/src/user.py b/src/user.py
index b2b8790c..eb8587f8 100644
--- a/src/user.py
+++ b/src/user.py
@@ -64,7 +64,7 @@ class User(object):
return True
def __repr__(self):
- return ">%s<" % (self.nick.decode('utf-8'))
+ return ">%s<" % (self.nick)
def __eq__(self, b):
return self.role == b.role and self.nick.lower() == b.nick.lower()
diff --git a/src/window.py b/src/window.py
index 64113cfb..88683853 100644
--- a/src/window.py
+++ b/src/window.py
@@ -976,8 +976,8 @@ class Input(Win):
def do_command(self, key, reset=True):
if key in self.key_func:
return self.key_func[key]()
- # if not key or len(key) > 1:
- # return # ignore non-handled keyboard shortcuts
+ if not key or len(key) > 1:
+ return # ignore non-handled keyboard shortcuts
self.reset_completion()
self.text = self.text[:self.pos+self.line_pos]+key+self.text[self.pos+self.line_pos:]
(y, x) = self._win.getyx()