diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-03 12:57:24 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-03 12:57:31 -0300 |
| commit | 32d3ec7ea8bda6afc8614a100dfdc7421ecf76be (patch) | |
| tree | 16a0ad8d535f3f80fb3f72f44d13eb5f497b267e /test | |
| parent | b421b07697cc4c9834e2db401ccf3083eab346ae (diff) | |
| download | pardes-32d3ec7ea8bda6afc8614a100dfdc7421ecf76be.tar.gz pardes-32d3ec7ea8bda6afc8614a100dfdc7421ecf76be.zip | |
fs: kbdin and mousein at the root, rio's and devmouse's (windows/rio/xfid.c:515, kernel/devices/mouse/devmouse.c:445): each rune written to kbdin is a key typed at the pane with the keyboard (control runes Ctrl and a letter but Plan 9's keys: \n Enter, \t Tab, \b Backspace, 0x7f Delete, 0x1b Esc, keyboard.h's private-use runes for the arrows, Home, End, Page Up and Down, Insert, F1-F12), a mousein line `m col row buttons` the mouse as it now is in cells (1 left, 2 middle, 4 right, 8 and 16 a wheel notch), what changed released, moved or pressed; each done before the write is answered, so a script's next read sees it with no sleep; the held buttons are core state, which a replica replays; test/fs.py's keys_and_mouse types, finds the word on /screen and right-clicks it, the first e2e case written through the files alone
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test')
| -rw-r--r-- | test/fs.py | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -1095,6 +1095,42 @@ def cut_writes(binary): assert (screen['cols'], screen['rows']) == (132, 40), (screen['cols'], screen['rows']) +def find_on_screen(client, word): + """Where `word` is drawn, as (col, row), off /screen: what a mousein + line clicks.""" + screen = client.screen() + cols = screen['cols'] + for row in range(screen['rows']): + line = ''.join(cell[0] or ' ' for cell in screen['cells'][row * cols:(row + 1) * cols]) + at = line.find(word) + if at >= 0: + return at, row + raise AssertionError((word, 'not on the screen')) + + +def keys_and_mouse(binary): + """kbdin and mousein: a script types and clicks as the user does, each + write done before it is answered, so no sleep or poll between a write + and the read that checks it; where to click is read off /screen.""" + with tempfile.TemporaryDirectory(prefix='pardes-kbd-') as directory: + root = Path(directory) + (root / 'target.txt').write_bytes(b'hello-target\n') + with session(binary, root, 'kbd') as (client, _): + serial = new_pane(client, b'see \n') + client.write('/focus', f'{serial}\n'.encode()) + client.write('/kbdin', 'Atarget.txt\x1b'.encode()) + assert client.read(f'/pane/{serial}/body') == b'see target.txt\n' + col, row = find_on_screen(client, 'target.txt') + client.write('/mousein', f'm {col + 2} {row} 4\nm {col + 2} {row} 0\n'.encode()) + opened = newest(client) + assert opened != serial and client.read('/index').splitlines()[-1].endswith(b'target.txt 1'), client.read('/index') + assert client.read(f'/pane/{opened}/body') == b'hello-target\n' + # Undone from the keyboard, as the user would: u in normal mode. + client.write('/focus', f'{serial}\n'.encode()) + client.write('/kbdin', b'u') + assert client.read(f'/pane/{serial}/body') == b'see \n' + + def edit_commands(binary): """Edit's `< | >` run off the loop and answer the write that ran them once applied; a failing one changes nothing and fails the write in its @@ -1207,6 +1243,7 @@ def edit_commands(binary): def test(binary, quic=False): started = time.monotonic() + keys_and_mouse(binary) cut_writes(binary) edit_commands(binary) odd_paths(binary) |
