diff --git a/Makefile b/Makefile index 30169a46..080bced1 100644 --- a/Makefile +++ b/Makefile @@ -21,3 +21,4 @@ clean: $(PY_PREFIX)clean $(DZ_PREFIX)clean s: ./venv$(PYTHON_VERSION)/bin/runtimepy arbiter --curses \ ./local/arbiter/test.yaml + +@echo "success" diff --git a/local/arbiter/tasks/__init__.py b/local/arbiter/tasks/__init__.py index 747f9a69..05fad155 100644 --- a/local/arbiter/tasks/__init__.py +++ b/local/arbiter/tasks/__init__.py @@ -27,7 +27,18 @@ async def noop2(app: AppInfo) -> int: async def gui(app: AppInfo) -> int: """Run a channel GUI for application connections.""" - print(app) + window = app.tui.window + while not app.stop.is_set(): + data = window.getch() + if data != -1 and not await app.tui.handle_char(data): + # trigger this with 'q' + app.stop.set() + + # do stuff + + # make this updating a task + app.tui.tui_update() + await asyncio.sleep(0.1) return 0 diff --git a/local/arbiter/test.yaml b/local/arbiter/test.yaml index 0850be4d..5fd68013 100644 --- a/local/arbiter/test.yaml +++ b/local/arbiter/test.yaml @@ -16,4 +16,4 @@ tasks: app: # - [tasks.test, tasks.noop1, tasks.noop2] - - tasks.noop1 + - tasks.gui diff --git a/runtimepy/net/arbiter/base.py b/runtimepy/net/arbiter/base.py index 755632ed..8ab55b55 100644 --- a/runtimepy/net/arbiter/base.py +++ b/runtimepy/net/arbiter/base.py @@ -199,6 +199,7 @@ async def _entry( self._namespace, self.stop_sig, config if config is not None else self._config, + self, ) # Initialize tasks. diff --git a/runtimepy/net/arbiter/info.py b/runtimepy/net/arbiter/info.py index 2d7b0511..45b55cc6 100644 --- a/runtimepy/net/arbiter/info.py +++ b/runtimepy/net/arbiter/info.py @@ -19,6 +19,7 @@ # internal from runtimepy.net.connection import Connection as _Connection +from runtimepy.tui.mixin import TuiMixin ConnectionMap = _MutableMapping[str, _Connection] T = _TypeVar("T", bound=_Connection) @@ -48,6 +49,8 @@ class AppInfo: # Configuration data that may be specified in a configuration file. config: _JsonObject + tui: TuiMixin + def with_new_logger(self, name: str) -> "AppInfo": """Get a copy of this AppInfo instance, but with a new logger.""" @@ -58,6 +61,7 @@ def with_new_logger(self, name: str) -> "AppInfo": self.names, self.stop, self.config, + self.tui, ) def search(