summaryrefslogtreecommitdiff
path: root/src/tabs.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/tabs.py')
-rw-r--r--src/tabs.py36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/tabs.py b/src/tabs.py
index 4ea3c280..8d4e6447 100644
--- a/src/tabs.py
+++ b/src/tabs.py
@@ -269,6 +269,7 @@ class ChatTab(Tab):
self.commands['say'] = (self.command_say,
_("""Usage: /say <message>\nSay: Just send the message.
Useful if you want your message to begin with a '/'"""), None)
+ self.chat_state = None
def last_words_completion(self):
"""
@@ -308,6 +309,7 @@ class ChatTab(Tab):
msg = self.core.xmpp.make_message(self.get_name())
msg['type'] = self.message_type
msg['chat_state'] = state
+ self.chat_state = state
msg.send()
def send_composing_chat_state(self, empty_before, empty_after):
@@ -316,8 +318,13 @@ class ChatTab(Tab):
on the the current status of the input
"""
if config.get('send_chat_states', 'true') == 'true' and self.remote_wants_chatstates:
- if empty_after:
+ if self.chat_state == "composing" and not empty_after:
+ self.cancel_paused_delay()
+ self.set_paused_delay(True)
+ elif empty_after and not self.chat_state == 'active':
+ self.cancel_paused_delay()
self.send_chat_state("active")
+ elif empty_after:
self.cancel_paused_delay()
elif empty_before or (self.timed_event_paused is not None and not self.timed_event_paused()):
self.cancel_paused_delay()
@@ -388,7 +395,6 @@ class MucTab(ChatTab):
self.ignores = [] # set of Users
# keys
self.key_func['^I'] = self.completion
- self.key_func['M-i'] = self.completion
self.key_func['M-u'] = self.scroll_user_list_down
self.key_func['M-y'] = self.scroll_user_list_up
# commands
@@ -912,6 +918,7 @@ class MucTab(ChatTab):
if status:
leave_msg += ' (%s)' % status
room.add_message(leave_msg)
+ self.core.refresh_window()
self.core.on_user_left_private_conversation(from_room, from_nick, status)
def on_user_change_status(self, room, user, from_nick, from_room, affiliation, role, show, status):
@@ -971,7 +978,6 @@ class PrivateTab(ChatTab):
self.input = windows.MessageInput()
# keys
self.key_func['^I'] = self.completion
- self.key_func['M-i'] = self.completion
# commands
self.commands['unquery'] = (self.command_unquery, _("Usage: /unquery\nUnquery: close the tab"), None)
self.commands['part'] = (self.command_unquery, _("Usage: /part\Part: close the tab"), None)
@@ -983,7 +989,11 @@ class PrivateTab(ChatTab):
def command_say(self, line):
msg = self.core.xmpp.make_message(self.get_name())
msg['type'] = 'chat'
- msg['body'] = line
+ if line.find('\x19') == -1:
+ msg['body'] = line
+ else:
+ msg['body'] = xhtml.clean_text(line)
+ msg['xhtml_im'] = xhtml.poezio_colors_to_html(line)
if config.get('send_chat_states', 'true') == 'true' and self.remote_wants_chatstates is not False:
msg['chat_state'] = 'active'
msg.send()
@@ -1041,7 +1051,8 @@ class PrivateTab(ChatTab):
empty_before = self.input.get_text() == '' or (self.input.get_text().startswith('/') and not self.input.get_text().startswith('//'))
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 self.core.get_tab_by_name(JID(self.get_room().name).bare, MucTab).get_room().joined:
+ self.send_composing_chat_state(empty_before, empty_after)
return False
def on_lose_focus(self):
@@ -1054,7 +1065,7 @@ class PrivateTab(ChatTab):
def on_gain_focus(self):
self._room.set_color_state(theme.COLOR_TAB_CURRENT)
curses.curs_set(1)
- if config.get('send_chat_states', 'true') == 'true' and not self.input.get_text():
+ if self.get_room().joined and config.get('send_chat_states', 'true') == 'true' and not self.input.get_text():
self.send_chat_state('active')
def on_scroll_up(self):
@@ -1089,9 +1100,9 @@ class PrivateTab(ChatTab):
The user left the associated MUC
"""
if not status_message:
- self.get_room().add_message(_('%(spec)s "[%(nick)s]" has left the room') % {'nick':from_nick.replace('"', '\\"'), 'spec':theme.CHAR_QUIT.replace('"', '\\"')})
+ self.get_room().add_message(_('\x191%(spec)s \x193%(nick)s\x195 has left the room') % {'nick':from_nick.replace('"', '\\"'), 'spec':theme.CHAR_QUIT.replace('"', '\\"')})
else:
- self.get_room().add_message(_('%(spec)s "[%(nick)s]" has left the room "(%(status)s)"') % {'nick':from_nick.replace('"', '\\"'), 'spec':theme.CHAR_QUIT, 'status': status_message.replace('"', '\\"')})
+ self.get_room().add_message(_('\x191%(spec)s \x193%(nick)s\x195 has left the room (%(status)s)"') % {'nick':from_nick.replace('"', '\\"'), 'spec':theme.CHAR_QUIT, 'status': status_message.replace('"', '\\"')})
class RosterInfoTab(Tab):
"""
@@ -1110,7 +1121,6 @@ class RosterInfoTab(Tab):
self.input = self.default_help_message
self.set_color_state(theme.COLOR_TAB_NORMAL)
self.key_func['^I'] = self.completion
- self.key_func['M-i'] = self.completion
self.key_func[' '] = self.on_space
self.key_func["/"] = self.on_slash
self.key_func["KEY_UP"] = self.move_cursor_up
@@ -1457,7 +1467,6 @@ class ConversationTab(ChatTab):
self.input = windows.MessageInput()
# keys
self.key_func['^I'] = self.completion
- self.key_func['M-i'] = self.completion
# commands
self.commands['unquery'] = (self.command_unquery, _("Usage: /unquery\nUnquery: close the tab"), None)
self.commands['part'] = (self.command_unquery, _("Usage: /part\Part: close the tab"), None)
@@ -1469,7 +1478,11 @@ class ConversationTab(ChatTab):
def command_say(self, line):
msg = self.core.xmpp.make_message(self.get_name())
msg['type'] = 'chat'
- msg['body'] = line
+ if line.find('\x19') == -1:
+ msg['body'] = line
+ else:
+ msg['body'] = xhtml.clean_text(line)
+ msg['xhtml_im'] = xhtml.poezio_colors_to_html(line)
if config.get('send_chat_states', 'true') == 'true' and self.remote_wants_chatstates is not False:
msg['chat_state'] = 'active'
msg.send()
@@ -1585,7 +1598,6 @@ class MucListTab(Tab):
self.key_func["KEY_DOWN"] = self.listview.move_cursor_down
self.key_func["KEY_UP"] = self.listview.move_cursor_up
self.key_func['^I'] = self.completion
- self.key_func['M-i'] = self.completion
self.key_func["/"] = self.on_slash
self.key_func['j'] = self.join_selected
self.key_func['J'] = self.join_selected_no_focus