diff options
| author | blasty <peter@haxx.in> | 2026-08-21 12:14:46 +0200 |
|---|---|---|
| committer | blasty <peter@haxx.in> | 2026-08-21 12:15:15 +0200 |
| commit | 02d02417800184fb76cd0245cdaa94c437aa4081 (patch) | |
| tree | 7589e6e2e8426bb7370fc56eee52d1559c9d7e57 /experiments/modal_shot.py | |
| parent | adopt ruff: pinned formatter + import sorting, opt-in pre-commit hook (diff) | |
| download | ida-tui-02d02417800184fb76cd0245cdaa94c437aa4081.tar.gz ida-tui-02d02417800184fb76cd0245cdaa94c437aa4081.tar.xz ida-tui-02d02417800184fb76cd0245cdaa94c437aa4081.zip | |
reformat: ruff format + import sort, mechanically (see ruff.toml)
No behavior. Listed in .git-blame-ignore-revs (next commit).
Diffstat (limited to 'experiments/modal_shot.py')
| -rw-r--r-- | experiments/modal_shot.py | 70 |
1 files changed, 42 insertions, 28 deletions
diff --git a/experiments/modal_shot.py b/experiments/modal_shot.py index 2e6cd7a..82f1e2f 100644 --- a/experiments/modal_shot.py +++ b/experiments/modal_shot.py @@ -11,6 +11,7 @@ IDA and no .i64 -- it runs under any python with textual, in about a second. The app it boots is a bare `App` carrying `IdaTui.CSS` and the app theme, which is exactly what the modals resolve their styles against. """ + import asyncio import os import sys @@ -18,16 +19,23 @@ import sys REPO = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.insert(0, REPO) -from textual.app import App, ComposeResult # noqa: E402 -from textual.widgets import Static # noqa: E402 +from textual.app import App, ComposeResult # noqa: E402 +from textual.widgets import Static # noqa: E402 -from idatui.app import ( # noqa: E402 - IDATUI_THEME, IdaTui, BusyScreen, ConfirmScreen, HelpScreen, LoadingScreen, - QuitScreen, StructEditor, XrefsScreen, +from idatui._sync import wait_for # noqa: E402 +from idatui.app import ( # noqa: E402 + IDATUI_THEME, + BusyScreen, + ConfirmScreen, + HelpScreen, + IdaTui, + LoadingScreen, + QuitScreen, + StructEditor, + XrefsScreen, ) -from idatui.domain import Struct # noqa: E402 -from idatui.rpc import screen_text # noqa: E402 -from idatui._sync import wait_for # noqa: E402 +from idatui.domain import Struct # noqa: E402 +from idatui.rpc import screen_text # noqa: E402 class _StubProgram: @@ -36,14 +44,15 @@ class _StubProgram: _STRUCTS = [ Struct(name="timespec", size=0x10, members=2, is_union=False, ordinal=1), Struct(name="stat", size=0x90, members=15, is_union=False, ordinal=2), - Struct(name="pthread_mutex_t", size=0x28, members=4, is_union=True, - ordinal=3), + Struct(name="pthread_mutex_t", size=0x28, members=4, is_union=True, ordinal=3), ] - _SRC = ("struct timespec\n" - "{\n" - " __time_t tv_sec; /* seconds */\n" - " __syscall_slong_t tv_nsec;\n" - "};\n") + _SRC = ( + "struct timespec\n" + "{\n" + " __time_t tv_sec; /* seconds */\n" + " __syscall_slong_t tv_nsec;\n" + "};\n" + ) def list_structs(self): return list(self._STRUCTS) @@ -57,8 +66,7 @@ def _make(name: str): if name == "structs": return StructEditor(_StubProgram()) if name == "confirm": - return ConfirmScreen("Delete struct 'timespec' ?", - "This cannot be undone.") + return ConfirmScreen("Delete struct 'timespec' ?", "This cannot be undone.") if name == "quit": return QuitScreen(["echo", "libc.so.6"]) if name == "help": @@ -68,10 +76,13 @@ def _make(name: str): if name == "loading": return LoadingScreen("echo", "opening database\u2026") if name == "xrefs": - return XrefsScreen(" xrefs to main", [ - (0x1234, " sub_2297+0x1c call main"), - (0x5678, " _start+0x21 mov rdi, main"), - ]) + return XrefsScreen( + " xrefs to main", + [ + (0x1234, " sub_2297+0x1c call main"), + (0x5678, " _start+0x21 mov rdi, main"), + ], + ) raise SystemExit(f"unknown modal {name!r}; --list to see them") @@ -84,8 +95,9 @@ class _Shot(App): def compose(self) -> ComposeResult: # A little content underneath, so the modal's edge is visible against # something rather than floating on an empty screen. - yield Static("\n".join(" .... the view behind the dialog ...." - for _ in range(60))) + yield Static( + "\n".join(" .... the view behind the dialog ...." for _ in range(60)) + ) def on_mount(self) -> None: self.register_theme(IDATUI_THEME) @@ -108,12 +120,14 @@ async def main() -> None: await pilot.pause() if name == "structs": await wait_for( - lambda: bool(getattr(app.screen, "_structs", None)), - pilot.pause, 5) + lambda: bool(getattr(app.screen, "_structs", None)), pilot.pause, 5 + ) app.screen.on_option_list_option_selected( - type("E", (), {"option_index": 0})()) - await wait_for(lambda: "{" in app.screen.query_one( - "#se-edit").text, pilot.pause, 5) + type("E", (), {"option_index": 0})() + ) + await wait_for( + lambda: "{" in app.screen.query_one("#se-edit").text, pilot.pause, 5 + ) await pilot.pause() print(f"\n=== {name} " + "=" * (cols - len(name) - 5)) print(screen_text(app)["text"]) |
