From 033dcf5e9ac46e31257d80f3fed2ae63b49a6b0d Mon Sep 17 00:00:00 2001 From: Andrew Hamilton Date: Thu, 18 Feb 2016 23:08:36 +0000 Subject: [PATCH] Coding style. Moved urwid_screen from terminal.py to vigil.py, because it didn't really belong in terminal.py. --- terminal.py | 14 -------------- vigil | 19 ++++++++++++++++--- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/terminal.py b/terminal.py index 20f8231..2e7826d 100644 --- a/terminal.py +++ b/terminal.py @@ -8,9 +8,6 @@ import curses import os import sys -import urwid -import urwid.raw_display - curses.setupterm(os.environ.get("TERM", "unknown"), sys.stdout.fileno()) @@ -96,14 +93,3 @@ def console_title(title): yield finally: sys.stdout.write(restore) - - -@contextlib.contextmanager -def urwid_screen(): - screen = urwid.raw_display.Screen() - screen.set_mouse_tracking(True) - screen.start() - try: - yield screen - finally: - screen.stop() diff --git a/vigil b/vigil index 6c05993..676c512 100755 --- a/vigil +++ b/vigil @@ -70,6 +70,8 @@ import traceback import docopt import pyinotify +import urwid +import urwid.raw_display import fill3 import sandbox_fs @@ -898,6 +900,17 @@ def _add_watch_manager_to_mainloop(root_path, mainloop, on_filesystem_change, return watch_manager_fd +@contextlib.contextmanager +def _urwid_screen(): + screen = urwid.raw_display.Screen() + screen.set_mouse_tracking(True) + screen.start() + try: + yield screen + finally: + screen.stop() + + _UPDATE_THREAD_STOPPED = False @@ -983,7 +996,7 @@ def main(root_path, worker_count=multiprocessing.cpu_count()*2, target=_update_screen, args=(screen, appearance_changed_event), daemon=True) with terminal.hidden_cursor(): - with terminal.urwid_screen() as urwid_screen: + with _urwid_screen() as urwid_screen: loop.add_reader(sys.stdin, on_input, urwid_screen) update_display_thread.start() signal.signal(signal.SIGWINCH, on_window_resize) @@ -1036,7 +1049,7 @@ def _manage_cache(root_path): open(timestamp_path, "w").close() -def check_arguments(): +def _check_arguments(): arguments = docopt.docopt(__doc__.replace("*", ""), help=False) if arguments["--help"]: print(_get_help_text()) @@ -1064,7 +1077,7 @@ def check_arguments(): if __name__ == "__main__": - root_path, worker_count, is_sandboxed, editor_command = check_arguments() + root_path, worker_count, is_sandboxed, editor_command = _check_arguments() subprocess.call(["sudo", "-p", "Vigil uses sudo... " "[sudo] password for %u: ", "true"]) with terminal.console_title("vigil: " + os.path.basename(root_path)):