diff --git a/eris/eris/__main__.py b/eris/eris/__main__.py index 28c3f43..c30e4f1 100755 --- a/eris/eris/__main__.py +++ b/eris/eris/__main__.py @@ -1014,8 +1014,8 @@ def on_filesystem_event(event, summary, root_path): fill3.APPEARANCE_CHANGED_EVENT.set() -async def main(root_path, worker_count=None, editor_command=None, theme=None, compression=None, - is_being_tested=False): +async def main(title, root_path, worker_count=None, editor_command=None, theme=None, + compression=None, is_being_tested=False): loop = asyncio.get_running_loop() if worker_count is None: worker_count = max(multiprocessing.cpu_count() - 1, 1) @@ -1043,7 +1043,7 @@ async def main(root_path, worker_count=None, editor_command=None, theme=None, co loop.create_task(worker_.future) try: if sys.stdout.isatty() or is_being_tested: - await fill3.tui(screen) + await fill3.tui(title, screen) log.log_message("Program stopped.") else: shutdown_event = asyncio.Event() @@ -1155,12 +1155,12 @@ def inotify_watches_exceeded(): def entry_point(): root_path, worker_count, editor_command, theme, compression = check_arguments() manage_cache(root_path) - with terminal.terminal_title("eris: " + os.path.basename(root_path)): - with chdir(root_path): # FIX: Don't change directory if possible. - try: - asyncio.run(main(root_path, worker_count, editor_command, theme, compression)) - except pyinotify.WatchManagerError: - inotify_watches_exceeded() + title = "eris: " + os.path.basename(root_path) + with chdir(root_path): # FIX: Don't change directory if possible. + try: + asyncio.run(main(title, root_path, worker_count, editor_command, theme, compression)) + except pyinotify.WatchManagerError: + inotify_watches_exceeded() if __name__ == "__main__": diff --git a/eris/tests/__main___test.py b/eris/tests/__main___test.py index f49e1c1..e1e8e94 100755 --- a/eris/tests/__main___test.py +++ b/eris/tests/__main___test.py @@ -202,7 +202,7 @@ class MainTestCase(unittest.TestCase): with __main__.chdir(root_path): loop = asyncio.get_event_loop() with contextlib.redirect_stdout(io.StringIO()): - loop.run_until_complete(__main__.main( + loop.run_until_complete(__main__.main("test", root_path, worker_count=2, is_being_tested=True)) for file_name in ["summary.pickle", "creation_time", "foo-metadata", "foo-contents"]: diff --git a/fill3/fill3/__init__.py b/fill3/fill3/__init__.py index cd1cd99..a1e33bc 100755 --- a/fill3/fill3/__init__.py +++ b/fill3/fill3/__init__.py @@ -452,16 +452,17 @@ def signal_handler(loop, signal_, func): loop.remove_signal_handler(signal_) -async def tui(screen_widget): +async def tui(title, screen_widget): global APPEARANCE_CHANGED_EVENT global SHUTDOWN_EVENT APPEARANCE_CHANGED_EVENT = asyncio.Event() SHUTDOWN_EVENT = asyncio.Event() loop = asyncio.get_running_loop() - with (signal_handler(loop, signal.SIGWINCH, lambda: draw_screen(screen_widget)), + with (terminal.title(title), signal_handler(loop, signal.SIGWINCH, lambda: draw_screen(screen_widget)), signal_handler(loop, signal.SIGINT, SHUTDOWN_EVENT.set), signal_handler(loop, signal.SIGTERM, SHUTDOWN_EVENT.set), - terminal.alternate_buffer(), terminal.interactive(), terminal.mouse_tracking()): + terminal.alternate_buffer(), terminal.interactive(), terminal.mouse_tracking() + ): update_task = asyncio.create_task(update_screen(screen_widget)) try: loop.add_reader(sys.stdin, on_terminal_input, screen_widget) @@ -498,4 +499,4 @@ class _Screen: if __name__ == "__main__": - asyncio.run(tui(_Screen())) + asyncio.run(tui("Hello World", _Screen())) diff --git a/fill3/fill3/terminal.py b/fill3/fill3/terminal.py index 01ca969..335e686 100644 --- a/fill3/fill3/terminal.py +++ b/fill3/fill3/terminal.py @@ -35,7 +35,7 @@ def move(x, y): @contextlib.contextmanager -def terminal_title(title): +def title(title): sys.stdout.write(ESC + "7") # save sys.stdout.write(f"\033]0;{title}\007") # set title try: