fix some issues with recent-words completion, make the ConversationTabs...

fix some issues with recent-words completion, make the ConversationTabs closable with /unquery and ignore the keyboard shortcuts not handled.  fixed #1941
parent f729e79a
......@@ -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):
"""
......
......@@ -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
......
......@@ -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()
......
......@@ -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()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment