equal
deleted
inserted
replaced
1 from tuikit.core.window import WindowManager, Window |
1 from tuikit.core.window import WindowManager, Window |
2 from tuikit.core.theme import default_theme |
2 from tuikit.core.theme import default_theme |
3 from tuikit.core.timer import Timer |
3 from tuikit.core.timer import Timer |
4 from tuikit.core.buffer import ProxyBuffer |
4 from tuikit.core.buffer import ProxyBuffer |
|
5 from tuikit.core.events import ResizeEvent |
5 |
6 |
6 import logging |
7 import logging |
7 |
8 |
8 |
9 |
9 class Application: |
10 class Application: |
54 self._quit = True |
55 self._quit = True |
55 |
56 |
56 def main_loop(self): |
57 def main_loop(self): |
57 """The main loop.""" |
58 """The main loop.""" |
58 self._started = True |
59 self._started = True |
59 self.window_manager.handle_event('resize', *self.driver.size) |
60 self.window_manager.handle_event(ResizeEvent(*self.driver.size)) |
60 |
61 |
61 screen = ProxyBuffer(self.driver) |
62 screen = ProxyBuffer(self.driver) |
62 while not self._quit: |
63 while not self._quit: |
63 self.window_manager.draw(screen) |
64 self.window_manager.draw(screen) |
64 self.driver.cursor = self.window_manager.cursor |
65 self.driver.cursor = self.window_manager.cursor |
67 timeout = self.timer.nearest_timeout() |
68 timeout = self.timer.nearest_timeout() |
68 events = self.driver.getevents(timeout) |
69 events = self.driver.getevents(timeout) |
69 |
70 |
70 self.timer.process_timeouts() |
71 self.timer.process_timeouts() |
71 for event in events: |
72 for event in events: |
72 self.window_manager.handle_event(event[0], *event[1:]) |
73 self.window_manager.handle_event(event) |
73 |
74 |
74 self._started = False |
75 self._started = False |
75 self.log.info('=== End ===') |
76 self.log.info('=== End ===') |
76 |
77 |