summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2011-05-13 20:19:10 +0200
committermathieui <mathieui@mathieui.net>2011-05-13 20:19:10 +0200
commit03a691c4d16e2b40c081d89629172c4f0ac870be (patch)
treed2b4e5e9474a912949934086e307456af66cfb2f /src
parent3d43517a41dfd568400cffb2e7b480cec315498f (diff)
downloadpoezio-03a691c4d16e2b40c081d89629172c4f0ac870be.tar.gz
poezio-03a691c4d16e2b40c081d89629172c4f0ac870be.tar.bz2
poezio-03a691c4d16e2b40c081d89629172c4f0ac870be.tar.xz
poezio-03a691c4d16e2b40c081d89629172c4f0ac870be.zip
Fix #2176, and remove useless stuff added by 2to3
Diffstat (limited to 'src')
-rw-r--r--src/core.py18
-rw-r--r--src/tabs.py28
-rw-r--r--src/windows.py2
3 files changed, 25 insertions, 23 deletions
diff --git a/src/core.py b/src/core.py
index f5980af1..381110da 100644
--- a/src/core.py
+++ b/src/core.py
@@ -682,7 +682,7 @@ class Core(object):
else:
self.command_win('%d' % nb)
# search for keyboard shortcut
- if char in list(self.key_func.keys()):
+ if char in self.key_func:
self.key_func[char]()
else:
self.do_command(char)
@@ -853,7 +853,7 @@ class Core(object):
code = error['error']['code']
body = error['error']['text']
if not body:
- if code in list(ERROR_AND_STATUS_CODES.keys()):
+ if code in ERROR_AND_STATUS_CODES:
body = ERROR_AND_STATUS_CODES[code]
else:
body = condition or _('Unknown error')
@@ -980,15 +980,15 @@ class Core(object):
args = arg.split()
if len(args) == 0:
msg = _('Available commands are: ')
- for command in list(self.commands.keys()):
+ for command in self.commands:
msg += "%s " % command
- for command in list(self.current_tab().commands.keys()):
+ for command in self.current_tab().commands:
msg += "%s " % command
msg += _("\nType /help <command_name> to know what each command does")
if len(args) >= 1:
- if args[0] in list(self.commands.keys()):
+ if args[0] in self.commands:
msg = self.commands[args[0]][1]
- elif args[0] in list(self.current_tab().commands.keys()):
+ elif args[0] in self.current_tab().commands:
msg = self.current_tab().commands[args[0]][1]
else:
msg = _('Unknown command: %s') % args[0]
@@ -1024,7 +1024,7 @@ class Core(object):
self.set_status(show, msg)
def completion_status(self, the_input):
- return the_input.auto_completion([status for status in list(possible_show.keys())], ' ')
+ return the_input.auto_completion([status for status in possible_show], ' ')
def command_message(self, arg):
"""
@@ -1430,12 +1430,12 @@ class Core(object):
command = line.strip()[:].split()[0][1:]
arg = line[2+len(command):] # jump the '/' and the ' '
# example. on "/link 0 open", command = "link" and arg = "0 open"
- if command in list(self.commands.keys()):
+ if command in self.commands:
func = self.commands[command][0]
func(arg)
return
else:
- self.information(_("unknown command (%s)") % (command), _('Error'))
+ self.information(_("Unknown command (%s)") % (command), _('Error'))
def doupdate(self):
if not self.running:
diff --git a/src/tabs.py b/src/tabs.py
index fa8cc5f8..796c2f26 100644
--- a/src/tabs.py
+++ b/src/tabs.py
@@ -119,8 +119,8 @@ class Tab(object):
return command[2](the_input)
else:
# complete the command's name
- words = ['/%s'%(name) for name in list(self.core.commands.keys())] +\
- ['/%s'% (name) for name in list(self.commands.keys())]
+ words = ['/%s'%(name) for name in self.core.commands] +\
+ ['/%s'% (name) for name in self.commands]
the_input.auto_completion(words, '')
return True
return False
@@ -307,8 +307,10 @@ class ChatTab(Tab):
if not empty_before and empty_after:
self.send_chat_state("active")
self.cancel_paused_delay()
- elif (empty_before or (self.timed_event_paused is not None and not self.timed_event_paused())) and not empty_after:
+ elif (empty_before or (self.timed_event_paused is not None and not self.timed_event_paused())):
+ self.cancel_paused_delay()
self.send_chat_state("composing")
+ self.set_paused_delay(True)
def set_paused_delay(self, composing):
"""
@@ -593,6 +595,8 @@ class MucTab(ChatTab):
msg = arg[len(nick)+1:]
muc.send_private_message(self.core.xmpp, r.name, msg)
self.core.add_message_to_text_buffer(r, msg, None, r.own_nick)
+ if not r:
+ self.core.information(_("Cannot find user: %s" % nick), 'Error')
def command_topic(self, arg):
"""
@@ -719,9 +723,6 @@ class MucTab(ChatTab):
self.input.do_command(key)
empty_after = self.input.get_text() == '' or (self.input.get_text().startswith('/') and not self.input.get_text().startswith('//'))
self.send_composing_chat_state(empty_before, empty_after)
- if not empty_before and empty_after:
- self.cancel_paused_delay()
- self.set_paused_delay(empty_before and not empty_after)
return False
def completion(self):
@@ -730,6 +731,11 @@ class MucTab(ChatTab):
"""
if self.complete_commands(self.input):
return
+
+ empty_before = self.input.get_text() == '' or (self.input.get_text().startswith('/') and not self.input.get_text().startswith('//'))
+ empty_after = self.input.get_text() == '' or (self.input.get_text().startswith('/') and not self.input.get_text().startswith('//'))
+ self.send_composing_chat_state(empty_before, empty_after)
+
# If we are not completing a command or a command's argument, complete a nick
compare_users = lambda x: x.last_talked
word_list = [user.nick for user in sorted(self._room.users, key=compare_users, reverse=True)\
@@ -740,6 +746,7 @@ class MucTab(ChatTab):
add_after = after
else:
add_after = ' '
+
self.input.auto_completion(word_list, add_after)
def get_color_state(self):
@@ -1063,9 +1070,6 @@ class PrivateTab(ChatTab):
self.input.do_command(key)
empty_after = self.input.get_text() == '' or (self.input.get_text().startswith('/') and not self.input.get_text().startswith('//'))
self.send_composing_chat_state(empty_before, empty_after)
- if not empty_before and empty_after:
- self.cancel_paused_delay()
- self.set_paused_delay(empty_before and not empty_after)
return False
def on_lose_focus(self):
@@ -1195,6 +1199,7 @@ class RosterInfoTab(Tab):
"""
jid = JID(args.strip()).bare
if not jid:
+ self.core.information(_('No JID specified'), 'Error')
return
self.core.xmpp.sendPresence(pto=jid, ptype='subscribe')
@@ -1242,7 +1247,7 @@ class RosterInfoTab(Tab):
if isinstance(item, Contact) and item.get_ask() == 'asked':
jid = item.get_bare_jid()
else:
- self.core.information('No subscription to deny')
+ self.core.information('No subscription to accept')
return
else:
jid = args[0]
@@ -1506,9 +1511,6 @@ class ConversationTab(ChatTab):
self.input.do_command(key)
empty_after = self.input.get_text() == '' or (self.input.get_text().startswith('/') and not self.input.get_text().startswith('//'))
self.send_composing_chat_state(empty_before, empty_after)
- self.set_paused_delay(empty_before and not empty_after)
- if not empty_before and empty_after:
- self.cancel_paused_delay()
return False
def on_lose_focus(self):
diff --git a/src/windows.py b/src/windows.py
index 75b08961..df361ed8 100644
--- a/src/windows.py
+++ b/src/windows.py
@@ -126,7 +126,7 @@ class Win(object):
self._win.attron(curses.A_UNDERLINE)
elif attr_char == 'b':
self._win.attron(curses.A_BOLD)
- elif attr_char in string.digits:
+ elif attr_char in string.digits and attr_char != '':
self._win.attron(common.curses_color_pair(int(attr_char)))
next_attr_char = text.find('\x19')
self.addstr(text)