diff options
Diffstat (limited to 'src/core.py')
-rw-r--r-- | src/core.py | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/src/core.py b/src/core.py index 043a0c44..db860926 100644 --- a/src/core.py +++ b/src/core.py @@ -127,19 +127,18 @@ class Core(object): 'list': (self.command_list, _('Usage: /list\nList: get the list of public chatrooms on the specified server'), self.completion_list), 'message': (self.command_message, _('Usage: /message <jid> [optional message]\nMessage: Open a conversation with the specified JID (even if it is not in our roster), and send a message to it, if specified'), None), 'version': (self.command_version, _('Usage: /version <jid>\nVersion: get the software version of the given JID (usually its XMPP client and Operating System)'), None), - 'reconnect': (self.command_reconnect, _('Usage: /connect\nConnect: disconnect from the remote server if you are currently connected and then connect to it again'), None), + 'connect': (self.command_reconnect, _('Usage: /connect\nConnect: disconnect from the remote server if you are currently connected and then connect to it again'), None), 'server_cycle': (self.command_server_cycle, _('Usage: /server_cycle [domain] [message]\nServer Cycle: disconnect and reconnects in all the rooms in domain.'), None), + 'bind': (self.command_bind, _('Usage: /bind <key> <equ>\nBind: bind a key to an other key or to a “command”. For example "/bind ^H KEY_UP" makes Control + h do the same same than the Up key.')), } self.key_func = { "KEY_PPAGE": self.scroll_page_up, "KEY_NPAGE": self.scroll_page_down, "KEY_F(5)": self.rotate_rooms_left, - "M-[1;6D": self.rotate_rooms_left, "^P": self.rotate_rooms_left, 'kLFT3': self.rotate_rooms_left, "KEY_F(6)": self.rotate_rooms_right, - "M-[1;6C": self.rotate_rooms_right, "^N": self.rotate_rooms_right, 'kRIT3': self.rotate_rooms_right, "KEY_F(7)": self.shrink_information_win, @@ -485,12 +484,11 @@ class Core(object): # Differentiate both type of messages, and call the appropriate handler. jid_from = message['from'] for tab in self.tabs: - if tab.get_name() == jid_from and isinstance(tab, tabs.PrivateTab): + if tab.get_name() == jid_from.bare and isinstance(tab, tabs.MucTab): if message['type'] == 'error': return self.room_error(message, jid_from) else: return self.on_groupchat_private_message(message) - return self.on_normal_message(message) def on_groupchat_private_message(self, message): @@ -516,6 +514,8 @@ class Core(object): conversation.remote_wants_chatstates = True else: conversation.remote_wants_chatstates = False + if 'private' in config.get('beep_on', 'highlight private').split(): + curses.beep() logger.log_message(jid.full.replace('/', '\\'), nick_from, body) if conversation is self.current_tab(): self.refresh_window() @@ -568,6 +568,8 @@ class Core(object): else: conversation.remote_wants_chatstates = False logger.log_message(jid.bare, remote_nick, body) + if 'private' in config.get('beep_on', 'highlight private').split(): + curses.beep() if self.current_tab() is not conversation: conversation.set_color_state(theme.COLOR_TAB_PRIVATE) self.refresh_tab_win() @@ -673,7 +675,8 @@ class Core(object): """ # curses.ungetch(0) # FIXME while self.running: - char_list = self.read_keyboard() + char_list = [common.replace_key_with_bound(key)\ + for key in self.read_keyboard()] # Special case for M-x where x is a number if len(char_list) == 1: char = char_list[0] @@ -982,12 +985,14 @@ class Core(object): body = xhtml.get_body_from_message_stanza(message) if body: date = date if delayed == True else None - self.add_message_to_text_buffer(room, body, date, nick_from) + self.add_message_to_text_buffer(room, body, date, nick_from, history=True if date else False) if tab is self.current_tab(): tab.text_win.refresh(tab._room) self.refresh_tab_win() + if 'message' in config.get('beep_on', 'highlight private').split(): + curses.beep() - def add_message_to_text_buffer(self, room, txt, time=None, nickname=None): + def add_message_to_text_buffer(self, room, txt, time=None, nickname=None, history=None): """ Add the message to the room if possible, else, add it to the Info window (in the Info tab of the info window in the RosterTab) @@ -995,7 +1000,7 @@ class Core(object): if not room: self.information('Trying to add a message in no room: %s' % txt, 'Error') else: - room.add_message(txt, time, nickname) + room.add_message(txt, time, nickname, history=history) def command_help(self, arg): """ @@ -1234,6 +1239,7 @@ class Core(object): else: # no server could be found, print a message and return self.information(_("You didn't specify a server for the room you want to join"), 'Error') return + room = room.lower() r = self.get_room_by_name(room) if len(args) == 2: # a password is provided password = args[1] @@ -1242,7 +1248,6 @@ class Core(object): return if room.startswith('@'): room = room[1:] - room = room.lower() current_status = self.get_status() if r and not r.joined: muc.join_groupchat(self.xmpp, room, nick, password, @@ -1372,6 +1377,16 @@ class Core(object): tab.get_room().joined = False self.command_join(tab.get_name()) + def command_bind(self, arg): + """ + Bind a key. + """ + args = common.shell_split(arg) + if len(args) != 2: + return self.command_help('bind') + config.set_and_save(args[0], args[1], section='bindings') + self.information('%s is now bound to %s' % (args[0], args[1]), 'Info') + def go_to_room_number(self): """ Read 2 more chars and go to the tab |