diff options
author | Thomas Nixon <tom@tomn.co.uk> | 2018-02-19 22:31:38 +0000 |
---|---|---|
committer | Thomas Nixon <tom@tomn.co.uk> | 2018-02-19 23:15:29 +0000 |
commit | 01016563fccf31ddee6e5b8b4b13c065149dd814 (patch) | |
tree | b40d9ec08e364ea7b21185b2379efa42e1b6a161 /alot/commands/globals.py | |
parent | 021735bdcba6763a5ed42cfce305e0ca33714db4 (diff) |
Move screen stop/start logic into context manager.
As well as reducing duplication and adding screen size detection to
:pipeto and :pyshell, this ensures that the screen is always restarted,
resulting in cleaner error handling if an error occurs while the screen
is stopped.
Diffstat (limited to 'alot/commands/globals.py')
-rw-r--r-- | alot/commands/globals.py | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/alot/commands/globals.py b/alot/commands/globals.py index e8721758..4e0ed506 100644 --- a/alot/commands/globals.py +++ b/alot/commands/globals.py @@ -284,13 +284,8 @@ class ExternalCommand(Command): d = threads.deferToThread(thread_code) d.addCallback(afterwards) else: - ui.mainloop.stop() - ret = thread_code() - ui.mainloop.start() - - # make sure urwid renders its canvas at the correct size - ui.mainloop.screen_size = None - ui.mainloop.draw_screen() + with ui.paused(): + ret = thread_code() afterwards(ret) @@ -348,9 +343,8 @@ class PythonShellCommand(Command): repeatable = True def apply(self, ui): - ui.mainloop.stop() - code.interact(local=locals()) - ui.mainloop.start() + with ui.paused(): + code.interact(local=locals()) @registerCommand(MODE, 'repeat') |