From 35b6e146cb6a0b313d6297f0d91654aa21f58c1b Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Sat, 9 Apr 2011 22:18:36 +0200 Subject: Basic timed event implementation. --- src/core.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'src/core.py') diff --git a/src/core.py b/src/core.py index bf7283fe..8629ecc8 100644 --- a/src/core.py +++ b/src/core.py @@ -43,9 +43,10 @@ import tabs import xhtml import windows import connection +import timed_events from data_forms import DataFormsTab -from config import config +from config import config, options from logger import logger from user import User from room import Room @@ -619,9 +620,6 @@ class Core(object): tab.resize() self.refresh_window() - def check_timed_events(self): - pass - def read_keyboard(self): """ Get the next keyboard key pressed and returns it. @@ -631,6 +629,7 @@ class Core(object): """ res = read_char(self.stdscr) while res is None: + log.debug('checking events') self.check_timed_events() res = read_char(self.stdscr) return res @@ -705,7 +704,8 @@ class Core(object): curses.curs_set(1) curses.noecho() curses.nonl() - curses.raw() + if not options.debug: + curses.raw() theme.init_colors() stdscr.keypad(True) curses.ungetch(" ") # H4X: without this, the screen is @@ -1379,6 +1379,18 @@ class Core(object): self.focus_tab_named(roster_row.get_jid().full) self.refresh_window() + def add_timed_event(self, event): + self.timed_events.add(event) + + def check_timed_events(self): + now = datetime.now() + for event in self.timed_events: + if event.has_timed_out(now): + res = event() + if not res: + self.timed_events.remove(event) + break + def execute(self,line): """ Execute the /command or just send the line on the current room -- cgit v1.2.3