summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/commands.py1
-rw-r--r--src/core/core.py67
-rw-r--r--src/core/handlers.py5
3 files changed, 38 insertions, 35 deletions
diff --git a/src/core/commands.py b/src/core/commands.py
index 82d2d6da..1713c0f1 100644
--- a/src/core/commands.py
+++ b/src/core/commands.py
@@ -822,7 +822,6 @@ def command_quit(self, arg=''):
self.disconnect(msg)
self.running = False
self.reset_curses()
- sys.exit()
def command_destroy_room(self, arg=''):
"""
diff --git a/src/core/core.py b/src/core/core.py
index 00d7c364..42d8df31 100644
--- a/src/core/core.py
+++ b/src/core/core.py
@@ -468,6 +468,7 @@ class Core(object):
' ask for help or tell us how great it is.'),
_('Help'))
self.refresh_window()
+ self.xmpp.plugin['xep_0012'].begin_idle(jid=self.xmpp.boundjid)
def on_exception(self, typ, value, trace):
"""
@@ -480,7 +481,7 @@ class Core(object):
pass
sys.__excepthook__(typ, value, trace)
- def main_loop(self):
+ def on_input_readable(self):
"""
main loop waiting for the user to press a key
"""
@@ -527,39 +528,41 @@ class Core(object):
res.append(current)
return res
- while self.running:
- self.xmpp.plugin['xep_0012'].begin_idle(jid=self.xmpp.boundjid)
- big_char_list = [replace_key_with_bound(key)\
- for key in self.read_keyboard()]
- # whether to refresh after ALL keys have been handled
- for char_list in separate_chars_from_bindings(big_char_list):
- if self.paused:
- self.current_tab().input.do_command(char_list[0])
- self.current_tab().input.prompt()
- self.event.set()
- continue
- # Special case for M-x where x is a number
- if len(char_list) == 1:
- char = char_list[0]
- if char.startswith('M-') and len(char) == 3:
- try:
- nb = int(char[2])
- except ValueError:
- pass
- else:
- if self.current_tab().nb == nb:
- self.go_to_previous_tab()
- else:
- self.command_win('%d' % nb)
- # search for keyboard shortcut
- func = self.key_func.get(char, None)
- if func:
- func()
+ log.debug("Input is readable.")
+ big_char_list = [replace_key_with_bound(key)\
+ for key in self.read_keyboard()]
+ log.debug("Got from keyboard: %s", (big_char_list,))
+
+ # whether to refresh after ALL keys have been handled
+ for char_list in separate_chars_from_bindings(big_char_list):
+ if self.paused:
+ self.current_tab().input.do_command(char_list[0])
+ self.current_tab().input.prompt()
+ self.event.set()
+ continue
+ # Special case for M-x where x is a number
+ if len(char_list) == 1:
+ char = char_list[0]
+ if char.startswith('M-') and len(char) == 3:
+ try:
+ nb = int(char[2])
+ except ValueError:
+ pass
else:
- self.do_command(replace_line_breaks(char), False)
+ if self.current_tab().nb == nb:
+ self.go_to_previous_tab()
+ else:
+ self.command_win('%d' % nb)
+ # search for keyboard shortcut
+ func = self.key_func.get(char, None)
+ if func:
+ func()
else:
- self.do_command(''.join(char_list), True)
- self.doupdate()
+ self.do_command(replace_line_breaks(char), False)
+ else:
+ self.do_command(''.join(char_list), True)
+ self.doupdate()
+ self.xmpp.plugin['xep_0012'].begin_idle(jid=self.xmpp.boundjid)
def save_config(self):
"""
diff --git a/src/core/handlers.py b/src/core/handlers.py
index e9e1c892..654ce376 100644
--- a/src/core/handlers.py
+++ b/src/core/handlers.py
@@ -170,7 +170,8 @@ def on_message(self, message):
def on_normal_message(self, message):
"""
- When receiving "normal" messages (from someone in our roster)
+ When receiving "normal" messages (not a private message from a
+ muc participant)
"""
if message['type'] == 'error':
return self.information(self.get_error_message(message, deprecated=True), 'Error')
@@ -889,7 +890,7 @@ def on_session_start(self, event):
show=self.status.show)
if config.get('enable_user_nick', True):
- self.xmpp.plugin['xep_0172'].publish_nick(nick=self.own_nick, callback=dumb_callback, block=False)
+ self.xmpp.plugin['xep_0172'].publish_nick(nick=self.own_nick, callback=dumb_callback)
self.xmpp.plugin['xep_0115'].update_caps()
### Other handlers ###