From c1990b3e6e196ad41379aa432bf3ccca8a65d9f0 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sun, 20 Sep 2026 00:36:50 -0300 Subject: Flatten the 9P control tree and move it out of fs.zig The served tree loses the self/ level: /index /ctl /new /log /screen /listeners /pane//... /os, with /src only in -Dembed-sources=true builds (default off, on for esp32p4). ctl speaks the editor's own language with two lowercase verbs, look TEXT and exec TEXT, plus acme's addr verbs; the new/ factory directory becomes one clone file; cons is gone (exec Msg); name and sel are files; stats report real lengths, modes and mtimes; /log streams pane new/del/rename/save events. The tree code lives in src/ninep/ (tree, pane, ctl, addr, pty, events, screen, sources); fs.zig keeps host access, mounts, resolution and find/grep. Same engine and transports. README (fs-help.txt) and docs rewritten; tests updated and extended. Co-Authored-By: Claude Fable 5.1 --- src/ninep/testing.zig | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 src/ninep/testing.zig (limited to 'src/ninep/testing.zig') diff --git a/src/ninep/testing.zig b/src/ninep/testing.zig new file mode 100644 index 00000000..ba26cb38 --- /dev/null +++ b/src/ninep/testing.zig @@ -0,0 +1,135 @@ +//! Test helpers shared by the control-tree modules: drive one request +//! through the core and collect the reply and the effects it raised. +const std = @import("std"); +const pardes = @import("../pardes.zig"); +const tree = @import("tree.zig"); + +const Pardes = pardes.Pardes; +pub const Req = tree.Req; +pub const Reply = tree.Reply; +pub const E = tree.E; + +pub const Answer = struct { + reply: Reply = .{ .tag = 0, .status = .err, .errno = E.IO }, + bytes: []const u8 = "", + saved: bool = false, + watch: ?bool = null, + pty_buf: [256]u8 = undefined, + pty_len: usize = 0, + winsize: ?struct { cols: u16, rows: u16 } = null, + signal: ?pardes.PtySignal = null, + spawned: bool = false, + + pub fn pty(a: *const Answer) []const u8 { + return a.pty_buf[0..a.pty_len]; + } + + pub fn errno(a: Answer) u16 { + return if (a.reply.status == .err) a.reply.errno else 0; + } +}; + +pub fn call(p: *Pardes, req: Req) Answer { + p.update(.{ .fs_req = req }); + var ans: Answer = .{}; + while (p.nextEffect()) |e| switch (e) { + .fs_reply => |r| { + ans.reply = r; + ans.bytes = p.fsPayload(r); + }, + .save_file, .save_text => ans.saved = true, + .watch => |w| ans.watch = w.on, + .write => |w| { + const b = w.bytes.slice(); + const n = @min(b.len, ans.pty_buf.len - ans.pty_len); + @memcpy(ans.pty_buf[ans.pty_len..][0..n], b[0..n]); + ans.pty_len += n; + }, + .resize_pty => |r| ans.winsize = .{ .cols = r.cols, .rows = r.rows }, + .signal_pty => |s| ans.signal = s.sig, + .spawn => ans.spawned = true, + else => {}, + }; + return ans; +} + +pub fn rd(p: *Pardes, node: u64, off: u64, size: u32) Answer { + return call(p, .{ .tag = 1, .op = .read, .node = node, .off = off, .size = size }); +} + +pub fn wr(p: *Pardes, node: u64, data: []const u8) Answer { + return call(p, .{ .tag = 2, .op = .write, .node = node, .data = data }); +} + +pub fn rdir(p: *Pardes, node: u64, skip: u64) Answer { + return call(p, .{ .tag = 4, .op = .readdir, .node = node, .off = skip, .size = 4096 }); +} + +pub fn look_up(p: *Pardes, dir: u64, name: []const u8) Answer { + return call(p, .{ .tag = 3, .op = .lookup, .node = dir, .data = name }); +} + +/// Opens /new once, as a client would, and returns the pane it made. +pub fn newPane(p: *Pardes) !u32 { + const new = @intFromEnum(tree.TopFile.new); + const opened = call(p, .{ .tag = 9, .op = .open, .node = new }); + if (opened.reply.status != .ok or opened.reply.handle == 0) return error.NoPane; + _ = call(p, .{ .tag = 9, .op = .release, .node = new, .handle = opened.reply.handle }); + return opened.reply.handle; +} + +pub fn withFile(gpa: std.mem.Allocator, text: []const u8) !*Pardes { + const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 }); + errdefer p.deinit(); + while (p.nextEffect()) |_| {} + _ = try p.setTestFile(text); + while (p.nextEffect()) |_| {} + return p; +} + +pub fn withTerm(gpa: std.mem.Allocator) !*Pardes { + const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 }); + errdefer p.deinit(); + while (p.nextEffect()) |_| {} + std.debug.assert(p.panes[0].?.isTerminal()); + return p; +} + +pub fn serialOf(p: *Pardes) u32 { + return p.panes[0].?.serial; +} + +pub const Dirent = struct { node: u64, dir: bool, name: []const u8 }; + +pub fn dirents(bytes: []const u8, out: []Dirent) []Dirent { + var n: usize = 0; + var i: usize = 0; + while (i + 10 <= bytes.len and n < out.len) { + const node = std.mem.readInt(u64, bytes[i..][0..8], .little); + const kind = bytes[i + 8]; + const len = bytes[i + 9]; + i += 10; + if (i + len > bytes.len) break; + out[n] = .{ .node = node, .dir = kind == 1, .name = bytes[i .. i + len] }; + i += len; + n += 1; + } + return out[0..n]; +} + +pub fn nameAt(list: []const Dirent, want: []const u8) ?Dirent { + for (list) |d| if (std.mem.eql(u8, d.name, want)) return d; + return null; +} + +pub const FakeTty = struct { + taken: bool, + + pub const vtable: pardes.Host.VTable = .{ .tty_taken = answer }; + + fn answer(ctx: ?*anyopaque, pane: u8) bool { + _ = pane; + const f: *FakeTty = @ptrCast(@alignCast(ctx.?)); + return f.taken; + } +}; -- cgit v1.3 From 9070942b29bd10dddcdecdb0e88ba0fb40608467 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 21 Sep 2026 20:07:43 -0300 Subject: Plan 9 idiom for the control filesystem, and the regressions a624a56 left The 9P tree stops being a command language wearing a filesystem. /new created a pane as a side effect of a *read*; it is now Tcreate in /pane, with Tremove to close, which cloud9's engine has always supported and the editor never declared: tree.zig now says `features = .{ .create = true, .remove = true }`. Eleven pane ctl verbs become files that can be read as well as written -- dot, limit, dirty, mark, scroll, look, exec -- leaving ctl with `get`, the one verb no file would say better. Root /ctl splits into a read-only /status and the /look and /exec files whose write IS the click. stat carries real sizes where it used to answer 0, and qid versions track a pane's revision, so a client can poll for change without re-reading the body. Commit a624a56 moved raw-tty keys to an early-return branch that knew only Ctrl-B and bare Escape, and in the same edit deleted the paste branch below it. That cost Shift-Escape (the unconditional way out of tty mode) and both paste chords: Ctrl-V and Ctrl-Shift-V reached the child as keystrokes, so an agent CLI running in a pane took Ctrl-V for its image-paste binding and answered "No image found in clipboard". Both are restored, with tests. Nested detection was not subtly broken but deleted: 60367d8 removed nested.zig's process-ancestry walk and left "am I inside pardes" derived from PARDES_FORWARD_LOOK, which read "0" both for --nested and for "the listener did not come up". PARDES_PID now answers that question on its own, checked with kill(pid, 0); PARDES_9P and PARDES_PANE answer how to reach it; the flag is gone. The posted-9P registry also self-heals now -- a session that aborts cannot unlink its own socket, so posting sweeps entries whose target refuses a connection, symlinks only and on a definite ECONNREFUSED only. Elsewhere: tty scrolling is sticky-bottom, following new output only from the last row, with typing and entering raw mode snapping back to live; the boot layouts are a Boot enum instead of a chain of ifs, and the bare tty startup (Boot.tty, which main.zig names) opens an empty text pane under the shell while tests keep Boot.tty_shell; builtins announce themselves on the message row under a Verbose setting that is on by default; Config prints each setting the way you would type it back, so WindowOpacity 70 rather than "WindowOpacity: 70%"; LocationsConfig opens its window only when called bare; every tagline puts the word that closes the thing last, and a column now outlives its panes -- closing the last one leaves an empty pane, and only Delcol, newly on the column tagline, takes the column away. Co-Authored-By: Claude Opus 5 (1M context) --- .agents/skills/pardes-9p/SKILL.md | 271 +++++++++++++++++++------------- docs/cloud9.md | 11 ++ docs/config.md | 18 ++- docs/design.typ | 31 ++-- docs/fs.md | 120 +++++++++----- docs/v9fs.md | 2 +- features.txt | 48 ++++++ src/9p_io.zig | 290 +++++++++++++++++++++++++++++++--- src/builtins.zig | 15 +- src/config.zig | 187 +++++++++++----------- src/fs-help.txt | 42 ++--- src/fs.zig | 11 +- src/host_io.zig | 3 + src/main.zig | 71 +++++++-- src/ninep/addr.zig | 16 +- src/ninep/ctl.zig | 319 ++++++++++++++++---------------------- src/ninep/events.zig | 15 +- src/ninep/pane.zig | 241 ++++++++++++++++++++++++---- src/ninep/pty.zig | 9 +- src/ninep/screen.zig | 25 ++- src/ninep/testing.zig | 29 +++- src/ninep/tree.zig | 207 ++++++++++++++++--------- src/panes.zig | 14 +- src/pardes.zig | 294 +++++++++++++++++++++++++++++------ src/tty/tty.zig | 31 ++++ src/tutor.txt | 21 +-- test/appearance_gallery.py | 14 +- test/column_tags.py | 4 +- test/e2e_harness.zig | 2 +- test/font_size.py | 6 +- test/fs.py | 134 +++++++++------- test/fs_bench.zig | 4 +- test/fs_namespace.zig | 15 +- test/fs_soak.py | 8 +- test/look_placement.py | 6 +- test/ninep.py | 19 +++ test/output.zig | 32 ++-- test/panes.zig | 76 ++++++++- test/pdf.zig | 2 +- test/tag_cleanup.py | 2 +- test/ui_review.py | 12 +- test/v9fs.py | 35 +++-- test/window_opacity.py | 2 +- 43 files changed, 1898 insertions(+), 816 deletions(-) (limited to 'src/ninep/testing.zig') diff --git a/.agents/skills/pardes-9p/SKILL.md b/.agents/skills/pardes-9p/SKILL.md index 09dee666..2cea4d4a 100644 --- a/.agents/skills/pardes-9p/SKILL.md +++ b/.agents/skills/pardes-9p/SKILL.md @@ -1,23 +1,127 @@ --- name: pardes-9p -description: Inspect and drive a running Pardes editor over 9P, or exercise its panes, builtins, terminal input and rendered output in an isolated session. Use for Pardes interaction, plugin development and end-to-end debugging through its control filesystem. +description: Inspect and drive a running Pardes editor through its control filesystem, or exercise its panes, builtins, terminal input and rendered output in an isolated session. Use for Pardes interaction, plugin development and end-to-end debugging. --- # Pardes over 9P -Use the existing [Python client](../../../test/ninep.py) for ad hoc interaction -and functional tests. Do not build another wire client. Project tooling stays -in Zig. Run the examples from the repository root; paths below are relative to -that root unless linked. +Pardes is driven by reading and writing files. Prefer ordinary file tools over +a mount; reach for the Python client only when nothing is mounted, or when the +work needs a fid held open. Do not build another wire client: project tooling +stays in Zig. Run the examples from the repository root; paths below are +relative to that root unless linked. -## Connect and identify panes +## Find the session through the mount -Every native session opens a Unix socket. Inside a pane, `PARDES_9P` names the -socket and `PARDES_PANE` is that pane's serial. Outside Pardes, find -`pardes-9p-*.sock` under `$XDG_RUNTIME_DIR`, or `~/.local/state/pardes` when -that variable is unset. Select the intended session explicitly; do not assume -the newest socket is the right one. Names come from `--9p=name`, the detached -session name, or the process ID. +This machine keeps a FUSE mount of every posted session under `/mnt/9p`: +`/mnt/9p/pardes//` is one session's served root. Inside a pane, +`$PARDES_9P` is that session's socket (`/run/user/1000/pardes-9p-.sock`), +so its pid is the directory to use, and `$PARDES_PANE` is the calling pane's +serial: + +```sh +m=/mnt/9p/pardes/$(basename "$PARDES_9P" .sock | sed 's/^pardes-9p-//') +cat "$m/index" +cat "$m/pane/$PARDES_PANE/body" +``` + +Entries for dead sessions stay listed and answer `Input/output error` on any +access, so name the session you mean rather than globbing or taking the newest. +`cat "$m/index"` is the cheapest liveness check, and `cat "$m/status"` reports +the `pid`, `version` and `panes` of a session new enough to serve it. + +`/mnt/9p/pardes` is the registry of posted sessions, mounted once for the +machine. It is not the per-pane kernel mount the `Tty9p` builtin makes, which +gives one pane's shell `$PARDES_MOUNT`; see [docs/v9fs.md](../../../docs/v9fs.md) +for that. Either mountpoint serves the same tree. + +A running session serves whatever binary started it. If a listing does not +match this document, that session predates the change; restart it. + +## The tree, and what to do with it + +``` +$m/README the served guide, worth reading first +$m/index one line per pane: serial, kind (text|term|pdf|image), dirty flag, name +$m/status pid, version, panes +$m/look write a line = a right click on it at the active pane +$m/exec write a line = a middle click: an editor command word, or a shell line +$m/log one record per read: new|del|rename|save ; reads park +$m/screen the rendered screen as JSON, frozen per open +$m/listeners this session's dial addresses +$m/pane/ mkdir opens a pane; rmdir closes it +$m/os/ the host filesystem +``` + +The first field of an index row is a stable pane serial, not a slot or row +number. A row is `serial kind dirty name`, so `row.split(maxsplit=3)` keeps a +name with spaces intact. Re-read the index after anything that might open, +reuse or close a pane. + +```sh +cat "$m/index" # which panes exist +mkdir "$m/pane/x"; n=$(awk 'END{print $1}' "$m/index") # open one, take its serial +printf 'text\n' > "$m/pane/$n/body" # append +cat "$m/pane/$n/tag" # what its tagline offers +echo notes.txt > "$m/pane/$n/name" # rename the buffer +echo Save > "$m/pane/$n/exec" # save it +echo "/etc/hosts:3" > "$m/look"; cat "$m/look" # open a file, see where it landed +rmdir "$m/pane/$n" # close it, dirty or not +``` + +The name `mkdir` asks for is ignored: a pane is named by the serial the editor +gives it, and because `/index` is ordered by serial its last row is the pane +just made. Nothing else in the tree can be created or removed, and no read +creates anything, so `ls`, `stat` and `find` over the whole tree are inert. + +`look` and `exec` are the editor's two clicks, one per line of a write, at the +active pane from the root and at that pane from `$m/pane//look` and +`$m/pane//exec`. Reading any of them answers the serials the last command +made, or the pane it focused or acted on. A command that fails is reported in +the editor, not as a write error, so inspect the resulting pane, index, message +or screen; only a malformed line fails the write itself. + +## Edit through addresses, dot and the flag files + +For a file or scratch pane, with `pane=$m/pane/`: + +| Operation | Shell | Python client | +|---|---|---| +| Read text | `cat $pane/body` | `client.read(pane + '/body')` | +| Append text | `echo text >> $pane/body` | `client.write(pane + '/body', b'text\n')` | +| Replace all text | `echo text > $pane/body` | `client.write(pane + '/body', b'text\n', truncate=True)` | +| Address a byte range | `echo '#0,#2' > $pane/addr` | `client.write(pane + '/addr', b'#0,#2')` | +| Replace that range | `echo 'pub fn' > $pane/data` | `client.write(pane + '/data', b'pub fn')` | +| Read the selection | `cat $pane/dot` (offsets), `cat $pane/sel` (text) | the same two reads | +| Select the addressed range | `cp $pane/addr $pane/dot` | `client.write(pane + '/dot', client.read(pane + '/addr'))` | +| Reload from disk | `echo get > $pane/ctl` | `client.write(pane + '/ctl', b'get\n')` | +| Close it | `rmdir $pane` | `client.remove(pane)` | + +`addr`, `dot` and `limit` each read the pair of offsets they also accept, which +is why copying one onto another is all that acme's `addr=dot`, `dot=addr` and +`limit=addr` ever were; a write may also be an address expression (`#0,#5`, +`/pattern/`, `2+1`). Moving `dot` scrolls the pane to it. `limit` bounds a +search and reads empty until set; truncate it to lift it. + +`dirty`, `mark` and `scroll` read `0` or `1` and take `0` or `1`: whether the +buffer differs from its file, whether a write pushes an undo point, and whether +a write scrolls. Truncating `tag` clears the part of the tag you may edit. + +Address state belongs to the pane, not to a client: opening `addr` resets it, +so two clients addressing the same pane will interfere. `$pane/ctl` reads +acme's window status line — serial, tag length, body length, a reserved zero, +the dirty flag, the width in cells, the font and the tab width — and takes the +one verb `get`. + +Terminal panes have no file: writing their `body` sends child input, and +truncation does not erase terminal history. + +## The Python client, for what a shell cannot express + +Use the existing [Python client](../../../test/ninep.py) when there is no +mount, or when the work needs a fid held open across several operations — +`log`, `event` and `pty/data` are consuming queues whose reads park, and shell +redirection cannot hold one open. ```sh PYTHONPATH=test python3 -B - "$PARDES_9P" <<'PY' @@ -25,103 +129,56 @@ import sys from ninep import Client with Client(sys.argv[1]) as client: - print(client.read('/self/index').decode(), end='') - print(client.read('/self/listeners').decode(), end='') + print(client.read('/index').decode(), end='') + print(client.read('/listeners').decode(), end='') PY ``` -`Client` takes a raw Unix socket path, or `(numeric_ip, port)` for TCP; it -does not parse Pardes dial strings or implement QUIC. It negotiates 9P2000, -uses a five-second socket timeout, and closes on leaving `with`. - -The first field of each index row is a stable pane serial, not a slot or row -number. The tag starts after five numeric fields; use `row.split(maxsplit=5)` -to preserve spaces. Inspect `/self/pane//tag`, `body`, or directory -entries before choosing a target. Re-read the index after actions that might -open, reuse or close panes. - -Wire paths start with `/self` or `/os`. `/n/self`, `/n/os`, `/n/peer` and -`/virtual` belong to editor Look paths, not the server root. For example, -Look `/virtual/src/pardes.zig` corresponds to reading `/self/src/pardes.zig`. - -## Edit, Look and execute - -For a file or scratch pane, with a connected `client` and a confirmed -`serial`, let `pane = f'/self/pane/{serial}'`. Terminal body writes instead -send child input; truncation does not erase terminal history. - -| Operation | Client call | -|---|---| -| Read text | `client.read(pane + '/body')` | -| Append text | `client.write(pane + '/body', b'text\n')` | -| Replace all text | `client.write(pane + '/body', b'text\n', truncate=True)` | -| Select a byte range | `client.write(pane + '/addr', b'#0,#2')` | -| Replace that range | `client.write(pane + '/data', b'pub fn')` | -| Show the addressed selection | `client.write(pane + '/ctl', b'dot=addr\n')` | -| Look from this pane | `client.write(pane + '/ctl', b'look /virtual/src/pardes.zig:10\n')` | -| Save | `client.write(pane + '/ctl', b'put\n')` | -| Reload | `client.write(pane + '/ctl', b'get\n')` | -| Close, refusing dirty text | `client.write(pane + '/ctl', b'del\n')` | - -`delete` force-closes, discarding unsaved text. `get` replaces edits with file -contents. Use those only when that loss is intended. Reading `/self/new/ctl` -creates a scratch pane and returns its serial as the first field; it is not -an observational read. - -`ctl` is not a builtin interpreter. Execute builtins through a body Exec event -on an owned scratch pane: - -```python -from fs import new_pane, execute - -control = new_pane(client, b'') -execute(client, control, 'Msg 9p-ready') -``` - -`execute` overwrites that pane's body with the command, then writes -`MX0 \n` to its `event` file. Keep the control pane separate -from user text. The same helper can run `Mini path`, `Mount peer dial`, and -`Unmount peer`; commands resolve relative to the control pane's directory. -A successful event write acknowledges dispatch, not completion: inspect the -resulting pane, message or screen for success. +`Client` takes a raw Unix socket path, or `(numeric_ip, port)` for TCP; it does +not parse Pardes dial strings or implement QUIC. It negotiates 9P2000, uses a +five-second socket timeout, and closes on leaving `with`. Its paths are the +served root: `/index`, `/pane/2/body`, `/os/...`. `/n/self`, `/n/os`, `/n/peer` +and `/virtual` are editor Look paths, not server paths — Look +`/virtual/src/pardes.zig` corresponds to reading `/src/pardes.zig`. -Opening `addr` resets its range. To inspect the current selection, open -`addr` first, write `addr=dot\n` to `ctl`, then use `read_fid` on that already -open handle. Do not replace that last step with `client.read`, which reopens -and resets it. Address state is shared by the pane, not private to a client. +For live terminal output or plugin events, use `open` / `read_fid` / `close`, +not the read-until-EOF helper. `pty/data` captures output while held open; it +is not a history replay. Both files are shared, consuming queues, not +per-client broadcasts, so a slow reader loses older data. Holding `event` open +intercepts that pane's Look and Exec clicks, so it is not a passive logger: for +Look/Exec records whose offsets identify the intended text, forward the short +record ` \n`, not the whole report with flags and text. +Expansion and chord reports need explicit handling, and terminal-body events +can carry text only in the report, which a short writeback cannot reproduce. +Read the event implementation before building an interceptor. Close handles in +`finally`, and disconnect after a socket timeout. The service shares four +connection slots and 32 screen/terminal-history snapshot handles. + +A file's qid version is the pane's revision for `body`, `data` and `xdata`, so +`stat` sees an edit land without reading the text; it stays zero elsewhere. +Stat sizes are real, and for `log`, `event` and `pty/data` report the length of +the record a read would answer — zero when nothing is waiting. ## Terminal input and screen observations Only terminal panes have `pty/`. Write keystroke bytes to `pty/data`, not `body`: `client.write(pane + '/pty/data', b'printf hello\r')` submits a shell -command. For an interactive application, send its actual input bytes; -`b'\x03'` is Ctrl-C, and Ctrl-U is `b'\x15'` where that application supports it. -These inputs go to the child terminal, not Pardes editor key bindings. +command. For an interactive application, send its actual input bytes; `b'\x03'` +is Ctrl-C, and Ctrl-U is `b'\x15'` where that application supports it. These go +to the child terminal, not to Pardes key bindings. `pty/ctl` takes `winsize C R`, +`sig INT` and `exec`, one per line. -`client.screen()` returns `cols`, `rows`, `cursor`, `styles`, and row-major +`client.screen()` returns `cols`, `rows`, `cursor`, `styles` and row-major `cells` of `[grapheme, style_index]`. Reconstruct rows using `cols`; resolve -each cell's style through `styles` when checking highlighting. Compare colors -and attributes, not just style-table indices or flattened text. +each cell's style through `styles` when checking highlighting, and compare +colors and attributes rather than style-table indices or flattened text. -Each screen open freezes one frame. A terminal `body` freezes history on its -first read. `client.read` and `client.screen` reopen each time; use repeated -calls for fresh observations. Do not poll a stale handle. Poll a specific -condition with a deadline and a short delay, rather than a fixed long sleep. -For large histories, measure whole-body reads separately from screen polling; -9P write-to-observation timing includes RPC, rendering and polling overhead. - -For live terminal output or plugin events, use `open` / `read_fid` / `close`, -not the read-until-EOF helper. `pty/data` captures output while held open; -it is not a history replay. Both files are shared, consuming queues, not -per-client broadcasts; slow readers can lose older data. Holding `event` open -intercepts Look/Exec clicks, so it is not a passive logger. For Look/Exec -records whose offsets identify the intended file/tag text, forward the short -record ` \n`, not the entire report with flags and text. -Expansion/chord reports need explicit handling; terminal-body events can have -empty ranges with text carried only in the report, so short writeback cannot -reproduce them. Read the event implementation before building an interceptor. -Close handles in `finally`; disconnect after a socket timeout. The service -shares four connection slots and 32 screen/terminal-history snapshot handles. +Each screen open freezes one frame, and a terminal `body` freezes its history +on its first read. `client.read` and `client.screen` reopen each time, so +repeat the call for a fresh observation rather than polling a stale handle. +Poll a specific condition with a deadline and a short delay, not a fixed long +sleep. For large histories, measure whole-body reads separately from screen +polling; write-to-observation timing includes RPC, rendering and polling. ## Exercise an isolated session @@ -140,22 +197,23 @@ binary = str(Path(sys.argv[1]).resolve()) with tempfile.TemporaryDirectory(prefix='pardes-9p-skill-') as directory: with session(binary, Path(directory), 'skill') as (client, address): serial = new_pane(client, b'fn main() void {}\n') - pane = f'/self/pane/{serial}' - client.write(pane + '/ctl', b'name probe.zig\n') + pane = f'/pane/{serial}' + client.write(pane + '/name', b'probe.zig\n') client.write(pane + '/addr', b'#0,#2') client.write(pane + '/data', b'pub fn') assert client.read(pane + '/body') == b'pub fn main() void {}\n' - control = new_pane(client, b'') - execute(client, control, 'Msg 9p-ready') + execute(client, serial, 'Msg 9p-ready') frame = client.screen() assert '9p-ready' in ''.join(cell[0] for cell in frame['cells']) print('9P edit, builtin and screen checks passed') PY ``` -For terminal tests, use `session(..., tty=True)` and read +`new_pane` is `mkdir` plus a read of the index; `execute` writes one line to a +pane's `exec`. Both are in `test/fs.py`. For terminal tests, use +`session(..., tty=True)` and read [test/agent_session.py](../../../test/agent_session.py) for bounded interactive -driving. Its readiness text and history threshold are application-specific; +driving; its readiness text and history threshold are application-specific, and session cleanup alone does not guarantee arbitrary grandchildren have exited. Use [test/snapshot.zig](../../../test/snapshot.zig) when editor key/mouse input or an independent terminal-rendering comparison matters; 9P screen inspection @@ -163,6 +221,7 @@ alone does not test physical input routing or the host renderer. Read [docs/fs.md](../../../docs/fs.md) for runtime mounts, TCP/QUIC listeners, Plan9port and Linux v9fs compatibility. Unix is always available; network -listeners are opt-in and grant full session/OS-file access. Use isolated -loopback listeners for tests. For less common control verbs or event details, -read their implementation and tests in [src/fs.zig](../../../src/fs.zig). +listeners are opt-in and grant full session and OS-file access, so use isolated +loopback listeners for tests. For event details or anything this page leaves +open, read the implementation and its tests in +[src/ninep/](../../../src/ninep/). diff --git a/docs/cloud9.md b/docs/cloud9.md index 79fda717..d030db1d 100644 --- a/docs/cloud9.md +++ b/docs/cloud9.md @@ -54,6 +54,17 @@ way a private `ZMX_DIR` does for zmx. Stopping unposts, and only while the entry is still ours, so a name another editor has since claimed is never unlinked. +An exit that cannot run any code of its own — an aborted test, a kill, a +crash — leaves its entry and its socket behind, so posting first sweeps the +group: every entry that is a symlink and whose socket answers a connect with +a definite ECONNREFUSED is unlinked, along with the socket it points at when +a `stat` agrees that is a socket of ours. Anything that is not a symlink is +somebody else's, and any other answer — connected, busy, refused permission, +a surprise — counts as live, because uncertainty belongs to the server that +owns the socket rather than to the sweeper. That is `cloud9.post.Probe`'s +classification, repeated in `src/9p_io.zig` only because `post.probe` is raw +Linux syscalls and pardes also builds for darwin. + **Consuming.** Nothing. `9ns --mntgen` mounts the whole registry at `/mnt/9p`, and an interactive fish already self-wraps in one, so a pardes started from a terminal sees every posted service as ordinary files — diff --git a/docs/config.md b/docs/config.md index a55aef1c..04b0fd82 100644 --- a/docs/config.md +++ b/docs/config.md @@ -111,6 +111,10 @@ Workspace, column and pane command text can be edited directly; see `ColumnTags` toggles the column command row in both GUI and TTY; it is on by default. Add `ColumnTags` to startup configuration to reclaim that row on a compact screen. Hiding it preserves your custom column commands. +`Verbose` toggles the message-row announcement every builtin makes of its own +name before it runs; it is on by default, and the builtins that own the message +row themselves (`Msg`) never announce. Turning it off leaves the row to the +messages a builtin chooses to write. `SyntaxBold` toggles bold syntax keywords; it is off by default. These settings are shared by GUI and TTY, and `Config` reports their current states. Like `Colors` and `Wrap`, these commands take no argument and invert @@ -334,10 +338,16 @@ The installed `pardes-v9fs` helper lives beside the editor; development builds can set `PARDES_V9FS_HELPER` to its absolute path. See [v9fs.md](v9fs.md). Ctrl-B switches between raw TTY and editor mode. Plain Escape at a detected -shell prompt hops back to the previous pane. Other keys, including Ctrl-O, Ctrl-W, -paste shortcuts, and modified Escape belong -to the child. Use `Mode` in the pane tag to return to editor -mode in place. Desktop paste events still feed the terminal. +shell prompt hops back to the previous pane. Other keys, including Ctrl-O, +Ctrl-W and modified Escape, belong to the child. Use `Mode` in the pane tag to +return to editor mode in place. Desktop paste events still feed the terminal. + +The paste chords are the exception the window keeps. Ctrl-V types the yank +register at the program, and Ctrl-Shift-V asks the desktop for its clipboard +and types that; both go through the program's bracketed paste when it has +asked for one. Neither reaches the child as a keystroke, so an application +that would otherwise answer Ctrl-V by reading the system clipboard itself +never gets the chance to read the wrong thing. `Font` and `FontSel` exist ONLY in the SDL GUI and native macOS builds — a terminal's font belongs to its emulator and a browser's to the page — so a diff --git a/docs/design.typ b/docs/design.typ index 4c8956ba..f8f0b05c 100644 --- a/docs/design.typ +++ b/docs/design.typ @@ -1492,15 +1492,20 @@ same thread as editing. == Nested Look -Pane shells inherit `PARDES_9P`, `PARDES_PANE` (the pane serial), and -`PARDES_FORWARD_LOOK`. A child launch resolves its OS-relative argument in -the child's working directory, then writes `look ` to the parent's -`self/pane//ctl`. Explicit `/virtual` and `/n` paths resolve in the -parent. The ordinary filesystem update performs layout and drains host effects. - -`--nested` starts a separate editor and disables forwarding from its direct -pane shells. Its 9P socket remains available for control and plugins. There is -no executable-name discovery or separate Look listener. +Pane shells inherit `PARDES_PID` (the editor's process id), `PARDES_9P` and +`PARDES_PANE` (the pane serial). The first answers whether the shell is inside +a pardes at all, the other two answer how to reach it, and they are separate +because a session whose listener never came up still owns its children. A child +launch that finds a live `PARDES_PID` and no way to reach it says so instead of +starting a second editor. Otherwise it resolves its OS-relative argument in the +child's working directory, then writes `look ` to the parent's +`pane//ctl`. Explicit `/virtual` and `/n` paths resolve in the parent. +The ordinary filesystem update performs layout and drains host effects. + +`--nested` starts a separate editor and withholds `PARDES_PID` from its direct +pane shells, which is the whole of the opt-out. Its 9P socket remains available +for control and plugins, so those shells still get `PARDES_9P` and +`PARDES_PANE`. There is no executable-name discovery or separate Look listener. Detached frontends use `pardes-detached-.sock` in the same runtime directory. The shared Unix socket conventions live in `src/9p_io.zig`. @@ -1928,9 +1933,11 @@ arrives bracketed, as one `paste` event. staged edits: Enter commits a new buffer save target, Escape cancels, and no disk rename or write happens until explicit Save. Terminal cwd and image/PDF status stay generated. Save leads the tail of every pane holding text of its own: -`Save Tty Del Collapse` for a file or an output buffer, -`Save Tty Del Togglettymode Filter Collapse` for a terminal, and `Tty Del Collapse` -for an image. PDFs use `Tty Del PdfSections PdfTint Collapse`, without tint status text. +`Save Tty Collapse Del` for a file or an output buffer, +`Tty Save Mode Filter Collapse Del` for a terminal, and `Tty Collapse Del` +for an image. PDFs use `Tty PdfSections PdfTint Collapse Del`, without tint status text. +The word that closes the thing is last on every tagline, so overshooting the +click before it cannot destroy anything. `Collapse` toggles a pane between its tagline alone and its expanded height; hidden body contents and running terminals are retained. An unsaved file has `*` after its name; an image tag diff --git a/docs/fs.md b/docs/fs.md index 55ffdc9c..0bcc0313 100644 --- a/docs/fs.md +++ b/docs/fs.md @@ -1,14 +1,19 @@ # Filesystem Every native session serves 9P2000 on a Unix socket. Pane shells receive -`PARDES_9P` (socket path) and `PARDES_PANE` (pane serial). The socket is +`PARDES_PID` (the editor's process id), `PARDES_9P` (socket path) and +`PARDES_PANE` (pane serial). The socket is `$XDG_RUNTIME_DIR/pardes-9p-.sock`, or lives under `~/.local/state/pardes` when XDG_RUNTIME_DIR is unset. Detached sessions use their session name; `--9p=` overrides it. A `pardes ` launched from a pane forwards Look to that pane over 9P. -`--nested` opens a separate editor and disables forwarding from its pane shells; -its 9P service stays available. +`PARDES_PID` alone says the shell is inside pardes; `PARDES_9P` and +`PARDES_PANE` say how to reach it, and a launch that has the first without the +other two refuses rather than opening a second editor. `--nested` opens a +separate editor and withholds `PARDES_PID` from its pane shells, so a pardes +started in one of them runs a session of its own; its 9P service stays +available. Look resolves the OS filesystem first, then the editor's virtual filesystem. Explicit paths bypass that search: @@ -68,53 +73,79 @@ Existing Plan9port/v9fs clients need a userspace bridge for QUIC. ``` /README this guide, also src/fs-help.txt /index one line per pane: serial, kind (text|term|pdf|image), dirty flag, name -/ctl write: one command per line; read: the serials the last command made or touched -/new reading it creates one empty pane and answers "\n" (the /net/tcp/clone idiom) +/status pid, version and pane count +/look write a line: a right click on it at the active pane; read: the serials it touched +/exec write a line: a middle click; read the same serials /log one line per editor event: new|del|rename|save ; reads park /screen rendered screen JSON; frozen per open handle /listeners the session's dial addresses -/pane// name body tag ctl addr data xdata sel errors event, plus pty/{ctl,status,data} +/pane/ create a directory here to open a pane; remove one to close it +/pane// name body tag ctl addr dot limit data xdata sel dirty mark scroll + errors event look exec, plus pty/{ctl,status,data} on terminals /os/ the host filesystem /src/ the editor's embedded sources, only when built with -Dembed-sources=true ``` -Nothing in the tree is created by list, stat, walk or read, except that -reading `/new` makes a pane; that is its whole purpose, so a recursive read -of the tree makes one pane per open of it. - -`/ctl` and `/pane//ctl` take the editor's own command language, two verbs: - -- `look TEXT` is a right click on `TEXT`: a path opens a file, `file:12` jumps - to a line, a directory opens a shell there, a URL opens in the browser. From - `/ctl` the look happens at the active pane; from a pane's `ctl` at that pane. -- `exec TEXT` is a middle click: a command word from `src/builtins.zig` - (`Save`, `Del`, `New`, `Newcol`, `Mount NAME DIAL`, `Unmount NAME`, `Dump`, - `Restore`, `Msg TEXT`, `Find`, `Grep`, `Tty`, ...), or anything else, which - runs in the pane's terminal. - -Both verbs are lowercase; the words after `exec` are the editor's capitalized -commands. A pane's `ctl` also keeps acme's addr verbs (`addr=dot`, `dot=addr`, -`limit=addr`, `clean`, `dirty`, `cleartag`, `get`, `mark`, `nomark`, -`noscroll`, `scroll`, `show`). Every line of a write is checked before any -line runs; a malformed line fails the write with EINVAL. A command that fails -inside the editor is reported on the message row, not as a write error. - -After a write to either `ctl`, reading `/ctl` answers the serials of the panes -the command created, or, when it created none, the pane a look focused or the -pane an exec acted on (even one it closed), one per line. Before any command it answers `pid`, `version` and `panes` lines. +Nothing in the tree is created by list, stat, walk or read. A pane is opened +by Tcreate in `/pane` (`mkdir`) and closed by Tremove on `/pane/` (`rmdir`), +which is the only create and the only remove the tree serves. The name a +create asks for is ignored, since a pane is named by the serial the editor +gives it: the Rcreate qid names the new directory, and because `/index` is +ordered by serial its last line is the pane just made. + +`/look` and `/exec` are the editor's two clicks, one per line of a write: + +- a line written to `look` is a right click on it: a path opens a file, + `file:12` jumps to a line, a directory opens a shell there, a URL opens in + the browser. +- a line written to `exec` is a middle click: a command word from + `src/builtins.zig` (`Save`, `Del`, `New`, `Newcol`, `Mount NAME DIAL`, + `Unmount NAME`, `Dump`, `Restore`, `Msg TEXT`, `Find`, `Grep`, `Tty`, ...), + or anything else, which runs in the pane's terminal. + +The root's pair clicks at the active pane and `/pane//look` and +`/pane//exec` at that pane. Blank lines are skipped, and every other line +is checked before any of them runs, so a control character fails the whole +write with EINVAL; a command that fails inside the editor is reported on the +message row, not as a write error. Reading any of these files answers the +serials of the panes the last command created, or, when it created none, the +pane a look focused or the pane an exec acted on (even one it closed), one +per line. `/pane//name` reads the pane's file name (a terminal's directory) and writing it renames the buffer; a relative name resolves against the pane's -directory. `sel` reads the editor selection and writing it replaces the -selection. `body` appends on write and replaces on truncating open. `addr` -selects a range and `data` or `xdata` read or replace it. `errors` appends to -the directory's `+Errors` pane. Holding `event` open redirects the pane's Look -and Exec clicks to that client; writing a record back performs the action. - -Stats report real lengths for `index`, `ctl`, `name`, `body`, `tag` and `sel`, -modes 0644/0666 (0444 for read-only files, 0222 for write-only), the pane's -last edit time or the process start as mtime, and stable qids. Directory -entries carry no sizes; stat the entry. +directory. `body` appends on write and replaces on truncating open. `sel` +reads the selected text and writing it replaces the selection. `errors` +appends to the directory's `+Errors` pane. Holding `event` open redirects the +pane's Look and Exec clicks to that client; writing a record back performs the +action. `ctl` reads acme's window status line — serial, tag length, body +length, a reserved zero, the dirty flag, the width in cells, the font and the +tab width — and takes one verb, `get`, which reloads the buffer from the name +it carries. + +The three range files `addr`, `dot` and `limit` each read the pair of offsets +they also accept, so copying one onto another is all that acme's `addr=dot`, +`dot=addr` and `limit=addr` ever were. A write is either that pair or an +address expression (`#0,#5`, `/pattern/`, `2+1`); `addr` selects what `data` +and `xdata` read or replace, `dot` is the editor's own selection and moving it +scrolls the pane into view, and `limit` bounds a search and reads empty until +it is set. Truncating a range file empties it; truncating `limit` lifts it. + +The three flag files `dirty`, `mark` and `scroll` read `0` or `1` and take +`0` or `1`: whether the buffer differs from its file, whether a write pushes +an undo point (writing `1` pushes one now), and whether a write scrolls the +pane. Truncating `tag` clears the part of the tag you may edit. + +Stats report real lengths for `index`, `status`, `look`, `exec`, `listeners`, +`name`, `body`, `tag`, `sel`, `ctl`, the range files and the flag files, and +for `log`, `event` and `pty/data` the length of the record a read would +answer, which is zero when nothing is waiting. Modes are 0644/0666 (0444 for +read-only files, 0222 for write-only); mtime is the pane's last edit or the +process start. The qid version of `body`, `data` and `xdata` is the pane's +revision, so a stat sees an edit land without reading the text; every other +file leaves it zero rather than promise a version it cannot keep. Directory +entries carry no sizes, and neither does `/screen`, which has no length until +an open renders its frame; stat the entry. `/log` records `new`, `del`, `rename` and `save` while at least one client holds it open; a read parks until a record arrives. `/screen` returns JSON with @@ -132,8 +163,10 @@ enables the option by default, so the device can serve its own source. This is a control filesystem, not a complete POSIX export. Native filenames may contain up to 255 bytes. Existing regular OS files support read, write, -and truncation to zero; protocol create, remove, rename, and other metadata -changes are refused. Ownership and permissions under `/os` are synthetic. +and truncation to zero; under `/os` protocol create, remove, rename and other +metadata changes are refused, as is every create and remove in the control +tree but the pane directories. Ownership and permissions under `/os` are +synthetic. Zero-length truncation accepts the accompanying `mtime` hint sent by Linux v9fs; the hint is not stored. Standalone timestamp changes remain refused. @@ -148,7 +181,8 @@ for Unix and TCP, a poll loop for QUIC, and the 9P client for mounts); `zig build fs-test` drives real sessions using the independent Python client in `test/ninep.py`; `zig build fs-discovery-test` checks that browsing creates -nothing and that `new`, `ctl`, `name`, `sel` and `log` behave. `zig build +nothing, that a pane create and remove work, and that `look`, `exec`, `name`, +`sel` and `log` behave. `zig build 9p-test` checks the two engine configurations' budgets (the engine's own tests are cloud9's `zig build test`); `zig build fs-bench` measures filesystem transactions in the core. diff --git a/docs/v9fs.md b/docs/v9fs.md index 6cb4e998..8cc97ff9 100644 --- a/docs/v9fs.md +++ b/docs/v9fs.md @@ -12,7 +12,7 @@ ls "$PARDES_MOUNT/pane" cat "$PARDES_MOUNT/index" cat "$PARDES_MOUNT/README" cat "$PARDES_MOUNT/pane/$PARDES_PANE/body" -echo 'exec Msg hello' > "$PARDES_MOUNT/ctl" +echo 'Msg hello' > "$PARDES_MOUNT/exec" ``` The mount belongs to that pane's subprocess tree. Other panes and the editor diff --git a/features.txt b/features.txt index 3bfc6967..bee079a7 100644 --- a/features.txt +++ b/features.txt @@ -20,3 +20,51 @@ on tty mode the mouse selection works but the pardes selection on that pane shou between tty panes without changing the pardes semantics or adding anything extra, just neat tricks like this. Still, you might need to come up with something to decrease the number of movements/interactions needed to do simple things like copy and pasting text from a terminal to another. + +The 9p protocol needs to be simplified and made plan9 idiomatic. Stop leaning on ctl verbs: a name should be the operation. The filesystem should carry more +in stat metadata (real sizes, mtimes, qid versions so a client can poll for change cheaply) and use the real 9P operations for what is currently a ctl verb or a +magic read. cloud9's engine already exposes fs.Features{create, remove, wstat} and the editor backend simply never declared them, so /new creating a pane on +*read* becomes a Tcreate in /pane, del becomes Tremove, cleartag becomes a truncating write to tag, and clean/dirty, scroll/noscroll, mark/nomark and +addr=dot/dot=addr/limit=addr become their own files. What is left of ctl should be only the verbs with no file analog. + +shift-esc stopped leaving raw tty mode on the sdl backend. Commit a624a56 moved raw tty keys to an early-return branch that only knew ctrl-B and bare Esc, so +shift-esc was forwarded to the child instead. It is the unconditional way out of tty mode and should stay that way. + +On tty mode scrolling should work and not always move the focus down to follow a new line. The terminal only moves down to follow new output when the last line +is already at the bottom, like most terminals and editors. Typing and entering raw mode snap back to live output, so nobody types blind. + +The different kinds of layout pardes can initialize (tty mode, file mode, the classic three-shell boot, and the others that already exist) should be an explicit +enum rather than a chain of ifs over tty_only/shells/file/missing. That part of the code needs to be more explicit. The bare tty startup should always start with +an empty text pane at the bottom, not focused. + +Nested pardes detection stopped working. Spawning a subprocess should export an env variable holding the pardes pid, so a child can see it and call a Look on the +parent through the 9p mount instead of starting a second session; whether 9p is mounted is another env variable the child can check. + +Builtins should call Msg with the builtin name when they are called, minus a few exceptions like Msg itself. This is gated on a verbose config that is on by +default and can be turned off. + +The sr.ht upstream has a macos update pushed to it. Pull it, merge it into the tip here as its own change, then look at what the macos backend gained and port +those features to the sdl backend wherever it makes sense. + +Config options should print symmetrically with the way they are set: instead of showing transparency with a colon and a percent sign it should read like +`Etcetera 70`, exactly what you would type to set it, and the same for every other setting. LocationsConfig should only open an output window with the current +config when it is called with no arguments. + +Closing the last pane in a column should not delete the column: it should leave a new empty pane there instead. A column closes only when it is closed explicitly, +so if there is no builtin for that, add a Delcol that sits on the column tagline by default. And in every tagline the builtin that kills or closes the thing should +come last, which does not look like the case for panes right now. + +Pasting regressed on the terminal: inside agent sessions text is being pasted as an image and simply does not work. Reproduce it first, then fix it. + +The 9p skill documentation should teach interacting with a running pardes through the /mnt/9p mount with ordinary file tools — cat, echo, ls — as the normal +ad-hoc path, and fall back to the python client only when nothing is mounted. + +Dead sessions are never removed from the posted-9P registry, which is a bug. A session that aborts or is killed leaves both its socket in $XDG_RUNTIME_DIR and its +symlink under the registry directory, so /mnt/9p/pardes lists entries that give Input/output error on access. postToRegistry only ever replaces its own name's +entry; nothing sweeps the rest. Posting should sweep the service directory and unlink every entry whose target refuses a connection, and the dangling socket with +it. cloud9 already classifies a refused connect as stale (post.zig Probe), and 9p_io.zig already has `alive`, which treats uncertainty as live -- that is the right +bias, so only a definite refusal reaps. + +After all of the above, do an optimization pass on startup time for the gui and tty platforms: measure first, then optimize. build.zig already has a `perf` step +(gesture latency and bounded terminal stress, with --json and a --base baseline to compare against), so a startup measurement belongs there rather than in a new +harness, and the baseline files are how a regression gets caught later. diff --git a/src/9p_io.zig b/src/9p_io.zig index 4f7c2e97..3d019e0d 100644 --- a/src/9p_io.zig +++ b/src/9p_io.zig @@ -596,7 +596,7 @@ pub const Listener = struct { } for (l.control) |fd| { setCloexec(fd); - setNonblock(fd); + _ = setNonblock(fd); } l.arm(); l.watcher = try std.Thread.spawn(.{}, watchQuic, .{l}); @@ -671,6 +671,7 @@ pub const Listener = struct { log.warn("registry post skipped: cannot create {s}", .{svc}); return; } + sweepRegistry(l.io, svc); var entry_buf: [sun_path_len:0]u8 = undefined; const entry = std.fmt.bufPrintSentinel(&entry_buf, "{s}/{s}", .{ svc, name }, 0) catch { log.warn("registry post skipped: name too long: {s}", .{name}); @@ -679,15 +680,15 @@ pub const Listener = struct { const target = l.path_buf[0..l.path_len]; // Replace only what is provably not live: our own entry, or a - // dead predecessor's symlink. `isListening` treats uncertainty - // as live, so it is only asked about an entry that *is* a - // symlink; anything else is left strictly alone and the - // symlink below simply fails. + // dead predecessor's symlink. `probe` treats uncertainty as + // live, so it is only asked about an entry that *is* a symlink; + // anything else is left strictly alone and the symlink below + // simply fails. var link_buf: [sun_path_len]u8 = undefined; const n = libc.readlink(entry, &link_buf, link_buf.len); if (n >= 0) { const had = link_buf[0..@intCast(n)]; - if (!std.mem.eql(u8, had, target) and alive(entry)) { + if (!std.mem.eql(u8, had, target) and probe(entry) == .live) { log.warn("registry entry pardes/{s} is live; not re-posted", .{name}); return; } @@ -842,12 +843,129 @@ pub fn listen(io: std.Io, gpa: std.mem.Allocator, named: []const u8, fallback: [ const alive = transport.isListening; -fn setNonblock(fd: c_int) void { +/// What is at a socket path, in cloud9's three answers (`post.Probe`). +/// Asked here with libc rather than through `cloud9.post.probe`, whose +/// raw Linux syscalls darwin cannot compile, but the classification is +/// that file's and must not become a second opinion: the one definite +/// refusal is `.stale`, nothing at the path at all is `.none`, and +/// everything else — connected, busy, refused permission, a surprise — +/// is `.live`. Uncertainty belongs to the server that owns the socket, +/// never to a sweeper deciding what to delete. +const Probe = enum { none, stale, live }; + +/// `SOCK.STREAM`, and the kernel's own non-blocking bit where there is +/// one. Darwin's `SOCK.NONBLOCK` is a Zig shim for `std.posix.socket` +/// to unpack, not an ABI value, so handing it to the raw libc call +/// would ask a kernel that has never heard of it; there it is an +/// `fcntl` instead. +const probe_socket_kind: c_uint = libc.SOCK.STREAM | (if (darwin) 0 else libc.SOCK.NONBLOCK); + +fn probe(path: [:0]const u8) Probe { + if (path.len + 1 > sun_path_len) return .live; // cannot ask; assume occupied + var addr: libc.sockaddr.un = .{ .path = @splat(0) }; + @memcpy(addr.path[0 .. path.len + 1], path[0 .. path.len + 1]); + const fd = libc.socket(libc.AF.UNIX, probe_socket_kind, 0); + if (fd < 0) return .live; + defer _ = libc.close(fd); + + // Non-blocking is the whole safety of this function, so it is read + // back rather than assumed: a BLOCKING connect to a live server + // whose backlog is full parks in the kernel with no timeout to end + // it — measured, it simply never returns — and a sweep that parks + // takes the editor's startup with it. An fd that cannot be proven + // non-blocking is never connected at all, which lands on `.live`, + // the answer that deletes nothing. + if (comptime darwin) _ = setNonblock(fd); + if (!isNonblocking(fd)) return .live; + + if (libc.connect(fd, @ptrCast(&addr), @sizeOf(@TypeOf(addr))) == 0) return .live; + // cloud9's `post.probe` mapping, answer for answer. The connection + // is never wanted: EAGAIN (a full Unix backlog) and EINPROGRESS say + // somebody is listening, which is all that was asked, and the fd + // closes without ever waiting for it to become writable. + return switch (libc.errno(-1)) { + .AGAIN, .INPROGRESS, .PERM, .ACCES => .live, + .CONNREFUSED => .stale, + .NOENT, .NOTDIR => .none, + else => .live, + }; +} + +/// Reaps the registry entries whose editor is gone, once per post. +/// +/// A clean exit unposts itself (`unpostFromRegistry`), so everything +/// left behind comes from an exit that could not: an aborted test, a +/// kill, a crash. No code in the dead process can ever run, so the cure +/// has to be somebody else's readdir, and the next editor to start is +/// the somebody. It is only ever a symlink that is followed or +/// unlinked, because that is the only thing `postToRegistry` makes and +/// anything else under a name belongs to whoever put it there; and only +/// a definite refusal counts as gone. The socket a stale entry points +/// at goes too, but not before a stat agrees it is a socket of ours: a +/// plain file answers a connect with the same refusal. +fn sweepRegistry(io: std.Io, svc: [:0]const u8) void { + if (comptime !supported) return; + + // The names are staged before anything is unlinked, so the sweep + // never asks a directory to keep reading while it is being edited. + var names: [4096]u8 = undefined; + var staged: usize = 0; + { + const dir = std.Io.Dir.openDirAbsolute(io, svc, .{ .iterate = true }) catch return; + defer dir.close(io); + var read_buf: [std.Io.Dir.Iterator.reader_buffer_len]u8 align(@alignOf(usize)) = undefined; + var reader: std.Io.Dir.Reader = .init(dir, &read_buf); + while (true) { + const listed = (reader.next(io) catch break) orelse break; + if (listed.name.len == 0 or listed.name.len > 255) continue; + if (staged + 1 + listed.name.len > names.len) break; + names[staged] = @intCast(listed.name.len); + @memcpy(names[staged + 1 ..][0..listed.name.len], listed.name); + staged += 1 + listed.name.len; + } + } + + var reaped: usize = 0; + var i: usize = 0; + while (i < staged) { + const name = names[i + 1 ..][0..names[i]]; + i += 1 + name.len; + var entry_buf: [sun_path_len:0]u8 = undefined; + const entry = std.fmt.bufPrintSentinel(&entry_buf, "{s}/{s}", .{ svc, name }, 0) catch continue; + const facts = statNoFollow(entry) orelse continue; + if (facts.mode & 0o170000 != 0o120000) continue; // not a symlink: not ours to judge + const state = probe(entry); + if (state == .live) continue; + var link_buf: [sun_path_len]u8 = undefined; + const n = libc.readlink(entry, &link_buf, link_buf.len); + if (libc.unlink(entry) != 0) continue; + reaped += 1; + // A relative target would resolve against this editor's working + // directory, which says nothing about what the entry named. + if (state != .stale or n <= 0 or link_buf[0] != '/') continue; + var target_buf: [sun_path_len:0]u8 = undefined; + const target = std.fmt.bufPrintSentinel(&target_buf, "{s}", .{link_buf[0..@intCast(n)]}, 0) catch continue; + const t = statNoFollow(target) orelse continue; + if (t.mode & 0o170000 == 0o140000 and t.uid == libc.getuid()) _ = libc.unlink(target); + } + if (reaped != 0) log.info("reaped {d} stale registry entries under {s}", .{ reaped, svc }); +} + +/// Whether it worked, because `probe` is not allowed to find out the +/// hard way: a caller that needs the guarantee has to be able to check. +fn setNonblock(fd: c_int) bool { const flags = libc.fcntl(fd, libc.F.GETFL, @as(c_int, 0)); - if (flags < 0) return; + if (flags < 0) return false; var o: libc.O = @bitCast(@as(u32, @bitCast(flags))); o.NONBLOCK = true; - _ = libc.fcntl(fd, libc.F.SETFL, @as(c_int, @bitCast(@as(u32, @bitCast(o))))); + return libc.fcntl(fd, libc.F.SETFL, @as(c_int, @bitCast(@as(u32, @bitCast(o))))) >= 0; +} + +fn isNonblocking(fd: c_int) bool { + const flags = libc.fcntl(fd, libc.F.GETFL, @as(c_int, 0)); + if (flags < 0) return false; + const o: libc.O = @bitCast(@as(u32, @bitCast(flags))); + return o.NONBLOCK; } const testing = std.testing; @@ -866,6 +984,108 @@ test "a name that is not one path component is no address at all" { try testing.expect(socketPath(&buf, "/run", "a\x00b") == null); } +test "the registry sweep takes the dead entries and leaves everything else" { + if (comptime !supported) return error.SkipZigTest; + // Under the real runtime directory, because a sun_path is 108 bytes + // and the test cache's temporary directories are longer than that. + var dir_buf: [sun_path_len:0]u8 = undefined; + const base = socketDir(&dir_buf) orelse return error.SkipZigTest; + if (!ensureSocketDir(base)) return error.SkipZigTest; + + var svc_buf: [sun_path_len:0]u8 = undefined; + const svc = std.fmt.bufPrintSentinel(&svc_buf, "{s}/sweep-{d}", .{ base, @as(u32, @intCast(libc.getpid())) }, 0) catch + return error.SkipZigTest; + if (libc.mkdir(svc, 0o700) != 0) return error.SkipZigTest; + + var paths: [5][sun_path_len:0]u8 = undefined; + const live_sock = try std.fmt.bufPrintSentinel(&paths[0], "{s}/live.sock", .{svc}, 0); + const dead_sock = try std.fmt.bufPrintSentinel(&paths[1], "{s}/dead.sock", .{svc}, 0); + const live = try std.fmt.bufPrintSentinel(&paths[2], "{s}/live", .{svc}, 0); + const dead = try std.fmt.bufPrintSentinel(&paths[3], "{s}/dead", .{svc}, 0); + const stranger = try std.fmt.bufPrintSentinel(&paths[4], "{s}/stranger", .{svc}, 0); + defer { + for ([_][:0]const u8{ live_sock, dead_sock, live, dead, stranger }) |p| _ = libc.unlink(p); + _ = libc.rmdir(svc); + } + + const listening = bindSocket(live_sock); + try testing.expect(listening >= 0); + defer _ = libc.close(listening); + try testing.expectEqual(@as(c_int, 0), libc.listen(listening, 1)); + + // Bound and then dropped: the file stays, and nobody answers it — + // exactly what an aborted test leaves behind. + const abandoned = bindSocket(dead_sock); + try testing.expect(abandoned >= 0); + _ = libc.close(abandoned); + + try testing.expectEqual(@as(c_int, 0), libc.symlink(live_sock, live)); + try testing.expectEqual(@as(c_int, 0), libc.symlink(dead_sock, dead)); + // Not a symlink, so not this program's to reason about, even though + // connecting to it is refused exactly like the dead socket. + try std.Io.Dir.cwd().writeFile(testing.io, .{ .sub_path = stranger, .data = "" }); + + // The guarantee itself, asserted rather than inferred from the fact + // that the test finished: if a probe socket ever stops being + // non-blocking the connect below parks instead of failing, and a + // parked test costs whoever is building far more than a red one. + const checking = libc.socket(libc.AF.UNIX, probe_socket_kind, 0); + try testing.expect(checking >= 0); + if (comptime darwin) try testing.expect(setNonblock(checking)); + try testing.expect(isNonblocking(checking)); + _ = libc.close(checking); + + // The listener's backlog is filled before anything is asked, because + // a full backlog is the one place a blocking connect parks forever + // (`unix_wait_for_peer`, no timeout) and a sweep that only answers + // while nobody is queued is the sweep that hangs a build. Nothing + // below accepts any of these, so the queue stays full throughout. + var queued: [8]c_int = @splat(-1); + defer for (queued) |fd| { + if (fd >= 0) _ = libc.close(fd); + }; + for (&queued) |*slot| { + const fd = libc.socket(libc.AF.UNIX, probe_socket_kind, 0); + if (fd < 0) break; + if (comptime darwin) _ = setNonblock(fd); + var addr: libc.sockaddr.un = .{ .path = @splat(0) }; + @memcpy(addr.path[0 .. live_sock.len + 1], live_sock[0 .. live_sock.len + 1]); + _ = libc.connect(fd, @ptrCast(&addr), @sizeOf(@TypeOf(addr))); + slot.* = fd; + } + + const started = transport.nowMs(); + try testing.expectEqual(Probe.live, probe(live)); + try testing.expectEqual(Probe.stale, probe(dead)); + + sweepRegistry(testing.io, svc); + + // Promptly, and not "eventually": a blocking probe never comes back + // at all, so any wall-clock bound at all is the assertion that + // matters. A second is several thousand times what three connects + // and a readdir cost. + try testing.expect(transport.nowMs() - started < 1000); + + try testing.expect(statNoFollow(dead) == null); + try testing.expect(statNoFollow(dead_sock) == null); + try testing.expect(statNoFollow(live) != null); + try testing.expect(statNoFollow(live_sock) != null); + try testing.expect(statNoFollow(stranger) != null); + try testing.expectEqual(Probe.live, probe(live)); +} + +fn bindSocket(path: [:0]const u8) c_int { + const fd = libc.socket(libc.AF.UNIX, libc.SOCK.STREAM, 0); + if (fd < 0) return fd; + var addr: libc.sockaddr.un = .{ .path = @splat(0) }; + @memcpy(addr.path[0 .. path.len + 1], path[0 .. path.len + 1]); + if (libc.bind(fd, @ptrCast(&addr), @sizeOf(@TypeOf(addr))) != 0) { + _ = libc.close(fd); + return -1; + } + return fd; +} + test "one connection's buffers are sized from the one msize constant" { try testing.expect(msize >= ninep.min_msize); try testing.expectEqual(@as(u32, msize), Runner.msize); @@ -1102,24 +1322,41 @@ pub fn start(io: std.Io, gpa: std.mem.Allocator, core: *pardes.Pardes) ?*Listene return listener; } -pub fn exportPaneEnv(listener: ?*const Listener, serial: u32, forward_look: bool) void { - _ = unsetenv("PARDES_FORWARD_LOOK"); +/// What a pane shell is told about the editor above it, set into this +/// process's environment just before `forkpty` so the child inherits it. +/// +/// Two independent facts, and they are separate variables because they answer +/// separate questions. `PARDES_PID` says "you are inside this editor, and it +/// will take a Look from you": a session whose 9P listener never came up still +/// owns its children, so the child says so rather than looking, from its own +/// side, exactly like no pardes at all. `PARDES_9P` and `PARDES_PANE` say how +/// to reach it, and a `--nested` session exports them too — its socket stays +/// open to scripts and to mounted shells — while withholding `PARDES_PID`, +/// which is the whole of what `--nested` means. +pub fn exportPaneEnv(listener: ?*const Listener, serial: u32, adopts: bool) void { + var announced = false; + if (adopts) announcing: { + var buf: [16]u8 = undefined; + const text = std.fmt.bufPrintSentinel(&buf, "{d}", .{@as(u32, @intCast(libc.getpid()))}, 0) catch + break :announcing; + announced = setenv("PARDES_PID", text, 1) == 0; + } + if (!announced) _ = unsetenv("PARDES_PID"); + if (listener) |l| exporting: { var sock: [sun_path_len]u8 = undefined; const path = std.fmt.bufPrintSentinel(&sock, "{s}", .{l.path()}, 0) catch break :exporting; var buf: [16]u8 = undefined; const id = std.fmt.bufPrintSentinel(&buf, "{d}", .{serial}, 0) catch break :exporting; if (setenv("PARDES_9P", path, 1) != 0) break :exporting; - if (setenv("PARDES_PANE", id, 1) != 0) break :exporting; - if (setenv("PARDES_FORWARD_LOOK", if (forward_look) "1" else "0", 1) == 0) return; + if (setenv("PARDES_PANE", id, 1) == 0) return; } _ = unsetenv("PARDES_9P"); _ = unsetenv("PARDES_PANE"); - _ = setenv("PARDES_FORWARD_LOOK", "0", 1); } -test "9P shell environment preserves identity when nested Look forwarding is disabled" { - const names = [_][*:0]const u8{ "XDG_RUNTIME_DIR", "HOME", "PARDES_9P", "PARDES_PANE", "PARDES_FORWARD_LOOK" }; +test "9P shell environment states being inside pardes apart from how to reach it" { + const names = [_][*:0]const u8{ "XDG_RUNTIME_DIR", "HOME", "PARDES_PID", "PARDES_9P", "PARDES_PANE" }; var saved: [names.len]?[:0]u8 = @splat(null); for (names, &saved) |name, *value| { if (libc.getenv(name)) |old| value.* = try testing.allocator.dupeZ(u8, std.mem.span(old)); @@ -1146,17 +1383,32 @@ test "9P shell environment preserves identity when nested Look forwarding is dis const path = "/tmp/pardes-example.sock"; @memcpy(listener.path_buf[0..path.len], path); listener.path_len = path.len; + var own: [16]u8 = undefined; + const own_pid = try std.fmt.bufPrint(&own, "{d}", .{@as(u32, @intCast(libc.getpid()))}); + + // A `--nested` session: reachable for scripts and mounts, but nobody's + // parent, so a pardes started in one of its shells runs a session of + // its own instead of handing its argument over. exportPaneEnv(listener, 7, false); try testing.expectEqualStrings(path, std.mem.span(libc.getenv("PARDES_9P").?)); try testing.expectEqualStrings("7", std.mem.span(libc.getenv("PARDES_PANE").?)); - try testing.expectEqualStrings("0", std.mem.span(libc.getenv("PARDES_FORWARD_LOOK").?)); + try testing.expect(libc.getenv("PARDES_PID") == null); + exportPaneEnv(listener, 8, true); try testing.expectEqualStrings("8", std.mem.span(libc.getenv("PARDES_PANE").?)); - try testing.expectEqualStrings("1", std.mem.span(libc.getenv("PARDES_FORWARD_LOOK").?)); + try testing.expectEqualStrings(own_pid, std.mem.span(libc.getenv("PARDES_PID").?)); + + // A session whose listener never came up is still the session this shell + // is inside: the pid stands on its own, and only the address is missing. + exportPaneEnv(null, 0, true); + try testing.expect(libc.getenv("PARDES_9P") == null); + try testing.expect(libc.getenv("PARDES_PANE") == null); + try testing.expectEqualStrings(own_pid, std.mem.span(libc.getenv("PARDES_PID").?)); + exportPaneEnv(null, 0, false); try testing.expect(libc.getenv("PARDES_9P") == null); try testing.expect(libc.getenv("PARDES_PANE") == null); - try testing.expectEqualStrings("0", std.mem.span(libc.getenv("PARDES_FORWARD_LOOK").?)); + try testing.expect(libc.getenv("PARDES_PID") == null); } pub const Client = struct { diff --git a/src/builtins.zig b/src/builtins.zig index 39d70e5d..aa2b2d6d 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -137,6 +137,14 @@ pub const registry = struct { unreachable; } + /// Does this builtin say its own name on the message row before it runs? + /// The ones that own that row themselves declare `quiet` and do not. + pub fn announces(b: Builtin()) bool { + inline for (manualBuiltinList(), 0..) |T, i| + if (@intFromEnum(b) == i) return !(@hasDecl(T, "quiet") and T.quiet); + return true; // a setting builtin changes something invisible; say so + } + pub fn dispatch(b: Builtin(), c: Ctx) void { inline for (manualBuiltinList(), 0..) |T, i| if (@intFromEnum(b) == i) return T.run(c); @@ -259,6 +267,7 @@ pub const Unmount = struct { pub const Msg = struct { pub const takes_arg = true; + pub const quiet = true; // it IS the message row pub fn run(c: Ctx) void { if (c.arg) |text| c.p.setMessage(c.id, text) @@ -542,11 +551,15 @@ pub const LocationsConfig = struct { pub const output: OutputTraits = .{ .name = "+LocationsConfig" }; pub fn run(c: Ctx) void { - const next = c.p.locations_config.parse(c.arg orelse "") catch |err| { + const argument = std.mem.trim(u8, c.arg orelse "", " \t\r\n"); + const next = c.p.locations_config.parse(argument) catch |err| { c.p.reportError(c.id, "LocationsConfig", err); return; }; c.p.locations_config = next; + // Bare, it is a question, and the window is the answer. With arguments + // it is a setting, and a setting that opens a window is noise. + if (argument.len != 0) return; report(c) catch |err| c.p.reportError(c.id, "LocationsConfig", err); } diff --git a/src/config.zig b/src/config.zig index 440549b3..3169b20c 100644 --- a/src/config.zig +++ b/src/config.zig @@ -71,6 +71,7 @@ pub const leader_path = paths: { .FocusTint = null, .ColumnTags = null, .SyntaxBold = null, + .Verbose = null, .TreeContextTagStyle = null, .Wrap = "tw", .Tagbottom = "tb", @@ -224,10 +225,10 @@ pub const tty_filter_min_contrast: f64 = 1.5; pub const topbar_str = "Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill"; -pub const pane_builtins_str = "Tty Del Collapse"; -pub const pdf_pane_builtins_str = "Tty Del PdfSections PdfTint Collapse"; -pub const file_pane_builtins_str = "Save Tty Del Collapse"; -pub const terminal_pane_builtins_str = "Tty Save Del Mode Filter Collapse"; +pub const pane_builtins_str = "Tty Collapse Del"; +pub const pdf_pane_builtins_str = "Tty PdfSections PdfTint Collapse Del"; +pub const file_pane_builtins_str = "Save Tty Collapse Del"; +pub const terminal_pane_builtins_str = "Tty Save Mode Filter Collapse Del"; // Each mode badge is one codepoint. pub const tag_normal = " "; @@ -540,6 +541,8 @@ pub const Runtime = struct { focus_tint: bool = true, column_tags: bool = true, syntax_bold: bool = false, + /// Builtins announce themselves on the message row. + verbose: bool = true, window_opacity: u8 = 100, window_blur: u8 = 0, window_opacity_pending: bool = true, @@ -637,7 +640,7 @@ pub const Runtime = struct { pub const Capability = std.meta.FieldEnum(Capabilities); - pub const Toggle = enum { colors, wrap, tree_context_tag_style, tag_bottom, debug, focus_tint, column_tags, syntax_bold }; + pub const Toggle = enum { colors, wrap, tree_context_tag_style, tag_bottom, debug, focus_tint, column_tags, syntax_bold, verbose }; pub const Scene = std.meta.FieldEnum(layout.SceneEffect); pub const Action = union(enum) { @@ -682,6 +685,7 @@ pub const Runtime = struct { .{ .word = "FocusTint", .action = .{ .toggle = .focus_tint } }, .{ .word = "ColumnTags", .action = .{ .toggle = .column_tags } }, .{ .word = "SyntaxBold", .action = .{ .toggle = .syntax_bold } }, + .{ .word = "Verbose", .action = .{ .toggle = .verbose } }, .{ .word = "Theme", .action = .theme }, .{ .word = "Shell", .action = .shell }, .{ .word = "Font", .action = .font, .availability = .font_picker }, @@ -761,15 +765,10 @@ pub const Runtime = struct { pub fn apply(state: *Runtime, setting: Setting, argument: ?[]const u8) bool { switch (setting.action) { + // Every toggle names a bool field of its own, so one line covers + // all of them and a new toggle needs no arm here. .toggle => |field| switch (field) { - .colors => state.colors = !state.colors, - .wrap => state.wrap = !state.wrap, - .tree_context_tag_style => state.tree_context_tag_style = !state.tree_context_tag_style, - .tag_bottom => state.tag_bottom = !state.tag_bottom, - .debug => state.debug = !state.debug, - .focus_tint => state.focus_tint = !state.focus_tint, - .column_tags => state.column_tags = !state.column_tags, - .syntax_bold => state.syntax_bold = !state.syntax_bold, + inline else => |f| @field(state, @tagName(f)) = !@field(state, @tagName(f)), }, .shell => { const value = std.mem.trim(u8, argument orelse return false, " \t\r\n"); @@ -835,46 +834,42 @@ pub const Runtime = struct { return findAction(.{ .transition = transition }).?.word; } + /// Each line reads as the command that would set it: the word, then the + /// value you would type after it. No colons, no units — `WindowOpacity 70` + /// is both what Config prints and what you write back. pub fn writeReport(out: *std.Io.Writer, context: ReportContext) !void { const state = context.state; var wrote_transition = false; for (settings) |setting| switch (setting.action) { .toggle => |field| { const value = switch (field) { - .colors => state.colors, - .wrap => state.wrap, - .tree_context_tag_style => state.tree_context_tag_style, - .tag_bottom => state.tag_bottom, - .debug => state.debug, - .focus_tint => state.focus_tint, - .column_tags => state.column_tags, - .syntax_bold => state.syntax_bold, + inline else => |f| @field(state, @tagName(f)), }; - try out.print("{s}: {s}\n", .{ setting.word, onOff(value) }); + try out.print("{s} {s}\n", .{ setting.word, onOff(value) }); }, - .theme => try out.print("{s}: {s}\n", .{ setting.word, context.theme_name }), + .theme => try out.print("{s} {s}\n", .{ setting.word, context.theme_name }), .window_opacity => { if (setting.enabled(context.capabilities)) - try out.print("{s}: {d}%{s}\n", .{ + try out.print("{s} {d}{s}\n", .{ setting.word, state.window_opacity, if (state.window_opacity_pending) " (pending)" else "", }) else - try out.print("{s}: unsupported\n", .{setting.word}); + try out.print("{s} unsupported\n", .{setting.word}); }, .window_blur => { if (setting.enabled(context.capabilities)) - try out.print("{s}: {d}%\n", .{ setting.word, state.window_blur }) + try out.print("{s} {d}\n", .{ setting.word, state.window_blur }) else - try out.print("{s}: unsupported\n", .{setting.word}); + try out.print("{s} unsupported\n", .{setting.word}); }, .shell => { const chosen = state.shell.requested.get(); try out.print( - "{s} requested (new panes): {s}{s}\n" ++ - "{s} effective (last spawn): {s}\n" ++ - "{s} pending: {s}\n", + "{s} requested (new panes) {s}{s}\n" ++ + "{s} effective (last spawn) {s}\n" ++ + "{s} pending {s}\n", .{ setting.word, if (chosen.len == 0) context.compiled_default_shell else chosen, @@ -887,18 +882,18 @@ pub const Runtime = struct { ); }, .font => if (!setting.enabled(context.capabilities)) - try out.print("{s}: unsupported\n", .{setting.word}) + try out.print("{s} unsupported\n", .{setting.word}) else { if (state.font.requested_size_hundredths == 0) - try out.print("{s} requested size: unchanged\n", .{setting.word}) + try out.print("{s} requested size unchanged\n", .{setting.word}) else - try out.print("{s} requested size: {d}.{d:0>2}\n", .{ setting.word, state.font.requested_size_hundredths / 100, state.font.requested_size_hundredths % 100 }); + try out.print("{s} requested size {d}.{d:0>2}\n", .{ setting.word, state.font.requested_size_hundredths / 100, state.font.requested_size_hundredths % 100 }); try out.print( - "{s} requested: {s}\n" ++ - "{s} requested path: {s}\n" ++ - "{s} effective: {s}\n" ++ - "{s} pending: {s}\n" ++ - "{s} effective size: {d}.{d:0>2} {s}\n", + "{s} requested {s}\n" ++ + "{s} requested path {s}\n" ++ + "{s} effective {s}\n" ++ + "{s} pending {s}\n" ++ + "{s} effective size {d}.{d:0>2} {s}\n", .{ setting.word, shown(state.font.requested_name.get()), @@ -916,28 +911,28 @@ pub const Runtime = struct { ); }, .tagline_size => if (!context.capabilities.tagline_font_size) - try out.print("{s}: unsupported\n", .{setting.word}) + try out.print("{s} unsupported\n", .{setting.word}) else if (!setting.enabled(context.capabilities)) - try out.print("{s}: {d}% (build-time only)\n", .{ setting.word, state.font.tagline_percent }) + try out.print("{s} {d} (build-time only)\n", .{ setting.word, state.font.tagline_percent }) else - try out.print("{s}: {d}%\n", .{ setting.word, state.font.tagline_percent }), + try out.print("{s} {d}\n", .{ setting.word, state.font.tagline_percent }), .transition => { if (wrote_transition) continue; wrote_transition = true; if (!setting.enabled(context.capabilities)) - try out.writeAll("Panel transition: unsupported\n") + try out.writeAll("Panel transition unsupported\n") else - try out.print("Panel transition: {s}\n", .{transitionSettingName(state.panel_transition)}); + try out.print("Panel transition {s}\n", .{transitionSettingName(state.panel_transition)}); }, .scene => |effect| { if (!setting.enabled(context.capabilities)) { - try out.print("{s}: unsupported\n", .{setting.word}); + try out.print("{s} unsupported\n", .{setting.word}); continue; } const enabled = switch (effect) { inline else => |field| @field(state.scene_effects, @tagName(field)), }; - try out.print("{s}: {s}\n", .{ setting.word, onOff(enabled) }); + try out.print("{s} {s}\n", .{ setting.word, onOff(enabled) }); }, }; @@ -1073,7 +1068,8 @@ pub const Runtime = struct { test "Config report observes every simple setting and all live context" { var state: Runtime = .{}; - var storage: [4096]u8 = undefined; + // Every setting, every context line: the report outgrows 4K. + var storage: [8192]u8 = undefined; const context: ReportContext = .{ .startup_config_path = "/tmp/pardes/init", .platform = "gui", @@ -1112,37 +1108,38 @@ pub const Runtime = struct { const report = storage[0..out.end]; const expected = switch (setting.action) { .toggle => |field| switch (field) { - .colors => "Colors: off\n", - .wrap => "Wrap: off\n", - .tree_context_tag_style => "TreeContextTagStyle: off\n", - .tag_bottom => "Tagbottom: on\n", - .debug => "Debug: on\n", - .focus_tint => "FocusTint: off\n", - .column_tags => "ColumnTags: off\n", - .syntax_bold => "SyntaxBold: on\n", + .colors => "Colors off\n", + .wrap => "Wrap off\n", + .tree_context_tag_style => "TreeContextTagStyle off\n", + .tag_bottom => "Tagbottom on\n", + .debug => "Debug on\n", + .focus_tint => "FocusTint off\n", + .column_tags => "ColumnTags off\n", + .syntax_bold => "SyntaxBold on\n", + .verbose => "Verbose off\n", }, - .shell => "Shell requested (new panes): fish\n", - .tagline_size => "TaglineSize: 73%\n", - .window_opacity => "WindowOpacity: 85% (pending)\n", - .window_blur => "WindowBlur: 40%\n", + .shell => "Shell requested (new panes) fish\n", + .tagline_size => "TaglineSize 73\n", + .window_opacity => "WindowOpacity 85 (pending)\n", + .window_blur => "WindowBlur 40\n", .transition => |transition| switch (transition) { .off => unreachable, - .slide => "Panel transition: PanelSlide\n", - .zoom => "Panel transition: PanelZoom\n", - .dissolve => "Panel transition: PanelDissolve\n", - .ascii => "Panel transition: PanelAscii\n", - .vertical => "Panel transition: PanelVertical\n", - .edges => "Panel transition: PanelEdges\n", - .fall => "Panel transition: PanelFall\n", - .wave => "Panel transition: PanelWave\n", - .curtain => "Panel transition: PanelCurtain\n", - .scramble => "Panel transition: PanelScramble\n", - .typewriter => "Panel transition: PanelType\n", + .slide => "Panel transition PanelSlide\n", + .zoom => "Panel transition PanelZoom\n", + .dissolve => "Panel transition PanelDissolve\n", + .ascii => "Panel transition PanelAscii\n", + .vertical => "Panel transition PanelVertical\n", + .edges => "Panel transition PanelEdges\n", + .fall => "Panel transition PanelFall\n", + .wave => "Panel transition PanelWave\n", + .curtain => "Panel transition PanelCurtain\n", + .scramble => "Panel transition PanelScramble\n", + .typewriter => "Panel transition PanelType\n", }, .scene => |effect| switch (effect) { - .crt => "Crt: on\n", - .ripple => "Ripple: on\n", - .glitch => "Glitch: on\n", + .crt => "Crt on\n", + .ripple => "Ripple on\n", + .glitch => "Glitch on\n", }, .theme, .font => unreachable, }; @@ -1163,15 +1160,15 @@ pub const Runtime = struct { try writeReport(&out, context); const report = storage[0..out.end]; for ([_][]const u8{ - "Theme: acme\n", - "WindowOpacity: 85%\n", - "Font requested size: 18.50\n", - "Font requested: Wanted Mono\n", - "Font requested path: /fonts/wanted.ttf\n", - "Font effective: Effective Mono\n", - "Font pending: on\n", - "Font effective size: 13.75 points\n", - "TaglineSize: 82%\n", + "Theme acme\n", + "WindowOpacity 85\n", + "Font requested size 18.50\n", + "Font requested Wanted Mono\n", + "Font requested path /fonts/wanted.ttf\n", + "Font effective Effective Mono\n", + "Font pending on\n", + "Font effective size 13.75 points\n", + "TaglineSize 82\n", "Startup config: /tmp/pardes/init\n", "Platform: gui\n", "Compiled default shell: /bin/sh\n", @@ -1197,23 +1194,23 @@ pub const Runtime = struct { out = .fixed(&storage); try writeReport(&out, defaults_context); const defaults_report = storage[0..out.end]; - try std.testing.expect(std.mem.indexOf(u8, defaults_report, "WindowOpacity: unsupported\n") != null); + try std.testing.expect(std.mem.indexOf(u8, defaults_report, "WindowOpacity unsupported\n") != null); try std.testing.expect(!find("WindowOpacity").?.enabled(defaults_context.capabilities)); - try std.testing.expect(std.mem.indexOf(u8, defaults_report, "WindowBlur: unsupported\n") != null); + try std.testing.expect(std.mem.indexOf(u8, defaults_report, "WindowBlur unsupported\n") != null); try std.testing.expect(!find("WindowBlur").?.enabled(defaults_context.capabilities)); try std.testing.expect(find("WindowOpacity").?.enabled(context.capabilities)); - try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Shell requested (new panes): /bin/sh (default)\n") != null); - try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Shell effective (last spawn): (none)\n") != null); - try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Shell pending: on\n") != null); + try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Shell requested (new panes) /bin/sh (default)\n") != null); + try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Shell effective (last spawn) (none)\n") != null); + try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Shell pending on\n") != null); try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Startup config: no per-user config path\n") != null); try std.testing.expect(std.mem.indexOf(u8, defaults_report, "GUI shader source:") == null); - try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Font: unsupported\n") != null); - try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Font requested:") == null); - try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Panel transition: off\n") != null); - try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Crt: unsupported\n") != null); - try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Ripple: unsupported\n") != null); - try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Glitch: unsupported\n") != null); - try std.testing.expect(std.mem.indexOf(u8, defaults_report, "TaglineSize: unsupported\n") != null); + try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Font unsupported\n") != null); + try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Font requested") == null); + try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Panel transition off\n") != null); + try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Crt unsupported\n") != null); + try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Ripple unsupported\n") != null); + try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Glitch unsupported\n") != null); + try std.testing.expect(std.mem.indexOf(u8, defaults_report, "TaglineSize unsupported\n") != null); try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Look hover delay: off\n") != null); try std.testing.expect(std.mem.indexOf(u8, defaults_report, "Native images: off\n") != null); @@ -1223,8 +1220,8 @@ pub const Runtime = struct { out = .fixed(&storage); try writeReport(&out, defaults_context); const web_report = storage[0..out.end]; - try std.testing.expect(std.mem.indexOf(u8, web_report, "Panel transition: unsupported\n") != null); - try std.testing.expect(std.mem.indexOf(u8, web_report, "TaglineSize: 100% (build-time only)\n") != null); + try std.testing.expect(std.mem.indexOf(u8, web_report, "Panel transition unsupported\n") != null); + try std.testing.expect(std.mem.indexOf(u8, web_report, "TaglineSize 100 (build-time only)\n") != null); } }; diff --git a/src/fs-help.txt b/src/fs-help.txt index a0a84b28..1e5d64c2 100644 --- a/src/fs-help.txt +++ b/src/fs-help.txt @@ -2,41 +2,43 @@ Pardes control filesystem ========================= README this guide index one line per pane: serial, kind (text|term|pdf|image), dirty flag, name -ctl write commands; read the serials the last command made or touched -new reading it creates one empty pane and answers its serial +status pid, version and pane count +look write a line: a right click on it at the active pane; read: the serials it touched +exec write a line: a middle click, an editor command word or a shell line; read the same log one line per editor event (new/del/rename/save ); reads wait screen rendered screen as JSON, frozen from open to close listeners the session's dial addresses -pane// name body tag ctl addr data xdata sel errors event, and pty/ for terminals +pane/ mkdir makes a pane, rmdir closes it +pane// name body tag ctl addr dot limit data xdata sel dirty mark scroll + errors event look exec, and pty/ for terminals os/ the host filesystem src/ the editor's own sources, only in a -Dembed-sources=true build -Commands, on /ctl (applied at the active pane) or on pane//ctl (at that pane): - look TEXT a right click: open a file, a file:12 location, a directory, a URL - exec TEXT a middle click: an editor command word (Save Del New Newcol Mount Unmount - Dump Restore Msg Find Grep Tty ...), or a shell command for the pane's terminal Below, $m is the mount point (PARDES_MOUNT in a Tty9p shell; 9ns and 9p work too): cat $m/index which panes exist - n=$(cat $m/new) make a pane, remember its serial - echo 'look /etc/hosts:3' > $m/ctl; cat $m/ctl open a file, see the pane it went to - printf 'text\n' > $m/pane/$n/body append to a pane (>| truncates first) + mkdir $m/pane/x; n=$(awk 'END{print $1}' $m/index) make a pane, take its serial + echo /etc/hosts:3 > $m/look; cat $m/look open a file, see the pane it went to + printf 'text\n' > $m/pane/$n/body append to a pane (>| truncates first) cat $m/pane/$n/name; echo notes.txt > $m/pane/$n/name read, then rename - echo 'exec Save' > $m/pane/$n/ctl save it (exec Del closes it) - echo 'exec Msg hello' > $m/ctl show text in the editor + echo Save > $m/pane/$n/exec save it; rmdir $m/pane/$n closes it + echo 'Msg hello' > $m/exec show text in the editor echo '#0,#5' > $m/pane/$n/addr; echo NEW > $m/pane/$n/data replace bytes 0..5 - echo 'dot=addr' > $m/pane/$n/ctl; cat $m/pane/$n/sel select the range, read it + cp $m/pane/$n/addr $m/pane/$n/dot; cat $m/pane/$n/sel select the range, read it + cat $m/pane/$n/dirty; echo 0 > $m/pane/$n/dirty is it modified? say it is not cat $m/log block until a pane is made, renamed, saved or closed cat $m/pane/$n/event hold it open to own that pane's clicks - echo 'exec' > $m/pane/$n/pty/ctl restart a shell; also winsize C R, sig INT + echo exec > $m/pane/$n/pty/ctl restart a shell; also winsize C R, sig INT Pitfalls, one each: - Every open of new makes another pane, so `cat $m/new` twice makes two. - ls, stat and find create nothing; reading log, event or pty/data blocks until something happens. - exec Del closes a pane even when it is dirty; index shows the dirty flag first. - look and exec are lowercase verbs; the words after exec are the editor's capitalized commands. - ctl also takes acme's addr verbs (addr=dot dot=addr limit=addr clean dirty get show ...), one per line. + Only mkdir in pane/ makes a pane; ls, stat, find and every read create nothing. + Panes are named by the serial the editor gives them, not by the name mkdir asked for. + rmdir closes a pane even when it is dirty; index and pane//dirty show the flag. + addr, dot and limit read the same pair of offsets they take, so cp between them works. + dirty, mark and scroll read "0" or "1" and take "0" or "1"; truncating limit lifts it. Writing body appends; open it with truncation to replace; writes are whole UTF-8 sequences. + Truncating tag clears the part you may edit; truncating dot or addr empties it. A terminal's body is a history snapshot frozen per open; pty/data is the live stream. screen is frozen per open handle as well; reopen it for a fresh frame. - A command that fails is reported in the editor, not as a write error; a malformed line fails the write. + A failing command is reported in the editor, not as a write error; a bad line fails the write. + pane//ctl reads acme's window status line and takes one verb, get, which reloads from disk. diff --git a/src/fs.zig b/src/fs.zig index 7f416440..7cb08980 100644 --- a/src/fs.zig +++ b/src/fs.zig @@ -260,12 +260,13 @@ test "unmount refuses pane paths inherited directories and queued save targets" } gpa.free(pane.file.?.path); pane.file.?.path = try gpa.dupe(u8, "/n/peer2/file"); - const shell = try p.newShell(1, "/n/peer/dir"); - p.setCwd(1, "/n/peer/dir"); + const slot = p.freeSlot().?; + const shell = try p.newShell(slot, "/n/peer/dir"); + p.setCwd(slot, "/n/peer/dir"); try std.testing.expectError(error.MountInUse, unmount(p, "peer")); pane.cwd = .{ .inherited = shell }; try std.testing.expectError(error.MountInUse, unmount(p, "peer")); - p.setCwd(1, "/"); + p.setCwd(slot, "/"); while (p.nextEffect()) |_| {} p.emit(.{ .save_text = .{ .pane = 0, .serial = pane.serial, .path = .from("/n/peer/pending") } }); try std.testing.expectError(error.MountInUse, unmount(p, "peer")); @@ -1261,10 +1262,10 @@ pub const Namespace = struct { /// The editor-wide event stream, recorded only while /log is held open. log: tree.events.Queue = .{}, log_readers: u16 = 0, - /// What the last ctl command created or touched, answered by reading /ctl. + /// What the last look or exec created or touched, answered by reading + /// either of those files. results: [MAX_PANES]u32 = undefined, results_len: u8 = 0, - results_valid: bool = false, /// Process start, the mtime of everything that has no edit time of its own. started: u32 = 0, diff --git a/src/host_io.zig b/src/host_io.zig index 212c23b4..fb09fcc7 100644 --- a/src/host_io.zig +++ b/src/host_io.zig @@ -874,6 +874,9 @@ pub fn forkShell( if (fs == null) return error.SessionSocketRequired; break :blk try @import("linux/v9fs.zig").helperPath(&helper_buf); } else null; + // The last argument is whether this session takes its children's Looks — + // every session does but a `--nested` one, and a fork with no core at all + // (the tests below) is nobody's parent. ninep_io.exportPaneEnv( fs, if (core) |c| (if (c.panes[pane]) |pn| pn.serial else 0) else 0, diff --git a/src/main.zig b/src/main.zig index 4b1910bd..1cbdf24c 100644 --- a/src/main.zig +++ b/src/main.zig @@ -112,6 +112,16 @@ const nested_text = \\ ; +/// $PARDES_PID named a live editor, so this shell IS inside one, but the Look +/// never got there. Saying so beats quietly opening the second editor that +/// $PARDES_PID exists to prevent. +const unreachable_text = + \\pardes: this shell is inside pardes, but that session did not take the + \\file. Check that it is still running, or pass --nested to start a second + \\editor in here anyway. + \\ +; + // The browser runtime calls a C main (exported below); everything else keeps // the std.process.Init entry. pub const main = if (is_emscripten) webMain else nativeMain; @@ -260,6 +270,10 @@ fn nativeMain(init: std.process.Init) !void { } } opts.tty_only = explicit_tty or session_only; + // The real bare-tty startup wants the editor half present from the first + // frame, so it names that layout; a core booted for a test names none and + // gets the raw shell by itself. + if (opts.tty_only) opts.boot = .tty; opts.mounts = mounts[0..mounts_len]; if (detach != null and attach != null) badArgs(init.io, "--detach and --attach are opposites: one runs the session, the other joins one", .{}); @@ -272,31 +286,60 @@ fn nativeMain(init: std.process.Init) !void { if (opts.mounts.len != 0 and attach != null) badArgs(init.io, "--mount configures a session's own core, and --attach has none of its own", .{}); if (!new_session and !opts.nested and detach == null and attach == null) forwarding: { - const enabled = std.c.getenv("PARDES_FORWARD_LOOK") orelse break :forwarding; - if (!std.mem.eql(u8, std.mem.span(enabled), "1")) break :forwarding; - const dial = std.mem.span(std.c.getenv("PARDES_9P") orelse break :forwarding); - ninep_io.Client.validateDial(dial) catch break :forwarding; - const pane_text = std.mem.span(std.c.getenv("PARDES_PANE") orelse break :forwarding); - for (pane_text) |byte| if (!std.ascii.isDigit(byte)) break :forwarding; - const serial = std.fmt.parseInt(u32, pane_text, 10) catch break :forwarding; - if (serial == 0) break :forwarding; - var ctl_buf: [64]u8 = undefined; - const ctl = try std.fmt.bufPrint(&ctl_buf, "/pane/{d}/ctl", .{serial}); + // Am I inside a pardes at all? That is $PARDES_PID and nothing else — + // one variable, exported by every session that means to take its + // children's Looks, so a session that could not open a socket is still + // recognisably the session this shell is inside. A pid naming no live + // process is a shell that outlived its editor (a daemon started from a + // pane, a stale environment carried into a new terminal), which is not + // nested at all. + const owner = std.mem.span(std.c.getenv("PARDES_PID") orelse break :forwarding); + const pid = std.fmt.parseInt(std.c.pid_t, owner, 10) catch break :forwarding; + if (pid <= 0 or std.c.kill(pid, @enumFromInt(0)) != 0) break :forwarding; + + // Can I reach it? That is the other two, and it is a separate answer. + const Parent = struct { dial: []const u8, serial: u32 }; + const found: ?Parent = reaching: { + const dial = std.mem.span(std.c.getenv("PARDES_9P") orelse break :reaching null); + ninep_io.Client.validateDial(dial) catch break :reaching null; + const pane_text = std.mem.span(std.c.getenv("PARDES_PANE") orelse break :reaching null); + for (pane_text) |byte| if (!std.ascii.isDigit(byte)) break :reaching null; + const serial = std.fmt.parseInt(u32, pane_text, 10) catch break :reaching null; + if (serial == 0) break :reaching null; + break :reaching .{ .dial = dial, .serial = serial }; + }; + const parent = found orelse { + try std.Io.File.stderr().writeStreamingAll(init.io, unreachable_text); + std.process.exit(1); + }; + // The pane's `look` file: one line, and the line is the clicked text + // itself, which is what a right click in that pane would have been. + var look_buf: [64]u8 = undefined; + const look = try std.fmt.bufPrint(&look_buf, "/pane/{d}/look", .{parent.serial}); const word = positional orelse { var tag_buf: [64]u8 = undefined; - const tag = try std.fmt.bufPrint(&tag_buf, "/pane/{d}/tag", .{serial}); - const contents = ninep_io.Client.read(arena, dial, tag, tag) catch break :forwarding; + const tag = try std.fmt.bufPrint(&tag_buf, "/pane/{d}/tag", .{parent.serial}); + const contents = ninep_io.Client.read(arena, parent.dial, tag, tag) catch { + try std.Io.File.stderr().writeStreamingAll(init.io, unreachable_text); + std.process.exit(1); + }; arena.free(contents); try std.Io.File.stderr().writeStreamingAll(init.io, nested_text); std.process.exit(1); }; + // A word this launch cannot turn into a path is an argument problem + // rather than a nesting one: fall through and let the session that + // starts report it, the way `pardes typo` outside pardes does. if (std.mem.indexOfAny(u8, word, "\r\n") != null) break :forwarding; const target = @import("look.zig").parsePathLine(word); var realbuf: [4096]u8 = undefined; const path = if (pardes.filesystem.isVirtual(target.path)) target.path else (pardes.filesystem.resolveOs(target.path, &realbuf) orelse break :forwarding).path; var command_buf: [8192]u8 = undefined; - const command = std.fmt.bufPrint(&command_buf, "look {s}{s}\n", .{ path, word[target.path.len..] }) catch break :forwarding; - ninep_io.Client.write(arena, dial, ctl, command) catch break :forwarding; + const command = std.fmt.bufPrint(&command_buf, "{s}{s}\n", .{ path, word[target.path.len..] }) catch break :forwarding; + ninep_io.Client.write(arena, parent.dial, look, command) catch { + try std.Io.File.stderr().writeStreamingAll(init.io, unreachable_text); + std.process.exit(1); + }; return; } if (positional) |a| { diff --git a/src/ninep/addr.zig b/src/ninep/addr.zig index f7642b9e..566e2364 100644 --- a/src/ninep/addr.zig +++ b/src/ninep/addr.zig @@ -255,17 +255,25 @@ test "the address language, form by form" { try testing.expectEqual(@as(u32, 6), p.fs.panes[0].addr.q0); // the `o` in "two" try testing.expectEqual(@as(u32, 7), p.fs.panes[0].addr.q1); + // limit is its own file: copying addr onto it bounds the search, and + // truncating it lifts the bound again. + const limit = Node.of(serial, .limit); _ = th.wr(p, addr, "1"); - _ = th.wr(p, Node.of(serial, .ctl), "limit=addr\n"); + try testing.expectEqualStrings("", th.rd(p, limit, 0, 64).bytes); + var copied: [64]u8 = undefined; + const pair = th.rd(p, addr, 0, 64).bytes; + @memcpy(copied[0..pair.len], pair); + _ = th.wr(p, limit, copied[0..pair.len]); + try testing.expectEqual(@as(u32, 4), p.fs.panes[0].limit.?.q1); + try testing.expectEqualStrings(" 0 4 ", th.rd(p, limit, 0, 64).bytes); _ = th.wr(p, addr, "#0"); try testing.expectEqual(E.INVAL, th.wr(p, addr, "/three/").errno()); - _ = th.wr(p, Node.of(serial, .ctl), "clean\n"); - _ = th.call(p, .{ .tag = 6, .op = .open, .node = Node.of(serial, .ctl) }); + _ = th.call(p, .{ .tag = 6, .op = .setattr, .node = limit, .truncate = true }); try testing.expect(p.fs.panes[0].limit == null); _ = th.wr(p, addr, "#0"); try testing.expectEqual(Status.ok, th.wr(p, addr, "/three/").reply.status); - for ([_][]const u8{ "zzz", "#", "//", "/nomatch/", "1 2", "99", "/a\\" }) |bad| { + for ([_][]const u8{ "zzz", "#", "//", "/nomatch/", "1 2 3", "99", "/a\\" }) |bad| { _ = th.wr(p, addr, "#0"); try testing.expectEqual(E.INVAL, th.wr(p, addr, bad).errno()); } diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index d61ebf75..c213ece5 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -1,6 +1,9 @@ -//! The two ctl files. `look TEXT` is a right click and `exec TEXT` a middle -//! click in the editor's own command language; a pane's ctl adds the addr -//! verbs. Reading /ctl answers the serials the last command made or touched. +//! The command files and the status they answer. Writing a line to `look` is +//! a right click on it and writing one to `exec` a middle click, at the +//! active pane from the root and at that pane from /pane//; reading either +//! answers the serials the last command made or touched. /status reports the +//! editor, and a pane's ctl its acme status line and the one verb, `get`, +//! that no file of its own would say any better. const std = @import("std"); const pardes = @import("../pardes.zig"); const panes = @import("../panes.zig"); @@ -16,36 +19,6 @@ const Req = tree.Req; const Reply = tree.Reply; const E = tree.E; -const Verb = enum { - @"addr=dot", - clean, - cleartag, - dirty, - @"dot=addr", - get, - @"limit=addr", - mark, - nomark, - noscroll, - scroll, - show, -}; - -fn verbIs(line: []const u8, word: []const u8) bool { - if (!std.mem.startsWith(u8, line, word)) return false; - return line.len == word.len or line[word.len] == ' ' or line[word.len] == '\t'; -} - -/// The text after `look` or `exec`, or null when the line is not that verb. -/// Control characters other than tab are refused. -fn textAfter(line: []const u8, verb: []const u8) ?[]const u8 { - if (!verbIs(line, verb)) return null; - const text = std.mem.trim(u8, line[verb.len..], " \t"); - if (text.len == 0) return ""; - for (text) |c| if (c < ' ' and c != '\t') return ""; - return text; -} - // ---- which panes a command made or touched ---- const Serials = struct { @@ -96,37 +69,49 @@ fn run(p: *Pardes, id: usize, exec: bool, text: []const u8) void { noteResult(p, if (exec) context else activeSerial(p) orelse return); } -fn beginResults(p: *Pardes) void { - p.fs.results_len = 0; - p.fs.results_valid = true; -} - -// ---- /ctl ---- +// ---- look and exec ---- -pub fn writeRoot(p: *Pardes, req: Req) Reply { +/// One command per line, checked whole before any line runs: a line is the +/// clicked text itself, so it may not be empty or carry control characters. +/// A null `serial` clicks at whichever pane is active as each line runs, +/// which is what the root's own look and exec mean; a serial stays put. +pub fn command(p: *Pardes, req: Req, serial: ?u32, exec: bool) Reply { for ([2]bool{ false, true }) |apply| { - if (apply) beginResults(p); + if (apply) p.fs.results_len = 0; var it = std.mem.splitScalar(u8, req.data, '\n'); while (it.next()) |raw| { - const line = std.mem.trim(u8, raw, " \t\r"); - if (line.len == 0) continue; - const exec = verbIs(line, "exec"); - const text = textAfter(line, if (exec) "exec" else "look") orelse return Reply.fail(req.tag, E.INVAL); - if (text.len == 0) return Reply.fail(req.tag, E.INVAL); + const text = std.mem.trim(u8, raw, " \t\r"); + if (text.len == 0) continue; + for (text) |c| if (c < ' ' and c != '\t') return Reply.fail(req.tag, E.INVAL); if (!apply) continue; - if (p.panes[p.active] == null) return Reply.fail(req.tag, E.NOENT); - run(p, p.active, exec, text); + const id = if (serial) |s| p.paneBySerial(s) orelse break else p.active; + if (p.panes[id] == null) return Reply.fail(req.tag, E.NOENT); + run(p, id, exec, text); } } return .{ .tag = req.tag, .written = @intCast(req.data.len) }; } -pub fn rootText(p: *Pardes, buf: []u8) []const u8 { - var w = std.Io.Writer.fixed(buf); - if (p.fs.results_valid) { - for (p.fs.results[0..p.fs.results_len]) |serial| w.print("{d}\n", .{serial}) catch break; - return w.buffered(); +pub fn resultsLen(p: *Pardes) u64 { + var n: u64 = 0; + for (p.fs.results[0..p.fs.results_len]) |serial| { + var digits: [16]u8 = undefined; + n += (std.fmt.bufPrint(&digits, "{d}\n", .{serial}) catch unreachable).len; } + return n; +} + +pub fn readResults(p: *Pardes, req: Req) Reply { + const out = p.fs.stage(p.gpa); + for (p.fs.results[0..p.fs.results_len]) |serial| + out.print(p.gpa, "{d}\n", .{serial}) catch return Reply.fail(req.tag, E.NOMEM); + return tree.stagedReply(p, req); +} + +// ---- /status ---- + +fn statusText(p: *Pardes, buf: []u8) []const u8 { + var w = std.Io.Writer.fixed(buf); var count: usize = 0; for (p.panes) |slot| count += @intFromBool(slot != null); const pid: u32 = if (comptime pardes.hosted) @intCast(std.c.getpid()) else 0; @@ -134,13 +119,17 @@ pub fn rootText(p: *Pardes, buf: []u8) []const u8 { return w.buffered(); } -pub const root_text_cap = @max(MAX_PANES * 11, 64 + pardes.version.len); +pub const status_text_cap = 64 + pardes.version.len; + +pub fn statusLen(p: *Pardes) u64 { + var buf: [status_text_cap]u8 = undefined; + return statusText(p, &buf).len; +} -pub fn readRoot(p: *Pardes, req: Req) Reply { - var buf: [root_text_cap]u8 = undefined; - const text = rootText(p, &buf); +pub fn readStatus(p: *Pardes, req: Req) Reply { + var buf: [status_text_cap]u8 = undefined; const out = p.fs.stage(p.gpa); - out.appendSlice(p.gpa, text) catch return Reply.fail(req.tag, E.NOMEM); + out.appendSlice(p.gpa, statusText(p, &buf)) catch return Reply.fail(req.tag, E.NOMEM); return tree.stagedReply(p, req); } @@ -190,74 +179,35 @@ pub fn readPane(p: *Pardes, req: Req, pane: *Pane) Reply { return tree.stagedReply(p, req); } -pub fn writePane(p: *Pardes, req: Req, serial: u32) Reply { - for ([2]bool{ false, true }) |apply| { - if (apply) beginResults(p); - var it = std.mem.splitScalar(u8, req.data, '\n'); - while (it.next()) |raw| { - const line = std.mem.trim(u8, raw, " \t\r"); - if (line.len == 0) continue; - const live = p.paneBySerial(serial) orelse if (apply) break else return Reply.fail(req.tag, E.NOENT); - const errno = paneVerb(p, live, line, apply); - if (errno != 0) return Reply.fail(req.tag, errno); - } +/// `get` is the one thing here that no file of the pane's own would say: it +/// reloads the buffer from the name it carries, wherever that name resolves. +/// Repeating it in one write would only reload the same bytes, so it runs once. +pub fn writePane(p: *Pardes, req: Req, pane: *Pane) Reply { + var asked = false; + var it = std.mem.splitScalar(u8, req.data, '\n'); + while (it.next()) |raw| { + const line = std.mem.trim(u8, raw, " \t\r"); + if (line.len == 0) continue; + if (!std.mem.eql(u8, line, "get")) return Reply.fail(req.tag, E.INVAL); + asked = true; + } + if (asked) { + const errno = get(p, pane); + if (errno != 0) return Reply.fail(req.tag, errno); } return .{ .tag = req.tag, .written = @intCast(req.data.len) }; } -fn paneVerb(p: *Pardes, id: usize, line: []const u8, apply: bool) u16 { - const pane = p.panes[id] orelse return E.INVAL; - const pf = &p.fs.panes[id]; - - for ([_]bool{ false, true }) |exec| if (textAfter(line, if (exec) "exec" else "look")) |text| { - if (text.len == 0) return E.INVAL; - if (apply) run(p, id, exec, text); - return 0; +fn get(p: *Pardes, pane: *Pane) u16 { + const f = pane_files.fileOf(pane) orelse return 0; + if (!panes.Output.fileTraits(f.output).saves) return 0; + const bytes = fs.read(p, f.path) catch |err| return switch (err) { + error.FileNotFound => E.NOENT, + else => E.IO, }; - const v = std.meta.stringToEnum(Verb, line) orelse return E.INVAL; - if (!apply) return 0; - - switch (v) { - .@"addr=dot" => pf.addr = pane_files.dotOf(pane), - .@"dot=addr" => { - pane_files.clampAddr(pf, pane_files.bodyOf(pane).len); - pane_files.setDot(pane, pf.addr); - }, - .@"limit=addr" => { - pane_files.clampAddr(pf, pane_files.bodyOf(pane).len); - pf.limit = pf.addr; - }, - .clean => if (pane_files.fileOf(pane)) |f| { - f.saved_revision = f.revision; - }, - .dirty => if (pane_files.fileOf(pane)) |f| { - f.saved_revision = f.revision -% 1; - }, - .cleartag => { - pane.tag_tail_len = 0; - pane.tag_init = true; - }, - .get => if (pane_files.fileOf(pane)) |f| { - if (panes.Output.fileTraits(f.output).saves) { - if (fs.read(p, f.path)) |bytes| { - panes.File.pushUndo(p, pane); - panes.File.setContent(p, f, bytes); - f.saved_revision = f.revision; - } else |err| return switch (err) { - error.FileNotFound => E.NOENT, - else => E.IO, - }; - } - }, - .mark => { - pf.nomark = false; - panes.File.pushUndo(p, pane); - }, - .nomark => pf.nomark = true, - .noscroll => pf.noscroll = true, - .scroll => pf.noscroll = false, - .show => pane_files.showOffset(pane, pane_files.dotOf(pane).q0), - } + panes.File.pushUndo(p, pane); + panes.File.setContent(p, f, bytes); + f.saved_revision = f.revision; return 0; } @@ -272,7 +222,9 @@ const withFile = th.withFile; const serialOf = th.serialOf; const Node = tree.Node; const Status = tree.Status; -const root_ctl = @intFromEnum(tree.TopFile.ctl); +const root_status = @intFromEnum(tree.TopFile.status); +const root_look = @intFromEnum(tree.TopFile.look); +const root_exec = @intFromEnum(tree.TopFile.exec); test "pane ctl read is index's five fields plus width in cells, font and tab width" { const gpa = testing.allocator; @@ -299,37 +251,18 @@ test "pane ctl read is index's five fields plus width in cells, font and tab wid try testing.expectEqualStrings("'it''s'", w.buffered()); } -test "every pane ctl verb, and every refusal" { +test "the pane ctl takes get, and nothing that a file of its own now answers" { const gpa = testing.allocator; const p = try withFile(gpa, "one\ntwo\n"); defer p.deinit(); - const serial = serialOf(p); - const ctl_node = Node.of(serial, .ctl); - const pane = p.panes[0].?; - const pf = &p.fs.panes[0]; - - try testing.expectEqual(Status.ok, wr(p, ctl_node, "nomark\nnoscroll\ndirty\n").reply.status); - try testing.expect(pf.nomark and pf.noscroll and pane_files.dirtyOf(pane)); - try testing.expectEqual(Status.ok, wr(p, ctl_node, "mark\nscroll\nclean\n").reply.status); - try testing.expect(!pf.nomark and !pf.noscroll and !pane_files.dirtyOf(pane)); - - _ = wr(p, ctl_node, "cleartag\n"); - try testing.expectEqual(@as(usize, 0), pane.tag_tail_len); - - _ = wr(p, Node.of(serial, .addr), "2"); - _ = wr(p, ctl_node, "limit=addr\n"); - try testing.expectEqual(@as(u32, 4), pf.limit.?.q0); - _ = wr(p, ctl_node, "dot=addr\nshow\n"); - try testing.expectEqual(@as(i32, 1), pane.cur_row); - + const ctl_node = Node.of(serialOf(p), .ctl); for ([_][]const u8{ - "menu", "nomenu", "dump echo hi", "dumpdir /tmp", "font Go Mono", "lock", "unlock", "bogus", "DEL", - "name x.txt", "put", "del", "delete", "Look x", "Exec Save", + "menu", "nomenu", "dump echo hi", "font Go Mono", "lock", "bogus", "DEL", + "name x.txt", "put", "del", "delete", "Look x", "Exec Save", "clean", + "dirty", "cleartag", "dot=addr", "addr=dot", "show", "mark", "nomark", + "scroll", "limit=addr", "get x", "look /tmp", "exec Del", }) |bad| try testing.expectEqual(E.INVAL, wr(p, ctl_node, bad).errno()); - - try testing.expect(!pane_files.dirtyOf(pane)); - try testing.expectEqual(E.INVAL, wr(p, ctl_node, "dirty\nbogus\n").errno()); - try testing.expect(!pane_files.dirtyOf(pane)); + try testing.expect(p.paneBySerial(serialOf(p)) != null); } test "exec runs a builtin at the pane and records the pane it acted on" { @@ -338,61 +271,69 @@ test "exec runs a builtin at the pane and records the pane it acted on" { defer p.deinit(); const serial = serialOf(p); const pane = p.panes[0].?; - try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .ctl), "exec Msg from ctl\n").reply.status); - try testing.expectEqualStrings("from ctl", pane.msg[0..pane.msg_len]); + try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .exec), "Msg from exec\n").reply.status); + try testing.expectEqualStrings("from exec", pane.msg[0..pane.msg_len]); var expected: [16]u8 = undefined; - try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n", .{serial}), rd(p, root_ctl, 0, 4096).bytes); + const own = try std.fmt.bufPrint(&expected, "{d}\n", .{serial}); + try testing.expectEqualStrings(own, rd(p, root_exec, 0, 4096).bytes); + // Either command file reads back what the last one did. + try testing.expectEqualStrings(own, rd(p, Node.of(serial, .look), 0, 4096).bytes); + try testing.expectEqual(@as(u64, own.len), call(p, .{ .tag = 1, .op = .getattr, .node = root_exec }).reply.attr.size); - try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .ctl), "exec New\n").reply.status); + try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .exec), "New\n").reply.status); const made = p.panes[p.active].?; try testing.expect(made.serial != serial); - try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n", .{made.serial}), rd(p, root_ctl, 0, 4096).bytes); + try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n", .{made.serial}), rd(p, root_exec, 0, 4096).bytes); - try testing.expectEqual(Status.ok, wr(p, Node.of(made.serial, .ctl), "exec Del\n").reply.status); + try testing.expectEqual(Status.ok, wr(p, Node.of(made.serial, .exec), "Del\n").reply.status); try testing.expect(p.paneBySerial(made.serial) == null); - try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n", .{made.serial}), rd(p, root_ctl, 0, 4096).bytes); + try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n", .{made.serial}), rd(p, root_exec, 0, 4096).bytes); } -test "the root ctl reads editor status until a command runs and validates whole batches" { +test "status reads the editor, and look and exec validate whole batches" { const gpa = testing.allocator; const p = try withFile(gpa, "Msg root\n"); defer p.deinit(); - const status = rd(p, root_ctl, 0, 4096); + const status = rd(p, root_status, 0, 4096); try testing.expectEqual(Status.ok, status.reply.status); var lines = std.mem.tokenizeScalar(u8, status.bytes, '\n'); try testing.expect(std.mem.startsWith(u8, lines.next().?, "pid ")); var expected: [64]u8 = undefined; try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "version {s}", .{pardes.version}), lines.next().?); - try testing.expectEqualStrings("panes 1", lines.next().?); + var live: usize = 0; + for (p.panes) |slot| live += @intFromBool(slot != null); + try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "panes {d}", .{live}), lines.next().?); try testing.expect(lines.next() == null); - const stat = call(p, .{ .tag = 1, .op = .getattr, .node = root_ctl }); + const stat = call(p, .{ .tag = 1, .op = .getattr, .node = root_status }); try testing.expectEqual(@as(u64, status.bytes.len), stat.reply.attr.size); - try testing.expectEqual(@as(u16, 0o666), stat.reply.attr.mode); + try testing.expectEqual(@as(u16, 0o444), stat.reply.attr.mode); + try testing.expectEqual(E.PERM, wr(p, root_status, "anything\n").errno()); + try testing.expectEqualStrings("", rd(p, root_exec, 0, 4096).bytes); const serial = p.next_serial; - for ([_][]const u8{ "look", "exec", "look \t", "Look /virtual/index", "exec Msg a\x00b", "exec Msg x\nbogus\n", "name x", "put" }) |invalid| { - try testing.expectEqual(E.INVAL, wr(p, root_ctl, invalid).errno()); + for ([_][]const u8{ "Msg a\x00b", "Msg x\nMsg \x01y\n" }) |invalid| { + try testing.expectEqual(E.INVAL, wr(p, root_exec, invalid).errno()); try testing.expectEqual(serial, p.next_serial); } - try testing.expectEqualStrings(status.bytes, rd(p, root_ctl, 0, 4096).bytes); + // An empty write is a no-op, not a command. + try testing.expectEqual(Status.ok, wr(p, root_exec, "\n \n").reply.status); + try testing.expectEqualStrings("", rd(p, root_exec, 0, 4096).bytes); + try testing.expectEqualStrings(status.bytes, rd(p, root_status, 0, 4096).bytes); const pane = p.panes[0].?; - try testing.expectEqual(Status.ok, wr(p, root_ctl, "exec Msg hello there\n").reply.status); + try testing.expectEqual(Status.ok, wr(p, root_exec, "Msg hello there\n").reply.status); try testing.expectEqualStrings("hello there", pane.msg[0..pane.msg_len]); - try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n", .{pane.serial}), rd(p, root_ctl, 0, 4096).bytes); - - try testing.expectEqual(Status.ok, wr(p, root_ctl, "look /virtual/index\nexec New\n").reply.status); - var made: [MAX_PANES]u32 = undefined; - var n: usize = 0; - for (p.panes) |slot| if (slot) |q| if (q.serial != pane.serial) { - made[n] = q.serial; - n += 1; - }; - try testing.expectEqual(@as(usize, 2), n); - const listed = rd(p, root_ctl, 0, 4096); - try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n{d}\n", .{ @min(made[0], made[1]), @max(made[0], made[1]) }), listed.bytes); - const opened = p.panes[p.paneBySerial(@min(made[0], made[1])).?].?; + try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n", .{pane.serial}), rd(p, root_exec, 0, 4096).bytes); + + try testing.expectEqual(Status.ok, wr(p, root_look, "/virtual/index\n").reply.status); + const opened = p.panes[p.active].?; try testing.expectEqualStrings("/virtual/index", opened.file.?.path); + try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n", .{opened.serial}), rd(p, root_look, 0, 4096).bytes); + + try testing.expectEqual(Status.ok, wr(p, root_exec, "New\n").reply.status); + const made = p.panes[p.active].?; + try testing.expect(made.serial != opened.serial); + try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n", .{made.serial}), rd(p, root_exec, 0, 4096).bytes); } test "look opens spaced paths and locations without editing the source pane" { @@ -406,12 +347,12 @@ test "look opens spaced paths and locations without editing the source pane" { const p = try withFile(gpa, "source stays intact\n"); defer p.deinit(); const source = p.panes[0].?; - const ctl_node = Node.of(source.serial, .ctl); + const look_node = Node.of(source.serial, .look); const revision = source.file.?.revision; const undo_len = source.file.?.history.undo_len; source.cur_col = 3; - var command: [4200]u8 = undefined; - try testing.expectEqual(Status.ok, wr(p, ctl_node, try std.fmt.bufPrint(&command, "look {s}:2:3\n", .{path})).reply.status); + var clicked: [4200]u8 = undefined; + try testing.expectEqual(Status.ok, wr(p, look_node, try std.fmt.bufPrint(&clicked, "{s}:2:3\n", .{path})).reply.status); const opened = p.panes[p.active].?; try testing.expect(opened != source); try testing.expectEqualStrings(path, opened.file.?.path); @@ -423,14 +364,14 @@ test "look opens spaced paths and locations without editing the source pane" { try testing.expectEqual(undo_len, source.file.?.history.undo_len); try testing.expectEqual(@as(i32, 3), source.cur_col); var expected: [16]u8 = undefined; - try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n", .{opened.serial}), rd(p, root_ctl, 0, 4096).bytes); + try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n", .{opened.serial}), rd(p, root_look, 0, 4096).bytes); p.active = 0; - try testing.expectEqual(Status.ok, wr(p, root_ctl, try std.fmt.bufPrint(&command, "look {s}:3:2\n", .{path})).reply.status); + try testing.expectEqual(Status.ok, wr(p, root_look, try std.fmt.bufPrint(&clicked, "{s}:3:2\n", .{path})).reply.status); try testing.expect(p.panes[p.active].? == opened); try testing.expectEqual(@as(i32, 2), opened.cur_row); try testing.expectEqual(@as(i32, 1), opened.cur_col); - try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n", .{opened.serial}), rd(p, root_ctl, 0, 4096).bytes); + try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}\n", .{opened.serial}), rd(p, root_look, 0, 4096).bytes); } test "look validates the whole batch before opening virtual files" { @@ -438,17 +379,17 @@ test "look validates the whole batch before opening virtual files" { const p = try withFile(gpa, "source\n"); defer p.deinit(); const source = p.panes[0].?; - const ctl_node = Node.of(source.serial, .ctl); + const look_node = Node.of(source.serial, .look); const serial = p.next_serial; for ([_][]const u8{ - "look", "look \t", "look /virtual/index\x00ignored", "look /virtual/index\nbogus\n", + "/virtual/index\x00ignored", "/virtual/index\n/virtual/\x01index\n", }) |invalid| { - try testing.expectEqual(E.INVAL, wr(p, ctl_node, invalid).errno()); + try testing.expectEqual(E.INVAL, wr(p, look_node, invalid).errno()); try testing.expectEqual(serial, p.next_serial); try testing.expectEqual(@as(usize, 0), p.active); try testing.expectEqualStrings("source\n", source.file.?.content); } - try testing.expectEqual(Status.ok, wr(p, ctl_node, "look /n/self/index\n").reply.status); + try testing.expectEqual(Status.ok, wr(p, look_node, "/n/self/index\n").reply.status); const opened = p.panes[p.active].?; try testing.expectEqualStrings("/virtual/index", opened.file.?.path); try testing.expect(std.mem.indexOf(u8, opened.file.?.content, "/test.txt") != null); @@ -480,7 +421,7 @@ test "get reloads the pane from disk and reports a missing file without losing d _ = wr(p, Node.of(serial, .name), try std.fmt.bufPrint(&name, "{s}/missing.txt\n", .{directory})); _ = wr(p, Node.of(serial, .body), "unsaved\n"); - try testing.expectEqual(E.NOENT, wr(p, ctl_node, "get\nexec Del\n").errno()); + try testing.expectEqual(E.NOENT, wr(p, ctl_node, "get\n").errno()); try testing.expect(p.paneBySerial(serial) != null); try testing.expectEqualStrings("from disk\nunsaved\n", pane.file.?.content); try testing.expect(pane_files.dirtyOf(pane)); @@ -494,7 +435,7 @@ test "exec Save writes the named file through the host" { const pane = p.panes[0].?; try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .name), "/tmp/renamed.txt\n").reply.status); try testing.expect(pane_files.dirtyOf(pane)); - const saved = wr(p, Node.of(serial, .ctl), "exec Save\n"); + const saved = wr(p, Node.of(serial, .exec), "Save\n"); try testing.expectEqual(Status.ok, saved.reply.status); try testing.expect(saved.saved); p.perform(.{ .save_file = .{ .pane = 0 } }); diff --git a/src/ninep/events.zig b/src/ninep/events.zig index fb49e41b..bd53bcd9 100644 --- a/src/ninep/events.zig +++ b/src/ninep/events.zig @@ -89,6 +89,13 @@ pub const Queue = struct { } }; +/// What the next read would answer, which is the size a stat reports: a +/// client can see there is something waiting without parking on it. +pub fn pending(q: *const Queue) u64 { + const record = q.peek() orelse return 0; + return record.len; +} + /// One record per read; `.again` parks the read until a record arrives. pub fn readQueue(p: *Pardes, req: Req, q: *Queue) Reply { const record = q.peek() orelse return .{ .tag = req.tag, .status = .again }; @@ -461,7 +468,7 @@ test "a pane deleted while its event file is open leaves no suppression behind" const b = call(p, .{ .tag = 19, .op = .open, .node = event }); try testing.expectEqual(@as(u16, 2), p.fs.listeners); - _ = wr(p, Node.of(serial, .ctl), "exec Del\n"); + _ = wr(p, Node.of(serial, .exec), "Del\n"); try testing.expect(p.paneBySerial(serial) == null); try testing.expectEqual(@as(u16, 0), p.fs.listeners); @@ -471,7 +478,7 @@ test "a pane deleted while its event file is open leaves no suppression behind" try testing.expectEqual(E.NOENT, rd(p, event, 0, 64).errno()); try testing.expectEqual(E.NOENT, rd(p, Node.of(serial, .body), 0, 64).errno()); - try testing.expectEqual(E.NOENT, wr(p, Node.of(serial, .ctl), "clean\n").errno()); + try testing.expectEqual(E.NOENT, wr(p, Node.of(serial, .dirty), "0\n").errno()); try testing.expectEqual(E.NOENT, call(p, .{ .tag = 22, .op = .open, .node = event }).errno()); } @@ -535,7 +542,7 @@ test "the log parks until a pane is created, renamed, saved or deleted" { try std.fmt.bufPrint(&expected, "rename {d} /tmp/logged.txt\n", .{serial}), rd(p, log, 0, 4096).bytes, ); - const saving = wr(p, Node.of(serial, .ctl), "exec Save\n"); + const saving = wr(p, Node.of(serial, .exec), "Save\n"); try testing.expectEqual(Status.ok, saving.reply.status); try testing.expect(saving.saved); p.perform(.{ .save_file = .{ .pane = @intCast(id) } }); @@ -543,7 +550,7 @@ test "the log parks until a pane is created, renamed, saved or deleted" { try std.fmt.bufPrint(&expected, "save {d} /tmp/logged.txt\n", .{serial}), rd(p, log, 0, 4096).bytes, ); - try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .ctl), "exec Del\n").reply.status); + try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .exec), "Del\n").reply.status); try testing.expectEqualStrings( try std.fmt.bufPrint(&expected, "del {d} /tmp/logged.txt\n", .{serial}), rd(p, log, 0, 4096).bytes, diff --git a/src/ninep/pane.zig b/src/ninep/pane.zig index b37ae645..42c0c48e 100644 --- a/src/ninep/pane.zig +++ b/src/ninep/pane.zig @@ -1,5 +1,6 @@ -//! The files under /pane//: name, body, tag, ctl, addr, data, xdata, -//! sel, errors and event. Terminal panes add pty/ (pty.zig). +//! The files under /pane//: name, body, tag, ctl, the three range +//! files addr, dot and limit, data, xdata, sel, the three flag files dirty, +//! mark and scroll, errors, event, look and exec. Terminals add pty/ (pty.zig). const std = @import("std"); const pardes = @import("../pardes.zig"); const panes = @import("../panes.zig"); @@ -187,10 +188,15 @@ pub fn spliceBody(p: *Pardes, id: usize, pane: *Pane, q0: usize, q1: usize, byte return take; } -// ---- sizes reported by stat ---- +// ---- what stat reports ---- + +/// A range file's text: acme's addr format, two right-aligned offsets, so +/// that copying one range file onto another is the whole of `dot=addr`. +pub const range_len: u64 = 24; pub fn fileSize(p: *Pardes, id: usize, f: PaneFile) u64 { const pane = p.panes[id] orelse return 0; + const pf = &p.fs.panes[id]; return switch (f) { .body, .data, .xdata => bodyOf(pane).len, .tag => tagOf(p, pane).len, @@ -203,7 +209,24 @@ pub fn fileSize(p: *Pardes, id: usize, f: PaneFile) u64 { const d = dotOf(pane); break :sel @max(d.q0, d.q1) - d.q0; }, - .dir, .addr, .errors, .event, .pty, .pty_ctl, .pty_status, .pty_data => 0, + .addr, .dot => range_len, + .limit => if (pf.limit == null) 0 else range_len, + .dirty, .mark, .scroll => 2, + .look, .exec => ctl.resultsLen(p), + .event => events.pending(&pf.events), + .pty_status => pty.status_len, + .pty_data => events.pending(&pf.pty_out), + .dir, .errors, .pty, .pty_ctl => 0, + }; +} + +/// The qid version, which a client polls to watch a file for change. Only +/// the pane's text can promise one: its revision counts every edit, and +/// nothing else here changes in step with it. +pub fn versionOf(pane: *const Pane, f: PaneFile) u32 { + return switch (f) { + .body, .data, .xdata => if (pane.file) |*file| file.revision else 0, + else => 0, }; } @@ -246,13 +269,17 @@ pub fn read(p: *Pardes, req: Req, id: usize, pane: *Pane, file: PaneFile) Reply .ctl => ctl.readPane(p, req, pane), .addr => addr: { clampAddr(pf, bodyOf(pane).len); - const out = p.fs.stage(p.gpa); - out.print(p.gpa, "{d:>11} {d:>11} ", .{ pf.addr.q0, pf.addr.q1 }) catch {}; - break :addr tree.stagedReply(p, req); + break :addr readRange(p, req, pf.addr); }, + .dot => readRange(p, req, dotOf(pane)), + .limit => readRange(p, req, pf.limit), .data => readData(req, id, pane, pf, false), .xdata => readData(req, id, pane, pf, true), .sel => readSel(req, id, pane), + .dirty => readFlag(p, req, dirtyOf(pane)), + .mark => readFlag(p, req, !pf.nomark), + .scroll => readFlag(p, req, !pf.noscroll), + .look, .exec => ctl.readResults(p, req), .event => events.readQueue(p, req, &pf.events), .pty_status => pty.readStatus(p, req, id, pane), .pty_data => pty.readData(p, req, pf), @@ -260,6 +287,20 @@ pub fn read(p: *Pardes, req: Req, id: usize, pane: *Pane, file: PaneFile) Reply }; } +/// An unset limit reads empty, which is how a client tells it from one that +/// happens to bound nothing. +fn readRange(p: *Pardes, req: Req, r: ?State.Range) Reply { + const out = p.fs.stage(p.gpa); + if (r) |range| out.print(p.gpa, "{d:>11} {d:>11} ", .{ range.q0, range.q1 }) catch {}; + return tree.stagedReply(p, req); +} + +fn readFlag(p: *Pardes, req: Req, on: bool) Reply { + const out = p.fs.stage(p.gpa); + out.appendSlice(p.gpa, if (on) "1\n" else "0\n") catch {}; + return tree.stagedReply(p, req); +} + fn readBody(p: *Pardes, req: Req, id: usize, pane: *Pane) Reply { if (pane.file != null) { const text = bodyOf(pane); @@ -322,10 +363,12 @@ pub fn write(p: *Pardes, req: Req, id: usize, pane: *Pane, file: PaneFile) Reply .name => writeName(p, req, id, pane), .body => writeBody(p, req, id, pane), .tag => writeTag(p, req, pane), - .ctl => ctl.writePane(p, req, pane.serial), - .addr => writeAddr(p, req, id, pane), + .ctl => ctl.writePane(p, req, pane), + .addr, .dot, .limit => writeRange(p, req, id, pane, file), .data, .xdata => writeData(p, req, id, pane), .sel => writeSel(p, req, id, pane), + .dirty, .mark, .scroll => writeFlag(p, req, id, pane, file), + .look, .exec => ctl.command(p, req, pane.serial, file == .exec), .event => events.writeEvent(p, req, id), .errors => if (appendErrors(p, id, req.data)) |took| .{ .tag = req.tag, .written = @intCast(took) } @@ -389,15 +432,68 @@ fn writeSel(p: *Pardes, req: Req, id: usize, pane: *Pane) Reply { return .{ .tag = req.tag, .written = @intCast(take) }; } -fn writeAddr(p: *Pardes, req: Req, id: usize, pane: *Pane) Reply { +/// The pair of offsets a range file reads back, so that copying `addr` onto +/// `dot` or `limit` does what acme spelled `dot=addr` and `limit=addr`. +fn pairOf(text: []const u8) ?State.Range { + var it = std.mem.tokenizeAny(u8, text, " \t"); + const q0 = std.fmt.parseInt(u32, it.next() orelse return null, 10) catch return null; + const q1 = std.fmt.parseInt(u32, it.next() orelse return null, 10) catch return null; + if (it.next() != null) return null; + return .{ .q0 = q0, .q1 = @max(q0, q1) }; +} + +/// A range file takes an address expression, or that pair of offsets. +fn rangeOf(pf: *State, text: []const u8, data: []const u8) ?State.Range { + const expr = std.mem.trimEnd(u8, data, "\n"); + if (pairOf(expr)) |r| { + const n = clip(text.len); + return .{ .q0 = @min(r.q0, n), .q1 = @min(r.q1, n) }; + } + var a: addressing.Addr = .{ .text = text, .lim = pf.limit, .expr = expr }; + const r = a.address(pf.addr) orelse return null; + return if (a.i < expr.len) null else r; +} + +fn writeRange(p: *Pardes, req: Req, id: usize, pane: *Pane, file: PaneFile) Reply { const pf = &p.fs.panes[id]; const text = bodyOf(pane); clampAddr(pf, text.len); - const expr = std.mem.trimEnd(u8, req.data, "\n"); - var a: addressing.Addr = .{ .text = text, .lim = pf.limit, .expr = expr }; - const r = a.address(pf.addr) orelse return Reply.fail(req.tag, E.INVAL); - if (a.i < expr.len) return Reply.fail(req.tag, E.INVAL); - pf.addr = r; + const r = rangeOf(pf, text, req.data) orelse return Reply.fail(req.tag, E.INVAL); + switch (file) { + .addr => pf.addr = r, + .limit => pf.limit = r, + // Setting dot scrolls to it, which is the whole of acme's `show`. + .dot => { + if (fileOf(pane) == null) return Reply.fail(req.tag, E.INVAL); + setDot(pane, r); + }, + else => unreachable, + } + return .{ .tag = req.tag, .written = @intCast(req.data.len) }; +} + +fn flagOf(data: []const u8) ?bool { + const word = std.mem.trim(u8, data, " \t\r\n"); + if (std.mem.eql(u8, word, "1")) return true; + if (std.mem.eql(u8, word, "0")) return false; + return null; +} + +fn writeFlag(p: *Pardes, req: Req, id: usize, pane: *Pane, file: PaneFile) Reply { + const on = flagOf(req.data) orelse return Reply.fail(req.tag, E.INVAL); + const pf = &p.fs.panes[id]; + switch (file) { + .dirty => { + const f = fileOf(pane) orelse return Reply.fail(req.tag, E.INVAL); + f.saved_revision = if (on) f.revision -% 1 else f.revision; + }, + .mark => { + pf.nomark = !on; + if (on) panes.File.pushUndo(p, pane); + }, + .scroll => pf.noscroll = !on, + else => unreachable, + } return .{ .tag = req.tag, .written = @intCast(req.data.len) }; } @@ -475,14 +571,24 @@ pub fn appendErrors(p: *Pardes, id: usize, text: []const u8) ?usize { return text.len; } -/// Truncation empties a body; every other setattr just answers fresh attributes. +/// Truncation empties whatever the file holds: the body, the tag's editable +/// tail (acme's `cleartag`), a range. Every other setattr just answers fresh +/// attributes. pub fn truncate(p: *Pardes, id: usize, pane: *Pane, file: PaneFile) tree.Status { + const pf = &p.fs.panes[id]; switch (file) { .body, .data, .xdata => if (fileOf(pane) != null) { _ = spliceBody(p, id, pane, 0, bodyOf(pane).len, "") orelse return .err; - p.fs.panes[id].addr = .{}; + pf.addr = .{}; setDot(pane, .{}); }, + .tag => { + pane.tag_tail_len = 0; + pane.tag_init = true; + }, + .addr => pf.addr = .{}, + .limit => pf.limit = null, + .dot => if (fileOf(pane) != null) setDot(pane, .{}), else => {}, } return .ok; @@ -509,15 +615,19 @@ test "index lists serial kind dirty flag and name and stat reports its length" { const a = rd(p, index, 0, 4096); try testing.expectEqual(Status.ok, a.reply.status); var want: [64]u8 = undefined; - try testing.expectEqualStrings(try std.fmt.bufPrint(&want, "{d} text 0 /test.txt\n", .{pane.serial}), a.bytes); + const clean_row = try std.fmt.bufPrint(&want, "{d} text 0 /test.txt\n", .{pane.serial}); + try testing.expect(std.mem.indexOf(u8, a.bytes, clean_row) != null); + const at = std.mem.indexOf(u8, a.bytes, clean_row).?; const stat = call(p, .{ .tag = 1, .op = .getattr, .node = index }); try testing.expectEqual(@as(u64, a.bytes.len), stat.reply.attr.size); try testing.expectEqual(@as(u16, 0o444), stat.reply.attr.mode); pane.file.?.saved_revision = pane.file.?.revision -% 1; - try testing.expectEqualStrings(try std.fmt.bufPrint(&want, "{d} text 1 /test.txt\n", .{pane.serial}), rd(p, index, 0, 4096).bytes); - const mid = rd(p, index, 2, 4); - try testing.expectEqualStrings("text", mid.bytes); + var dirty_want: [64]u8 = undefined; + const dirty_row = try std.fmt.bufPrint(&dirty_want, "{d} text 1 /test.txt\n", .{pane.serial}); + try testing.expect(std.mem.indexOf(u8, rd(p, index, 0, 4096).bytes, dirty_row) != null); + const kind = at + std.mem.indexOfScalar(u8, clean_row, ' ').? + 1; + try testing.expectEqualStrings("text", rd(p, index, kind, 4).bytes); const serial = try th.newPane(p); const both = rd(p, index, 0, 4096); @@ -533,10 +643,11 @@ test "a terminal is listed as term with its directory as name" { const pane = p.panes[0].?; p.setCwd(0, "/work/dir"); var want: [64]u8 = undefined; - try testing.expectEqualStrings( - try std.fmt.bufPrint(&want, "{d} term 0 /work/dir\n", .{pane.serial}), + try testing.expect(std.mem.indexOf( + u8, rd(p, @intFromEnum(tree.TopFile.index), 0, 4096).bytes, - ); + try std.fmt.bufPrint(&want, "{d} term 0 /work/dir\n", .{pane.serial}), + ) != null); try testing.expectEqualStrings("/work/dir\n", rd(p, Node.of(pane.serial, .name), 0, 4096).bytes); try testing.expectEqual(E.PERM, wr(p, Node.of(pane.serial, .name), "/elsewhere\n").errno()); } @@ -566,6 +677,13 @@ test "body reads at any offset and writes append" { try testing.expectEqual(@as(u64, "one\ntwo\nthree\na".len), stat.reply.attr.size); try testing.expectEqual(@as(u16, 0o666), stat.reply.attr.mode); try testing.expect(stat.reply.attr.mtime >= p.fs.started); + + // The qid version is the pane's revision, so a stat sees an edit land. + try testing.expectEqual(p.panes[0].?.file.?.revision, stat.reply.attr.version); + _ = wr(p, body, "more\n"); + const later = call(p, .{ .tag = 7, .op = .getattr, .node = body }); + try testing.expect(later.reply.attr.version != stat.reply.attr.version); + try testing.expectEqual(@as(u32, 0), call(p, .{ .tag = 8, .op = .getattr, .node = Node.of(serial, .tag) }).reply.attr.version); } test "a body write to a terminal pane types at its shell" { @@ -653,18 +771,29 @@ test "sel reads the selection and writing sel replaces it" { const p = try withFile(gpa, "one\ntwo\n"); defer p.deinit(); const serial = serialOf(p); - const ctl_node = Node.of(serial, .ctl); + const addr_node = Node.of(serial, .addr); + const dot = Node.of(serial, .dot); const sel = Node.of(serial, .sel); - _ = wr(p, Node.of(serial, .addr), "#0,#3"); - try testing.expectEqual(Status.ok, wr(p, ctl_node, "dot=addr\n").reply.status); + // Copying addr onto dot is the whole of acme's `dot=addr`, and back again + // of `addr=dot`; each range file reads exactly what the other takes. + _ = wr(p, addr_node, "#0,#3"); + try testing.expectEqual(Status.ok, wr(p, dot, " 0 3 ").reply.status); + try testing.expectEqualStrings(" 0 3 ", rd(p, dot, 0, 100).bytes); + try testing.expectEqual(range_len, call(p, .{ .tag = 1, .op = .getattr, .node = dot }).reply.attr.size); try testing.expectEqualStrings("one", rd(p, sel, 0, 100).bytes); try testing.expectEqual(@as(u64, 3), call(p, .{ .tag = 1, .op = .getattr, .node = sel }).reply.attr.size); - _ = wr(p, ctl_node, "addr=dot\n"); + _ = wr(p, addr_node, "#0"); + _ = wr(p, addr_node, " 0 3 "); try testing.expectEqual(@as(u32, 0), p.fs.panes[0].addr.q0); try testing.expectEqual(@as(u32, 3), p.fs.panes[0].addr.q1); + // A truncation empties dot; an address expression addresses it. + _ = call(p, .{ .tag = 9, .op = .setattr, .node = dot, .truncate = true }); + try testing.expectEqualStrings("", rd(p, sel, 0, 100).bytes); + try testing.expectEqual(Status.ok, wr(p, dot, "#0,#3").reply.status); + try testing.expectEqual(Status.ok, wr(p, sel, "ONE").reply.status); try testing.expectEqualStrings("ONE\ntwo\n", p.panes[0].?.file.?.content); _ = wr(p, sel, "!"); @@ -672,6 +801,62 @@ test "sel reads the selection and writing sel replaces it" { try testing.expectEqual(@as(u64, 0), call(p, .{ .tag = 2, .op = .getattr, .node = sel }).reply.attr.size); } +test "the flag files read and write the state acme kept behind ctl verbs" { + const gpa = testing.allocator; + const p = try withFile(gpa, "one\ntwo\n"); + defer p.deinit(); + const serial = serialOf(p); + const pane = p.panes[0].?; + const pf = &p.fs.panes[0]; + const dirty = Node.of(serial, .dirty); + const mark = Node.of(serial, .mark); + const scroll = Node.of(serial, .scroll); + + for ([_]u64{ dirty, mark, scroll }) |node| { + try testing.expectEqual(@as(u64, 2), call(p, .{ .tag = 1, .op = .getattr, .node = node }).reply.attr.size); + for ([_][]const u8{ "", "yes", "2", "0 1", "true" }) |bad| + try testing.expectEqual(E.INVAL, wr(p, node, bad).errno()); + } + + try testing.expectEqualStrings("0\n", rd(p, dirty, 0, 8).bytes); + try testing.expectEqualStrings("1\n", rd(p, mark, 0, 8).bytes); + try testing.expectEqualStrings("1\n", rd(p, scroll, 0, 8).bytes); + + try testing.expectEqual(Status.ok, wr(p, dirty, "1\n").reply.status); + try testing.expect(dirtyOf(pane)); + try testing.expectEqualStrings("1\n", rd(p, dirty, 0, 8).bytes); + _ = wr(p, dirty, "0"); + try testing.expect(!dirtyOf(pane)); + + _ = wr(p, mark, "0"); + _ = wr(p, scroll, "0"); + try testing.expect(pf.nomark and pf.noscroll); + try testing.expectEqualStrings("0\n", rd(p, mark, 0, 8).bytes); + try testing.expectEqualStrings("0\n", rd(p, scroll, 0, 8).bytes); + _ = wr(p, mark, "1"); + _ = wr(p, scroll, "1"); + try testing.expect(!pf.nomark and !pf.noscroll); + + // A terminal has no file, so its dirty flag is readable but not writable. + const term = try th.withTerm(gpa); + defer term.deinit(); + try testing.expectEqualStrings("0\n", rd(term, Node.of(serialOf(term), .dirty), 0, 8).bytes); + try testing.expectEqual(E.INVAL, wr(term, Node.of(serialOf(term), .dirty), "1").errno()); +} + +test "truncating the tag clears its editable tail" { + const p = try withFile(testing.allocator, "x\n"); + defer p.deinit(); + const pane = p.panes[0].?; + const tag = Node.of(pane.serial, .tag); + _ = wr(p, tag, " Mine"); + try testing.expect(pane.tag_tail_len > 0); + const cleared = call(p, .{ .tag = 1, .op = .setattr, .node = tag, .truncate = true }); + try testing.expectEqual(Status.ok, cleared.reply.status); + try testing.expectEqual(@as(usize, 0), pane.tag_tail_len); + try testing.expect(std.mem.indexOf(u8, rd(p, tag, 0, 4096).bytes, " Mine") == null); +} + test "name reads the file name and writing it promotes a scratch without touching its body" { const gpa = testing.allocator; const p = try withFile(gpa, "opener\n"); diff --git a/src/ninep/pty.zig b/src/ninep/pty.zig index e6696b85..1b71a8d3 100644 --- a/src/ninep/pty.zig +++ b/src/ninep/pty.zig @@ -76,6 +76,9 @@ fn verb(p: *Pardes, id: usize, line: []const u8, apply: bool) bool { return true; } +/// Three right-aligned fields: cols, rows and whether the host holds the tty. +pub const status_len: u64 = 36; + pub fn readStatus(p: *Pardes, req: Req, id: usize, pane: *Pane) Reply { const out = p.fs.stage(p.gpa); out.print(p.gpa, "{d:>11} {d:>11} {d:>11} ", .{ @@ -146,7 +149,7 @@ test "a pane that is not a terminal has no pty/ at all" { var buf: [32]th.Dirent = undefined; const files = th.dirents(rdir(p, dir, 0).bytes, &buf); - try testing.expectEqual(@as(usize, 10), files.len); + try testing.expectEqual(@as(usize, 17), files.len); try testing.expect(th.nameAt(files, "pty") == null); try testing.expectEqual(E.NOENT, look_up(p, dir, "pty_ctl").errno()); @@ -167,7 +170,7 @@ test "a terminal pane's pty/ holds exactly ctl, status and data" { var buf: [32]th.Dirent = undefined; const files = th.dirents(rdir(p, dir, 0).bytes, &buf); - try testing.expectEqual(@as(usize, 11), files.len); + try testing.expectEqual(@as(usize, 18), files.len); try testing.expect(th.nameAt(files, "pty").?.dir); const inside = th.dirents(rdir(p, Node.of(serial, .pty), 0).bytes, &buf); @@ -247,7 +250,7 @@ test "every pty/ctl verb, and every refusal" { "cooked", "winsize 80 24\nbogus", // a good verb beside a bad one "bogus\nwinsize 80 24", - "look x", // a `ctl` verb; the two files share no vocabulary + "look x", // a pane command; pty/ctl shares none of that vocabulary "exec Del", }) |bad| { const a = wr(p, ctl, bad); diff --git a/src/ninep/screen.zig b/src/ninep/screen.zig index 5b68b34c..2684aa41 100644 --- a/src/ninep/screen.zig +++ b/src/ninep/screen.zig @@ -83,22 +83,33 @@ pub fn releaseSnapshot(p: *Pardes, req: Req) bool { return true; } -pub fn readListeners(p: *Pardes, req: Req) Reply { - var buf: [512]u8 = undefined; - var text = std.Io.Writer.fixed(&buf); +const listeners_cap = 512; + +fn listenersText(p: *Pardes, buf: []u8) []const u8 { + var text = std.Io.Writer.fixed(buf); if (p.fs.socket_path.len != 0) - text.print("unix!{s}\n", .{p.fs.socket_path}) catch return Reply.fail(req.tag, E.IO); + text.print("unix!{s}\n", .{p.fs.socket_path}) catch return text.buffered(); for ([_]?std.Io.net.IpAddress{ p.fs.tcp_address, p.fs.quic_address }, [_][]const u8{ "tcp", "quic" }) |maybe, transport| { const address = maybe orelse continue; switch (address) { .ip4 => |ip| text.print("{s}!{d}.{d}.{d}.{d}!{d}\n", .{ transport, ip.bytes[0], ip.bytes[1], ip.bytes[2], ip.bytes[3], ip.port }) catch - return Reply.fail(req.tag, E.IO), + return text.buffered(), .ip6 => |ip| text.print("{s}!{f}!{d}\n", .{ transport, std.Io.net.Ip6Address.Unresolved{ .bytes = ip.bytes, .interface_name = null }, ip.port }) catch - return Reply.fail(req.tag, E.IO), + return text.buffered(), } } + return text.buffered(); +} + +pub fn listenersLen(p: *Pardes) u64 { + var buf: [listeners_cap]u8 = undefined; + return listenersText(p, &buf).len; +} + +pub fn readListeners(p: *Pardes, req: Req) Reply { + var buf: [listeners_cap]u8 = undefined; const out = p.fs.stage(p.gpa); - out.appendSlice(p.gpa, text.buffered()) catch return Reply.fail(req.tag, E.NOMEM); + out.appendSlice(p.gpa, listenersText(p, &buf)) catch return Reply.fail(req.tag, E.NOMEM); return tree.stagedReply(p, req); } diff --git a/src/ninep/testing.zig b/src/ninep/testing.zig index ba26cb38..ad1d84e4 100644 --- a/src/ninep/testing.zig +++ b/src/ninep/testing.zig @@ -69,13 +69,30 @@ pub fn look_up(p: *Pardes, dir: u64, name: []const u8) Answer { return call(p, .{ .tag = 3, .op = .lookup, .node = dir, .data = name }); } -/// Opens /new once, as a client would, and returns the pane it made. +/// Creates a pane in /pane, as a client's mkdir does, and returns its serial. pub fn newPane(p: *Pardes) !u32 { - const new = @intFromEnum(tree.TopFile.new); - const opened = call(p, .{ .tag = 9, .op = .open, .node = new }); - if (opened.reply.status != .ok or opened.reply.handle == 0) return error.NoPane; - _ = call(p, .{ .tag = 9, .op = .release, .node = new, .handle = opened.reply.handle }); - return opened.reply.handle; + const made = mkdir(p, "scratch"); + if (made.reply.status != .ok) return error.NoPane; + const target = tree.Node.target(made.reply.attr.node) orelse return error.NoPane; + return switch (target) { + .pane => |t| t.serial, + .top => error.NoPane, + }; +} + +pub fn mkdir(p: *Pardes, name: []const u8) Answer { + return call(p, .{ + .tag = 9, + .op = .open, + .node = @intFromEnum(tree.TopFile.pane), + .data = name, + .create = true, + .perm = 0x8000_0000 | 0o755, + }); +} + +pub fn rmdir(p: *Pardes, node: u64) Answer { + return call(p, .{ .tag = 9, .op = .release, .node = node, .remove = true }); } pub fn withFile(gpa: std.mem.Allocator, text: []const u8) !*Pardes { diff --git a/src/ninep/tree.zig b/src/ninep/tree.zig index 56c3112d..46609649 100644 --- a/src/ninep/tree.zig +++ b/src/ninep/tree.zig @@ -4,8 +4,10 @@ //! extended here with the editor's reply payload; fs.zig keeps host access //! and mounts. //! -//! /README /index /ctl /new /log /screen /listeners -//! /pane//{name,body,tag,ctl,addr,data,xdata,sel,errors,event,pty/} +//! /README /index /status /look /exec /log /screen /listeners +//! /pane/ mkdir makes a pane, rmdir closes it +//! /pane//{name,body,tag,ctl,addr,dot,limit,data,xdata,sel, +//! dirty,mark,scroll,errors,event,look,exec,pty/} //! /os/... the host filesystem /src/... embedded sources (opt-in) const std = @import("std"); const cloud9 = @import("cloud9"); @@ -47,11 +49,16 @@ pub const Payload = union(enum) { pub const Reply = cloud9.fs.ReplyWith(Payload); +/// Tcreate opens a pane and Tremove closes one; nothing else in the tree is +/// created or destroyed by the protocol, and wstat stays a truncation. +pub const features: cloud9.fs.Features = .{ .create = true, .remove = true }; + pub fn changesPane(req: Req) bool { return switch (req.op) { .write, .setattr => true, - .open => req.node == @intFromEnum(TopFile.new), - .lookup, .getattr, .read, .release, .readdir => false, + .open => req.create, + .release => req.remove, + .lookup, .getattr, .read, .readdir => false, }; } @@ -63,8 +70,9 @@ pub const TopFile = enum(u4) { root = 1, README, index, - ctl, - new, + status, + look, + exec, log, screen, listeners, @@ -77,8 +85,8 @@ pub const TopFile = enum(u4) { pub fn mode(f: TopFile) u16 { return switch (f) { .root, .pane => 0o755, - .ctl => 0o666, - .README, .index, .new, .log, .screen, .listeners => 0o444, + .look, .exec => 0o666, + .README, .index, .status, .log, .screen, .listeners => 0o444, }; } @@ -89,18 +97,26 @@ pub const TopFile = enum(u4) { pub const root: u64 = @intFromEnum(TopFile.root); -pub const PaneFile = enum(u4) { +/// Declaration order is readdir order. +pub const PaneFile = enum(u5) { dir = 0, name, body, tag, ctl, addr, + dot, + limit, data, xdata, sel, + dirty, + mark, + scroll, errors, event, + look, + exec, pty, pty_ctl, pty_status, @@ -138,8 +154,8 @@ pub const PaneFile = enum(u4) { }; pub const Node = packed struct(u64) { - file: u4 = 0, - serial: u60 = 0, + file: u5 = 0, + serial: u59 = 0, pub fn of(serial: u32, file: PaneFile) u64 { std.debug.assert(serial != 0); @@ -240,8 +256,13 @@ pub fn stagedReply(p: *Pardes, req: Req) Reply { // ---- dispatch ---- pub fn handle(p: *Pardes, req: Req) Reply { - if (req.node == fs.os_root or req.node & fs.os_node != 0) return fs.osHandle(p, req); - if (req.node & sources.archive_node != 0) return sources.handle(p, req); + const host = req.node == fs.os_root or req.node & fs.os_node != 0; + const archive = req.node & sources.archive_node != 0; + // Only /pane is created in and removed from. The host tree and the + // embedded sources say so, rather than quietly doing nothing. + if ((host or archive) and (req.create or req.remove)) return Reply.fail(req.tag, E.PERM); + if (host) return fs.osHandle(p, req); + if (archive) return sources.handle(p, req); const target = Node.target(req.node) orelse return Reply.fail(req.tag, E.NOENT); if (req.op == .write or req.op == .setattr) p.fs.origin = switch (target) { .pane => |t| @as(u8, if (t.file == .body or t.file == .tag) 'E' else 'F'), @@ -280,6 +301,7 @@ fn attrOf(p: *Pardes, target: Target) ?Reply.Attr { .mode = t.file.mode(), .size = pane.fileSize(p, id, t.file), .mtime = pane.mtimeOf(p, pn), + .version = pane.versionOf(pn, t.file), }; }, } @@ -292,13 +314,14 @@ fn attrReply(p: *Pardes, tag: u64, target: Target) Reply { fn topSize(p: *Pardes, f: TopFile) u64 { return switch (f) { - .root, .pane, .new, .log, .screen, .listeners => 0, + // ponytail: /screen has no length until an open renders its frame. + .root, .pane, .screen => 0, .index => pane.indexLen(p), .README => fs.help.len, - .ctl => ctl: { - var buf: [ctl.root_text_cap]u8 = undefined; - break :ctl ctl.rootText(p, &buf).len; - }, + .status => ctl.statusLen(p), + .look, .exec => ctl.resultsLen(p), + .log => events.pending(&p.fs.log), + .listeners => screen.listenersLen(p), }; } @@ -366,7 +389,7 @@ fn readdir(p: *Pardes, req: Req, target: Target) Reply { switch (target) { .top => |f| switch (f) { .root => { - inline for (.{ TopFile.README, TopFile.index, TopFile.ctl, TopFile.new, TopFile.log, TopFile.screen, TopFile.listeners, TopFile.pane }) |t| { + inline for (.{ TopFile.README, TopFile.index, TopFile.status, TopFile.look, TopFile.exec, TopFile.log, TopFile.screen, TopFile.listeners, TopFile.pane }) |t| { if (skip > 0) skip -= 1 else stageDirent(out, p.gpa, @intFromEnum(t), t.dir(), t.fileName()); } if (skip > 0) skip -= 1 else stageDirent(out, p.gpa, fs.os_root, true, "os"); @@ -403,21 +426,27 @@ fn readdir(p: *Pardes, req: Req, target: Target) Reply { return .{ .tag = req.tag, .payload = .{ .staged = @intCast(out.items.len) } }; } -fn newPane(p: *Pardes) ?u32 { - const slot = p.freeSlot() orelse return null; +/// Tcreate in /pane opens a pane, the way mkdir opens a directory. The name +/// asked for is ignored: a pane is named by the serial the editor gives it, +/// which the reply carries back and /index lists last. +fn create(p: *Pardes, req: Req, target: Target) Reply { + switch (target) { + .top => |f| if (f != .pane) return Reply.fail(req.tag, E.PERM), + .pane => return Reply.fail(req.tag, E.PERM), + } + if (req.perm & cloud9.dmdir == 0) return Reply.fail(req.tag, E.PERM); + const slot = p.freeSlot() orelse return Reply.fail(req.tag, E.NFILE); p.newScratchBelow(p.active); - const pn = p.panes[slot] orelse return null; - return pn.serial; + const made = p.panes[slot] orelse return Reply.fail(req.tag, E.NFILE); + const attr = attrOf(p, .{ .pane = .{ .serial = made.serial, .file = .dir } }) orelse + return Reply.fail(req.tag, E.NFILE); + return .{ .tag = req.tag, .handle = 1, .attr = attr }; } fn open(p: *Pardes, req: Req, target: Target) Reply { + if (req.create) return create(p, req, target); switch (target) { .top => |f| switch (f) { - // The clone idiom: each open makes one empty pane; reads answer its serial. - .new => { - const serial = newPane(p) orelse return Reply.fail(req.tag, E.NFILE); - return .{ .tag = req.tag, .handle = serial }; - }, .screen => return screen.openSnapshot(p, req, true), .log => p.fs.log_readers +|= 1, else => {}, @@ -429,11 +458,7 @@ fn open(p: *Pardes, req: Req, target: Target) Reply { if (t.file.inPty() and !pn.isTerminal()) return Reply.fail(req.tag, E.NOENT); switch (t.file) { .body => if (pn.isTerminal()) return screen.openSnapshot(p, req, false), - .ctl => pf.limit = null, - .addr => { - pf.addr = .{}; - pf.limit = null; - }, + .addr => pf.addr = .{}, .event => { pf.readers +|= 1; p.fs.listeners +|= 1; @@ -446,7 +471,27 @@ fn open(p: *Pardes, req: Req, target: Target) Reply { return .{ .tag = req.tag, .handle = 1 }; } +/// Tremove closes a pane. Nothing else in the tree can be removed, and this +/// is also where an ORCLOSE open lands, so every node is checked here. +fn remove(p: *Pardes, req: Req) Reply { + const target = Node.target(req.node) orelse return Reply.fail(req.tag, E.NOENT); + const t = switch (target) { + .pane => |t| t, + .top => return Reply.fail(req.tag, E.PERM), + }; + if (t.file != .dir) return Reply.fail(req.tag, E.PERM); + const id = p.paneBySerial(t.serial) orelse return Reply.fail(req.tag, E.NOENT); + p.removePane(id) catch return Reply.fail(req.tag, E.IO); + return .{ .tag = req.tag }; +} + fn release(p: *Pardes, req: Req) Reply { + // The handle's bookkeeping runs whether or not the removal is allowed. + const done = releaseHandle(p, req); + return if (req.remove) remove(p, req) else done; +} + +fn releaseHandle(p: *Pardes, req: Req) Reply { if (screen.releaseSnapshot(p, req)) return .{ .tag = req.tag }; const target = Node.target(req.node) orelse return .{ .tag = req.tag }; switch (target) { @@ -502,12 +547,8 @@ fn read(p: *Pardes, req: Req, target: Target) Reply { } break :index stagedReply(p, req); }, - .ctl => ctl.readRoot(p, req), - .new => new: { - if (req.handle == 0) break :new Reply.fail(req.tag, E.INVAL); - p.fs.stage(p.gpa).print(p.gpa, "{d}\n", .{req.handle}) catch break :new Reply.fail(req.tag, E.NOMEM); - break :new stagedReply(p, req); - }, + .status => ctl.readStatus(p, req), + .look, .exec => ctl.readResults(p, req), .log => events.readQueue(p, req, &p.fs.log), .screen => screen.readSnapshot(p, req, null), .listeners => screen.readListeners(p, req), @@ -525,7 +566,7 @@ fn read(p: *Pardes, req: Req, target: Target) Reply { fn write(p: *Pardes, req: Req, target: Target) Reply { switch (target) { .top => |f| return switch (f) { - .ctl => ctl.writeRoot(p, req), + .look, .exec => ctl.command(p, req, null, f == .exec), else => Reply.fail(req.tag, E.PERM), }, .pane => |t| { @@ -587,8 +628,8 @@ test "filesystem inspection preserves pending and displayed Look hover" { const preview = p.look_hover_preview; const requests = [_]Req{ .{ .tag = 1, .op = .lookup, .node = root, .data = "screen" }, - .{ .tag = 1, .op = .lookup, .node = root, .data = "new" }, - .{ .tag = 1, .op = .getattr, .node = @intFromEnum(TopFile.new) }, + .{ .tag = 1, .op = .lookup, .node = root, .data = "status" }, + .{ .tag = 1, .op = .getattr, .node = @intFromEnum(TopFile.pane) }, .{ .tag = 2, .op = .getattr, .node = body }, .{ .tag = 3, .op = .open, .node = body }, .{ .tag = 4, .op = .read, .node = body, .size = 5 }, @@ -614,7 +655,7 @@ test "filesystem inspection preserves pending and displayed Look hover" { test "filesystem pane creation and truncation cancel Look hover" { const requests = [_]Req{ - .{ .tag = 2, .op = .open, .node = @intFromEnum(TopFile.new) }, + .{ .tag = 2, .op = .open, .node = @intFromEnum(TopFile.pane), .data = "x", .create = true, .perm = cloud9.dmdir | 0o755 }, .{ .tag = 3, .op = .setattr, .node = 0, .truncate = true }, }; for (requests) |request| { @@ -644,13 +685,13 @@ test "readdir lists the root and a pane directory without creating anything" { var top_bytes: [4096]u8 = undefined; @memcpy(top_bytes[0..top_reply.bytes.len], top_reply.bytes); const top = th.dirents(top_bytes[0..top_reply.bytes.len], &buf); - try testing.expect(top.len >= 9); - for ([_][]const u8{ "README", "index", "ctl", "new", "log", "screen", "listeners", "pane", "os" }, 0..) |name, i| { + try testing.expect(top.len >= 10); + for ([_][]const u8{ "README", "index", "status", "look", "exec", "log", "screen", "listeners", "pane", "os" }, 0..) |name, i| { try testing.expectEqualStrings(name, top[i].name); - try testing.expectEqual(i >= 7, top[i].dir); + try testing.expectEqual(i >= 8, top[i].dir); } - try testing.expectEqual(@intFromEnum(TopFile.pane), top[7].node); - try testing.expectEqual(fs.os_root, top[8].node); + try testing.expectEqual(@intFromEnum(TopFile.pane), top[8].node); + try testing.expectEqual(fs.os_root, top[9].node); var idbuf: [16]u8 = undefined; try testing.expect(th.nameAt(top, try std.fmt.bufPrint(&idbuf, "{d}", .{serial})) == null); try testing.expect(th.nameAt(top, "self") == null); @@ -674,13 +715,18 @@ test "readdir lists the root and a pane directory without creating anything" { } const panes_dir = rdir(p, @intFromEnum(TopFile.pane), 0); const listed = th.dirents(panes_dir.bytes, &buf); - try testing.expectEqual(@as(usize, 1), listed.len); - try testing.expectEqual(Node.of(serial, .dir), listed[0].node); + var idname: [16]u8 = undefined; + const own = th.nameAt(listed, try std.fmt.bufPrint(&idname, "{d}", .{serial})).?; + try testing.expectEqual(Node.of(serial, .dir), own.node); + try testing.expect(own.dir); const dir = rdir(p, Node.of(serial, .dir), 0); const files = th.dirents(dir.bytes, &buf); - try testing.expectEqual(@as(usize, 10), files.len); - for ([_][]const u8{ "name", "body", "tag", "ctl", "addr", "data", "xdata", "sel", "errors", "event" }, 0..) |name, i| + try testing.expectEqual(@as(usize, 17), files.len); + for ([_][]const u8{ + "name", "body", "tag", "ctl", "addr", "dot", "limit", "data", "xdata", + "sel", "dirty", "mark", "scroll", "errors", "event", "look", "exec", + }, 0..) |name, i| try testing.expectEqualStrings(name, files[i].name); try testing.expect(th.nameAt(files, ".") == null); try testing.expect(th.nameAt(files, "rdsel") == null); @@ -703,8 +749,10 @@ test "lookup resolves top files, pane serials and pane files" { const serial = serialOf(p); try testing.expectEqual(@as(u64, @intFromEnum(TopFile.index)), look_up(p, root, "index").reply.attr.node); - try testing.expect(!look_up(p, root, "new").reply.attr.dir); - try testing.expectEqual(@as(u16, 0o444), look_up(p, root, "new").reply.attr.mode); + try testing.expect(!look_up(p, root, "status").reply.attr.dir); + try testing.expectEqual(@as(u16, 0o444), look_up(p, root, "status").reply.attr.mode); + try testing.expectEqual(@as(u16, 0o666), look_up(p, root, "look").reply.attr.mode); + try testing.expectEqual(E.NOENT, look_up(p, root, "new").errno()); try testing.expect(look_up(p, root, "pane").reply.attr.dir); try testing.expect(look_up(p, root, "os").reply.attr.dir); try testing.expectEqual(E.NOENT, look_up(p, root, "nosuchthing").errno()); @@ -732,38 +780,46 @@ test "lookup resolves top files, pane serials and pane files" { try testing.expectEqual(E.NOTDIR, look_up(p, Node.of(serial, .body), "x").errno()); } -test "each open of new creates exactly one pane whose serial the read answers" { +test "creating in the pane directory opens a pane and removing one closes it" { const gpa = testing.allocator; const p = try withFile(gpa, "first\n"); defer p.deinit(); const before = p.next_serial; - const new = @intFromEnum(TopFile.new); + const panes_dir = @intFromEnum(TopFile.pane); - try testing.expectEqual(Status.ok, look_up(p, root, "new").reply.status); - try testing.expectEqual(Status.ok, call(p, .{ .tag = 1, .op = .getattr, .node = new }).reply.status); + // Browsing /pane creates nothing; only a create does. + try testing.expectEqual(Status.ok, rdir(p, panes_dir, 0).reply.status); try testing.expectEqual(before, p.next_serial); - const opened = call(p, .{ .tag = 1, .op = .open, .node = new }); - try testing.expectEqual(Status.ok, opened.reply.status); + const made = th.mkdir(p, "scratch"); + try testing.expectEqual(Status.ok, made.reply.status); try testing.expectEqual(before + 1, p.next_serial); - try testing.expectEqual(before + 1, opened.reply.handle); - try testing.expectEqual(@as(u64, 0), opened.reply.attr.node); + const serial = before + 1; + try testing.expectEqual(Node.of(serial, .dir), made.reply.attr.node); + try testing.expect(made.reply.attr.dir); var expected: [16]u8 = undefined; - const line = try std.fmt.bufPrint(&expected, "{d}\n", .{opened.reply.handle}); - try testing.expectEqualStrings(line, call(p, .{ .tag = 2, .op = .read, .node = new, .handle = opened.reply.handle, .size = 64 }).bytes); - try testing.expectEqualStrings(line[1..], call(p, .{ .tag = 2, .op = .read, .node = new, .handle = opened.reply.handle, .off = 1, .size = 64 }).bytes); - try testing.expectEqualStrings("", call(p, .{ .tag = 2, .op = .read, .node = new, .handle = opened.reply.handle, .off = line.len, .size = 64 }).bytes); - try testing.expectEqual(before + 1, p.next_serial); - _ = call(p, .{ .tag = 3, .op = .release, .node = new, .handle = opened.reply.handle }); + try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}", .{serial}), made.reply.attr.name); - const id = p.paneBySerial(opened.reply.handle).?; + const id = p.paneBySerial(serial).?; try testing.expectEqualStrings("", p.panes[id].?.file.?.content); - _ = wr(p, Node.of(opened.reply.handle, .body), "hi"); - const second = call(p, .{ .tag = 4, .op = .open, .node = new }); + _ = wr(p, Node.of(serial, .body), "hi"); + const second = th.mkdir(p, "another"); try testing.expectEqual(Status.ok, second.reply.status); - try testing.expect(second.reply.handle != opened.reply.handle); + try testing.expect(second.reply.attr.node != made.reply.attr.node); try testing.expectEqualStrings("hi", p.panes[id].?.file.?.content); - try testing.expectEqual(E.INVAL, call(p, .{ .tag = 5, .op = .read, .node = new, .size = 64 }).errno()); + + // A plain file, and a create anywhere else, are refused. + try testing.expectEqual(E.PERM, call(p, .{ .tag = 1, .op = .open, .node = panes_dir, .data = "f", .create = true, .perm = 0o666 }).errno()); + try testing.expectEqual(E.PERM, call(p, .{ .tag = 1, .op = .open, .node = root, .data = "d", .create = true, .perm = cloud9.dmdir | 0o755 }).errno()); + try testing.expectEqual(E.PERM, call(p, .{ .tag = 1, .op = .open, .node = Node.of(serial, .dir), .data = "d", .create = true, .perm = cloud9.dmdir | 0o755 }).errno()); + + // Tremove closes the pane it names, and nothing else in the tree. + try testing.expectEqual(E.PERM, th.rmdir(p, Node.of(serial, .body)).errno()); + try testing.expectEqual(E.PERM, th.rmdir(p, @intFromEnum(TopFile.index)).errno()); + try testing.expect(p.paneBySerial(serial) != null); + try testing.expectEqual(Status.ok, th.rmdir(p, Node.of(serial, .dir)).reply.status); + try testing.expect(p.paneBySerial(serial) == null); + try testing.expectEqual(E.NOENT, th.rmdir(p, Node.of(serial, .dir)).errno()); } test "directories walk to their parents" { @@ -791,14 +847,15 @@ test "editor paths resolve to the same nodes the wire serves" { try testing.expectEqual(root, resolveSelf(p, "").?); try testing.expectEqual(root, resolveSelf(p, "/./pane/../").?); try testing.expectEqual(@intFromEnum(TopFile.index), resolveSelf(p, "index").?); - try testing.expectEqual(@intFromEnum(TopFile.new), resolveSelf(p, "new").?); + try testing.expectEqual(@intFromEnum(TopFile.status), resolveSelf(p, "status").?); + try testing.expect(resolveSelf(p, "new") == null); try testing.expectEqual(@intFromEnum(TopFile.pane), resolveSelf(p, "pane").?); try testing.expectEqual(Node.of(serial, .dir), resolveSelf(p, try std.fmt.bufPrint(&path, "pane/{d}", .{serial})).?); try testing.expectEqual(Node.of(serial, .sel), resolveSelf(p, try std.fmt.bufPrint(&path, "pane/{d}/sel", .{serial})).?); try testing.expect(resolveSelf(p, try std.fmt.bufPrint(&path, "pane/{d}/pty/ctl", .{serial})) == null); try testing.expect(resolveSelf(p, try std.fmt.bufPrint(&path, "pane/{d}/rdsel", .{serial})) == null); try testing.expect(resolveSelf(p, "self/index") == null); - try testing.expect(resolveSelf(p, "new/ctl") == null); + try testing.expect(resolveSelf(p, "status/ctl") == null); try testing.expect(resolveSelf(p, "cons") == null); try testing.expect(resolveSelf(p, "pane/0") == null); } diff --git a/src/panes.zig b/src/panes.zig index edd7038f..9a6802d0 100644 --- a/src/panes.zig +++ b/src/panes.zig @@ -6273,6 +6273,13 @@ pub const Terminal = struct { state.vt.screens.active.scroll(.{ .delta_row = delta }); } + /// Is the viewport already showing the last row of output? + pub fn atBottom(pane: *const Pane) bool { + if (comptime !enabled) return true; + const sb = scrollbar(pane); + return sb.offset + sb.len >= sb.total; + } + /// Snap the viewport back onto live output. pub fn followOutput(pane: *Pane) void { if (comptime !enabled) return; @@ -6559,10 +6566,14 @@ pub const Terminal = struct { const has_positions = pane.ovl != null or pane.cur_pinned or pane.vsel.active or pane.msel.active or pane.nsel > 0 or pane.append_at != null or pane.look_at != null or pane.ed_undo_len > 0 or pane.ed_redo_len > 0 or pointerRowCount(pane) > 0; + // Sticky bottom, as every other terminal does it: output drags the + // viewport down only when the viewport was already on the last row, so + // a reader scrolled back into the scrollback stays where they scrolled. + const at_bottom = atBottom(pane); if (has_positions) ingestWithPositions(pane, bytes) else ingest(pane, bytes); p.shell_rows.markStale(pane); const body_mode = if (pane.tag_edit) pane.tag_mode else pane.mode; - if (body_mode == .tty) followOutput(pane); + if (body_mode == .tty and at_bottom) followOutput(pane); } const RowPin = struct { pin: ?*ghostty_vt.Pin = null, offset: i32 = 0 }; @@ -6890,6 +6901,7 @@ pub const Terminal = struct { }; pane.mode = .tty; + followOutput(pane); // entering raw mode is a request for the live shell pane.msel.active = false; pane.vsel.active = false; pane.nsel = 0; diff --git a/src/pardes.zig b/src/pardes.zig index ed71102e..c66688f5 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -295,6 +295,12 @@ const pre_collapse_pdf_pane_tail = " Tty Del PdfSections PdfTint"; const pre_collapse_terminal_pane_tail = " Save Tty Del Togglettymode Filter"; const pre_tty_first_terminal_pane_tail = " Save Tty Del Togglettymode Filter Collapse"; const pre_mode_terminal_pane_tail = " Tty Save Del Togglettymode Filter Collapse"; +// ...and the defaults from before the closing word moved to the end of every +// tagline, where a click cannot land on it by overshooting the one before. +const pre_close_last_pane_tail = " Tty Collapse Del"; +const pre_close_last_file_pane_tail = " Save Tty Del Collapse"; +const pre_close_last_pdf_pane_tail = " Tty Del PdfSections PdfTint Collapse"; +const pre_close_last_terminal_pane_tail = " Tty Save Del Mode Filter Collapse"; const Builtin = builtins.registry.Builtin(); @@ -1078,7 +1084,7 @@ test "Collapse builtin keeps content and restores the pane from its default tag" const height = p.rects[0].h; const revision = pane.file.?.revision; for ([_][]const u8{ pane_tail, file_pane_tail, pdf_pane_tail, terminal_pane_tail }) |tail| - try std.testing.expect(std.mem.endsWith(u8, tail, " Collapse")); + try std.testing.expect(std.mem.endsWith(u8, tail, " Collapse Del")); try std.testing.expect(p.executeBuiltinLine(0, "Collapse")); p.sync(); @@ -1115,6 +1121,8 @@ test "LocationsConfig command reports partial updates and survives restore" { try std.testing.expectEqual(expected, p.locations_config); try std.testing.expect(p.executeBuiltinLine(0, "LocationsConfig context:2 unknown:on")); try std.testing.expectEqual(expected, p.locations_config); + // Setting it is silent; asking bare is what opens the window. + try std.testing.expect(p.executeBuiltinLine(0, "LocationsConfig")); var reports: usize = 0; for (p.panes) |slot| { const pane = slot orelse continue; @@ -1409,7 +1417,7 @@ test "legacy default tag tails upgrade while custom tails remain owned" { }); p.restoreTail(file, file_old); try std.testing.expect(!file.tag_init); - try std.testing.expectEqualStrings(" Save Tty Del Collapse", Pardes.curTail(file)); + try std.testing.expectEqualStrings(" Save Tty Collapse Del", Pardes.curTail(file)); const file_custom = try std.fmt.allocPrint(p.scratch.allocator(), "{s} Save Mine Del", .{ try p.tagPrefix(file), @@ -1430,7 +1438,7 @@ test "legacy default tag tails upgrade while custom tails remain owned" { try std.testing.expectEqualStrings(" New Del", Pardes.curTail(file)); const image_doc = try panes.Image.create(p, 1, "/tmp/legacy image.ppm", &.{}); - try std.testing.expectEqualStrings(" Tty Del Collapse", Pardes.curTail(image_doc)); + try std.testing.expectEqualStrings(" Tty Collapse Del", Pardes.curTail(image_doc)); p.restoreDumpTail(image_doc, .{ .kind = .image, .tag = "img /tmp/legacy image.ppm Keep Del", @@ -1576,7 +1584,7 @@ test "pane defaults keep creation of scratch panes in column tags" { var words = std.mem.tokenizeScalar(u8, tag, ' '); while (words.next()) |word| try std.testing.expect(!std.mem.eql(u8, word, "New")); } - try std.testing.expectEqualStrings("New Tty Find Grep Joincol", p.columnTag(0)); + try std.testing.expectEqualStrings("New Tty Find Grep Joincol Delcol", p.columnTag(0)); const terminal = p.panes[0].?; p.restoreTailAt(terminal, pre_column_terminal_pane_tail, "", .terminal); try std.testing.expect(!terminal.tag_init); @@ -2441,13 +2449,13 @@ test "Save reaches every tagline with text behind it and no other" { }); p.restoreTail(out, scratch_dumped); try std.testing.expect(!out.tag_init); - try std.testing.expectEqualStrings(" Save Tty Del Collapse", Pardes.curTail(out)); + try std.testing.expectEqualStrings(" Save Tty Collapse Del", Pardes.curTail(out)); // An image's bytes on disk already are what they are: nothing of the // pane's own is unwritten, so the word is absent and inert. const img_id = p.freeSlot().?; const img = try panes.Image.create(p, img_id, "/tmp/pardes-tag.ppm", &.{}); - try std.testing.expectEqualStrings(" Tty Del Collapse", Pardes.curTail(img)); + try std.testing.expectEqualStrings(" Tty Collapse Del", Pardes.curTail(img)); try std.testing.expect(p.executeBuiltinLine(img_id, "Save")); try std.testing.expect(img.prompt != .save); var buf: [256]u8 = undefined; @@ -5818,8 +5826,42 @@ test "repeated non-dyadic column splits preserve every unrelated boundary" { pub const Rect = layout.Rect; +/// The session layouts `init` can put on screen. One name each, so choosing +/// between them reads as a choice instead of a chain of ifs over four options. +pub const Boot = enum { + /// the document named on the command line, or the pane explaining why not + document, + /// a Look that found nothing: reported, not opened + missing, + /// the firmware's boot buffer, the only pane a board has + embedded, + /// the bare tty startup: one shell in raw tty mode, with an empty text + /// pane under it so the editor half is there before you want it + tty, + /// that raw shell by itself, which is all a core booted for a test wants + tty_shell, + /// acme's boot: two columns, the left one split in two + classic, + /// one greeted shell + shell, + + pub fn of(opts: Options) Boot { + if (opts.boot) |named| return named; + if (opts.file != null) return .document; + if (opts.missing != null) return .missing; + if (comptime platform == .esp32p4) return .embedded; + if (opts.tty_only) return .tty_shell; + // ponytail: 1 and 3 are the only shell counts anyone asked for + return if (opts.shells >= 3) .classic else .shell; + } +}; + pub const Options = struct { tty_only: bool = false, + /// The layout to boot, when a host means one outright rather than leaving + /// it to be read off the options below. `--tty` names `.tty`; a core + /// booted for a test names nothing and gets `.tty_shell`. + boot: ?Boot = null, /// initial shell panes: 1 (default) or 3 for the classic two-column boot. /// A `file` outranks this — see there. shells: u8 = 1, @@ -6035,6 +6077,11 @@ pub const Pardes = struct { pipe_wait: ?PendingPipe = null, fs: filesystem.Namespace = .{}, + boot: Boot = .shell, + /// Builtins announce themselves on the message row. Off while startup + /// configuration is applied: those lines are nobody clicking, and should + /// not leave the row holding the name of the last one. + announce: bool = true, // Reject overflow: evicting an older effect would reorder a byte stream. effects: [limits.effect_cap]Effect = undefined, @@ -6114,7 +6161,10 @@ pub const Pardes = struct { for (opts.mounts) |mount| try p.fs.mount(gpa, mount.name, mount.dial); p.opts.mounts = &.{}; p.opts.ninep_identity = .{}; - if (opts.file) |path| { + p.boot = Boot.of(opts); + switch (p.boot) { + .document => { + const path = opts.file.?; const opened = initial_doc: { if (comptime pdf_enabled) if (look.isPdfPath(path)) break :initial_doc panes.Pdf.openPane(p, 0, path, opts.file_line); @@ -6137,10 +6187,10 @@ pub const Pardes = struct { errdefer gpa.free(content); _ = try panes.Output.open(p, 0, std.fs.path.dirname(path) orelse "/", .errors, "", content); } - p.ncol = 1; - p.col_n[0] = 1; - p.col_panes[0][0] = 0; - } else if (opts.missing) |missing| { + p.oneColumn(); + }, + .missing => { + const missing = opts.missing.?; const content = try std.fmt.allocPrint( gpa, "file or directory not found\n\n\t{s}\n", @@ -6148,24 +6198,26 @@ pub const Pardes = struct { ); errdefer gpa.free(content); _ = try panes.Output.open(p, 0, missing.dir, .errors, "", content); - p.ncol = 1; - p.col_n[0] = 1; - p.col_panes[0][0] = 0; - } else if (comptime platform == .esp32p4) { + p.oneColumn(); + }, + .embedded => { const content = try p.gpa.dupe(u8, boot_buffer); errdefer p.gpa.free(content); _ = try panes.Output.open(p, 0, "", .{ .cmd = .New }, "", content); - p.ncol = 1; - p.col_n[0] = 1; - p.col_panes[0][0] = 0; - } else if (opts.tty_only) { + p.oneColumn(); + }, + .tty, .tty_shell => { _ = try p.newShell(0, ""); p.panes[0].?.mode = .tty; - p.ncol = 1; - p.col_n[0] = 1; - p.col_panes[0][0] = 0; - } else if (opts.shells >= 3) { - // classic layout: two columns, the left one split in two. + p.oneColumn(); + // A bare tty is still an editor: it opens with somewhere to put + // text under the shell. The shell keeps the keyboard. + if (p.boot == .tty) { + p.newScratchBelow(0); + p.active = 0; + } + }, + .classic => { _ = try p.newShell(0, ""); _ = try p.newShell(1, ""); _ = try p.newShell(2, ""); @@ -6176,13 +6228,12 @@ pub const Pardes = struct { p.col_panes[0][1] = 1; p.col_n[1] = 1; p.col_panes[1][0] = 2; - } else { - // ponytail: 1 and 3 are the only boot layouts; anything else acts as 1 + }, + .shell => { _ = try p.newShell(0, ""); p.panes[0].?.greet = true; - p.ncol = 1; - p.col_n[0] = 1; - p.col_panes[0][0] = 0; + p.oneColumn(); + }, } p.sync(); p.applyStartupConfig(); @@ -6195,6 +6246,13 @@ pub const Pardes = struct { return p; } + /// The layout every single-pane boot starts from. + fn oneColumn(p: *Pardes) void { + p.ncol = 1; + p.col_n[0] = 1; + p.col_panes[0][0] = 0; + } + pub fn deinit(p: *Pardes) void { p.cancelLookHover(); for (0..MAX_PANES) |id| p.dropPendingWrite(id); @@ -6268,7 +6326,7 @@ pub const Pardes = struct { } pub fn columnTag(p: *const Pardes, c: usize) []const u8 { - return p.col_tags[c].slice("New Tty Find Grep Joincol"); + return p.col_tags[c].slice("New Tty Find Grep Joincol Delcol"); } fn headerText(p: *Pardes) []const u8 { @@ -6413,6 +6471,17 @@ pub const Pardes = struct { return np; } + /// The empty pane that stands in for one that closed, keeping its column + /// alive and its directory. Unlike `newScratch` it inherits nothing: the + /// pane it replaces is on its way out. + fn newScratchIn(p: *Pardes, free: usize, dir: []const u8) !*Pane { + const content = try p.gpa.dupe(u8, ""); + errdefer p.gpa.free(content); + const np = try panes.Output.open(p, free, dir, .{ .cmd = .New }, "", content); + np.cur_pinned = true; + return np; + } + /// New: a scratch below the calling pane, in its column. pub fn newScratchBelow(p: *Pardes, from_id: usize) void { const free = p.freeSlot() orelse return; @@ -8237,8 +8306,23 @@ pub const Pardes = struct { p.ctrl_w_pending = false; if (key.ctrl and !key.alt and key.cp == p.opts.tty_toggle) return p.toggleTty(p.active); + // Shift-Escape is the unconditional way out, even mid-application; + // bare Escape only leaves at a shell prompt. + if (hit(key, config.tty_toggle_alt)) + return p.runBuiltin(.Last, p.active, "", null); if (key.cp == Key.escape and !key.ctrl and !key.alt and !key.shift and p.takesCommandLine(p.active)) return p.runBuiltin(.Last, p.active, "", null); + panes.Terminal.followOutput(pane); // typing snaps back to live output + // Paste stays the window's, the one exception to forwarding a raw + // tty's keys: Ctrl-V types the register at the program and + // Ctrl-Shift-V asks the desktop for its clipboard first. Forwarded, + // they reach an application that reads the clipboard on its own + // account instead — a coding agent goes there hunting for an image. + // A host that folds Shift into the letter says the same thing. + if (key.ctrl and !key.alt and (key.cp == 'v' or key.cp == 'V')) { + if (key.shift or key.cp == 'V') return p.clipRequest(p.active, .after); + return p.typeToTty(p.active, pane, p.yank orelse return); + } return panes.Terminal.forwardKey(p, p.active, key); } if (p.leader_on) return p.leaderKey(key); @@ -12499,6 +12583,8 @@ pub const Pardes = struct { } fn applyStartupConfig(p: *Pardes) void { + p.announce = false; + defer p.announce = true; var lines = std.mem.splitScalar(u8, p.opts.startup_config orelse return, '\n'); while (lines.next()) |line| _ = p.executeBuiltinLine(p.active, line); } @@ -12506,6 +12592,11 @@ pub const Pardes = struct { fn runBuiltin(p: *Pardes, b: Builtin, id: usize, txt: []const u8, arg: ?[]const u8) void { if (!p.multiOnce()) return; // a builtin is per-keystroke, never per-cursor const pane = p.panes[id] orelse return; + // A builtin says its own name before it runs, so a tagline click is + // legible even when what it did is invisible. Whatever the builtin + // then says for itself replaces the announcement. + if (p.announce and p.settings.verbose and builtins.registry.announces(b)) + p.setMessage(id, @tagName(b)); const c: builtins.Ctx = .{ .p = p, .pane = pane, .id = id, .txt = txt, .arg = arg }; builtins.registry.dispatch(b, c); } @@ -12887,11 +12978,13 @@ pub const Pardes = struct { const rest = saved_tag[pfx.len..]; const said = std.mem.trimStart(u8, rest, " "); const defaults: []const []const u8 = switch (class) { - .generic => &.{ pdf_pane_tail, pane_tail, pre_collapse_pdf_pane_tail, pre_collapse_pane_tail, pre_column_pdf_pane_tail, pre_column_pane_tail, prev_pane_tail, legacy_pane_tail }, - .file => &.{ context_pane_tail, file_pane_tail, pre_collapse_file_pane_tail, pre_column_file_pane_tail, prev_file_pane_tail, legacy_file_pane_tail }, + .generic => &.{ pdf_pane_tail, pane_tail, pre_close_last_pdf_pane_tail, pre_close_last_pane_tail, pre_collapse_pdf_pane_tail, pre_collapse_pane_tail, pre_column_pdf_pane_tail, pre_column_pane_tail, prev_pane_tail, legacy_pane_tail }, + .file => &.{ context_pane_tail, file_pane_tail, pre_close_last_file_pane_tail, pre_collapse_file_pane_tail, pre_column_file_pane_tail, prev_file_pane_tail, legacy_file_pane_tail }, .output => &.{ locations_pane_tail, file_pane_tail, + pre_close_last_file_pane_tail, + pre_close_last_pane_tail, prev_file_pane_tail, legacy_file_pane_tail, pane_tail, @@ -12902,7 +12995,7 @@ pub const Pardes = struct { pre_collapse_file_pane_tail, pre_collapse_pane_tail, }, - .terminal => &.{ terminal_pane_tail, pre_mode_terminal_pane_tail, pre_tty_first_terminal_pane_tail, pre_collapse_terminal_pane_tail, pre_column_terminal_pane_tail, pre_tty_terminal_pane_tail, prev_terminal_pane_tail, legacy_terminal_pane_tail, pane_tail, pre_collapse_pane_tail, pre_column_pane_tail, prev_pane_tail, legacy_pane_tail }, + .terminal => &.{ terminal_pane_tail, pre_close_last_terminal_pane_tail, pre_close_last_pane_tail, pre_mode_terminal_pane_tail, pre_tty_first_terminal_pane_tail, pre_collapse_terminal_pane_tail, pre_column_terminal_pane_tail, pre_tty_terminal_pane_tail, prev_terminal_pane_tail, legacy_terminal_pane_tail, pane_tail, pre_collapse_pane_tail, pre_column_pane_tail, prev_pane_tail, legacy_pane_tail }, }; for (defaults) |default| if (std.mem.eql(u8, said, std.mem.trimStart(u8, default, " "))) return; @@ -12912,11 +13005,34 @@ pub const Pardes = struct { pub fn removePane(p: *Pardes, id: usize) !void { const pane = p.panes[id] orelse return; + // A column outlives its panes. Closing the last one leaves an empty + // pane standing in its place and in its directory; only Delcol ever + // takes a column away. + const place = layout.findPane(p, id); + const last_in_column = if (place) |f| p.col_n[f.col] == 1 else false; + var dir_buf: [limits.host_path_cap]u8 = undefined; + var dir: []const u8 = ""; + if (last_in_column) { + const had = paneDir(pane); + const n = @min(had.len, dir_buf.len); + @memcpy(dir_buf[0..n], had[0..n]); + dir = dir_buf[0..n]; + } + // Before anything is torn down, so a failure here changes nothing. try p.deinitPane(pane); + // ...and after it, so the stand-in inherits none of the closing pane. + const heir: ?usize = heir: { + if (!last_in_column) break :heir null; + const f = place.?; + const free = p.freeSlot() orelse break :heir null; + _ = p.newScratchIn(free, dir) catch break :heir null; + layout.insert(p, f.col, f.idx + 1, free); + break :heir free; + }; layout.absorbVWeight(p, id); layout.removePane(p, id); p.panes[id] = null; - if (p.active == id) p.active = p.prevFocus(id) orelse { + if (p.active == id) p.active = heir orelse p.prevFocus(id) orelse { p.quit = true; p.emit(.quit); return; @@ -14408,6 +14524,75 @@ test "Esc back into a tty leaves its view at the prompt" { try std.testing.expectEqual(live, sp.terminal.?.vt.screens.active.pages.scrollbar().offset); } +test "the bare tty startup opens a text pane under the shell, unfocused" { + if (platform == .web) return; + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .boot = .tty }); + defer p.deinit(); + try std.testing.expectEqual(Boot.tty, p.boot); + + // One column, shell on top in raw mode, an empty text pane under it. + try std.testing.expectEqual(@as(usize, 1), p.ncol); + try std.testing.expectEqual(@as(usize, 2), p.col_n[0]); + const shell = p.panes[p.col_panes[0][0]].?; + const scratch = p.panes[p.col_panes[0][1]].?; + try std.testing.expect(shell.isTerminal()); + try std.testing.expectEqual(Pane.Mode.tty, shell.mode); + try std.testing.expect(!scratch.isTerminal()); + try std.testing.expectEqualStrings("", scratch.file.?.content); + + // ...and the shell keeps the keyboard. + try std.testing.expectEqual(p.col_panes[0][0], p.active); + + // Unnamed, it is the bare shell every test asks for. + const plain = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); + defer plain.deinit(); + try std.testing.expectEqual(Boot.tty_shell, plain.boot); + try std.testing.expectEqual(@as(usize, 1), plain.col_n[0]); +} + +test "tty output follows only from the bottom" { + if (platform == .web) return; + const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 24, .file = "mise.toml" }); + defer p.deinit(); + p.update(.{ .resize = .{ .cols = 80, .rows = 24 } }); + p.update(.{ .key = .{ .cp = 'n', .alt = true } }); // a shell under the doc + const shell = p.active; + const sp = p.panes[shell].?; + p.update(.{ .key = .{ .cp = Key.escape, .shift = true } }); + try std.testing.expectEqual(Pane.Mode.tty, sp.mode); + + for (0..60) |i| { + var buf: [32]u8 = undefined; + p.update(.{ .output = .{ .pane = @intCast(shell), .bytes = std.fmt.bufPrint(&buf, "line {d}\r\n", .{i}) catch unreachable } }); + } + p.sync(); + const bottom = panes.Terminal.scrollbar(sp).offset; + try std.testing.expect(bottom > 0); + + // Scrolled back, the reader stays put however much the shell prints. + sp.scrollBy(-10); + p.sync(); + const parked = panes.Terminal.scrollbar(sp).offset; + try std.testing.expect(parked < bottom); + for (60..70) |i| { + var buf: [32]u8 = undefined; + p.update(.{ .output = .{ .pane = @intCast(shell), .bytes = std.fmt.bufPrint(&buf, "line {d}\r\n", .{i}) catch unreachable } }); + } + p.sync(); + try std.testing.expectEqual(parked, panes.Terminal.scrollbar(sp).offset); + + // Typing snaps back to live output, so nobody types blind. + p.update(.{ .key = .{ .cp = 'x', .text = "x" } }); + p.sync(); + try std.testing.expect(panes.Terminal.scrollbar(sp).offset > parked); + + // ...and from there output follows again. + const live = panes.Terminal.scrollbar(sp).offset; + p.update(.{ .output = .{ .pane = @intCast(shell), .bytes = "tail\r\n" } }); + p.sync(); + try std.testing.expect(panes.Terminal.scrollbar(sp).offset > live); +} + test "Esc back into a file leaves its view where it was" { if (platform == .web) return; const gpa = std.testing.allocator; @@ -14461,15 +14646,23 @@ test "raw tty Escape only leaves at a shell prompt" { const pane = p.panes[shell].?; var buf: [256]u8 = undefined; _ = drainWrites(p, &buf); - for ([_]Key{ - .{ .cp = Key.escape, .shift = true }, - }) |key| { - p.update(.{ .key = key }); - try std.testing.expectEqual(shell, p.active); - try std.testing.expectEqual(Pane.Mode.tty, pane.mode); - try std.testing.expect(drainWrites(p, &buf).len > 0); - } - p.update(.{ .key = .{ .cp = Key.escape } }); + + // Ordinary keys reach the child; Shift-Escape is the one unconditional way + // out and sends it nothing. + p.update(.{ .key = .{ .cp = 'x', .text = "x" } }); + try std.testing.expectEqual(shell, p.active); + try std.testing.expect(drainWrites(p, &buf).len > 0); + + p.update(.{ .key = .{ .cp = Key.escape, .shift = true } }); + try std.testing.expectEqual(@as(usize, 0), p.active); + try std.testing.expectEqualStrings("", drainWrites(p, &buf)); + try std.testing.expectEqual(Pane.Mode.tty, pane.mode); + + p.update(.{ .key = .{ .cp = Key.escape } }); // back into the shell + try std.testing.expectEqual(shell, p.active); + _ = drainWrites(p, &buf); + + p.update(.{ .key = .{ .cp = Key.escape } }); // bare Escape leaves at a prompt try std.testing.expectEqual(@as(usize, 0), p.active); try std.testing.expectEqualStrings("", drainWrites(p, &buf)); try std.testing.expectEqual(Pane.Mode.tty, pane.mode); @@ -14620,9 +14813,10 @@ test "raw tty forwards Ctrl letters and former global shortcuts to the child" { defer p.deinit(); var buf: [256]u8 = undefined; _ = drainWrites(p, &buf); - p.setYank("must not be pasted"); + p.setYank("register text"); for ('a'..'z' + 1) |letter| { if (letter == p.opts.tty_toggle) continue; // editor/TTY mode shortcut + if (letter == 'v') continue; // the window's paste, asserted just below p.update(.{ .key = .{ .cp = @intCast(letter), .ctrl = true } }); const expected = [_]u8{@intCast(letter - 'a' + 1)}; // The terminal encoder distinguishes Ctrl-I/M from Tab/Return. @@ -14636,15 +14830,21 @@ test "raw tty forwards Ctrl letters and former global shortcuts to the child" { try std.testing.expectEqual(Pane.Mode.tty, p.panes[0].?.mode); try std.testing.expect(!p.ctrl_w_pending and p.clip_pending == null); } - p.update(.{ .key = .{ .cp = 'v', .ctrl = true, .shift = true } }); - try std.testing.expectEqualStrings("\x1b[118;6u", drainWrites(p, &buf)); + // ...and the two paste chords are the exception: Ctrl-V types the register + // at the program, Ctrl-Shift-V asks the desktop first and types nothing yet. + p.update(.{ .key = .{ .cp = 'v', .ctrl = true } }); + try std.testing.expectEqualStrings("register text", drainWrites(p, &buf)); try std.testing.expect(p.clip_pending == null); + p.update(.{ .key = .{ .cp = 'v', .ctrl = true, .shift = true } }); + try std.testing.expectEqualStrings("", drainWrites(p, &buf)); + try std.testing.expect(p.clip_pending != null); + const unopened = p.freeSlot(); // whatever the boot layout already used for ([_]u8{ 'n', 'c' }) |letter| { p.update(.{ .key = .{ .cp = letter, .alt = true } }); const expected = [_]u8{ 0x1b, letter }; try std.testing.expectEqualStrings(&expected, drainWrites(p, &buf)); try std.testing.expectEqual(@as(usize, 0), p.active); - try std.testing.expect(p.panes[1] == null); + try std.testing.expectEqual(unopened, p.freeSlot()); } p.update(.{ .key = .{ .cp = Key.up } }); try std.testing.expectEqualStrings("\x1b[A", drainWrites(p, &buf)); diff --git a/src/tty/tty.zig b/src/tty/tty.zig index 23b7c09b..a1917ba9 100644 --- a/src/tty/tty.zig +++ b/src/tty/tty.zig @@ -71,6 +71,21 @@ fn inputReader(loop: *Loop, tty: anytype, cache: *vaxis.GraphemeCache) void { loop.postEvent(.quit) catch {}; } +/// How long a lone ESC waits for the rest of a sequence before it counts as +/// the Escape key. Long enough for the remainder of a real sequence to arrive +/// even over a slow link, short enough that nobody sees the delay. +const escape_hold_ms = 25; + +/// Is there more input right behind what we have already read? Only a real +/// terminal has an fd to ask; the test readers hand their parts over whole, so +/// for them the answer is always no. +fn morePending(tty: anytype) bool { + const Reader = @typeInfo(@TypeOf(tty)).pointer.child; + if (!@hasField(Reader, "fd") or @FieldType(Reader, "fd") != std.Io.File) return false; + var fds = [_]std.posix.pollfd{.{ .fd = tty.fd.handle, .events = std.posix.POLL.IN, .revents = 0 }}; + return (std.posix.poll(&fds, escape_hold_ms) catch return false) > 0; +} + fn readInput(loop: *Loop, tty: anytype, cache: *vaxis.GraphemeCache) !void { try loop.postEvent(.{ .winsize = try tty.getWinsize() }); var parser: vaxis.Parser = .{}; @@ -101,6 +116,22 @@ fn readInput(loop: *Loop, tty: anytype, cache: *vaxis.GraphemeCache) !void { } carried = end - consumed; std.mem.copyForwards(u8, buf[0..carried], buf[consumed..end]); + // A lone ESC opens most sequences and is also the Escape key, so the + // parser holds it for a remainder that a keypress never sends: the + // press would only land when the NEXT key arrived. Wait a beat, and + // when nothing follows it was the key. A terminal speaking the kitty + // protocol never reaches here — it spells Escape out in full. + if (carried == 1 and buf[0] == 0x1b and !morePending(tty)) { + carried = 0; + try vaxis.loop.handleEventGeneric( + loop, + loop.vaxis, + cache, + @TypeOf(Command.value), + @as(vaxis.Event, .{ .key_press = .{ .codepoint = vaxis.Key.escape } }), + loop.vaxis.opts.system_clipboard_allocator, + ); + } } } diff --git a/src/tutor.txt b/src/tutor.txt index 394a48a3..adf4ae3a 100644 --- a/src/tutor.txt +++ b/src/tutor.txt @@ -160,8 +160,10 @@ RAW INPUT Ctrl-b switches to editor mode. Other keys go to the child, - including Ctrl-o, Ctrl-w, Ctrl-V, Ctrl-Shift-V, Alt shortcuts, and - modified Escape. Plain Esc at a detected shell prompt hops + including Ctrl-o, Ctrl-w, Alt shortcuts, and + modified Escape. The two paste chords are the exception: Ctrl-V + types the yank register at the program and Ctrl-Shift-V types the + desktop clipboard. Plain Esc at a detected shell prompt hops to the previous pane. While a program owns the terminal, Esc goes to that program too. Use the Togglettymode tag to leave raw input in place. Desktop paste events still feed the child. @@ -387,15 +389,15 @@ typed pardes the 9P socket opens by default - A directory per pane holding `name`, `body`, `tag`, `ctl`, `addr`, - `data`, `sel`, `event`, `pty/` and the rest, plus `index`, `ctl`, - `new` and `log` at the root. Every pane shell receives `$PARDES_9P` - (the socket) and `$PARDES_PANE` (its serial). Use a 9P client: + A directory per pane holding `name`, `body`, `tag`, `addr`, `dot`, + `data`, `sel`, `dirty`, `event`, `pty/` and the rest, plus `index`, + `status`, `look`, `exec` and `log` at the root. Every pane shell + receives `$PARDES_9P` (the socket) and `$PARDES_PANE` (its serial): /pane//body /index - /new reading it makes a pane, answers its serial - /ctl `look FILE:12` and `exec Save`, as the mouse does + /pane mkdir here makes a pane, rmdir closes it + /look /exec `FILE:12` and `Save`, as the mouse does A terminal pane also has `pty/`: @@ -446,7 +448,8 @@ typed Esc goes to the program — except at a shell PROMPT, where it hops to the previous pane Ctrl-b switches to editor mode - All other keys belong to the child, including Ctrl-V + Ctrl-V types the register, Ctrl-Shift-V the clipboard + All other keys belong to the child DETACHED pardes --detach[=name] the core, no terminal pardes --attach[=name] a frontend for it diff --git a/test/appearance_gallery.py b/test/appearance_gallery.py index 0fa12136..48c0ea1b 100644 --- a/test/appearance_gallery.py +++ b/test/appearance_gallery.py @@ -82,7 +82,7 @@ def run(args): right = require(wait_for(lambda: next((s for s in panes(client) if s not in before), None)), 'right column missing') client.write(f'/pane/{right}/name', f'{root / "Review"}\n'.encode()) client.write(f'/pane/{right}/body', PREFERENCE_NOTES if args.theme_selector else NOTES, truncate=True) - client.write(f'/pane/{right}/ctl', b'clean\n') + client.write(f'/pane/{right}/dirty', b'0\n') before = set(panes(client)) command(client, right, 'Tty') terminal = require(wait_for(lambda: next((s for s in panes(client) if s not in before), None)), 'terminal missing') @@ -94,12 +94,12 @@ def run(args): command(client, right, 'Config') pane = require(wait_for(lambda: next((s for s in panes(client) if s not in before), None)), 'Config output missing') text = client.read(f'/pane/{pane}/body').decode() - client.write(f'/pane/{pane}/ctl', b'exec Del\n') + client.write(f'/pane/{pane}/exec', b'Del\n') return text settings = config_report() - require('Font effective size: 18.00 pixels' in settings, 'configured font size not applied: ' + settings) - require('TaglineSize: 80' in settings, 'configured tag size missing') + require('Font effective size 18.00 pixels' in settings, 'configured font size not applied: ' + settings) + require('TaglineSize 80' in settings, 'configured tag size missing') (root / 'effective-config.txt').write_text(settings) report['font_effective_pixels'] = 18 report['tagline_percent'] = 80 @@ -135,7 +135,7 @@ def run(args): command(client, right, 'Theme ' + theme) if args.theme_selector: # Keep both quiet active gutter ink and vivid comments in view. - client.write(f'/pane/{source}/ctl', f'look {source_path}:117\n'.encode()) + client.write(f'/pane/{source}/look', f'{source_path}:117\n'.encode()) take_frame('classic-' + theme) if args.theme_selector: frame = client.screen() @@ -171,14 +171,14 @@ def run(args): 'ThemeSel did not open at native first entry') take_frame('theme-selector') report['native_themes_first'] = True - client.write(f'/pane/{selector}/ctl', b'exec Del\n') + client.write(f'/pane/{selector}/exec', b'Del\n') command(client, terminal, 'Collapse') for pet in (() if args.skip_pets else ('cat', 'frog', 'off')): command(client, right, 'Pet ' + pet) settings = config_report() require('Pet: ' + pet + '\n' in settings, 'pet setting not applied') # Returning focus to the source closes all transient report state. - client.write(f'/pane/{source}/ctl', f'look {source_path}:1\n'.encode()) + client.write(f'/pane/{source}/look', f'{source_path}:1\n'.encode()) take_frame('pet-' + pet) if pet != 'off': frame = client.screen() diff --git a/test/column_tags.py b/test/column_tags.py index 80b623bd..fe3a8699 100644 --- a/test/column_tags.py +++ b/test/column_tags.py @@ -143,7 +143,7 @@ def run(args): client.write(f'/pane/{right}/name', f'{right_name}\n'.encode()) right_body = b'// Column-local scratch\nfn main() {\n let ready = true;\n}\n' client.write(f'/pane/{right}/body', right_body) - client.write(f'/pane/{right}/ctl', b'clean\n') + client.write(f'/pane/{right}/dirty', b'0\n') require(wait_for(lambda: locate(client, 'New Tty', row=1, minimum_col=75)), 'right column tag missing') require(locate(client, 'New Tty', row=1, minimum_col=75) == (75, 1), 'right column tag retains an inset') @@ -173,7 +173,7 @@ def run(args): extra = require(wait_for(lambda: new_serial(client, before)), 'right-column New did not create a pane') client.write(f'/pane/{extra}/body', b'RIGHT-COLUMN-NEW\n') require(wait_for(lambda: locate(client, 'RIGHT-COLUMN-NEW', minimum_col=75)), 'right-column command targeted another column') - client.write(f'/pane/{extra}/ctl', b'exec Del\n') + client.write(f'/pane/{extra}/exec', b'Del\n') checks.append('middle-click New targets the inactive right column') # An owned short-path file makes its complete tag visible. Pane-tag diff --git a/test/e2e_harness.zig b/test/e2e_harness.zig index f7f380df..5a181b78 100644 --- a/test/e2e_harness.zig +++ b/test/e2e_harness.zig @@ -92,7 +92,7 @@ pub const Harness = struct { const ws = posix.winsize{ .row = rows, .col = cols, .xpixel = 0, .ypixel = 0 }; const pid = forkpty(&master, null, null, &ws); if (pid == 0) { - for ([_][*:0]const u8{ "PARDES_9P", "PARDES_PANE", "PARDES_FORWARD_LOOK" }) |name| + for ([_][*:0]const u8{ "PARDES_PID", "PARDES_9P", "PARDES_PANE" }) |name| if (unsetenv(name) != 0) _exit(126); _ = execvp(exe, argv.ptr); _exit(127); diff --git a/test/font_size.py b/test/font_size.py index 3a0a9a28..b7104099 100644 --- a/test/font_size.py +++ b/test/font_size.py @@ -30,16 +30,16 @@ def run(args): for serial, tag in panes(client).items(): if '/+Config ' in tag: body = client.read(f'/pane/{serial}/body').decode() - if f'Font effective size: {size:.2f} pixels' in body: + if f'Font effective size {size:.2f} pixels' in body: return body return None return require(wait_for(ready), f'Font did not become {size} pixels') initial = report(18) - require('Font requested size: 18.00' in initial, 'startup size suffix ignored') + require('Font requested size 18.00' in initial, 'startup size suffix ignored') require(args.font in initial, 'requested font missing') execute(client, control, f'Font {args.font}:20.5') - require('Font requested size: 20.50' in report(20.5), 'fractional size ignored') + require('Font requested size 20.50' in report(20.5), 'fractional size ignored') execute(client, control, f'Font {args.font}') report(20.5) # no suffix preserves current size execute(client, control, f'Font {args.font}:900') diff --git a/test/fs.py b/test/fs.py index 819a78d6..c3ffa440 100644 --- a/test/fs.py +++ b/test/fs.py @@ -100,8 +100,15 @@ def session(binary, root, name, *options, socket_name=None, file=None, tty=False assert not reader.is_alive(), 'terminal reader did not stop' +def newest(client): + """The newest pane's serial: /index is ordered by serial.""" + return int(client.read('/index').splitlines()[-1].split()[0]) + + def new_pane(client, contents): - serial = int(client.read('/new').split()[0]) + """mkdir in /pane; the editor names the directory after the new serial.""" + client.mkdir('/pane', 'scratch') + serial = newest(client) if contents: client.write(f'/pane/{serial}/body', contents) return serial @@ -110,18 +117,18 @@ def new_pane(client, contents): def look(client, path, source=None): """A right click on `path` from a pane (a fresh scratch by default).""" serial = source if source is not None else new_pane(client, b'') - client.write(f'/pane/{serial}/ctl', f'look {path}\n'.encode()) - results = [int(row) for row in client.read('/ctl').split()] + client.write(f'/pane/{serial}/look', f'{path}\n'.encode()) + results = [int(row) for row in client.read('/look').split()] assert len(results) == 1 and results[0] != serial, (path, results) return results[0] def execute(client, serial, command): """A middle click on `command` from a pane.""" - client.write(f'/pane/{serial}/ctl', f'exec {command}\n'.encode()) + client.write(f'/pane/{serial}/exec', f'{command}\n'.encode()) -def walk_tree(client, path='/', skip=('/new', '/log', '/os', '/screen')): +def walk_tree(client, path='/', skip=('/log', '/os', '/screen')): """Stat every entry below `path`, as `find` does, without opening anything.""" seen = [] for name in client.list(path): @@ -138,18 +145,21 @@ def discovery(binary, embedded=False): root = Path(directory) with session(binary, root, 'discovery') as (client, _): top = client.list('/') - assert top[:9] == ['README', 'index', 'ctl', 'new', 'log', 'screen', 'listeners', 'pane', 'os'], top - assert 'self' not in top and 'cons' not in top, top + assert top[:10] == ['README', 'index', 'status', 'look', 'exec', 'log', 'screen', + 'listeners', 'pane', 'os'], top + assert 'self' not in top and 'cons' not in top and 'new' not in top, top assert ('src' in top) == embedded, (top, embedded) before = client.read('/index') guide = client.read('/README') - assert guide.count(b'\n') <= 45 and b'exec Msg' in guide and b'/new' in guide, guide + assert guide.count(b'\n') <= 45 and b'Msg hello' in guide and b'mkdir' in guide, guide assert client.stat('/README')['length'] == len(guide) # ls/stat/find over the whole tree, without opening, creates nothing. seen = walk_tree(client) names = {path for path, _ in seen} - assert {'/index', '/ctl', '/new', '/log', '/pane/1', '/pane/1/body', '/pane/1/name', - '/pane/1/sel', '/pane/1/ctl', '/pane/1/tag', '/pane/1/event'} <= names, sorted(names) + assert {'/index', '/status', '/look', '/exec', '/log', '/pane/1', '/pane/1/body', + '/pane/1/name', '/pane/1/sel', '/pane/1/ctl', '/pane/1/tag', '/pane/1/event', + '/pane/1/dot', '/pane/1/limit', '/pane/1/dirty', '/pane/1/mark', + '/pane/1/scroll', '/pane/1/look', '/pane/1/exec'} <= names, sorted(names) assert '/pane/1/pty' not in names, 'the fixture file pane grew a pty/' assert not any(name.startswith('/self') or name.endswith('/rdsel') or name.endswith('/wrsel') for name in names), sorted(names) @@ -159,18 +169,28 @@ def discovery(binary, embedded=False): assert client.read('/index') == before, 'browsing created a pane' assert client.stat('/index')['length'] == len(before) > 0 index = client.stat('/index') - assert index['mode'] == 0o444 and client.stat('/ctl')['mode'] == 0o666 + assert index['mode'] == 0o444 and client.stat('/status')['mode'] == 0o444 + assert client.stat('/exec')['mode'] == 0o666 assert client.stat('/pane/1/body')['mode'] == 0o666 and client.stat('/pane')['mode'] == 0o755 + # A range file reads the pair it takes; a flag file reads 0 or 1. + assert client.stat('/pane/1/addr')['length'] == 24 + assert client.stat('/pane/1/limit')['length'] == 0 + assert client.read('/pane/1/dirty') == b'0\n' + assert client.read('/pane/1/scroll') == b'1\n' fixture = int(before.split()[0]) assert before.split()[1:3] == [b'text', b'0'] and before.endswith(b'/discovery.txt\n'), before - # Before any command, /ctl reports the editor. - status = dict(line.split(maxsplit=1) for line in client.read('/ctl').decode().splitlines()) - assert int(status['pid']) > 0 and status['version'] and int(status['panes']) == 1, status - # /new: one pane per open, its serial is the file's content. + # /status reports the editor; /exec has nothing to report yet. + status = dict(line.split(maxsplit=1) for line in client.read('/status').decode().splitlines()) + assert int(status['pid']) > 0 and status['version'] and int(status['panes']) >= 1, status + assert client.read('/exec') == b'' + # mkdir makes a pane, named by the serial the editor gives it. log = client.open('/log') - first = int(client.read('/new').split()[0]) - second = int(client.read('/new').split()[0]) + client.mkdir('/pane', 'one') + first = newest(client) + client.mkdir('/pane', 'two') + second = newest(client) assert first != second and first != fixture, (first, second) + assert 'one' not in client.list('/pane') and 'two' not in client.list('/pane') assert client.read_fid(log) == f'new {first} {root}/+New\n'.encode() assert client.read_fid(log) == f'new {second} {root}/+New\n'.encode() assert set(client.list('/pane')) == {str(fixture), str(first), str(second)} @@ -186,51 +206,63 @@ def discovery(binary, embedded=False): assert client.read(f'/pane/{first}/name') == f'{root}/notes.txt\n'.encode() assert client.read_fid(log) == f'rename {first} {root}/notes.txt\n'.encode() assert client.stat(f'/pane/{first}/name')['length'] == len(f'{root}/notes.txt\n') + # Copying addr onto dot selects that range; sel reads and replaces it. client.write(f'/pane/{first}/addr', b'#0,#5') - client.write(f'/pane/{first}/ctl', b'dot=addr\n') + client.write(f'/pane/{first}/dot', client.read(f'/pane/{first}/addr')) + assert client.read(f'/pane/{first}/dot') == client.read(f'/pane/{first}/addr') assert client.read(f'/pane/{first}/sel') == b'first' assert client.stat(f'/pane/{first}/sel')['length'] == 5 client.write(f'/pane/{first}/sel', b'FIRST') assert client.read(f'/pane/{first}/body') == b'FIRST pane' assert client.read(f'/pane/{first}/sel') == b'' - # exec Msg shows text; exec Save writes the named file; exec Del closes. - client.write(f'/pane/{first}/ctl', b'exec Msg hello from 9P\n') + # exec Msg shows text; exec Save writes the named file; rmdir closes. + client.write(f'/pane/{first}/exec', b'Msg hello from 9P\n') assert 'hello from 9P' in ''.join(cell[0] for cell in client.screen()['cells']) - client.write(f'/pane/{first}/ctl', b'exec Save\n') + assert client.read(f'/pane/{first}/dirty') == b'1\n' + client.write(f'/pane/{first}/exec', b'Save\n') assert (root / 'notes.txt').read_bytes() == b'FIRST pane' assert client.read_fid(log) == f'save {first} {root}/notes.txt\n'.encode() - assert client.read('/ctl') == f'{first}\n'.encode() - client.write('/ctl', b'exec Del\n') + assert client.read('/exec') == f'{first}\n'.encode() + assert client.read(f'/pane/{first}/dirty') == b'0\n' + client.remove(f'/pane/{second}') assert client.read_fid(log) == f'del {second} {root}/+New\n'.encode() assert str(second) not in client.list('/pane') - # look through /ctl opens a file; the serial reads back. + # look opens a file; the serial reads back. (root / 'opened.txt').write_bytes(b'one\ntwo\nthree\n') - client.write('/ctl', f'look {root}/opened.txt:2\n'.encode()) - opened = int(client.read('/ctl')) + client.write('/look', f'{root}/opened.txt:2\n'.encode()) + opened = int(client.read('/look')) assert opened not in (fixture, first, second), opened assert client.read(f'/pane/{opened}/body') == b'one\ntwo\nthree\n' assert client.read(f'/pane/{opened}/name') == f'{root}/opened.txt\n'.encode() assert client.read_fid(log) == f'new {opened} {root}/opened.txt\n'.encode() - client.write(f'/pane/{first}/ctl', f'look {root}/opened.txt:3\n'.encode()) - assert client.read('/ctl') == f'{opened}\n'.encode(), 'a repeated look targets the open pane' - assert set(client.list('/pane')) == {str(fixture), str(first), str(opened)} + client.write(f'/pane/{first}/look', f'{root}/opened.txt:3\n'.encode()) + assert client.read('/look') == f'{opened}\n'.encode(), 'a repeated look targets the open pane' + assert {str(fixture), str(first), str(opened)} <= set(client.list('/pane')) # Writing an event record back still performs the action it names. client.write(f'/pane/{first}/body', b'Msg via event', truncate=True) client.write(f'/pane/{first}/event', b'FX0 13\n') assert 'via event' in ''.join(cell[0] for cell in client.screen()['cells']) - for bad in [b'Look x\n', b'Exec Msg x\n', b'put\n', b'name x\n', b'del\n']: + # A command line may not carry control characters, and nothing else + # in the tree may be created or removed. + refused = [lambda: client.write('/exec', b'Msg a\x00b'), + lambda: client.write('/status', b'anything\n'), + lambda: client.mkdir('/', 'x'), + lambda: client.create('/pane', 'plain-file'), + lambda: client.remove('/pane/1/body'), + lambda: client.remove('/index')] + for index, attempt in enumerate(refused): try: - client.write('/ctl', bad) + attempt() except OSError: pass else: - raise AssertionError(f'{bad!r} was accepted') + raise AssertionError(f'refusal {index} was accepted') client.close(log) if embedded: assert client.read('/src/pardes.zig').startswith(b'const std') assert client.stat('/src/pardes.zig')['mode'] == 0o444 assert b'pub const Pardes' in client.read(f'/pane/{look(client, "/virtual/src/pardes.zig")}/body') - print('9P discovery: listing/stat/find are inert; new, ctl, name, sel and log behave') + print('9P discovery: listing/stat/find are inert; create, remove, look, exec, name, sel and log behave') def test(binary, quic=False): @@ -266,7 +298,7 @@ def test(binary, quic=False): assert not (root / 'pardes-9p-renamed.sock').exists() assert named.read('/pane/1/body') == b'initial\n' with session(binary, root, 'first') as (client, address): - assert {'pane', 'index', 'new', 'ctl', 'log', 'os'} <= set(client.list('/')) + assert {'pane', 'index', 'status', 'look', 'exec', 'log', 'os'} <= set(client.list('/')) assert 'self' not in client.list('/') assert client.read('/pane/1/body') == b'initial\n' assert client.read('/os' + str(root / 'first.txt')) == b'initial\n' @@ -346,7 +378,7 @@ def test(binary, quic=False): opened = look(remote, '/n/peer/pane/' + str(serial) + '/body') assert remote.read(f'/pane/{opened}/body') == b'replaced\nevent\n' remote.write(f'/pane/{opened}/body', b'saved to peer\n', truncate=True) - remote.write(f'/pane/{opened}/ctl', b'exec Save\n') + remote.write(f'/pane/{opened}/exec', b'Save\n') assert client.read(body) == b'saved to peer\n' large = b'mounted file contents\n' * 60000 @@ -356,7 +388,7 @@ def test(binary, quic=False): assert remote.read(f'/pane/{opened}/body') == large edited = large[:-3] + b'edited\n' remote.write(f'/pane/{opened}/body', edited, truncate=True) - remote.write(f'/pane/{opened}/ctl', b'exec Save\n') + remote.write(f'/pane/{opened}/exec', b'Save\n') assert large_path.read_bytes() == edited assert client.read('/os' + str(large_path)) == edited @@ -368,12 +400,12 @@ def test(binary, quic=False): execute(remote, control, 'Mount peer ' + str(own_address)) execute(remote, control, 'Unmount peer') remote.write(f'/pane/{opened}/body', b'runtime mounted Save\n', truncate=True) - remote.write(f'/pane/{opened}/ctl', b'exec Save\n') + remote.write(f'/pane/{opened}/exec', b'Save\n') assert client.read('/pane/1/body') == b'runtime mounted Save\n' assert remote.read('/pane/1/body') == b'initial\n' roots = look(remote, '/n', source=control) assert b'/n/peer/\n' in remote.read(f'/pane/{roots}/body') - remote.write(f'/pane/{opened}/ctl', b'exec Del\n') + remote.write(f'/pane/{opened}/exec', b'Del\n') execute(remote, control, 'Unmount peer') remote.write(f'/pane/{roots}/ctl', b'get\n') assert remote.read(f'/pane/{roots}/body') == b'/n/os/\n/n/self/\n' @@ -385,7 +417,7 @@ def test(binary, quic=False): file='/n/peer/pane/1/body:1') as (remote, _): assert remote.read('/pane/1/body') == b'runtime mounted Save\n' - client.write(f'/pane/{serial}/ctl', b'exec Del\n') + client.write(f'/pane/{serial}/exec', b'Del\n') assert str(serial) not in client.list('/pane') for tty in [False, True]: @@ -424,7 +456,7 @@ def test(binary, quic=False): file_id, control_id = restored_ids contents = restored.read(f'/pane/{file_id}/body') assert contents == b'dumped state\n', (contents, saved.read_text(), restored.read('/index')) - assert restored.read(f'/pane/{control_id}/body') == b'', 'commands ran through ctl, not the body' + assert restored.read(f'/pane/{control_id}/body') == b'', 'commands ran through exec, not the body' assert restored.screen()['cols'] == 80 opened = look(restored, '/n/own/os' + str(root / (name + '.txt')), source=control_id) assert restored.read(f'/pane/{opened}/body') == b'initial\n' @@ -451,14 +483,12 @@ def test(binary, quic=False): assert client.read(f'/pane/{opened}/body') == expected assert client.read('/pane/1/body') == b'initial\n' if selected is not None: - addr = client.open(f'/pane/{opened}/addr') - client.write(f'/pane/{opened}/ctl', b'addr=dot\n') - actual = list(map(int, client.read_fid(addr).split())) - client.close(addr) + # The selection is dot; reading it takes no command at all. + actual = list(map(int, client.read(f'/pane/{opened}/dot').split())) assert actual == selected, (word, actual, selected) addr = client.open('/pane/1/addr', 2) - ctl = client.open('/pane/1/ctl', 1) - for fid, text in [(addr, b'#0,#3'), (ctl, b'limit=addr\n'), (addr, b'#0')]: + limit = client.open('/pane/1/limit', 2) + for fid, text in [(addr, b'#0,#3'), (limit, b'#0,#3'), (addr, b'#0')]: client.rpc(118, struct.pack(' req.size) return error.IncorrectReply; - const names = [_][]const u8{ "README", "index", "ctl", "new", "log", "screen", "listeners", "pane", "os" }; - const nodes = [_]u64{ @intFromEnum(ctlfs.TopFile.README), @intFromEnum(ctlfs.TopFile.index), @intFromEnum(ctlfs.TopFile.ctl), @intFromEnum(ctlfs.TopFile.new), @intFromEnum(ctlfs.TopFile.log), @intFromEnum(ctlfs.TopFile.screen), @intFromEnum(ctlfs.TopFile.listeners), @intFromEnum(ctlfs.TopFile.pane), filesystem.os_root }; + const names = [_][]const u8{ "README", "index", "status", "look", "exec", "log", "screen", "listeners", "pane", "os" }; + const nodes = [_]u64{ @intFromEnum(ctlfs.TopFile.README), @intFromEnum(ctlfs.TopFile.index), @intFromEnum(ctlfs.TopFile.status), @intFromEnum(ctlfs.TopFile.look), @intFromEnum(ctlfs.TopFile.exec), @intFromEnum(ctlfs.TopFile.log), @intFromEnum(ctlfs.TopFile.screen), @intFromEnum(ctlfs.TopFile.listeners), @intFromEnum(ctlfs.TopFile.pane), filesystem.os_root }; var off: usize = 0; var entry: usize = 0; while (off < bytes.len) : (entry += 1) { diff --git a/test/fs_namespace.zig b/test/fs_namespace.zig index 8b6f245e..3eba6639 100644 --- a/test/fs_namespace.zig +++ b/test/fs_namespace.zig @@ -245,22 +245,17 @@ test "virtual file opens do not request OS watches" { while (p.nextEffect()) |effect| if (effect == .watch) return error.VirtualFileWatch; } -test "Look at the clone file reserves its own pane and failed opens release it" { +test "Look at a virtual file opens one pane and failed opens release their slot" { const p = try pardes.Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer p.deinit(); - p.lookAt(0, "/virtual/new"); - var control_count: usize = 0; - var scratch_count: usize = 0; + p.lookAt(0, "/virtual/index"); + var opened: usize = 0; for (p.panes) |slot| { const pane = slot orelse continue; const file = pane.file orelse continue; - if (std.mem.eql(u8, file.path, "/virtual/new")) control_count += 1; - if (file.output) |output| if (output.from == .cmd and output.from.cmd == .New) { - scratch_count += 1; - }; + if (std.mem.eql(u8, file.path, "/virtual/index")) opened += 1; } - try std.testing.expectEqual(@as(usize, 1), control_count); - try std.testing.expectEqual(@as(usize, 1), scratch_count); + try std.testing.expectEqual(@as(usize, 1), opened); const free = p.freeSlot().?; try std.testing.expectError(error.FileNotFound, pardes.panes.File.open(p, free, "/n/self/does-not-exist", 0)); try std.testing.expect(p.panes[free] == null); diff --git a/test/fs_soak.py b/test/fs_soak.py index 5569a7c7..a62f03e6 100644 --- a/test/fs_soak.py +++ b/test/fs_soak.py @@ -145,7 +145,7 @@ def run(args): client.write(base + '/body', body, truncate=True) path = root / f'pane-{slot}-0.zig' client.write(base + '/name', f'{path}\n'.encode()) - client.write(base + '/ctl', b'exec Save\n') + client.write(base + '/exec', b'Save\n') panes.append({'serial': serial, 'body': body, 'path': path, 'variant': 0}) emit(kind='start', seed=args.seed, session_pid=pid, transport=args.transport, host='tty' if args.tty else 'detached', @@ -187,7 +187,7 @@ def run(args): pane['variant'] ^= 1 pane['path'] = root / f'pane-{slot}-{pane["variant"]}.zig' client.write(base + '/name', f'{pane["path"]}\n'.encode()) - client.write(base + '/ctl', b'exec Save\n') + client.write(base + '/exec', b'Save\n') check_bytes(pane['path'].read_bytes(), pane['body'], 'saved file') check_bytes(client.read('/os' + str(pane['path'])), pane['body'], 'OS mount') elif operation == 'reload': @@ -196,13 +196,13 @@ def run(args): client.write(base + '/ctl', b'get\n') elif operation == 'cycle': old_serial = pane['serial'] - client.write(base + '/ctl', b'exec Del\n') + client.remove(base) pane['body'] = payload(rng) pane['serial'] = new_pane(client, pane['body']) assert pane['serial'] != old_serial base = f'/pane/{pane["serial"]}' client.write(base + '/name', f'{pane["path"]}\n'.encode()) - client.write(base + '/ctl', b'exec Save\n') + client.write(base + '/exec', b'Save\n') elif operation == 'reconnect': client.socket.close() client = Client(address) diff --git a/test/look_placement.py b/test/look_placement.py index 1341e776..8a31157f 100644 --- a/test/look_placement.py +++ b/test/look_placement.py @@ -74,7 +74,7 @@ def run_case(args, root, source_index): require('pty' in client.list(pane), 'fixture contains an existing document') marker = f'LP_{index}' markers[serial] = marker - client.write(pane + '/ctl', b'cleartag\n') + client.write(pane + '/tag', b'', truncate=True) client.write(pane + '/tag', f' {marker} Tty Del Collapse'.encode()) # Establish non-pristine shells and a stable prompt before measuring. client.write(pane + '/pty/data', f"printf 'ready-{index}\\n'\r".encode()) @@ -89,7 +89,7 @@ def run_case(args, root, source_index): require(before[serials[0]][:2] == (0, 2) and before[serials[1]][0] == 0 and before[serials[1]][1] > 2 and before[serials[2]][:2] == (75, 2), f'unexpected initial classic layout: {before}') - client.write(f'/pane/{source}/ctl', f'look {target}\n'.encode()) + client.write(f'/pane/{source}/look', f'{target}\n'.encode()) opened = require(wait_for(lambda: next((serial for serial in panes(client) if serial not in serials), None)), 'Look did not open the first document') @@ -113,7 +113,7 @@ def run_case(args, root, source_index): f'Look changed unrelated terminal {serial} rendered text') require(client.read(f'/pane/{opened}/body') == contents, 'opened document contents differ') - client.write(f'/pane/{source}/ctl', f'look {target}:2\n'.encode()) + client.write(f'/pane/{source}/look', f'{target}:2\n'.encode()) require(list(panes(client)) == serials + [opened], 'repeated Look created a duplicate pane') require(wait_for(lambda: geometry(client, markers)[1] == after), 'repeated Look changed layout') diff --git a/test/ninep.py b/test/ninep.py index 6c625951..ac4e146b 100644 --- a/test/ninep.py +++ b/test/ninep.py @@ -97,6 +97,25 @@ class Client: def close(self, fid): self.rpc(120, struct.pack(' |w| { + const bytes = w.bytes.slice(); + if (n + bytes.len > buf.len) break; + @memcpy(buf[n..][0..bytes.len], bytes); + n += bytes.len; + }, + else => {}, + }; + return buf[0..n]; + } + + // Raw tty mode forwards nearly every key to the child; the two paste + // chords are the exception, and forwarding them instead is what broke + // pasting into a terminal pane. An application that gets Ctrl-V rather + // than the text goes and reads the desktop clipboard on its own account, + // and a coding agent reading it is looking for an image, not for words. + test "raw tty paste chords type at the program instead of reaching it as keys" { + if (comptime !panes.Terminal.enabled) return error.SkipZigTest; + for ([_]bool{ false, true }) |bracketed| { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 40, .rows = 12 }); + defer p.deinit(); + const pane = p.panes[0].?; + try std.testing.expectEqual(Pane.Mode.tty, pane.mode); + if (bracketed) p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[?2004h" } }); + try std.testing.expectEqual(bracketed, panes.Terminal.bracketedPaste(pane)); + p.yank = try p.gpa.dupe(u8, "one\ntwo"); // what a `y` anywhere left behind + var buf: [256]u8 = undefined; + _ = childInput(p, &buf); + + // Ctrl-V types the register straight at the program, asking the + // desktop for nothing. Under DECSET 2004 the program's own fences + // carry it, which is what stops readline RUNNING a multi-line paste. + p.update(.{ .key = .{ .cp = 'v', .ctrl = true } }); + try std.testing.expectEqualStrings( + if (bracketed) "\x1b[200~one\ntwo\x1b[201~" else "one\rtwo", + childInput(p, &buf), + ); + try std.testing.expect(p.clip_pending == null); + + // Ctrl-Shift-V is the other store: it ASKS, types nothing yet, and + // the answer lands at the program rather than in an edit buffer. A + // host that folds the Shift into the letter says the same thing. + for ([_]Key{ + .{ .cp = 'v', .ctrl = true, .shift = true }, + .{ .cp = 'V', .ctrl = true }, + }) |chord| { + p.update(.{ .key = chord }); + try std.testing.expect(p.clip_pending != null); + try std.testing.expectEqualStrings("", childInput(p, &buf)); + p.update(.{ .paste = "from-desktop" }); + try std.testing.expect(p.clip_pending == null); + try std.testing.expectEqualStrings( + if (bracketed) "\x1b[200~from-desktop\x1b[201~" else "from-desktop", + childInput(p, &buf), + ); + } + // ...and neither chord put the clipboard in the register on its way. + try std.testing.expectEqualStrings("one\ntwo", p.yank orelse ""); + } + } }; const ClickCursorTests = struct { @@ -1616,7 +1682,7 @@ test "generated output refuses every pipe prompt before seeding the tag" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer p.deinit(); const content = try p.gpa.dupe(u8, "generated\n"); - const pane = try panes.Output.open(p, 1, "/", .{ .cmd = .Help }, "", content); + const pane = try panes.Output.open(p, p.freeSlot().?, "/", .{ .cmd = .Help }, "", content); p.active = 1; for ([_]Key{ .{ .cp = '|' }, .{ .cp = '|', .alt = true }, .{ .cp = '!' }, .{ .cp = '!', .alt = true } }) |key| { p.update(.{ .key = key }); @@ -1825,14 +1891,14 @@ test "file history construction failures preserve existing panes" { defer if (incoming) |bytes| p.gpa.free(bytes); failing.fail_index = failing.alloc_index + failure; const result = switch (case) { - .open => panes.File.open(p, 1, path, 0), + .open => panes.File.open(p, p.freeSlot().?, path, 0), .restore => panes.File.restore(p, 1, .{ .kind = .file, .tag = "", .body = "", .file = .{ .path = "/restored.zig", .content = "restored\n" }, }), - .output => panes.Output.open(p, 1, "/", .{ .cmd = .Help }, "", incoming.?), + .output => panes.Output.open(p, p.freeSlot().?, "/", .{ .cmd = .Help }, "", incoming.?), .tutor => p.openTutorView(1), .replace => p.setTestFile("replacement\n"), }; @@ -1900,14 +1966,14 @@ test "file history owns bounded snapshot storage without per-edit bookkeeping al try std.testing.expectEqual(@as(usize, 0), history.redo_len); } -test "file history allocation precedes a filesystem read with side effects" { +test "file history allocation precedes reading the served tree" { var failing = std.testing.FailingAllocator.init(std.testing.allocator, .{}); const p = try Pardes.init(failing.allocator(), .{ .tty_only = true, .cols = 40, .rows = 12 }); defer p.deinit(); const original = p.panes[0].?; const serial = p.next_serial; failing.fail_index = failing.alloc_index + 2; - try std.testing.expectError(error.OutOfMemory, panes.File.open(p, 1, "/n/self/new", 0)); + try std.testing.expectError(error.OutOfMemory, panes.File.open(p, p.freeSlot().?, "/n/self/index", 0)); try std.testing.expect(failing.has_induced_failure); try std.testing.expectEqual(original, p.panes[0].?); try std.testing.expectEqual(serial, p.next_serial); diff --git a/test/pdf.zig b/test/pdf.zig index beeb0b40..930cc5c0 100644 --- a/test/pdf.zig +++ b/test/pdf.zig @@ -1253,7 +1253,7 @@ test "PdfTint cycles pane-local state without adding tag clutter" { try std.testing.expectEqual(PdfTintMode.filtered, pv.tint); const initial_tag = try pardes.test_api.tagText(p, p.scratch.allocator(), pane); try std.testing.expect(std.mem.startsWith(u8, initial_tag, pv.path)); - try std.testing.expect(std.mem.endsWith(u8, initial_tag, " PdfSections PdfTint Collapse")); + try std.testing.expect(std.mem.endsWith(u8, initial_tag, " PdfSections PdfTint Collapse Del")); try std.testing.expect(std.mem.indexOf(u8, initial_tag, "filtered") == null); try std.testing.expect(pardes.test_api.runBuiltin( diff --git a/test/tag_cleanup.py b/test/tag_cleanup.py index 7b7d8bbf..ae0a0e66 100644 --- a/test/tag_cleanup.py +++ b/test/tag_cleanup.py @@ -36,7 +36,7 @@ def run(args): before = set(panes(client)) execute(client, control, 'Tty') tty = require(wait_for(lambda: next((s for s in panes(client) if s not in before), None)), 'terminal missing') - client.write(f'/pane/{control}/ctl', b'exec Del\n') # owned command-only scratch + client.write(f'/pane/{control}/exec', b'Del\n') # owned command-only scratch def tag_position(): frame = client.screen() diff --git a/test/ui_review.py b/test/ui_review.py index 2b6faa29..a1cdcdeb 100644 --- a/test/ui_review.py +++ b/test/ui_review.py @@ -43,7 +43,7 @@ def command(client, serial, text): current = client.read(tag) start = current.rfind(text.encode()) client.write(f'/pane/{serial}/event', f'Mx{start} {start + len(text.encode())}\n'.encode()) - client.write(f'/pane/{serial}/ctl', b'cleartag\n') + client.write(f'/pane/{serial}/tag', b'', truncate=True) client.write(tag, before[tail_start:]) def new_output(client, before): @@ -111,7 +111,7 @@ def run(args): capture(client, root, '02-find', not args.tty) if find_pane: (root / 'find-results.txt').write_bytes(client.read(f'/pane/{find_pane}/body')) - client.write(f'/pane/{find_pane}/ctl', b'exec Del\n') + client.write(f'/pane/{find_pane}/exec', b'Del\n') before = panes(client) command(client, source, 'Grep CrdsValueLabel') grep_pane = require(wait_for(lambda: new_output(client, before)), 'Grep did not return results') @@ -140,10 +140,10 @@ def run(args): (root / 'symbols-results.txt').write_bytes(client.read(f'/pane/{symbols}/body')) capture(client, root, '05-symbols', not args.tty) if symbols: - client.write(f'/pane/{symbols}/ctl', b'exec Del\n') + client.write(f'/pane/{symbols}/exec', b'Del\n') offset = original.index(b'CrdsValue {') client.write(f'/pane/{source}/addr', f'#{offset},#{offset}'.encode()) - client.write(f'/pane/{source}/ctl', b'dot=addr\nshow\n') + client.write(f'/pane/{source}/dot', client.read(f'/pane/{source}/addr')) before = panes(client) command(client, source, 'Hover') hover = wait_for(lambda: new_output(client, before), args.lsp_wait) @@ -154,7 +154,7 @@ def run(args): # Look focuses the source without changing it; gd then travels through # the host's real input parser, unlike tag builtin dispatch above. line = original[:original.index(b'impl Sanitize for CrdsValue')].count(b'\n') + 1 - client.write(f'/pane/{source}/ctl', f'look {source_path}:{line}:19\n'.encode()) + client.write(f'/pane/{source}/look', f'{source_path}:{line}:19\n'.encode()) os.write(terminal_handle['input_fd'], b'gd') time.sleep(1) capture(client, root, '07-definition', not args.tty) @@ -166,7 +166,7 @@ def run(args): report['lsp'] = info.decode() capture(client, root, '08-lsp-info', not args.tty) if lsp: - client.write(f'/pane/{lsp}/ctl', b'exec Del\n') + client.write(f'/pane/{lsp}/exec', b'Del\n') for theme in args.themes: command(client, source, 'Theme ' + theme) capture(client, root, 'theme-' + theme, not args.tty) diff --git a/test/v9fs.py b/test/v9fs.py index 16916d0b..fa35388f 100644 --- a/test/v9fs.py +++ b/test/v9fs.py @@ -43,8 +43,8 @@ def worker(mountpoint, socket, uid, gid, original_namespace): assert not any(field.startswith(('shared:', 'master:')) for field in mounted[0].split()[6:]) tree = mountpoint - assert {'os', 'index', 'pane', 'new', 'ctl', 'log', 'screen', 'README'} <= set(os.listdir(tree)) - assert 'self' not in os.listdir(tree) + assert {'os', 'index', 'pane', 'status', 'look', 'exec', 'log', 'screen', 'README'} <= set(os.listdir(tree)) + assert 'self' not in os.listdir(tree) and 'new' not in os.listdir(tree) # A direct connection provides independent evidence for VFS reads/writes. with Client(socket) as client: assert (tree / 'index').read_bytes() == client.read('/index') @@ -52,14 +52,31 @@ def worker(mountpoint, socket, uid, gid, original_namespace): before = client.read('/index') subprocess.run(['ls', '-l', str(tree), str(tree / 'pane' / '1')], check=True, capture_output=True, timeout=5) - subprocess.run(['find', str(tree / 'pane'), str(tree / 'new'), '-ls'], check=True, capture_output=True, timeout=5) + subprocess.run(['find', str(tree / 'pane'), '-ls'], check=True, capture_output=True, timeout=5) assert (tree / 'README').read_bytes() == client.read('/README') - assert (tree / 'new').stat().st_size == 0 assert client.read('/index') == before, 'browsing created panes' - serial = int((tree / 'new').read_bytes().split()[0]) - another = int((tree / 'new').read_bytes().split()[0]) - assert serial != another, 'cached factory reused a pane' - client.write(f'/pane/{another}/ctl', b'exec Del\n') + # mkdir through the kernel mount opens a pane. The editor names it + # after its serial, not after the name asked for, so the kernel's own + # revalidation of that name may fail; the index is the answer. + def serials(): + return {int(row.split()[0]) for row in (tree / 'index').read_bytes().splitlines()} + + def mkpane(name): + known = serials() + try: + (tree / 'pane' / name).mkdir() + except FileNotFoundError: + pass + made = serials() - known + assert len(made) == 1, (name, made) + return made.pop() + + serial = mkpane('kernel-made') + another = mkpane('kernel-made-again') + assert serial != another, 'a second mkdir reused a pane' + assert not (tree / 'pane' / 'kernel-made').exists() + (tree / 'pane' / str(another)).rmdir() + assert another not in serials() pane = tree / 'pane' / str(serial) wire = f'/pane/{serial}' assert str(serial) in os.listdir(tree / 'pane') @@ -101,7 +118,7 @@ def worker(mountpoint, socket, uid, gid, original_namespace): # Reading OS files through the exported tree does not recurse through # the mount: the core still lives in the supervisor's namespace. assert (mountpoint / 'os' / str(socket.parent).lstrip('/') / 'kernel.txt').read_bytes() == b'initial\n' - write_existing(pane / 'ctl', b'exec Del\n') + (tree / 'pane' / str(serial)).rmdir() assert serial not in [int(row.split()[0]) for row in (tree / 'index').read_bytes().splitlines()] print('v9fs: namespace isolation, privilege drop, inherited mount, directory refresh, ' diff --git a/test/window_opacity.py b/test/window_opacity.py index b9529373..a576b1bd 100644 --- a/test/window_opacity.py +++ b/test/window_opacity.py @@ -60,7 +60,7 @@ def run(args): pane = require(wait_for(lambda: next((serial for serial in panes(client) if serial not in before), None)), builtin + ' output missing') text = client.read(f'/pane/{pane}/body').decode() - client.write(f'/pane/{pane}/ctl', b'exec Del\n') + client.write(f'/pane/{pane}/exec', b'Del\n') return text help_text = output('Help') -- cgit v1.3 From 5dcfade5f102256de787b2157b01293160780411 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 21 Sep 2026 22:37:06 -0300 Subject: Make a pane by opening /pane/new, and a Plan 9 idiom pass The Tcreate that replaced acme's /new was a step away from the idiom dressed up as a step toward it. A pane is named by a server-assigned serial, so the create ignored the client's name: `mkdir /pane/foo` succeeded and left you /pane/12. A mkdir that does not make the directory you named is worse than the read-with-side-effect it replaced, and it broke in the shell workflow that motivated the change. `create` is out of the declared features, so Tcreate is EPERM again; Tremove stays, since `rm` to close a pane is unambiguously right. /pane/new is now opened, not created: the open makes the pane, the read of that fid answers its serial, two reads agree, and closing it leaves the pane. That is /net/tcp/clone's mechanism (kernel/network/ip/devip.c, in ipopen), not acme's, and the difference is deliberate. acme allocates during the walk and lands inside the new window, so /dev/new/body works in one step, and it can afford to list `new` because a Plan 9 directory read carries every entry's stat and nothing walks. A kernel or FUSE mount walks and stats each name a listing gave it, so allocate-on-walk would make a pane per `ls -l`. Allocating on open keeps `new` listed -- a stat is not an open -- at the cost of the one-step new/body. `new` stays unreachable from an editor path, because that resolution serves Look hover previews. The idiom pass behind it, read out of the Plan 9 tree at ~/05-genizah/principia-softwarica rather than recalled: Rerror carries a string, not an errno (man 5 error: `ename[s]`), and acme names every refusal. The five refusals pardes shares with acme now say what they mean; the generic sites keep their bare errno rather than invent strings acme does not have. body and tag declare DMAPPEND, which they had always behaved as (acme(4): "always appended; the file offset is ignored"), checked first against Linux's fs/9p, which never maps the bit. excl stays unset everywhere, because acme sets DMEXCL on nothing. Blocking reads, per-object addr scope and the readable pane ctl were already right. Real stat sizes and qid versions stay: acme reports length 0 and version 0 for everything, and Linux clients need better. One bug fell out of it. open reset the addr range, so `echo '#0,#5' >addr; cat addr` answered `0 0` and `cp addr dot` copied zeros. acme(4) makes the contract explicit -- "a regular expression may be evaluated by writing it to addr and reading it back" -- and acme gets away with resetting on the 0-to-1 open only because its clients hold the fid across both. A shell cannot: that is two opens. The register is cleared by truncating it now. Co-Authored-By: Claude Opus 5 (1M context) --- .agents/skills/pardes-9p/SKILL.md | 38 ++++++--- docs/fs.md | 40 +++++++--- docs/v9fs.md | 9 +++ features.txt | 5 ++ src/fs-help.txt | 10 +-- src/ninep/ctl.zig | 2 +- src/ninep/events.zig | 6 +- src/ninep/pane.zig | 8 +- src/ninep/pty.zig | 2 +- src/ninep/testing.zig | 26 ++---- src/ninep/tree.zig | 162 ++++++++++++++++++++++++++++---------- src/tutor.txt | 2 +- test/fs.py | 27 ++++--- test/v9fs.py | 29 +++---- 14 files changed, 239 insertions(+), 127 deletions(-) (limited to 'src/ninep/testing.zig') diff --git a/.agents/skills/pardes-9p/SKILL.md b/.agents/skills/pardes-9p/SKILL.md index 2cea4d4a..91a8e864 100644 --- a/.agents/skills/pardes-9p/SKILL.md +++ b/.agents/skills/pardes-9p/SKILL.md @@ -49,7 +49,7 @@ $m/exec write a line = a middle click: an editor command word, or a shell $m/log one record per read: new|del|rename|save ; reads park $m/screen the rendered screen as JSON, frozen per open $m/listeners this session's dial addresses -$m/pane/ mkdir opens a pane; rmdir closes it +$m/pane/new open it to make a pane, read names it; rmdir $m/pane/ closes it $m/os/ the host filesystem ``` @@ -60,7 +60,7 @@ reuse or close a pane. ```sh cat "$m/index" # which panes exist -mkdir "$m/pane/x"; n=$(awk 'END{print $1}' "$m/index") # open one, take its serial +n=$(cat "$m/pane/new") # make one, take its serial printf 'text\n' > "$m/pane/$n/body" # append cat "$m/pane/$n/tag" # what its tagline offers echo notes.txt > "$m/pane/$n/name" # rename the buffer @@ -69,10 +69,20 @@ echo "/etc/hosts:3" > "$m/look"; cat "$m/look" # open a file, see where it land rmdir "$m/pane/$n" # close it, dirty or not ``` -The name `mkdir` asks for is ignored: a pane is named by the serial the editor -gives it, and because `/index` is ordered by serial its last row is the pane -just made. Nothing else in the tree can be created or removed, and no read -creates anything, so `ls`, `stat` and `find` over the whole tree are inert. +**Opening** `$m/pane/new` is what makes a pane, and reading the open file +answers its serial — `/net/tcp/clone`'s mechanism. Each open makes another one, +two reads of the same open file answer the same serial, and closing it leaves +the pane. A pane is named by the serial the editor gives it, never by a name +you choose. + +A *stat* makes nothing, which is the whole reason the allocation sits on open: +`new` is listed in `$m/pane`, so `ls` shows it, and `ls -l`, `find` and +anything else that stats every name a listing handed it stay inert. acme +allocates on the walk instead and lets it land inside the new window, so +`/dev/new/body` works in one step — it can afford that because a Plan 9 +directory read carries every entry's stat and nothing walks. Under a kernel or +FUSE mount that would be a pane per `ls -l`. Nothing else in the tree can be +created or removed, and no read creates anything. `look` and `exec` are the editor's two clicks, one per line of a write, at the active pane from the root and at that pane from `$m/pane//look` and @@ -107,11 +117,12 @@ search and reads empty until set; truncate it to lift it. buffer differs from its file, whether a write pushes an undo point, and whether a write scrolls. Truncating `tag` clears the part of the tag you may edit. -Address state belongs to the pane, not to a client: opening `addr` resets it, -so two clients addressing the same pane will interfere. `$pane/ctl` reads -acme's window status line — serial, tag length, body length, a reserved zero, -the dirty flag, the width in cells, the font and the tab width — and takes the -one verb `get`. +Address state belongs to the pane, not to a client: it keeps the last range +written until someone writes or truncates it, so writing an address and reading +it back evaluates it, and two clients addressing the same pane will interfere. +`$pane/ctl` reads acme's window status line — serial, tag length, body length, +a reserved zero, the dirty flag, the width in cells, the font and the tab +width — and takes the one verb `get`. Terminal panes have no file: writing their `body` sends child input, and truncation does not erase terminal history. @@ -209,8 +220,9 @@ with tempfile.TemporaryDirectory(prefix='pardes-9p-skill-') as directory: PY ``` -`new_pane` is `mkdir` plus a read of the index; `execute` writes one line to a -pane's `exec`. Both are in `test/fs.py`. For terminal tests, use +`new_pane` walks to `/pane/new` and reads the serial off the directory it +lands on; `execute` writes one line to a pane's `exec`. Both are in +`test/fs.py`. For terminal tests, use `session(..., tty=True)` and read [test/agent_session.py](../../../test/agent_session.py) for bounded interactive driving; its readiness text and history threshold are application-specific, and diff --git a/docs/fs.md b/docs/fs.md index 0bcc0313..8607a26f 100644 --- a/docs/fs.md +++ b/docs/fs.md @@ -79,19 +79,32 @@ Existing Plan9port/v9fs clients need a userspace bridge for QUIC. /log one line per editor event: new|del|rename|save ; reads park /screen rendered screen JSON; frozen per open handle /listeners the session's dial addresses -/pane/ create a directory here to open a pane; remove one to close it +/pane/new open it to make a pane; the read answers that pane's serial /pane// name body tag ctl addr dot limit data xdata sel dirty mark scroll errors event look exec, plus pty/{ctl,status,data} on terminals /os/ the host filesystem /src/ the editor's embedded sources, only when built with -Dembed-sources=true ``` -Nothing in the tree is created by list, stat, walk or read. A pane is opened -by Tcreate in `/pane` (`mkdir`) and closed by Tremove on `/pane/` (`rmdir`), -which is the only create and the only remove the tree serves. The name a -create asks for is ignored, since a pane is named by the serial the editor -gives it: the Rcreate qid names the new directory, and because `/index` is -ordered by serial its last line is the pane just made. +A pane is made by **opening** `/pane/new`, and closed by Tremove on +`/pane/` (`rmdir`), which is the only remove the tree serves; Tcreate is +refused everywhere, as it is in acme. Reading the open fid answers the serial +of the pane that open made, so `n=$(cat /pane/new)` makes one and names it in +a line. Each open makes another pane, and two reads of one fid answer the same +serial: the open acted, the read only observes. Closing the fid leaves the +pane. + +This is `/net/tcp/clone`'s mechanism, not acme's `new`, and the difference is +deliberate. acme allocates during the *walk* and lets the walk land inside the +new window, so `/dev/new/body` works in one step (acme(4): "accessing any file +in `new` creates a new window"). acme can also afford to list `new`, because a +Plan 9 directory read carries the stat of every entry and nothing walks. A +kernel or FUSE mount is not so lucky: it walks and stats each name a listing +gave it, so an allocate-on-walk name would make a pane per `ls -l`. Allocating +on open instead keeps `new` listed and `ls` honest — a stat is not an open — +at the cost of acme's one-step `new/body`. Nothing in the tree is created by +list, stat, walk or read; only that one open. Every other name in `/pane` is a +serial. `/look` and `/exec` are the editor's two clicks, one per line of a write: @@ -130,6 +143,9 @@ address expression (`#0,#5`, `/pattern/`, `2+1`); `addr` selects what `data` and `xdata` read or replace, `dot` is the editor's own selection and moving it scrolls the pane into view, and `limit` bounds a search and reads empty until it is set. Truncating a range file empties it; truncating `limit` lifts it. +`addr` belongs to the pane rather than to a client and keeps what was written +until someone writes or truncates it, so writing an address and reading it +back evaluates it, which is what acme(4) promises of its own `addr`. The three flag files `dirty`, `mark` and `scroll` read `0` or `1` and take `0` or `1`: whether the buffer differs from its file, whether a write pushes @@ -164,8 +180,8 @@ enables the option by default, so the device can serve its own source. This is a control filesystem, not a complete POSIX export. Native filenames may contain up to 255 bytes. Existing regular OS files support read, write, and truncation to zero; under `/os` protocol create, remove, rename and other -metadata changes are refused, as is every create and remove in the control -tree but the pane directories. Ownership and permissions under `/os` are +metadata changes are refused, as is every create in the control tree and every +remove in it but a pane directory's. Ownership and permissions under `/os` are synthetic. Zero-length truncation accepts the accompanying `mtime` hint sent by Linux v9fs; the hint is not stored. Standalone timestamp changes remain refused. @@ -180,9 +196,9 @@ for Unix and TCP, a poll loop for QUIC, and the 9P client for mounts); `src/fs.zig` keeps host access, mounts, resolution, find and grep. `zig build fs-test` drives real sessions using the independent Python client -in `test/ninep.py`; `zig build fs-discovery-test` checks that browsing creates -nothing, that a pane create and remove work, and that `look`, `exec`, `name`, -`sel` and `log` behave. `zig build +in `test/ninep.py`; `zig build fs-discovery-test` checks that browsing +creates nothing, that the walk to `/pane/new` and a remove work, and that +`look`, `exec`, `name`, `sel` and `log` behave. `zig build 9p-test` checks the two engine configurations' budgets (the engine's own tests are cloud9's `zig build test`); `zig build fs-bench` measures filesystem transactions in the core. diff --git a/docs/v9fs.md b/docs/v9fs.md index 8cc97ff9..1b14c21f 100644 --- a/docs/v9fs.md +++ b/docs/v9fs.md @@ -13,8 +13,17 @@ cat "$PARDES_MOUNT/index" cat "$PARDES_MOUNT/README" cat "$PARDES_MOUNT/pane/$PARDES_PANE/body" echo 'Msg hello' > "$PARDES_MOUNT/exec" +awk '{print $1}' "$PARDES_MOUNT/pane/new/ctl" ``` +Walking to `pane/new` opens a pane, and the walk lands on that pane's own +directory, so its `ctl` answers the serial to use afterwards. The kernel keeps +the name it walked rather than the one the server answers back, so +`pane/new` stays in the dentry cache as a name of its own; address the pane as +`pane/` once you have it, and expect a fresh path resolution of +`pane/new` to open another pane. It is not listed in `pane/`, so `ls -l` and +`find` over the mount create nothing. + The mount belongs to that pane's subprocess tree. Other panes and the editor core keep their original mount namespace. It works in native Linux TTY and SDL sessions, including detached sessions. A frontend attaching from elsewhere does diff --git a/features.txt b/features.txt index bee079a7..a09607ea 100644 --- a/features.txt +++ b/features.txt @@ -68,3 +68,8 @@ bias, so only a definite refusal reaps. After all of the above, do an optimization pass on startup time for the gui and tty platforms: measure first, then optimize. build.zig already has a `perf` step (gesture latency and bounded terminal stress, with --json and a --base baseline to compare against), so a startup measurement belongs there rather than in a new harness, and the baseline files are how a regression gets caught later. + +9p create semantics: doing an action on read is not how plan9 frames it. The canonical pattern is the clone file -- /net/tcp/clone -- where *opening* allocates the +object and reading the fid only tells you which one you got; acme's new/ctl is the same shape, and pardes's old /new already keyed its side effect on open. The +Tcreate that replaced it has a real wart: a pane is named by a server-assigned serial, so the create ignores the client's name and `mkdir /pane/foo` leaves you +/pane/12. Replace it with /pane/clone (open allocates, read answers the serial) and keep Tremove, which is unambiguously right. diff --git a/src/fs-help.txt b/src/fs-help.txt index 1e5d64c2..3113590a 100644 --- a/src/fs-help.txt +++ b/src/fs-help.txt @@ -8,16 +8,16 @@ exec write a line: a middle click, an editor command word or a shell line log one line per editor event (new/del/rename/save ); reads wait screen rendered screen as JSON, frozen from open to close listeners the session's dial addresses -pane/ mkdir makes a pane, rmdir closes it +pane/new open it to make a pane; the read answers that pane's serial pane// name body tag ctl addr dot limit data xdata sel dirty mark scroll - errors event look exec, and pty/ for terminals + errors event look exec, and pty/ for terminals; rmdir closes it os/ the host filesystem src/ the editor's own sources, only in a -Dembed-sources=true build Below, $m is the mount point (PARDES_MOUNT in a Tty9p shell; 9ns and 9p work too): cat $m/index which panes exist - mkdir $m/pane/x; n=$(awk 'END{print $1}' $m/index) make a pane, take its serial + n=$(cat $m/pane/new) make a pane, take its serial echo /etc/hosts:3 > $m/look; cat $m/look open a file, see the pane it went to printf 'text\n' > $m/pane/$n/body append to a pane (>| truncates first) cat $m/pane/$n/name; echo notes.txt > $m/pane/$n/name read, then rename @@ -31,8 +31,8 @@ Below, $m is the mount point (PARDES_MOUNT in a Tty9p shell; 9ns and 9p work too echo exec > $m/pane/$n/pty/ctl restart a shell; also winsize C R, sig INT Pitfalls, one each: - Only mkdir in pane/ makes a pane; ls, stat, find and every read create nothing. - Panes are named by the serial the editor gives them, not by the name mkdir asked for. + Each open of pane/new makes another pane; two reads of one fid name the same one. + Only that open creates: ls, stat, find and every other read leave the tree alone. rmdir closes a pane even when it is dirty; index and pane//dirty show the flag. addr, dot and limit read the same pair of offsets they take, so cp between them works. dirty, mark and scroll read "0" or "1" and take "0" or "1"; truncating limit lifts it. diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index c213ece5..7625f501 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -188,7 +188,7 @@ pub fn writePane(p: *Pardes, req: Req, pane: *Pane) Reply { while (it.next()) |raw| { const line = std.mem.trim(u8, raw, " \t\r"); if (line.len == 0) continue; - if (!std.mem.eql(u8, line, "get")) return Reply.fail(req.tag, E.INVAL); + if (!std.mem.eql(u8, line, "get")) return tree.failText(req.tag, E.INVAL, tree.e_bad_ctl); asked = true; } if (asked) { diff --git a/src/ninep/events.zig b/src/ninep/events.zig index bd53bcd9..d94fb54d 100644 --- a/src/ninep/events.zig +++ b/src/ninep/events.zig @@ -317,12 +317,12 @@ pub fn writeEvent(p: *Pardes, req: Req, id: usize) Reply { while (check.next()) |r| { switch (r.action) { .body_look, .tag_look, .body_exec, .tag_exec => {}, - else => return Reply.fail(req.tag, E.INVAL), + else => return tree.failText(req.tag, E.INVAL, tree.e_bad_event), } const n = if (r.action.onTag()) tag.len else body.len; - if (r.q0 > r.q1 or r.q1 > n) return Reply.fail(req.tag, E.INVAL); + if (r.q0 > r.q1 or r.q1 > n) return tree.failText(req.tag, E.INVAL, tree.e_bad_event); } - if (check.i != req.data.len) return Reply.fail(req.tag, E.INVAL); + if (check.i != req.data.len) return tree.failText(req.tag, E.INVAL, tree.e_bad_event); } var run: EventReader = .{ .data = req.data }; while (run.next()) |r| { diff --git a/src/ninep/pane.zig b/src/ninep/pane.zig index 42c0c48e..4b34cf96 100644 --- a/src/ninep/pane.zig +++ b/src/ninep/pane.zig @@ -24,6 +24,12 @@ const Node = tree.Node; /// Filesystem state a pane carries beside its editor state. pub const State = struct { + /// The range `data` and `xdata` read and write through. acme clears it + /// when the first client opens `addr` (editors/acme/xfid.c:105), which + /// suits a client that holds the fid open and leaves a shell reading back + /// `0 0` from the address it just wrote. Here it is the pane's own + /// register, cleared by truncating the file, so that `cp addr dot` and + /// `cat addr` answer what was written. addr: Range = .{}, limit: ?Range = null, readers: u16 = 0, @@ -458,7 +464,7 @@ fn writeRange(p: *Pardes, req: Req, id: usize, pane: *Pane, file: PaneFile) Repl const pf = &p.fs.panes[id]; const text = bodyOf(pane); clampAddr(pf, text.len); - const r = rangeOf(pf, text, req.data) orelse return Reply.fail(req.tag, E.INVAL); + const r = rangeOf(pf, text, req.data) orelse return tree.failText(req.tag, E.INVAL, tree.e_bad_addr); switch (file) { .addr => pf.addr = r, .limit => pf.limit = r, diff --git a/src/ninep/pty.zig b/src/ninep/pty.zig index 1b71a8d3..c657d27d 100644 --- a/src/ninep/pty.zig +++ b/src/ninep/pty.zig @@ -42,7 +42,7 @@ pub fn writeCtl(p: *Pardes, req: Req, id: usize) Reply { while (it.next()) |raw| { const line = std.mem.trim(u8, raw, " \t\r"); if (line.len == 0) continue; - if (!verb(p, id, line, apply)) return Reply.fail(req.tag, E.INVAL); + if (!verb(p, id, line, apply)) return tree.failText(req.tag, E.INVAL, tree.e_bad_ctl); } } return .{ .tag = req.tag, .written = @intCast(req.data.len) }; diff --git a/src/ninep/testing.zig b/src/ninep/testing.zig index ad1d84e4..44329eee 100644 --- a/src/ninep/testing.zig +++ b/src/ninep/testing.zig @@ -69,26 +69,14 @@ pub fn look_up(p: *Pardes, dir: u64, name: []const u8) Answer { return call(p, .{ .tag = 3, .op = .lookup, .node = dir, .data = name }); } -/// Creates a pane in /pane, as a client's mkdir does, and returns its serial. +/// Makes a pane the way a client does, by walking to /pane/new, and answers +/// the serial of the pane the walk landed on. +/// The open is what makes the pane; the handle it answers is the serial, which +/// is also what a read of that fid reports. pub fn newPane(p: *Pardes) !u32 { - const made = mkdir(p, "scratch"); - if (made.reply.status != .ok) return error.NoPane; - const target = tree.Node.target(made.reply.attr.node) orelse return error.NoPane; - return switch (target) { - .pane => |t| t.serial, - .top => error.NoPane, - }; -} - -pub fn mkdir(p: *Pardes, name: []const u8) Answer { - return call(p, .{ - .tag = 9, - .op = .open, - .node = @intFromEnum(tree.TopFile.pane), - .data = name, - .create = true, - .perm = 0x8000_0000 | 0o755, - }); + const made = call(p, .{ .tag = 8, .op = .open, .node = @intFromEnum(tree.TopFile.new) }); + if (made.reply.status != .ok or made.reply.handle == 0) return error.NoPane; + return made.reply.handle; } pub fn rmdir(p: *Pardes, node: u64) Answer { diff --git a/src/ninep/tree.zig b/src/ninep/tree.zig index 46609649..5a0c1e11 100644 --- a/src/ninep/tree.zig +++ b/src/ninep/tree.zig @@ -5,7 +5,8 @@ //! and mounts. //! //! /README /index /status /look /exec /log /screen /listeners -//! /pane/ mkdir makes a pane, rmdir closes it +//! /pane/new an open makes a pane, a read names it +//! /pane/ rmdir closes that pane //! /pane//{name,body,tag,ctl,addr,dot,limit,data,xdata,sel, //! dirty,mark,scroll,errors,event,look,exec,pty/} //! /os/... the host filesystem /src/... embedded sources (opt-in) @@ -49,14 +50,28 @@ pub const Payload = union(enum) { pub const Reply = cloud9.fs.ReplyWith(Payload); -/// Tcreate opens a pane and Tremove closes one; nothing else in the tree is -/// created or destroyed by the protocol, and wstat stays a truncation. -pub const features: cloud9.fs.Features = .{ .create = true, .remove = true }; +/// 9P answers a failure with a string, not a number (man 5 error): the errno +/// still travels, for clients that map it, but the string is what a person +/// reads. acme names its refusals the same way, and these are its spellings +/// (editors/acme/xfid.c:19) for the ones this tree shares. +pub fn failText(tag: u64, errno: u16, text: []const u8) Reply { + return .{ .tag = tag, .status = .err, .errno = errno, .ename = text }; +} + +pub const e_bad_addr = "bad address syntax"; +pub const e_bad_ctl = "ill-formed control message"; +pub const e_bad_event = "bad event syntax"; + +/// Tremove closes a pane; nothing else in the tree is created or destroyed by +/// the protocol, and wstat stays a truncation. Making a pane is an open of +/// /pane/new, which needs no feature of the engine's, so Tcreate is refused +/// everywhere, as it is in acme (editors/acme/fsys.c, fsyscreate). +pub const features: cloud9.fs.Features = .{ .remove = true }; pub fn changesPane(req: Req) bool { return switch (req.op) { .write, .setattr => true, - .open => req.create, + .open => req.node == @intFromEnum(TopFile.new), .release => req.remove, .lookup, .getattr, .read, .readdir => false, }; @@ -77,6 +92,7 @@ pub const TopFile = enum(u4) { screen, listeners, pane, + new, pub fn fileName(f: TopFile) []const u8 { return if (f == .root) "/" else @tagName(f); @@ -86,7 +102,7 @@ pub const TopFile = enum(u4) { return switch (f) { .root, .pane => 0o755, .look, .exec => 0o666, - .README, .index, .status, .log, .screen, .listeners => 0o444, + .README, .index, .status, .log, .screen, .listeners, .new => 0o444, }; } @@ -187,8 +203,21 @@ fn paneFileNamed(name: []const u8) ?PaneFile { fn topFileNamed(name: []const u8) ?TopFile { const f = std.meta.stringToEnum(TopFile, name) orelse return null; - return if (f == .root) null else f; -} + // `new` is reached in /pane, where the panes it makes are. + return if (f == .root or f == .new) null else f; +} + +/// Opening /pane/new makes a pane and reading the open fid answers its +/// serial, which is /net/tcp/clone's mechanism exactly (kernel/network/ip/ +/// devip.c, `case Qclone` in ipopen, whose Qctl read prints the number it +/// allocated). acme spells the same idea as a directory made by the walk +/// (editors/acme/fsys.c:481), which would be the nicer `new/body`, but a +/// Plan 9 directory read carries every entry's stat and a kernel or FUSE +/// mount instead walks each name it listed: allocating on the walk would +/// make a pane every time someone ran `ls -l`. A stat is not an open, so +/// this file can be listed. Panes are named by their serial, so the name +/// can never collide with one. +pub const new_pane = "new"; fn serialNamed(name: []const u8) ?u32 { if (name.len == 0 or name.len > 10) return null; @@ -218,7 +247,12 @@ pub fn resolveSelf(p: *Pardes, path: []const u8) ?u64 { if (top == .pane or parts.next() != null) return null; return @intFromEnum(top); } - const serial = serialNamed(parts.next() orelse return @intFromEnum(TopFile.pane)) orelse return null; + const next = parts.next() orelse return @intFromEnum(TopFile.pane); + // `new` is served on the wire but deliberately unreachable from an editor + // path: this resolves Look targets and hover previews, and a preview that + // opened `new` to see what was there would make a pane per hover. + if (std.mem.eql(u8, next, new_pane)) return null; + const serial = serialNamed(next) orelse return null; const id = p.paneBySerial(serial) orelse return null; const file = paneFileNamed(parts.next() orelse return Node.of(serial, .dir)) orelse return null; if (file.inPty() and !p.panes[id].?.isTerminal()) return null; @@ -258,9 +292,9 @@ pub fn stagedReply(p: *Pardes, req: Req) Reply { pub fn handle(p: *Pardes, req: Req) Reply { const host = req.node == fs.os_root or req.node & fs.os_node != 0; const archive = req.node & sources.archive_node != 0; - // Only /pane is created in and removed from. The host tree and the - // embedded sources say so, rather than quietly doing nothing. - if ((host or archive) and (req.create or req.remove)) return Reply.fail(req.tag, E.PERM); + // Only a pane directory is removed. The host tree and the embedded + // sources say so, rather than quietly doing nothing. + if ((host or archive) and req.remove) return Reply.fail(req.tag, E.PERM); if (host) return fs.osHandle(p, req); if (archive) return sources.handle(p, req); const target = Node.target(req.node) orelse return Reply.fail(req.tag, E.NOENT); @@ -302,6 +336,10 @@ fn attrOf(p: *Pardes, target: Target) ?Reply.Attr { .size = pane.fileSize(p, id, t.file), .mtime = pane.mtimeOf(p, pn), .version = pane.versionOf(pn, t.file), + // A write to body or tag appends whatever its offset says, + // which is why acme's dirtab marks both DMAPPEND + // (editors/acme/fsys.c:78). + .append = t.file == .body or t.file == .tag, }; }, } @@ -314,8 +352,9 @@ fn attrReply(p: *Pardes, tag: u64, target: Target) Reply { fn topSize(p: *Pardes, f: TopFile) u64 { return switch (f) { - // ponytail: /screen has no length until an open renders its frame. - .root, .pane, .screen => 0, + // ponytail: /screen has no length until an open renders its frame, + // and /pane/new none until an open has a pane to name. + .root, .pane, .screen, .new => 0, .index => pane.indexLen(p), .README => fs.help.len, .status => ctl.statusLen(p), @@ -348,6 +387,7 @@ fn lookup(p: *Pardes, req: Req, target: Target) Reply { return Reply.fail(req.tag, E.NOENT); }, .pane => pane: { + if (std.mem.eql(u8, name, new_pane)) break :pane @intFromEnum(TopFile.new); const serial = serialNamed(name) orelse return Reply.fail(req.tag, E.NOENT); break :pane Node.of(serial, .dir); }, @@ -396,6 +436,7 @@ fn readdir(p: *Pardes, req: Req, target: Target) Reply { sources.stage(p, out, "", &skip); }, .pane => { + if (skip > 0) skip -= 1 else stageDirent(out, p.gpa, @intFromEnum(TopFile.new), false, TopFile.new.fileName()); var last: u32 = 0; while (nextSerialAfter(p, last)) |serial| { last = serial; @@ -426,27 +467,19 @@ fn readdir(p: *Pardes, req: Req, target: Target) Reply { return .{ .tag = req.tag, .payload = .{ .staged = @intCast(out.items.len) } }; } -/// Tcreate in /pane opens a pane, the way mkdir opens a directory. The name -/// asked for is ignored: a pane is named by the serial the editor gives it, -/// which the reply carries back and /index lists last. -fn create(p: *Pardes, req: Req, target: Target) Reply { - switch (target) { - .top => |f| if (f != .pane) return Reply.fail(req.tag, E.PERM), - .pane => return Reply.fail(req.tag, E.PERM), - } - if (req.perm & cloud9.dmdir == 0) return Reply.fail(req.tag, E.PERM); - const slot = p.freeSlot() orelse return Reply.fail(req.tag, E.NFILE); +/// Opens a pane for an open of /pane/new, whose serial becomes the handle: +/// the fid remembers which pane it made, so reading it twice answers the +/// same one and closing it leaves the pane alone. +fn makePane(p: *Pardes) ?u32 { + const slot = p.freeSlot() orelse return null; p.newScratchBelow(p.active); - const made = p.panes[slot] orelse return Reply.fail(req.tag, E.NFILE); - const attr = attrOf(p, .{ .pane = .{ .serial = made.serial, .file = .dir } }) orelse - return Reply.fail(req.tag, E.NFILE); - return .{ .tag = req.tag, .handle = 1, .attr = attr }; + return (p.panes[slot] orelse return null).serial; } fn open(p: *Pardes, req: Req, target: Target) Reply { - if (req.create) return create(p, req, target); switch (target) { .top => |f| switch (f) { + .new => return .{ .tag = req.tag, .handle = makePane(p) orelse return Reply.fail(req.tag, E.NFILE) }, .screen => return screen.openSnapshot(p, req, true), .log => p.fs.log_readers +|= 1, else => {}, @@ -458,7 +491,6 @@ fn open(p: *Pardes, req: Req, target: Target) Reply { if (t.file.inPty() and !pn.isTerminal()) return Reply.fail(req.tag, E.NOENT); switch (t.file) { .body => if (pn.isTerminal()) return screen.openSnapshot(p, req, false), - .addr => pf.addr = .{}, .event => { pf.readers +|= 1; p.fs.listeners +|= 1; @@ -552,6 +584,14 @@ fn read(p: *Pardes, req: Req, target: Target) Reply { .log => events.readQueue(p, req, &p.fs.log), .screen => screen.readSnapshot(p, req, null), .listeners => screen.readListeners(p, req), + // The serial the open handed this fid, so that two reads of one + // fid answer the same pane: the read observes, the open acted. + .new => serial: { + if (req.handle == 0) break :serial Reply.fail(req.tag, E.IO); + p.fs.stage(p.gpa).print(p.gpa, "{d}\n", .{req.handle}) catch + break :serial Reply.fail(req.tag, E.NOMEM); + break :serial stagedReply(p, req); + }, .root, .pane => Reply.fail(req.tag, E.PERM), }, .pane => |t| { @@ -655,7 +695,9 @@ test "filesystem inspection preserves pending and displayed Look hover" { test "filesystem pane creation and truncation cancel Look hover" { const requests = [_]Req{ - .{ .tag = 2, .op = .open, .node = @intFromEnum(TopFile.pane), .data = "x", .create = true, .perm = cloud9.dmdir | 0o755 }, + // Opening `new` is what makes a pane now; walking to it makes none, + // and so must leave a pending hover alone. + .{ .tag = 2, .op = .open, .node = @intFromEnum(TopFile.new) }, .{ .tag = 3, .op = .setattr, .node = 0, .truncate = true }, }; for (requests) |request| { @@ -719,6 +761,14 @@ test "readdir lists the root and a pane directory without creating anything" { const own = th.nameAt(listed, try std.fmt.bufPrint(&idname, "{d}", .{serial})).?; try testing.expectEqual(Node.of(serial, .dir), own.node); try testing.expect(own.dir); + // `new` is listed, so `ls` shows it. Walking and stat-ing it allocates + // nothing — only an open does — which is what keeps `ls -l` and any other + // client that stats every name a listing gave it inert. + const shown = th.nameAt(listed, new_pane).?; + try testing.expect(!shown.dir); + try testing.expectEqual(Status.ok, look_up(p, @intFromEnum(TopFile.pane), new_pane).reply.status); + try testing.expectEqual(Status.ok, call(p, .{ .tag = 1, .op = .getattr, .node = @intFromEnum(TopFile.new) }).reply.status); + try testing.expectEqual(before, p.next_serial); const dir = rdir(p, Node.of(serial, .dir), 0); const files = th.dirents(dir.bytes, &buf); @@ -780,38 +830,58 @@ test "lookup resolves top files, pane serials and pane files" { try testing.expectEqual(E.NOTDIR, look_up(p, Node.of(serial, .body), "x").errno()); } -test "creating in the pane directory opens a pane and removing one closes it" { +test "opening /pane/new makes a pane and removing one closes it" { const gpa = testing.allocator; const p = try withFile(gpa, "first\n"); defer p.deinit(); const before = p.next_serial; const panes_dir = @intFromEnum(TopFile.pane); - // Browsing /pane creates nothing; only a create does. + // Browsing /pane creates nothing, and neither does walking or stat-ing + // `new` itself: only an open does. That is what lets `new` be listed at + // all, since `ls -l` stats every name a listing handed it. try testing.expectEqual(Status.ok, rdir(p, panes_dir, 0).reply.status); + try testing.expectEqual(Status.ok, look_up(p, panes_dir, new_pane).reply.status); + try testing.expectEqual(Status.ok, call(p, .{ .tag = 1, .op = .getattr, .node = @intFromEnum(TopFile.new) }).reply.status); try testing.expectEqual(before, p.next_serial); - const made = th.mkdir(p, "scratch"); + // The open makes the pane and hands back its serial; the read only + // observes, so two reads of one fid answer the same pane. + const made = call(p, .{ .tag = 2, .op = .open, .node = @intFromEnum(TopFile.new) }); try testing.expectEqual(Status.ok, made.reply.status); try testing.expectEqual(before + 1, p.next_serial); const serial = before + 1; - try testing.expectEqual(Node.of(serial, .dir), made.reply.attr.node); - try testing.expect(made.reply.attr.dir); + try testing.expectEqual(serial, made.reply.handle); var expected: [16]u8 = undefined; - try testing.expectEqualStrings(try std.fmt.bufPrint(&expected, "{d}", .{serial}), made.reply.attr.name); + const want = try std.fmt.bufPrint(&expected, "{d}\n", .{serial}); + for (0..2) |_| { + const answer = call(p, .{ .tag = 3, .op = .read, .node = @intFromEnum(TopFile.new), .handle = made.reply.handle, .size = 64 }); + try testing.expectEqualStrings(want, answer.bytes); + } const id = p.paneBySerial(serial).?; try testing.expectEqualStrings("", p.panes[id].?.file.?.content); _ = wr(p, Node.of(serial, .body), "hi"); - const second = th.mkdir(p, "another"); + + // A second open is a second pane, and releasing a clone fid leaves the + // pane it made standing. + const second = call(p, .{ .tag = 4, .op = .open, .node = @intFromEnum(TopFile.new) }); try testing.expectEqual(Status.ok, second.reply.status); - try testing.expect(second.reply.attr.node != made.reply.attr.node); + try testing.expect(second.reply.handle != made.reply.handle); + _ = call(p, .{ .tag = 5, .op = .release, .node = @intFromEnum(TopFile.new), .handle = made.reply.handle, .opened = true }); + try testing.expect(p.paneBySerial(serial) != null); try testing.expectEqualStrings("hi", p.panes[id].?.file.?.content); - // A plain file, and a create anywhere else, are refused. - try testing.expectEqual(E.PERM, call(p, .{ .tag = 1, .op = .open, .node = panes_dir, .data = "f", .create = true, .perm = 0o666 }).errno()); - try testing.expectEqual(E.PERM, call(p, .{ .tag = 1, .op = .open, .node = root, .data = "d", .create = true, .perm = cloud9.dmdir | 0o755 }).errno()); - try testing.expectEqual(E.PERM, call(p, .{ .tag = 1, .op = .open, .node = Node.of(serial, .dir), .data = "d", .create = true, .perm = cloud9.dmdir | 0o755 }).errno()); + // The tree declares no create, so the engine refuses every Tcreate + // (cloud9 fs.zig: `.tcreate => if (features.create) ... else fail(e_perm)`), + // and `new` is the only name in /pane that is not a serial. + try testing.expect(!features.create); + try testing.expectEqual(E.NOENT, look_up(p, panes_dir, "scratch").errno()); + try testing.expectEqual(E.NOENT, look_up(p, root, new_pane).errno()); + // ...and it is listed, because the user asked to see it in `ls`. + var listing: [32]th.Dirent = undefined; + const shown = rdir(p, panes_dir, 0); + try testing.expect(th.nameAt(th.dirents(shown.bytes, &listing), new_pane) != null); // Tremove closes the pane it names, and nothing else in the tree. try testing.expectEqual(E.PERM, th.rmdir(p, Node.of(serial, .body)).errno()); @@ -858,4 +928,10 @@ test "editor paths resolve to the same nodes the wire serves" { try testing.expect(resolveSelf(p, "status/ctl") == null); try testing.expect(resolveSelf(p, "cons") == null); try testing.expect(resolveSelf(p, "pane/0") == null); + // The editor resolves its own paths to inspect them, so `new` names + // nothing here; only a client's walk makes a pane. + const before = p.next_serial; + try testing.expect(resolveSelf(p, "pane/new") == null); + try testing.expect(resolveSelf(p, "pane/new/body") == null); + try testing.expectEqual(before, p.next_serial); } diff --git a/src/tutor.txt b/src/tutor.txt index adf4ae3a..ab73be33 100644 --- a/src/tutor.txt +++ b/src/tutor.txt @@ -396,7 +396,7 @@ typed /pane//body /index - /pane mkdir here makes a pane, rmdir closes it + /pane/new open it to make a pane; rmdir closes one /look /exec `FILE:12` and `Save`, as the mouse does A terminal pane also has `pty/`: diff --git a/test/fs.py b/test/fs.py index c3ffa440..b20dc8ee 100644 --- a/test/fs.py +++ b/test/fs.py @@ -106,9 +106,8 @@ def newest(client): def new_pane(client, contents): - """mkdir in /pane; the editor names the directory after the new serial.""" - client.mkdir('/pane', 'scratch') - serial = newest(client) + """An open of /pane/new makes a pane; the read names it.""" + serial = int(client.read('/pane/new')) if contents: client.write(f'/pane/{serial}/body', contents) return serial @@ -151,7 +150,7 @@ def discovery(binary, embedded=False): assert ('src' in top) == embedded, (top, embedded) before = client.read('/index') guide = client.read('/README') - assert guide.count(b'\n') <= 45 and b'Msg hello' in guide and b'mkdir' in guide, guide + assert guide.count(b'\n') <= 45 and b'Msg hello' in guide and b'pane/new' in guide, guide assert client.stat('/README')['length'] == len(guide) # ls/stat/find over the whole tree, without opening, creates nothing. seen = walk_tree(client) @@ -183,17 +182,20 @@ def discovery(binary, embedded=False): status = dict(line.split(maxsplit=1) for line in client.read('/status').decode().splitlines()) assert int(status['pid']) > 0 and status['version'] and int(status['panes']) >= 1, status assert client.read('/exec') == b'' - # mkdir makes a pane, named by the serial the editor gives it. + # An open of /pane/new makes a pane and the read names it; each + # open makes another. A stat makes none, which is why new can be + # listed at all: ls -l stats every name a listing gave it. log = client.open('/log') - client.mkdir('/pane', 'one') - first = newest(client) - client.mkdir('/pane', 'two') - second = newest(client) + first = int(client.read('/pane/new')) + assert first == newest(client) + second = int(client.read('/pane/new')) assert first != second and first != fixture, (first, second) - assert 'one' not in client.list('/pane') and 'two' not in client.list('/pane') + assert 'new' in client.list('/pane'), 'new should be visible to ls' + client.stat('/pane/new') + assert newest(client) == second, 'a stat of new made a pane' assert client.read_fid(log) == f'new {first} {root}/+New\n'.encode() assert client.read_fid(log) == f'new {second} {root}/+New\n'.encode() - assert set(client.list('/pane')) == {str(fixture), str(first), str(second)} + assert set(client.list('/pane')) == {'new', str(fixture), str(first), str(second)} client.write(f'/pane/{first}/body', b'first pane', truncate=True) assert client.read(f'/pane/{first}/body') == b'first pane' assert client.read(f'/pane/{second}/body') == b'' @@ -247,6 +249,7 @@ def discovery(binary, embedded=False): refused = [lambda: client.write('/exec', b'Msg a\x00b'), lambda: client.write('/status', b'anything\n'), lambda: client.mkdir('/', 'x'), + lambda: client.mkdir('/pane', 'one'), lambda: client.create('/pane', 'plain-file'), lambda: client.remove('/pane/1/body'), lambda: client.remove('/index')] @@ -262,7 +265,7 @@ def discovery(binary, embedded=False): assert client.read('/src/pardes.zig').startswith(b'const std') assert client.stat('/src/pardes.zig')['mode'] == 0o444 assert b'pub const Pardes' in client.read(f'/pane/{look(client, "/virtual/src/pardes.zig")}/body') - print('9P discovery: listing/stat/find are inert; create, remove, look, exec, name, sel and log behave') + print('9P discovery: listing/stat/find are inert; new, remove, look, exec, name, sel and log behave') def test(binary, quic=False): diff --git a/test/v9fs.py b/test/v9fs.py index fa35388f..30efe9fb 100644 --- a/test/v9fs.py +++ b/test/v9fs.py @@ -45,6 +45,7 @@ def worker(mountpoint, socket, uid, gid, original_namespace): tree = mountpoint assert {'os', 'index', 'pane', 'status', 'look', 'exec', 'log', 'screen', 'README'} <= set(os.listdir(tree)) assert 'self' not in os.listdir(tree) and 'new' not in os.listdir(tree) + assert 'new' not in os.listdir(tree / 'pane'), 'a listing would make a pane per stat' # A direct connection provides independent evidence for VFS reads/writes. with Client(socket) as client: assert (tree / 'index').read_bytes() == client.read('/index') @@ -55,26 +56,22 @@ def worker(mountpoint, socket, uid, gid, original_namespace): subprocess.run(['find', str(tree / 'pane'), '-ls'], check=True, capture_output=True, timeout=5) assert (tree / 'README').read_bytes() == client.read('/README') assert client.read('/index') == before, 'browsing created panes' - # mkdir through the kernel mount opens a pane. The editor names it - # after its serial, not after the name asked for, so the kernel's own - # revalidation of that name may fail; the index is the answer. + # Opening pane/new makes a pane and the read names it, so no trip + # through the index. Whether a repeated path reaches the server at all + # is the kernel's dentry cache's business, so the second pane comes + # over the wire, where the open is exact. def serials(): return {int(row.split()[0]) for row in (tree / 'index').read_bytes().splitlines()} - def mkpane(name): + def mkpane(): known = serials() - try: - (tree / 'pane' / name).mkdir() - except FileNotFoundError: - pass - made = serials() - known - assert len(made) == 1, (name, made) - return made.pop() - - serial = mkpane('kernel-made') - another = mkpane('kernel-made-again') - assert serial != another, 'a second mkdir reused a pane' - assert not (tree / 'pane' / 'kernel-made').exists() + made = int((tree / 'pane' / 'new').read_bytes()) + assert made not in known, 'the open of new made no pane' + return made + + serial = mkpane() + another = int(client.read('/pane/new')) + assert serial != another, 'a second open of new reused a pane' (tree / 'pane' / str(another)).rmdir() assert another not in serials() pane = tree / 'pane' / str(serial) -- cgit v1.3 From 31cb659ded4cf50af5903fc107f8c868ee3c7311 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 22 Sep 2026 11:15:46 -0300 Subject: Answer 9P on the connection's task, so a session can open its own tree The editor's loop was the only thing that could answer a 9P request, which made the editor's own syscalls through a mount of its own tree -- a Look at /mnt/9p/pardes//anything under a `9ns --mntgen` view, a Save into it -- requests only the blocked loop could serve. The name-based refusal that followed (ownMountSuffix) and the in-process routing of a mount of oneself (Client.sameSession) were patches over that, and both are gone, with the mailbox that shipped every request to the editor's thread. One rule replaces them, `pardes.turn`: the core is single-threaded, the editor's thread has the turn by default and gives it up in two kinds of gap -- while it waits for input and while a step of it is out in a host syscall -- and a cloud9 connection task takes it in those gaps to answer. `out` counts the steps that are out, from any thread: while one is, the core reads consistently but that step still holds pointers into it, so a request that would change a pane (a write, a truncation, an rmdir) is parked in the engine and retried when the turn is next given up with nothing out, and the editor's own wake waits for the count to reach zero. It is never a write of its own that a step waits on out there -- writes come from a shell performing a save between steps -- so a parked request is never the syscall's own, and making a pane or rendering a screen need not park: every yield sits before its step's mutation, so the layout and the surface are whole under it. A changing request that queued effects is answered once the editor has performed them (`echo Save > exec` returns with the file written, as acme's `put` does), and it settles the way a step does, because without that a /log reader waited for the user's next keystroke. Every host syscall on a user path has to give the turn up, not fs.zig's alone: the first end-to-end run hung in `inotify_add_watch` performing the new pane's watch effect. PDFs and images are read whole at open, so no draw goes out into the host. The core's allocator takes its fixed buffer through the lock-free interface, since a connection task allocates while the editor's thread is out in a syscall that allocates too. A Restore puts the replacement in first and releases every task waiting on the old core. cloud9 (pinned at eb1a104) parks an open, a truncating wstat, a clunk and a remove on `again`, not only reads and writes, and answers a parked job whose fid was clunked without asking the backend. Verified: test/selfmount.py runs the editor under `9ns --mntgen` and Looks at, reads and Saves its own tree through the mount; a unit test pins that a change parks while the editor is out mid-step and lands when it rests, while a read is answered in the window. 9P over the Unix socket against a tty session, same machine, Debug builds: a read of /index 278us -> 61us, a truncating body write 1184us -> 609us, exec Save 718us -> 583us; the gesture benchmark is unchanged (geometric mean 0.997 over 53 cells). Also from the reviews: a notice chip over an image or PDF pane was painted out by the picture drawn after the cells, so pictures give up the rows; in the GUI a tree-sitter context band painted over the chip, so body layers are emitted first; a message is one row of printable text, its 256-byte cut never leaves half a glyph, and one wider than its pane keeps its tail (the file name, the reason) rather than its head. Co-Authored-By: Claude Fable 5.1 --- .agents/skills/pardes-9p/SKILL.md | 7 +- build.zig.zon | 4 +- docs/cloud9.md | 13 +- docs/fs.md | 27 +- docs/v9fs.md | 6 +- features.txt | 56 ++++ src/9p.zig | 19 +- src/9p_io.zig | 511 +++++++++++++++-------------------- src/CHANGELOG.md | 13 + src/detached/server.zig | 27 +- src/detached/wire.zig | 8 +- src/file_watch.zig | 6 + src/fs.zig | 444 ++++++++++-------------------- src/gui/gui.zig | 30 +- src/host_io.zig | 3 + src/macos.zig | 125 ++++++++- src/memory.zig | 50 +++- src/ninep/testing.zig | 7 +- src/ninep/tree.zig | 16 ++ src/panes.zig | 45 ++- src/pardes.zig | 282 +++++++++++++++---- src/tty/tty.zig | 11 +- test/fs_namespace.zig | 24 -- test/selfmount.py | 126 +++++++++ test/snapshots/images.golden | 40 +-- test/snapshots/msg.golden | 4 + test/snapshots/msg.snap | 12 + test/snapshots/tagbottomimage.golden | 98 +++---- 28 files changed, 1205 insertions(+), 809 deletions(-) create mode 100644 test/selfmount.py (limited to 'src/ninep/testing.zig') diff --git a/.agents/skills/pardes-9p/SKILL.md b/.agents/skills/pardes-9p/SKILL.md index b776e407..2e065819 100644 --- a/.agents/skills/pardes-9p/SKILL.md +++ b/.agents/skills/pardes-9p/SKILL.md @@ -69,9 +69,10 @@ echo "/etc/hosts:3" > "$m/look"; cat "$m/look" # open a file, see where it land rmdir "$m/pane/$n" # close it, dirty or not ``` -Do not open a session's own mount from inside that session -- a Look at -`$m/anything` in the editor that serves `$m` would deadlock it, so such paths -are refused. Use `/n/self/...` from inside; `$m/...` is for everyone else. +A session may open its own mount from inside itself: a Look at `$m/anything` +in the editor that serves `$m` is answered on the connection's task while the +editor's own syscall waits. `/n/self/...` names the same tree without leaving +the process. **Opening** `$m/pane/new` is what makes a pane, and reading the open file answers its serial — `/net/tcp/clone`'s mechanism. Each open makes another one, diff --git a/build.zig.zon b/build.zig.zon index 3a172f3b..8f1b8068 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -9,8 +9,8 @@ // read-only HTTPS URL is what a manifest can carry. Re-pin with // `zig fetch --save=cloud9 git+https://git.sr.ht/~gbrls/cloud9#`. .cloud9 = .{ - .url = "git+https://git.sr.ht/~gbrls/cloud9#9c4d668c926e2d9eae6ef87cd9b391d8185605f9", - .hash = "cloud9-0.1.0-yt86qjAoGgBEPMJl2t4CZn7iWPMZUw4sMHAL54tq7spP", + .url = "git+https://git.sr.ht/~gbrls/cloud9#eb1a104f385f375a74319695e1a59f6f82e6384e", + .hash = "cloud9-0.1.0-yt86qiixGgCCjOhSDJ6tijGR7zj_zLT8mjvuUqrkeG9_", }, // ZLS as a LIBRARY, not a language server: src/lsp_zls.zig imports the // `zls` module its build.zig publishes and calls the analyser in diff --git a/docs/cloud9.md b/docs/cloud9.md index d030db1d..6eb76238 100644 --- a/docs/cloud9.md +++ b/docs/cloud9.md @@ -16,11 +16,14 @@ Mounting, Unix namespace discovery and permissions, the editor event loop, connection limits, and exported tree policy remain here. The Unix and TCP listeners run on cloud9's `serve.Runner` (`std.Io`: an accept task per listener, a reader and a writer task per connection, four slots); its handler -queues every backend request for the editor's thread, which answers them all -in `Listener.tick` after each editor update, retries parked reads there, and -has the runner ship the replies. `src/9p_quic.zig` selects the existing -`pardes-9p` ALPN for cloud9's optional OpenSSL transport; QUIC still runs on -the poll loop in `src/9p_io.zig`, since cloud9's QUIC adapter is +answers every backend request on the connection's task, taking the editor's +turn with the core (`pardes.turn`) while the editor waits for input or is out +in a syscall. A request that would change a pane while the editor is mid-step +is parked with `Status.again` -- the engine parks reads, writes, opens, +truncations, clunks and removes -- and retried by `Runner.wakeAll` when the +editor next rests. `src/9p_quic.zig` selects the existing `pardes-9p` ALPN for +cloud9's optional OpenSSL transport; QUIC still runs on the poll loop in +`src/9p_io.zig` on the editor's thread, since cloud9's QUIC adapter is nonblocking-descriptor based rather than `std.Io` based. The standalone protocol/GPIO tests import the same module. The separate `05-zig-p4` build also supplies cloud9 for the GPIO firmware entry. diff --git a/docs/fs.md b/docs/fs.md index 6d2891e0..335ee4e6 100644 --- a/docs/fs.md +++ b/docs/fs.md @@ -106,15 +106,24 @@ at the cost of acme's one-step `new/body`. Nothing in the tree is created by list, stat, walk or read; only that one open. Every other name in `/pane` is a serial. -A session cannot open its own tree through a mount. Looking at -`/mnt/9p/pardes//anything` from inside that very editor used to hang it -outright: the realpath, the stat and the read all leave through the mount and -come back as 9P requests only that editor's loop can answer, while the loop is -blocked making them, and the filesystem then stops answering anybody. Such a -path is now refused by name before any syscall runs, because the syscall is the -thing that never returns. Address your own tree as `/n/self/...`, which the -editor serves from memory without leaving the process. Another session's mount -is perfectly fine to open. +A session can open its own tree through a mount: a Look at +`/mnt/9p/pardes//pane/2/body` from inside that very editor opens it, and +a Save of that pane writes back through the mount into pane 2. Requests on +the Unix and TCP listeners are answered on the 9P connection's own task, not +by the editor's loop, so the realpath, the stat and the read the editor makes +out through the mount come back while it waits for them. The one rule is +whose turn it is with the core (`pardes.turn`): the editor has it, and gives +it up while it waits for input and while a step of it is out in a syscall. A +step of a connection task's own -- a Look written to `look` -- goes out the +same way, and the editor waits for it to return before it takes a step of +its own. While any step is out, a request that would change a pane (a write, +a truncation, an rmdir) parks in the engine until none is; everything else, +opening `pane/new` and `screen` included, is answered at once, which is why a +Look at any path in the tree comes back. A write into the tree from the +editor itself only ever happens between steps (a Save), so nothing it waits +on out there is a request that has to park. QUIC is still served on the +editor's loop, so through QUIC the old hang remains. `/n/self/...` names the +same tree without leaving the process. `/look` and `/exec` are the editor's two clicks, one per line of a write: diff --git a/docs/v9fs.md b/docs/v9fs.md index cfbbd35b..a105fe06 100644 --- a/docs/v9fs.md +++ b/docs/v9fs.md @@ -72,9 +72,9 @@ remain available for subsequent explicit authentication. The launcher waits for forwards termination signals, and removes its empty temporary directory on exit. Namespace destruction releases the mount when its last process exits. -The core stays outside the mount namespace because its event loop serves 9P. -A blocking filesystem operation through its own mount could wait for a request -that the blocked event loop must service. Even pathname resolution may do this. +The core stays outside the mount namespace, which is the helper's private +one: a path under `$PARDES_MOUNT` names nothing in the editor's own namespace, +so a Look on one from that shell opens nothing. Each `Tty9p` currently creates its own mount and consumes a server connection; the session has four application connection slots across all transports. This diff --git a/features.txt b/features.txt index fa1c0f6b..0db7c497 100644 --- a/features.txt +++ b/features.txt @@ -202,3 +202,59 @@ means what it says when fed back as configuration -- the symmetry the report was Left failing, deliberately: `nested-optout`. See docs/divergences.md -- two levels of nesting prepend U+E016 (vaxis's F3) to typed lines, which is a real bug in the key-forwarding path and not a stale expectation. + +9P is answered on the connection's task now, not by the editor's loop. The loop used to be the only thing that could answer a +request, which made the editor's own syscalls through a mount of its own tree -- a Look at /mnt/9p/pardes//anything under a +`9ns --mntgen` view, a Save into it -- a request only the blocked loop could serve. The name-based refusal that followed +(ownMountSuffix) and the in-process routing of a mount of oneself (Client.sameSession) were patches over that, and both are gone. +What replaced them is one rule, `pardes.turn`: the core is single-threaded, the editor's thread has the turn by default and gives it +up in two kinds of gap -- while it waits for input (`rest`/`wake`, one site per shell) and while a step is out in a host syscall +(`yield`/`back`, inside the leaf calls in fs.zig and the few host-side ones: the file watcher's marks, a shell's cwd stat) -- and a +cloud9 connection task takes it in those gaps to answer. Which gap it is matters: waiting, anything goes; out in a syscall +mid-step, the core reads consistently but the step still holds pointers into it, so a request that would change a pane +(tree.needsQuiet: writes, truncations, /pane/new, rmdir, and the screen open because it renders) is parked in the engine with +Status.again and retried when the turn is next given up quiet. That needed cloud9's engine to park an open, a truncating wstat, a +clunk and a remove, not only reads and writes -- a parked job goes back into the job slot on retry, and a walk still cannot park +because its names live in the input frame. A changing request that queued effects waits (`awaitSettled`) until the editor's pump has +performed them before it is answered, so `echo Save > exec` still returns with the file written, the way `put` does in acme; and a +request settles the way a step does (`sync`, `fsReport`, `events.announce`), because without that a `/log` reader waited for the +user's next keystroke to hear about the pane the request made. + +Two traps that cost real time. The first end-to-end run hung anyway: the Look completed on the connection task, then the editor woke +to perform the new pane's watch effect, and `inotify_add_watch` on a FUSE path is itself a request -- made while holding the turn. +The rule is therefore every host syscall on a user path, not fs.zig's alone; PDFs are read whole and opened from memory for the same +reason (MuPDF reads a file lazily at every page). The second: a parked write one byte longer than `park_data_max` fails EAGAIN, and +the client's largest write is msize less the 23-byte Twrite header, not less iohdrsz; a large Save to a peer's /os path came back +"save: Remote" until the engine's room was sized from a client. test/selfmount.py runs the editor under `9ns --mntgen` and Looks at, +reads and Saves its own tree through the mount; a unit test in 9p_io.zig pins that a change parks while the editor is out mid-step +and lands when it rests, while a read is answered in the window. + +Performance, same machine, Debug builds, 9P over the Unix socket against a tty session: a read of /index 278us -> 61us and a pane +body 283us -> 64us, because a read no longer waits for the editor to wake; a truncating body write 1184us -> 609us; exec Msg 696us +-> 543us; pane/new + rmdir 1535us -> 1295us; exec Save 718us -> 583us. A change still costs one editor frame, since the editor +draws it before it rests again. + +Left as they are: QUIC still runs on the editor's thread (cloud9's QUIC adapter is not std.Io based), so a QUIC client of a session +that Looks at its own QUIC-mounted tree would still wait on the loop; the Tty9p kernel mount lives in the helper's private +namespace, so a Look on `$PARDES_MOUNT/...` from that shell opens nothing in the editor -- no longer a deadlock, only a namespace +the editor is not in; and a message wider than its pane now keeps its tail rather than its head (msg.snap `msgtail`). + +Two adversarial reviews of that design. The concurrency one found the lost wake for real: a connection task's own yield saved the +editor's mid-step "not quiet" and restored it after the editor had rested, so a resting editor looked busy forever and every change +parked with nobody to wake it -- `quiet` is now `out`, a count of steps out in a syscall from any thread, and nothing saves or +restores it. Behind it, three more: the editor could take its turn back while a connection task's step was still out (that step's +pointers dangling when it returned) -- `wake` now waits for the count to reach zero; the core's allocator was a stack-fallback +over a FixedBufferAllocator, thread-safe only in Debug where the DebugAllocator wrapped it -- the fixed buffer is taken through +its lock-free interface now; and a Restore let a task waiting on the old core wake after that core was freed -- `reset` swaps the +listener's core first and releases every waiter, which then finds the core changed and answers nothing. It also showed that +parking `pane/new` and `screen` would have hung a Look at exactly those two paths in one's own mount (the editor's own open would +park, waiting for a rest that cannot come), so those are answered mid-step: every yield sits before its step's mutation, so the +layout and the surface are whole under it. Images are read at open for the same reason PDFs are. + +The rendering one found the chips drawn out from under: a placed image or PDF page is drawn after the cells (the GUI's image pass, +kitty's z-order), so a chip over a picture was painted over -- pictures give up the rows now, text keeps the overlay -- and in the +GUI a tree-sitter context band was emitted after the tag layers and painted over the chip, so body layers go first. A message is +one row of printable text (a language server's multi-line report read as one line with U+FFFD per newline), the 256-byte cut +never leaves half a glyph, and an over-wide message cut inside a wide glyph now drops that glyph rather than clipping its last. +The simplicity one cut the vestiges: `ninep_identity`, the restore's copy of listener addresses, `setWake`, the mailbox's +`Drained` name, the 64K read buffer, and the two macOS entry points whose multi-line signatures the wrapping had missed. diff --git a/src/9p.zig b/src/9p.zig index c0e7f61e..5ffe9058 100644 --- a/src/9p.zig +++ b/src/9p.zig @@ -52,9 +52,16 @@ pub const msize_min = cloud9.fs.msize_min; /// The smallest msize a native listener offers (src/9p_io.zig). pub const min_msize: u32 = 4096; +/// What a native listener negotiates. +pub const msize: u32 = 8192; -/// The editor's engine: native fid count, native file names. -pub const editor: cloud9.fs.Options = .{ .fid_capacity = max_fids, .name_capacity = 255 }; +/// The editor's engine: native fid count, native file names, and room to +/// park a write of any size a frame can carry -- a request that would change +/// a pane while the editor is out in a syscall waits in the engine +/// (src/9p_io.zig, `serve`), and a write it cannot keep would fail instead. +/// The largest write is msize less the Twrite header, 23 bytes (the test +/// below asks a client), one byte more than `iohdrsz` allows for. +pub const editor: cloud9.fs.Options = .{ .fid_capacity = max_fids, .name_capacity = 255, .park_data_max = msize - 23 }; /// The board's engine: the GPIO firmware's budget (src/esp32p4_9p.zig). pub const board: cloud9.fs.Options = .{ .fid_capacity = board_fids, .name_capacity = board_name_capacity }; @@ -70,6 +77,14 @@ const Stub = struct { pub const Reply = cloud9.fs.Reply; }; +test "9p server: the editor's engine can park the largest write a client sends" { + var in: [4096]u8 = undefined; + var out: [4096]u8 = undefined; + var client: Client = .init(.{ .in = &in, .out = &out }); + client.msize = msize; + try testing.expect(editor.park_data_max >= client.maxWrite()); +} + test "9p server: board and native capacities size the actual fid storage" { const Board = Server(Stub, board); const Native = Server(Stub, editor); diff --git a/src/9p_io.zig b/src/9p_io.zig index 08deae7a..7e09fb27 100644 --- a/src/9p_io.zig +++ b/src/9p_io.zig @@ -62,7 +62,7 @@ pub fn ensureSocketDir(dir: [:0]const u8) bool { const prefix = "pardes-9p-"; -pub const msize: u32 = 8192; +pub const msize = ninep.msize; pub const max_conns = 4; @@ -143,76 +143,17 @@ const Srv = ninep.Server(pardes.ctlfs, ninep.editor); /// The Unix and TCP listeners run on cloud9's `std.Io` runner: it accepts, /// reads frames, steps each connection's engine and writes replies on its -/// own tasks, and hands every backend request to the editor's thread -/// through `Slot` (see `tick`). QUIC keeps the poll loop below. +/// own tasks, and every backend request is answered right there, on the +/// connection's task, by taking the editor's turn (`pardes.turn`): while the +/// editor waits for input, or while a step of it is out in a syscall -- +/// which is what lets the editor read its own tree through a mount. QUIC +/// keeps the poll loop below, on the editor's thread. const Runner = if (supported) cloud9.serve.Runner(pardes.ctlfs, ninep.editor, .{ .msize = msize, .connections = max_conns, .listeners = 2, }) else void; -/// Answers one backend request on the editor's thread. -fn step(core: *pardes.Pardes, srv: *Srv, req: pardes.ctlfs.Req) void { - core.update(.{ .fs_req = req }); - var answered = false; - while (core.nextEffect()) |effect| { - if (effect == .fs_reply) { - const reply = effect.fs_reply; - if (reply.tag == req.tag) answered = true; - srv.reply(&reply, core.fsPayload(reply)); - } else core.perform(effect); - } - if (!answered) { - const reply = pardes.ctlfs.Reply.fail(req.tag, pardes.ctlfs.E.IO); - srv.reply(&reply, ""); - } -} - -/// Pays the backend a request whose connection is gone; replies go nowhere. -fn pay(core: *pardes.Pardes, req: pardes.ctlfs.Req) void { - core.update(.{ .fs_req = req }); - while (core.nextEffect()) |effect| if (effect != .fs_reply) core.perform(effect); -} - -/// One runner slot's mailbox: the requests its connection task handed over, -/// answered by the editor's thread in `tick`. A hangup's releases (at most -/// one per fid) and one outstanding request are the most it ever holds, -/// because a closing connection waits for its entries to be paid before -/// the slot is reused. -const Slot = struct { - const capacity = ninep.editor.fid_capacity + 2; - const Entry = struct { gen: u32, req: pardes.ctlfs.Req }; - - mutex: std.Io.Mutex = .init, - queue: [capacity]Entry = undefined, - head: usize = 0, - len: usize = 0, - /// Bumped when a connection takes the slot; entries carry the value. - gen: u32 = 0, - closing: bool = false, - drained: std.Io.Event = .unset, - /// Requests refused for want of room; never expected. - refused: u32 = 0, - - fn push(s: *Slot, req: pardes.ctlfs.Req) bool { - if (s.len == s.queue.len) { - s.refused += 1; - return false; - } - s.queue[(s.head + s.len) % capacity] = .{ .gen = s.gen, .req = req }; - s.len += 1; - return true; - } - - fn pop(s: *Slot) ?Entry { - if (s.len == 0) return null; - const e = s.queue[s.head]; - s.head = (s.head + 1) % capacity; - s.len -= 1; - return e; - } -}; - const quic_slots = if (quic_enabled) max_conns else 0; /// A QUIC connection on the poll path. @@ -229,12 +170,10 @@ const accept_pause_ms: i64 = 100; pub const Listener = struct { io: std.Io, + /// The core that answers; `reset` puts a replacement in. + core: *pardes.Pardes, runner: Runner = undefined, - slots: [max_conns]Slot = @splat(.{}), stopping: std.atomic.Value(bool) = .init(false), - /// While `reset` runs: the generation each slot is paying off; anything - /// newer waits for the replacement core. - resetting: ?[max_conns]u32 = null, tcp_address: ?std.Io.net.IpAddress = null, quic: if (quic_enabled) ?quic.Listener else void = if (quic_enabled) null else {}, quic_address: ?std.Io.net.IpAddress = null, @@ -264,47 +203,59 @@ pub const Listener = struct { return @ptrCast(@alignCast(ctx.?)); } - /// The runner's handler: on the connection's task. - fn onOpened(ctx: ?*anyopaque, conn: *Runner.Conn) void { - const l = of(ctx); - const s = &l.slots[conn.index]; - s.mutex.lockUncancelable(l.io); - s.gen +%= 1; - s.mutex.unlock(l.io); - } - + /// The runner's handler, on the connection's task: takes the turn and + /// answers. A request that would change a pane while the editor is out + /// in a syscall mid-step is parked in the engine instead, and retried + /// when the turn is next given up between steps (`wakeParked`). fn onServe(ctx: ?*anyopaque, conn: *Runner.Conn, req: pardes.ctlfs.Req) void { const l = of(ctx); - const s = &l.slots[conn.index]; - s.mutex.lockUncancelable(l.io); - const queued = s.push(req); - s.mutex.unlock(l.io); - if (!queued) { - const reply = pardes.ctlfs.Reply.fail(req.tag, pardes.ctlfs.E.IO); - conn.reply(&reply, ""); - return; + // Once `stop` has begun the editor is tearing down and may never + // rest again: answer without waiting on it. + if (l.stopping.load(.acquire)) { + const refused = pardes.ctlfs.Reply.fail(req.tag, pardes.ctlfs.E.IO); + return conn.reply(&refused, ""); + } + const quiet = pardes.turn.take(); + defer pardes.turn.give(); + if (!quiet and pardes.ctlfs.needsQuiet(req)) { + pardes.turn.parked = true; + const later: pardes.ctlfs.Reply = .{ .tag = req.tag, .status = .again }; + return conn.reply(&later, ""); } + const core = l.core; + const epoch = pardes.turn.epoch; + const restores = pardes.turn.restores; + const reply = core.serveFs(req); + if (req.op == .release and quiet) l.collectOs(); + if (!pardes.ctlfs.changesPane(req)) return conn.reply(&reply, core.fsPayload(reply)); + // The editor draws the change and performs what it asked for; when + // it asked for something -- a save, a shell, a watch -- the answer + // waits until that is done, so `echo Save > exec` returns with the + // file written. A change carries no payload, so the reply is still + // whole after the wait. l.kick(); - } - - /// Holds the slot until the editor's thread has paid what the - /// connection still owes, so a successor never inherits its entries. - fn onClosed(ctx: ?*anyopaque, conn: *Runner.Conn) void { + const restoring = core.restore_req != null; + if (core.effects_len != 0) pardes.turn.awaitSettled(epoch); + // Once a wait returns `core` may be gone: a Restore meanwhile put a + // replacement in (`reset`) and is hanging this connection up, which + // is a Restore's answer. Only one that failed leaves this connection + // here to answer. + if (l.core != core) return; + if (restoring) pardes.turn.awaitRestored(restores); + if (l.core != core) return; + conn.reply(&reply, ""); + } + + /// The turn was given up quiet with a request parked: every connection + /// retries what it parked. + fn wakeParked(ctx: ?*anyopaque) void { const l = of(ctx); - const s = &l.slots[conn.index]; if (l.stopping.load(.acquire)) return; - s.mutex.lockUncancelable(l.io); - if (s.len == 0) { - s.mutex.unlock(l.io); - return; - } - s.closing = true; - s.drained.reset(); - s.mutex.unlock(l.io); - l.kick(); - s.drained.wait(l.io) catch {}; + if (comptime supported) l.runner.wakeAll(); } + /// A request changed the core: the editor wakes to draw it and perform + /// what it asked for. fn kick(l: *Listener) void { if (l.stopping.load(.acquire)) return; if (l.wake) |f| f(l.wake_ctx); @@ -411,68 +362,46 @@ pub const Listener = struct { c.draining = true; } - pub const Drained = struct { count: usize = 0, pending: bool = false }; - - /// Answers what every connection has asked since the last call, retries - /// their parked reads against the editor's current state and has the - /// runner send the replies. Call it after each editor update, on the - /// editor's thread; `pending` says QUIC has more to do right away. - pub fn drain(l: *Listener, core: *pardes.Pardes) Drained { - core.fs.socket_path = l.path(); - core.fs.tcp_address = l.tcp_address; - core.fs.quic_address = l.quic_address; - l.expire(); - var result: Drained = .{}; - if (comptime supported) { - for (&l.slots, 0..) |*s, i| { - const conn = &l.runner.conns[i]; - s.mutex.lockUncancelable(l.io); - const only: ?u32 = if (l.resetting) |gens| gens[i] else null; - var count: usize = 0; - if (s.len != 0 or conn.live()) { - conn.lock(); - while (s.len != 0) { - if (only) |gen| if (s.queue[s.head].gen != gen) break; - const e = s.pop().?; - if (e.gen == s.gen) step(core, &conn.engine, e.req) else if (e.req.op == .release) pay(core, e.req); - count += 1; - } - if (conn.live() and (only == null or only.? == s.gen)) { - while (conn.engine.retry()) |req| { - step(core, &conn.engine, req); - count += 1; - } - while (conn.engine.next()) |req| { - step(core, &conn.engine, req); - count += 1; - } - } - const owed = conn.engine.output().len != 0; - conn.unlock(); - if (owed) conn.flush(); - } - if (s.closing and s.len == 0) { - s.closing = false; - s.drained.set(l.io); - } - s.mutex.unlock(l.io); - result.count += count; - if (count != 0) l.collectOs(core); - } - } + /// What one QUIC poll pass did: `pending` says there is more to do at + /// once. + pub const Polled = struct { count: usize = 0, pending: bool = false }; + + /// Answers one QUIC request, on the editor's thread. + fn step(l: *Listener, srv: *Srv, req: pardes.ctlfs.Req) void { + const reply = l.core.serveFs(req); + srv.reply(&reply, l.core.fsPayload(reply)); + if (req.op == .release) l.collectOs(); + } + + /// QUIC's events, accepts, reads, requests and replies, on the editor's + /// thread after each of its steps; `pending` says there is more to do + /// right away. Unix and TCP need none of this. + pub fn tick(l: *Listener) Polled { + var result: Polled = .{}; + // Between the editor's steps, which is when the table may be swept: + // the editor's own directory listings leave nodes in it too. + l.collectOs(); if (comptime quic_enabled) { + if (l.quic) |*listener| listener.events() catch |err| { + log.warn("QUIC listener stopped: {s}", .{@errorName(err)}); + for (&l.conns, 0..) |*conn, i| if (conn.quic != null) l.drop(@intCast(i)); + listener.deinit(); + l.quic = null; + l.quic_address = null; + }; + l.accept(); + for (0..quic_slots) |i| if (l.live(@intCast(i))) l.fill(@intCast(i)); + l.expire(); for (&l.conns, 0..) |*conn, i| { if (!l.live(@intCast(i)) and !conn.draining) continue; var count: usize = 0; while (conn.srv.retry()) |req| { - step(core, &conn.srv, req); - l.collectOs(core); + l.step(&conn.srv, req); count += 1; } while (count < 64) { const req = conn.srv.next() orelse break; - step(core, &conn.srv, req); - l.collectOs(core); + l.step(&conn.srv, req); count += 1; } result.count += count; @@ -482,64 +411,44 @@ pub const Listener = struct { } else l.flush(@intCast(i)); if (conn.quic) |*connection| result.pending = result.pending or connection.pending(); } + l.arm(); } return result; } - /// `drain` plus the QUIC listener's events, accepts and reads. - pub fn tick(l: *Listener, core: *pardes.Pardes) Drained { - if (comptime quic_enabled) { - if (l.quic) |*listener| listener.events() catch |err| { - log.warn("QUIC listener stopped: {s}", .{@errorName(err)}); - for (&l.conns, 0..) |*conn, i| if (conn.quic != null) l.drop(@intCast(i)); - listener.deinit(); - l.quic = null; - l.quic_address = null; - }; - l.accept(); - for (0..quic_slots) |i| if (l.live(@intCast(i))) l.fill(@intCast(i)); - } - const result = l.drain(core); - l.arm(); - return result; - } - - /// Hangs every connection up and pays `core` what they owed, so that a - /// replacement core starts with no client holding anything. A client - /// that connects meanwhile is not answered until the caller has put - /// the replacement in and calls `tick` again. - pub fn reset(l: *Listener, core: *pardes.Pardes) void { + /// Hangs every connection up, so that `replacement` starts with no + /// client holding anything. From here requests are answered from the + /// replacement -- a client that connects meanwhile is a client of the + /// replacement -- and every task waiting on the old core is let go: it + /// finds the core changed and answers nothing, its connection being + /// hung up. The connections pay their releases on their own tasks, so + /// the editor rests while they do. + pub fn reset(l: *Listener, replacement: *pardes.Pardes) void { for (0..quic_slots) |i| l.drop(@intCast(i)); + if (comptime quic_enabled) while (l.tick().pending) {}; + l.core = replacement; + replacement.fs.socket_path = l.path(); + replacement.fs.tcp_address = l.tcp_address; + replacement.fs.quic_address = l.quic_address; if (comptime supported) { - var gens: [max_conns]u32 = undefined; - for (&l.slots, &gens) |*s, *gen| { - s.mutex.lockUncancelable(l.io); - gen.* = s.gen; - s.mutex.unlock(l.io); - } - l.resetting = gens; - defer l.resetting = null; l.runner.closeAll(); + pardes.turn.settle(); + pardes.turn.restoreSettled(); + pardes.turn.rest(); const deadline = nowMs() +| 2000; - while (true) { - const drained = l.drain(core); - var idle = !drained.pending; - for (&l.slots, &gens, 0..) |*s, gen, i| { - s.mutex.lockUncancelable(l.io); - if (s.len != 0 and s.queue[s.head].gen == gen) idle = false; - if (s.gen == gen and l.runner.conns[i].live()) idle = false; - s.mutex.unlock(l.io); - } - if (idle or nowMs() >= deadline) break; - Client.nap(1); - } - } else while (l.drain(core).pending) {} - l.collectOs(core); + while (l.runner.count() != 0 and nowMs() < deadline) Client.nap(1); + pardes.turn.wake(); + } + l.collectOs(); for (&l.conns) |*conn| conn.accepted_ms = 0; l.arm(); } - fn collectOs(l: *Listener, core: *pardes.Pardes) void { + /// Forgets the host paths no connection names any more. With the turn, + /// and only between the editor's steps: a step out in a syscall may be + /// reading one of these entries. + fn collectOs(l: *Listener) void { + const core = l.core; var i: usize = 0; while (i < core.fs.os_paths.items.len) { const entry = core.fs.os_paths.items[i]; @@ -552,17 +461,10 @@ pub const Listener = struct { } } - /// Whether any connection, or a release still to be paid, names `node`. + /// Whether any connection names `node`. fn references(l: *Listener, node: u64) bool { if (comptime supported) { - for (&l.slots, 0..) |*s, i| { - const conn = &l.runner.conns[i]; - s.mutex.lockUncancelable(l.io); - defer s.mutex.unlock(l.io); - var k: usize = 0; - while (k < s.len) : (k += 1) { - if (s.queue[(s.head + k) % Slot.capacity].req.node == node) return true; - } + for (&l.runner.conns) |*conn| { if (!conn.live()) continue; conn.lock(); defer conn.unlock(); @@ -576,16 +478,12 @@ pub const Listener = struct { return false; } - /// Where the runner's tasks report that a request waits for `tick`. - pub fn setWake(l: *Listener, ctx: ?*anyopaque, wake: *const fn (?*anyopaque) void) void { + /// Where the runner's tasks report that a request changed the core, + /// and for QUIC a thread that watches its socket and calls `wake` when + /// `tick` has something to read. + pub fn watch(l: *Listener, ctx: ?*anyopaque, wake: *const fn (?*anyopaque) void) !void { l.wake_ctx = ctx; l.wake = wake; - } - - /// `setWake`, and for QUIC a thread that watches its socket and calls - /// `wake` when `tick` has something to read. - pub fn watch(l: *Listener, ctx: ?*anyopaque, wake: *const fn (?*anyopaque) void) !void { - l.setWake(ctx, wake); if (comptime !quic_enabled) return; if (l.quic == null or l.watcher != null) return; if (libc.pipe(&l.control) != 0) return error.PipeFailed; @@ -735,7 +633,15 @@ pub const Listener = struct { if (comptime quic_enabled) { if (l.quic) |*listener| listener.deinit(); } - if (comptime supported) l.runner.stop(); + if (comptime supported) { + // A connection task may be waiting for the turn; it answers + // nothing more once stopping, but the wait itself must end. + pardes.turn.rest(); + l.runner.stop(); + pardes.turn.wake(); + } + pardes.turn.wake_parked = null; + pardes.turn.stop(); if (l.path_len != 0) { var z: [sun_path_len:0]u8 = undefined; @memcpy(z[0..l.path_len], l.path_buf[0..l.path_len]); @@ -752,7 +658,9 @@ pub fn socketPath(buf: *[sun_path_len]u8, dir: []const u8, name: []const u8) ?[: return std.fmt.bufPrintSentinel(buf, "{s}/" ++ prefix ++ "{s}.sock", .{ dir, name }, 0) catch null; } -pub fn listen(io: std.Io, gpa: std.mem.Allocator, named: []const u8, fallback: []const u8, tcp_dial: ?[]const u8, quic_dial: ?[]const u8) ?*Listener { +/// Serves `core`. From here on the calling thread has the editor's turn +/// (`pardes.turn`) and must give it up while it waits. +pub fn listen(io: std.Io, gpa: std.mem.Allocator, core: *pardes.Pardes, named: []const u8, fallback: []const u8, tcp_dial: ?[]const u8, quic_dial: ?[]const u8) ?*Listener { if (comptime !supported) return null; var dir_buf: [sun_path_len:0]u8 = undefined; const dir = socketDir(&dir_buf) orelse { @@ -761,11 +669,14 @@ pub fn listen(io: std.Io, gpa: std.mem.Allocator, named: []const u8, fallback: [ }; if (!ensureSocketDir(dir)) return null; const l = gpa.create(Listener) catch return null; - l.* = .{ .io = io }; + l.* = .{ .io = io, .core = core }; + pardes.turn.start(io); + pardes.turn.wake_parked = Listener.wakeParked; + pardes.turn.wake_ctx = l; l.runner.init(.{ .io = io, .root = pardes.ctlfs.root, - .handler = .{ .ctx = l, .serve = Listener.onServe, .opened = Listener.onOpened, .closed = Listener.onClosed }, + .handler = .{ .ctx = l, .serve = Listener.onServe }, .greet_timeout_ms = Listener.greet_deadline_ms, }); const entry_name = if (named.len != 0) named else fallback; @@ -838,6 +749,9 @@ pub fn listen(io: std.Io, gpa: std.mem.Allocator, named: []const u8, fallback: [ } } log.info("serving 9P2000 on {s}", .{p}); + core.fs.socket_path = l.path(); + core.fs.tcp_address = l.tcp_address; + core.fs.quic_address = l.quic_address; return l; } @@ -1160,33 +1074,6 @@ test "TCP addresses are numeric and normalize mapped IPv4" { } else try testing.expectError(error.QuicUnavailable, Client.validateDial("quic!127.0.0.1!5640")); } -test "same-session TCP mounts compare canonical endpoints and local wildcard destinations" { - if (comptime !supported) return error.SkipZigTest; - const Case = struct { bound: []const u8, dial: []const u8, same: bool }; - for ([_]Case{ - .{ .bound = "tcp!127.0.0.1!5640", .dial = "tcp!::ffff:127.0.0.1!5640", .same = true }, - .{ .bound = "tcp!::ffff:127.0.0.1!5640", .dial = "tcp!127.0.0.1!5640", .same = true }, - .{ .bound = "tcp!::1!5640", .dial = "tcp!0:0:0:0:0:0:0:1!5640", .same = true }, - .{ .bound = "tcp!127.0.0.1!5640", .dial = "tcp!0.0.0.0!5640", .same = true }, - .{ .bound = "tcp!::1!5640", .dial = "tcp!::!5640", .same = true }, - .{ .bound = "tcp!0.0.0.0!5640", .dial = "tcp!127.0.0.2!5640", .same = true }, - .{ .bound = "tcp!::!5640", .dial = "tcp!::1!5640", .same = true }, - .{ .bound = "tcp!127.0.0.1!5640", .dial = "tcp!127.0.0.1!5641", .same = false }, - .{ .bound = "tcp!0.0.0.0!5640", .dial = "tcp!192.0.2.1!5640", .same = false }, - .{ .bound = "tcp!::!5640", .dial = "tcp!2001:db8::1!5640", .same = false }, - .{ .bound = "tcp!::!5640", .dial = "tcp!127.0.0.1!5640", .same = false }, - }) |c| try testing.expectEqual(c.same, Client.sameSession(c.dial, "", try networkAddress(c.bound, true), null)); - try testing.expect(Client.sameSession("/tmp/pardes-owned.sock", "/tmp/pardes-owned.sock", null, null)); - try testing.expect(Client.sameSession("unix!/tmp/pardes-owned.sock", "/tmp/pardes-owned.sock", null, null)); - try testing.expect(!Client.sameSession("tcp!127.0.0.1!5640", "/tmp/pardes-owned.sock", null, null)); - if (quic_enabled) { - const endpoint = try networkAddress("quic!127.0.0.1!5640", false); - try testing.expect(Client.sameSession("quic!::ffff:127.0.0.1!5640", "", null, endpoint)); - try testing.expect(!Client.sameSession("tcp!127.0.0.1!5640", "", null, endpoint)); - try testing.expect(!Client.sameSession("quic!127.0.0.1!5640", "", endpoint, null)); - } -} - extern "c" fn mkdtemp(template: [*:0]u8) ?[*:0]u8; extern "c" fn rmdir(path: [*:0]const u8) c_int; @@ -1225,7 +1112,9 @@ test "a listening editor posts itself into the 9P registry and unposts on stop" var link: [sun_path_len]u8 = undefined; { - const l = listen(testing.io, gpa, "unit", "", null, null) orelse return error.ListenFailed; + const p = try pardes.Pardes.init(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 }); + defer p.deinit(); + const l = listen(testing.io, gpa, p, "unit", "", null, null) orelse return error.ListenFailed; defer l.deinit(gpa); // The socket stays exactly where pardes has always bound it: // adopting the registry moves nothing, it only advertises. @@ -1312,7 +1201,7 @@ test "Unix TCP and QUIC share one listener through reads writes reconnects and r var bind_buf: [64]u8 = undefined; const bind = try std.fmt.bufPrint(&bind_buf, "{s}!{s}!0", .{ protocol, host }); const tcp = std.mem.eql(u8, protocol, "tcp"); - const l = listen(testing.io, gpa, "roundtrip", "", if (tcp) bind else null, if (tcp) null else bind) orelse return error.ListenFailed; + const l = listen(testing.io, gpa, p, "roundtrip", "", if (tcp) bind else null, if (tcp) null else bind) orelse return error.ListenFailed; defer { l.reset(p); l.deinit(gpa); @@ -1331,39 +1220,108 @@ test "Unix TCP and QUIC share one listener through reads writes reconnects and r var worker: Worker = .{ .dial = dial, .body_path = body, .expected = if (attempt == 0) "initial\n" else replacement, .replacement = replacement }; const thread = try std.Thread.spawn(.{}, Worker.run, .{&worker}); defer thread.join(); + // The editor rests while the client works: its requests are + // answered on the runner's tasks, not by this thread. const deadline = Client.nowMs() + 3 * Client.budget_ms; + pardes.turn.rest(); while (!worker.done.load(.acquire) and Client.nowMs() < deadline) { - _ = l.tick(p); + if (quic_enabled) { + pardes.turn.wake(); + _ = l.tick(); + pardes.turn.rest(); + } Client.nap(1); } + pardes.turn.wake(); try testing.expect(worker.done.load(.acquire)); if (worker.failure) |err| return err; l.reset(p); try testing.expectEqual(@as(usize, 0), l.runner.count()); - for (&l.slots) |*slot| try testing.expectEqual(@as(usize, 0), slot.len); for (&l.conns, 0..) |conn, i| try testing.expect(!l.live(@intCast(i)) and !conn.draining); for (p.fs.snapshots) |snapshot| try testing.expect(snapshot.node == 0); } }; } +test "a change waits while the editor is out mid-step, a read does not, and the change lands when the editor rests" { + if (comptime !supported) return error.SkipZigTest; + const gpa = testing.allocator; + var directory: [64:0]u8 = undefined; + _ = try std.fmt.bufPrintSentinel(&directory, "/tmp/pardes-park-XXXXXX", .{}, 0); + if (mkdtemp(&directory) == null) return error.TempDirectoryFailed; + defer _ = rmdir(&directory); + const old_runtime = if (libc.getenv("XDG_RUNTIME_DIR")) |v| try gpa.dupeZ(u8, std.mem.span(v)) else null; + defer { + if (old_runtime) |v| { + _ = setenv("XDG_RUNTIME_DIR", v, 1); + gpa.free(v); + } else _ = unsetenv("XDG_RUNTIME_DIR"); + } + try testing.expectEqual(@as(c_int, 0), setenv("XDG_RUNTIME_DIR", &directory, 1)); + + const p = try pardes.Pardes.init(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 }); + defer p.deinit(); + const pane = try p.setTestFile("before\n"); + while (p.nextEffect()) |_| {} + // This thread is the editor's: it has the turn from here on. + const l = listen(testing.io, gpa, p, "park", "", null, null) orelse return error.ListenFailed; + defer { + l.reset(p); + l.deinit(gpa); + } + var body_buf: [64]u8 = undefined; + const body = try std.fmt.bufPrint(&body_buf, "/pane/{d}/body", .{pane.serial}); + + const Writer = struct { + dial: []const u8, + path: []const u8, + done: std.atomic.Value(bool) = .init(false), + failure: ?anyerror = null, + fn run(w: *@This()) void { + defer w.done.store(true, .release); + Client.write(testing.allocator, w.dial, w.path, "after\n") catch |err| { + w.failure = err; + }; + } + }; + var writer: Writer = .{ .dial = l.path(), .path = body }; + + // The editor goes out mid-step -- a Look resolving a path, say -- and a + // write arrives meanwhile. It must not land: the step still holds + // pointers into the pane. A read is answered all the same. + pardes.turn.yield(); + const thread = try std.Thread.spawn(.{}, Writer.run, .{&writer}); + defer thread.join(); + Client.nap(150); + try testing.expect(!writer.done.load(.acquire)); + const seen = try Client.readLimit(gpa, l.path(), body, body, 64); + defer gpa.free(seen); + try testing.expectEqualStrings("before\n", seen); + try testing.expect(!writer.done.load(.acquire)); + pardes.turn.back(); + try testing.expectEqualStrings("before\n", pane.file.?.content); + + // Resting is what lets it in: the parked write is retried, served, and + // the client hears back. + pardes.turn.rest(); + const deadline = Client.nowMs() + Client.budget_ms; + while (!writer.done.load(.acquire) and Client.nowMs() < deadline) Client.nap(1); + pardes.turn.wake(); + try testing.expect(writer.done.load(.acquire)); + if (writer.failure) |err| return err; + try testing.expectEqualStrings("after\n", pane.file.?.content); +} + extern "c" fn setenv(name: [*:0]const u8, value: [*:0]const u8, overwrite: c_int) c_int; extern "c" fn unsetenv(name: [*:0]const u8) c_int; pub fn start(io: std.Io, gpa: std.mem.Allocator, core: *pardes.Pardes) ?*Listener { var name: [16]u8 = undefined; const fallback = std.fmt.bufPrint(&name, "{d}", .{@as(u32, @intCast(libc.getpid()))}) catch unreachable; - const listener = listen(io, gpa, core.opts.ninep_name, fallback, core.opts.ninep_tcp, core.opts.ninep_quic) orelse { + return listen(io, gpa, core, core.opts.ninep_name, fallback, core.opts.ninep_tcp, core.opts.ninep_quic) orelse { core.reportError(0, "9p listener", error.ListenFailed); return null; }; - core.fs.socket_path = listener.path(); - // So the editor can recognise its own tree by name and refuse to walk into - // it through the mount, which would deadlock the loop that serves it. - pardes.filesystem.noteOwnSocket(listener.path()); - core.fs.tcp_address = listener.tcp_address; - core.fs.quic_address = listener.quic_address; - return listener; } /// What a pane shell is told about the editor above it, set into this @@ -1423,7 +1381,7 @@ test "9P shell environment states being inside pardes apart from how to reach it const listener = try testing.allocator.create(Listener); defer testing.allocator.destroy(listener); - listener.* = .{ .io = testing.io }; + listener.* = .{ .io = testing.io, .core = undefined }; // only its path is read const path = "/tmp/pardes-example.sock"; @memcpy(listener.path_buf[0..path.len], path); listener.path_len = path.len; @@ -1549,35 +1507,6 @@ pub const Client = struct { _ = try resolve(&buf, dial); } - pub fn sameSession(dial: []const u8, socket_path: []const u8, tcp_address: ?std.Io.net.IpAddress, quic_address: ?std.Io.net.IpAddress) bool { - if (comptime !supported) return false; - var buf: [sun_path_len]u8 = undefined; - const address = resolve(&buf, dial) catch return false; - switch (address) { - .unix => |path| return socket_path.len != 0 and std.mem.eql(u8, path, socket_path), - .tcp, .quic => |destination| { - var ip = destination; - switch (ip) { - .ip4 => |v4| if (std.mem.allEqual(u8, &v4.bytes, 0)) { - ip = .{ .ip4 = .loopback(v4.port) }; - }, - .ip6 => |v6| if (std.mem.allEqual(u8, &v6.bytes, 0)) { - ip = .{ .ip6 = .loopback(v6.port) }; - }, - } - const bound = canonicalIp((if (address == .tcp) tcp_address else quic_address) orelse return false); - if (ip.getPort() != bound.getPort() or @as(std.Io.net.IpAddress.Family, ip) != @as(std.Io.net.IpAddress.Family, bound)) return false; - if (ip.eql(&bound)) return true; - const wildcard = switch (bound) { - .ip4 => |v4| std.mem.allEqual(u8, &v4.bytes, 0), - .ip6 => |v6| std.mem.allEqual(u8, &v6.bytes, 0), - }; - if (wildcard) return localIp(ip); - return false; - }, - } - } - const Session = struct { fd: c_int, quic: if (quic_enabled) ?quic.Connection else void = if (quic_enabled) null else {}, diff --git a/src/CHANGELOG.md b/src/CHANGELOG.md index e518f97a..0083f97f 100644 --- a/src/CHANGELOG.md +++ b/src/CHANGELOG.md @@ -2,6 +2,19 @@ ## 0.0.3 +- Answer 9P on the connection's task instead of the editor's loop. The core + is single-threaded and `pardes.turn` says whose turn it is with it: the + editor's by default, given up while it waits for input and while a step of + it is out in a syscall, and taken by a connection task to answer a request. + A request that would change a pane while a step is out parks in the engine + and is retried when the editor rests. So a session can open, read and save + its own tree through a mount -- which used to hang it outright, and was + then refused by name -- and the name-based refusal, the in-process routing + of a mount of oneself and the mailbox that shipped every request to the + editor's thread are gone. +- A notice wider than its pane keeps its tail rather than its head: the end + of a message is the file name or the reason. + - Give pty children their own terminal identity. `TERM`, `COLORTERM` and `TERM_PROGRAM` are now written by pardes rather than inherited from whatever launched it, and the child is exec'd with that environment. A macOS `.app` diff --git a/src/detached/server.zig b/src/detached/server.zig index ac9af2ee..3e98fc9d 100644 --- a/src/detached/server.zig +++ b/src/detached/server.zig @@ -156,7 +156,8 @@ pub const Session = struct { inotify_fd: c_int = -1, ninep: ?*ninep_io.Listener = null, ninep_pending: bool = false, - /// Set by the 9P runner's tasks: a request waits for `tick`. + /// A 9P request changed the core since the wake byte was last drained: + /// the next poll returns at once, to draw it. ninep_wake: std.atomic.Value(bool) = .init(false), watches: file_watch.Table = @splat(null), check_files: bool = false, @@ -240,7 +241,7 @@ pub const Session = struct { file_watch.watchPane(s.inotify_fd, &s.watches, @intCast(pane), null, 0, .{ .text = 0 }); _ = file_watch.applyThemeEffect(s.core, s.gpa, s.inotify_fd, &s.watches, 0, false, false); s.check_files = false; - if (s.ninep) |listener| listener.reset(s.core); + if (s.ninep) |listener| listener.reset(replacement); s.ninep_pending = false; replacement.host = s.host(); s.core.deinit(); @@ -587,7 +588,7 @@ pub const Session = struct { if (s.origins()) |c| s.send(c, .detach); } - /// The 9P runner has a request for `tick`: wake the poll loop. + /// A 9P request changed the core: wake the poll loop to draw it. fn wakeNinep(ctx: ?*anyopaque) void { const s = of(ctx); s.ninep_wake.store(true, .release); @@ -596,7 +597,7 @@ pub const Session = struct { fn pollFrame(ctx: ?*anyopaque) void { const s = of(ctx); - if (s.ninep) |l| s.ninep_pending = l.tick(s.core).pending; + if (s.ninep) |l| s.ninep_pending = l.tick().pending; for (&s.ptys, 0..) |*pt, pane| { if (pt.fd < 0) continue; var lbuf: [pardes.memory.limits.host_path_cap + 1]u8 = undefined; @@ -805,11 +806,18 @@ pub const Session = struct { } } } - if (n == 0) return nap(if (timeout_ms == 0) 16 else timeout_ms); + // The wait is the 9P connections' turn with the core. + if (n == 0) { + pardes.turn.rest(); + defer pardes.turn.wake(); + return nap(if (timeout_ms == 0) 16 else timeout_ms); + } var timeout: c_int = if (timeout_ms == 0) -1 else @intCast(@min(timeout_ms, std.math.maxInt(c_int))); if (s.nextWake(now)) |due| timeout = if (timeout < 0) due else @min(timeout, due); if (completed or s.check_files or regridded or s.ninep_pending) timeout = 0; + pardes.turn.rest(); const ready = libc.poll(&fds, @intCast(n), timeout); + pardes.turn.wake(); if (ready > 0) s.dispatch(fds[0..n], src[0..n]); _ = s.drainCompletions(true); s.expire(monotonicMs()); @@ -1134,18 +1142,17 @@ pub fn run(init: std.process.Init, opts: pardes.Options, name: []const u8) !void return error.NoSocket; } - session.ninep = ninep_io.listen(init.io, gpa, opts.ninep_name, name, opts.ninep_tcp, opts.ninep_quic); + session.ninep = ninep_io.listen(init.io, gpa, core, opts.ninep_name, name, opts.ninep_tcp, opts.ninep_quic); if (session.ninep == null) return error.ListenFailed; - session.ninep.?.setWake(&session, Session.wakeNinep); - core.fs.socket_path = session.ninep.?.path(); - core.fs.tcp_address = session.ninep.?.tcp_address; - core.fs.quic_address = session.ninep.?.quic_address; + session.ninep.?.wake_ctx = &session; + session.ninep.?.wake = Session.wakeNinep; const h = session.host(); core.host = h; while (core.nextEffect()) |effect| core.perform(effect); session.in_loop = true; while (!session.core.quit) { + pardes.turn.restoreSettled(); try session.core.pump(h); if (session.core.quit) break; if (session.core.takeRestore()) |path| restore: { diff --git a/src/detached/wire.zig b/src/detached/wire.zig index 6805d980..20b5c093 100644 --- a/src/detached/wire.zig +++ b/src/detached/wire.zig @@ -509,7 +509,7 @@ const Ul = @FieldType(pardes.CellStyle, "ul"); /// which is the whole property the six hand-written switches this replaced /// existed for, in a form that cannot fall out of step. A variant that has to /// travel under a DIFFERENT name than the core's gets an arm of its own before -/// the `inline else`, exactly as `clientTag` keeps `.fs_req`. +/// the `inline else`, exactly as `clientTag` keeps the machine-local reports. fn putUl(w: *Writer, u: Ul) Error!void { try w.putByte(switch (u) { inline else => |t| @intFromEnum(@field(UlTag, @tagName(t))), @@ -819,7 +819,7 @@ fn clientTag(msg: ClientMsg) ClientTag { return switch (msg) { .event => |ev| switch (ev) { // Machine-local reports and 9P requests belong to the session owner. - .output, .eof, .lsp_resp, .pipe_resp, .file_changed, .tick, .fs_req => unreachable, + .output, .eof, .lsp_resp, .pipe_resp, .file_changed, .tick => unreachable, inline else => |_, t| @field(ClientTag, @tagName(t)), }, inline else => |_, t| @field(ClientTag, @tagName(t)), @@ -946,7 +946,7 @@ pub fn encodeClient(out: []u8, msg: ClientMsg) Error![]const u8 { .touch_scroll => |v| try w.putF32(v), .pointer_leave => {}, // See `clientTag`: no tag, so nothing to encode. - .output, .eof, .lsp_resp, .pipe_resp, .file_changed, .tick, .fs_req => unreachable, + .output, .eof, .lsp_resp, .pipe_resp, .file_changed, .tick => unreachable, }, } try finishMessage(&w, at); @@ -1076,7 +1076,7 @@ pub fn clientBound(msg: ClientMsg) usize { .paste => |b| b.len, .command => |line| line.len, // See `clientTag`: not on this wire in this direction. - .output, .eof, .lsp_resp, .pipe_resp, .file_changed, .tick, .fs_req => unreachable, + .output, .eof, .lsp_resp, .pipe_resp, .file_changed, .tick => unreachable, }, }; } diff --git a/src/file_watch.zig b/src/file_watch.zig index b2908eb7..dfcce65f 100644 --- a/src/file_watch.zig +++ b/src/file_watch.zig @@ -382,6 +382,10 @@ fn watchPath( } const declared_path = path orelse return; const watched_path = filesystem.localPath(declared_path) orelse return; + // The path may lie in a mount this editor serves, and marking it is a + // stat and a lookup out there: the turn goes out with them. + pardes.turn.yield(); + defer pardes.turn.back(); const stat = std.Io.Dir.cwd().statFile(std.Io.Threaded.global_single_threaded.io(), watched_path, .{}) catch null; const dir = if (stat != null and stat.?.kind == .directory) watched_path else std.fs.path.dirname(watched_path) orelse "."; var dir_buf: [4096:0]u8 = undefined; @@ -601,6 +605,8 @@ pub fn reloadTheme( pub fn identify(io: std.Io, path: []const u8) !Identity { const native = filesystem.localPath(path) orelse return error.NonLocalPath; + pardes.turn.yield(); + defer pardes.turn.back(); const stat = try std.Io.Dir.cwd().statFile(io, native, .{}); if (stat.kind != .file) return error.NotFile; return .{ diff --git a/src/fs.zig b/src/fs.zig index 9200236d..85eae825 100644 --- a/src/fs.zig +++ b/src/fs.zig @@ -64,10 +64,9 @@ pub const WriteError = error{ WriteFailed, }; +/// The host takes the bytes. The caller has given the turn up (`write`), +/// because the path may be a mount this editor serves. pub fn writeFile(path: []const u8, bytes: []const u8) WriteError!void { - // No core here to answer from, so the only safe answer is no answer: an - // open(2) into our own mount is the call that never returns. - if (isOwnMount(path)) return error.OpenFailed; var pathbuf: [4096:0]u8 = undefined; if (path.len >= pathbuf.len) return error.PathTooLong; if (std.mem.indexOfScalar(u8, path, 0) != null) return error.OpenFailed; @@ -124,12 +123,21 @@ fn osNode(p: *pardes.Pardes, path: []const u8) !u64 { return node; } +/// The host filesystem under /os. Every syscall here may go out through a +/// mount this editor serves, so the turn is given up around each and taken +/// back before the core is touched; `path` is the table entry's own copy and +/// outlives the yield, and nothing is staged into the shared reply buffer +/// until the turn is back. pub fn osHandle(p: *pardes.Pardes, req: Req) Reply { if (comptime !platform_has_fs) return Reply.fail(req.tag, E.NOENT); const path = osPath(p, req.node) orelse return Reply.fail(req.tag, E.NOENT); if (req.op == .release) return .{ .tag = req.tag }; const io = std.Io.Threaded.global_single_threaded.io(); - const stat = std.Io.Dir.cwd().statFile(io, path, .{}) catch return Reply.fail(req.tag, E.NOENT); + const stat = stat: { + pardes.turn.yield(); + defer pardes.turn.back(); + break :stat std.Io.Dir.cwd().statFile(io, path, .{}) catch return Reply.fail(req.tag, E.NOENT); + }; const attr: Reply.Attr = .{ .name = if (req.node == os_root) "os" else std.fs.path.basename(path), .node = req.node, .dir = stat.kind == .directory, .size = stat.size, .mode = if (stat.kind == .directory) 0o755 else 0o644, .mtime = std.math.cast(u32, stat.mtime.toSeconds()) orelse 0 }; switch (req.op) { .getattr => return .{ .tag = req.tag, .attr = attr }, @@ -150,52 +158,67 @@ pub fn osHandle(p: *pardes.Pardes, req: Req) Reply { return osHandle(p, .{ .tag = req.tag, .op = .getattr, .node = node }); }, .readdir => { - var dir = std.Io.Dir.cwd().openDir(io, path, .{ .iterate = true }) catch return Reply.fail(req.tag, E.NOTDIR); - defer dir.close(io); - var it = dir.iterate(); - const out = p.fs.stage(p.gpa); - var skip = req.off; - while (it.next(io) catch return Reply.fail(req.tag, E.IO)) |entry| { - var buf: [4096]u8 = undefined; - const joined = std.fmt.bufPrint(&buf, "{s}/{s}", .{ std.mem.trimEnd(u8, path, "/"), entry.name }) catch continue; - var normalized_buf: [4096]u8 = undefined; - const normalized = resolveOs(joined, &normalized_buf) orelse continue; - const child = dir.statFile(io, entry.name, .{}) catch continue; - if (skip > 0) { - skip -= 1; - continue; + // Listed into a buffer of this request's own first; the shared + // reply buffer is another request's to use while the turn is out. + var listing: [16 * 1024]u8 = undefined; + var fixed: std.heap.FixedBufferAllocator = .init(&listing); + var listed: std.ArrayList(u8) = .empty; + { + pardes.turn.yield(); + defer pardes.turn.back(); + var dir = std.Io.Dir.cwd().openDir(io, path, .{ .iterate = true }) catch return Reply.fail(req.tag, E.NOTDIR); + defer dir.close(io); + var it = dir.iterate(); + var skip = req.off; + while (it.next(io) catch return Reply.fail(req.tag, E.IO)) |entry| { + var buf: [4096]u8 = undefined; + const joined = std.fmt.bufPrint(&buf, "{s}/{s}", .{ std.mem.trimEnd(u8, path, "/"), entry.name }) catch continue; + var normalized_buf: [4096]u8 = undefined; + const normalized = resolveOs(joined, &normalized_buf) orelse continue; + const child = dir.statFile(io, entry.name, .{}) catch continue; + if (skip > 0) { + skip -= 1; + continue; + } + const node = if (std.mem.eql(u8, normalized.path, "/")) os_root else os_node | (std.hash.Wyhash.hash(0, normalized.path) & (os_node - 1)); + tree.stageDirent(&listed, fixed.allocator(), node, child.kind == .directory, entry.name); + if (listed.items.len >= @max(req.size, 512)) break; } - const node = if (std.mem.eql(u8, normalized.path, "/")) os_root else os_node | (std.hash.Wyhash.hash(0, normalized.path) & (os_node - 1)); - tree.stageDirent(out, p.gpa, node, child.kind == .directory, entry.name); - if (out.items.len >= @max(req.size, 512)) break; } + const out = p.fs.stage(p.gpa); + out.appendSlice(p.gpa, listed.items) catch return Reply.fail(req.tag, E.NOMEM); return .{ .tag = req.tag, .payload = .{ .staged = @intCast(out.items.len) } }; }, .read, .write, .setattr => { if (stat.kind != .file) return Reply.fail(req.tag, E.PERM); var z: [4096]u8 = undefined; const path_z = std.fmt.bufPrintSentinel(&z, "{s}", .{path}, 0) catch return Reply.fail(req.tag, E.NOENT); - const fd = libc.open(path_z, .{ .ACCMODE = if (req.op == .read) .RDONLY else .WRONLY, .NONBLOCK = true, .CLOEXEC = true }); - if (fd < 0) return Reply.fail(req.tag, E.PERM); - defer _ = libc.close(fd); - if (req.op == .setattr) { - if (!req.truncate or req.off != 0 or libc.ftruncate(fd, 0) != 0) return Reply.fail(req.tag, E.INVAL); - var truncated = attr; - truncated.size = 0; - return .{ .tag = req.tag, .attr = truncated }; - } - if (req.off > std.math.maxInt(i64)) return Reply.fail(req.tag, E.INVAL); - if (libc.lseek(fd, @intCast(req.off), libc.SEEK.SET) < 0) return Reply.fail(req.tag, E.IO); - if (req.op == .write) { - const written = libc.write(fd, req.data.ptr, req.data.len); - if (written < 0) return Reply.fail(req.tag, E.IO); - return .{ .tag = req.tag, .written = @intCast(written) }; - } + var buf: [ninep_io.msize]u8 = undefined; // a read never asks for more than a frame + const got = io: { + pardes.turn.yield(); + defer pardes.turn.back(); + const fd = libc.open(path_z, .{ .ACCMODE = if (req.op == .read) .RDONLY else .WRONLY, .NONBLOCK = true, .CLOEXEC = true }); + if (fd < 0) return Reply.fail(req.tag, E.PERM); + defer _ = libc.close(fd); + if (req.op == .setattr) { + if (!req.truncate or req.off != 0 or libc.ftruncate(fd, 0) != 0) return Reply.fail(req.tag, E.INVAL); + var truncated = attr; + truncated.size = 0; + return .{ .tag = req.tag, .attr = truncated }; + } + if (req.off > std.math.maxInt(i64)) return Reply.fail(req.tag, E.INVAL); + if (libc.lseek(fd, @intCast(req.off), libc.SEEK.SET) < 0) return Reply.fail(req.tag, E.IO); + if (req.op == .write) { + const written = libc.write(fd, req.data.ptr, req.data.len); + if (written < 0) return Reply.fail(req.tag, E.IO); + return .{ .tag = req.tag, .written = @intCast(written) }; + } + const got = libc.read(fd, &buf, @min(req.size, buf.len)); + if (got < 0) return Reply.fail(req.tag, E.IO); + break :io @as(usize, @intCast(got)); + }; const out = p.fs.stage(p.gpa); - out.resize(p.gpa, @min(req.size, 65536)) catch return Reply.fail(req.tag, E.NOMEM); - const got = libc.read(fd, out.items.ptr, out.items.len); - if (got < 0) return Reply.fail(req.tag, E.IO); - out.shrinkRetainingCapacity(@intCast(got)); + out.appendSlice(p.gpa, buf[0..got]) catch return Reply.fail(req.tag, E.NOMEM); return .{ .tag = req.tag, .payload = .{ .staged = @intCast(got) } }; }, else => return Reply.fail(req.tag, E.PERM), @@ -378,21 +401,22 @@ test "bounded reads accept exact OS file lengths and empty files" { const empty = try readLimit(p, explicit, 0); defer gpa.free(empty); try std.testing.expectEqual(@as(usize, 0), empty.len); - try std.testing.expectEqual(@as(usize, 0), p.fs.os_paths.items.len); + // The directory's node stays in the table for the listener to collect + // once no connection names it (src/9p_io.zig, collectOs): a client may + // have walked to the same directory meanwhile and hold it by that node. + try std.testing.expectEqual(@as(usize, 1), p.fs.os_paths.items.len); + try std.testing.expectEqualStrings(native, p.fs.os_paths.items[0].path); } test "bounded reads apply the same limits to self bodies and embedded sources" { const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .tty_only = true }); defer p.deinit(); - p.fs.socket_path = "/tmp/pardes-limited-in-process.sock"; - try p.fs.mount(gpa, "own", p.fs.socket_path); var contents: [8209]u8 = @splat('x'); contents[contents.len - 1] = '\n'; for ([_][]const u8{ &contents, "" }) |expected| { const pane = try p.setTestFile(expected); - for ([_][]const u8{ "/virtual", "/n/self", "/n/own" }) |prefix| { - if (!platform_has_fs and std.mem.eql(u8, prefix, "/n/own")) continue; + for ([_][]const u8{ "/virtual", "/n/self" }) |prefix| { var path_buf: [128]u8 = undefined; const path = try std.fmt.bufPrint(&path_buf, "{s}/pane/{d}/body", .{ prefix, pane.serial }); const bytes = try readLimit(p, path, expected.len); @@ -407,8 +431,7 @@ test "bounded reads apply the same limits to self bodies and embedded sources" { } if (limits.embedded_sources) { const source = findEmbeddedSource("src/look.zig", false).?; - for ([_][]const u8{ "/virtual/src/look.zig", "/n/self/src/look.zig", "/n/own/src/look.zig" }) |path| { - if (!platform_has_fs and std.mem.startsWith(u8, path, "/n/own/")) continue; + for ([_][]const u8{ "/virtual/src/look.zig", "/n/self/src/look.zig" }) |path| { const bytes = try readLimit(p, path, source.contents.len); defer gpa.free(bytes); try std.testing.expectEqualStrings(source.contents, bytes); @@ -425,10 +448,8 @@ test "bounded reads count rendered directory paths and unknown self lengths" { const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .tty_only = true }); defer p.deinit(); - p.fs.socket_path = "/tmp/pardes-limited-in-process.sock"; - try p.fs.mount(gpa, "own", p.fs.socket_path); - for ([_][]const u8{ "/n", "/virtual", "/n/self", "/n/own", "/n/own/pane", "/virtual/listeners", "/virtual/README" }) |path| { - if (!platform_has_fs and std.mem.startsWith(u8, path, "/n/own")) continue; + p.fs.socket_path = "/tmp/pardes-limited-in-process.sock"; // so listeners has a line + for ([_][]const u8{ "/n", "/virtual", "/n/self", "/virtual/pane", "/virtual/listeners", "/virtual/README" }) |path| { const expected = try read(p, path); defer gpa.free(expected); try std.testing.expect(expected.len > 0); @@ -573,49 +594,6 @@ test "virtual body writes can read their input from the same pane" { try std.testing.expectEqualStrings("pane contents\n", pane.file.?.content); } -test "same-core mount directories preserve their mount prefix across reads" { - if (!platform_has_fs) return error.SkipZigTest; - const gpa = std.testing.allocator; - const p = try pardes.Pardes.init(gpa, .{ .tty_only = true }); - defer p.deinit(); - const socket_path = "/tmp/pardes-in-process-mount.sock"; - p.fs.socket_path = socket_path; - try p.fs.mount(gpa, "own", socket_path); - const roots = try read(p, "/n/own"); - defer gpa.free(roots); - try std.testing.expect(std.mem.startsWith(u8, roots, "/n/own/README\n/n/own/index\n")); - try std.testing.expect(std.mem.indexOf(u8, roots, "/n/own/pane/\n/n/own/os/\n") != null); - try std.testing.expectError(error.NotADirectory, read(p, "/n/own/index/..")); - try std.testing.expectError(error.FileNotFound, read(p, "/n/own/self/index")); - - var tmp = std.testing.tmpDir(.{}); - defer tmp.cleanup(); - for (0..520) |i| { - var name: [32]u8 = undefined; - try tmp.dir.writeFile(std.testing.io, .{ .sub_path = try std.fmt.bufPrint(&name, "entry-{d:0>4}.txt", .{i}), .data = "child\n" }); - } - var directory_buffer: [4096]u8 = undefined; - const directory = directory_buffer[0..try tmp.dir.realPath(std.testing.io, &directory_buffer)]; - const held_node = try osNode(p, directory); - const path = try std.fmt.allocPrint(gpa, "/n/own/os{s}", .{directory}); - defer gpa.free(path); - const listing = try read(p, path); - defer gpa.free(listing); - var entries = std.mem.tokenizeScalar(u8, listing, '\n'); - var count: usize = 0; - while (entries.next()) |entry| { - try std.testing.expect(std.mem.startsWith(u8, entry, path)); - const child = try read(p, entry); - defer gpa.free(child); - try std.testing.expectEqualStrings("child\n", child); - try std.testing.expectEqual(@as(usize, 1), p.fs.os_paths.items.len); - count += 1; - } - try std.testing.expectEqual(@as(usize, 520), count); - try std.testing.expectEqual(held_node, p.fs.os_paths.items[0].node); - try std.testing.expectEqualStrings(directory, p.fs.os_paths.items[0].path); -} - pub fn isVirtual(path: []const u8) bool { return std.mem.eql(u8, path, "/virtual") or std.mem.startsWith(u8, path, "/virtual/") or std.mem.eql(u8, path, "/n") or std.mem.startsWith(u8, path, "/n/"); @@ -674,9 +652,6 @@ pub fn resolve(p: ?*pardes.Pardes, word: []const u8, cwd: []const u8, out: *[409 } if (std.mem.eql(u8, joined, "/virtual")) return resolveVirtual(p, "/", out); if (std.mem.startsWith(u8, joined, "/virtual/")) return resolveVirtual(p, joined[8..], out); - // This editor's own tree, seen through a mount: answer from the tree - // instead of walking out into the view and back in. - if (ownMountSuffix(joined)) |inner| return resolveVirtual(p, inner, out); if (resolveOs(joined, out)) |found| return found; if (resolveVirtual(p, joined, out)) |found| return found; if (resolveVirtual(p, word, out)) |found| return found; @@ -687,116 +662,15 @@ pub fn resolve(p: ?*pardes.Pardes, word: []const u8, cwd: []const u8, out: *[409 return null; } -/// The name this session is posted under, taken from its socket path. -/// As wide as a name a listener will accept, so there is no session whose -/// name is too long to recognise and therefore too long to protect. -var own_name_buf: [108]u8 = undefined; -var own_name_len: usize = 0; - -pub fn noteOwnSocket(socket_path: []const u8) void { - own_name_len = 0; - const base = std.fs.path.basename(socket_path); - const head = "pardes-9p-"; - const tail = ".sock"; - if (!std.mem.startsWith(u8, base, head) or !std.mem.endsWith(u8, base, tail)) return; - const name = base[head.len .. base.len - tail.len]; - if (name.len == 0 or name.len > own_name_buf.len) return; - @memcpy(own_name_buf[0..name.len], name); - own_name_len = name.len; -} - -/// What this path names inside this editor's OWN 9P tree, if it does: -/// `/mnt/9p/pardes//pane/3/body` -> `pane/3/body`, and the mount root -/// itself -> `/`. -/// -/// A mount is a VIEW of a tree this editor already holds. Going out through -/// the view to reach it deadlocks the session outright -- the realpath, the -/// stat and the read all leave through the mount and come back as 9P requests -/// only this editor's loop can answer, while that loop is blocked making them, -/// and the filesystem then stops answering anybody. So the view is recognised -/// by NAME, before any syscall (the syscall is the thing that never returns), -/// and the request is served from the tree directly. Same answer, no round -/// trip, and a session can drive itself through its own 9P namespace. -pub fn ownMountSuffix(path: []const u8) ?[]const u8 { - if (own_name_len == 0 or path.len == 0 or path[0] != '/') return null; - // Whole components, and the registry's own layout: a session is posted at - // `/9p/pardes/` and mounts group under `/mnt/9p/pardes/`. - // Matching a bare `/pardes/` anywhere in the string would claim - // `~/src/pardes//README` -- an ordinary directory that happens to - // read like a mount -- and serve the tree's README over the real file. - var buf: [own_name_buf.len + 16]u8 = undefined; - const stem = std.fmt.bufPrint(&buf, "/9p/pardes/{s}", .{own_name_buf[0..own_name_len]}) catch return null; - var at: usize = 0; - while (std.mem.indexOfPos(u8, path, at, stem)) |found| : (at = found + 1) { - const rest = path[found + stem.len ..]; - if (rest.len != 0 and rest[0] != '/') continue; // a longer name that merely starts the same - if (rest.len <= 1) return "/"; - return rest[1..]; - } - return null; -} - -pub fn isOwnMount(path: []const u8) bool { - return ownMountSuffix(path) != null; -} - -test "a path inside this session's own mount is answered from the tree, not through the mount" { - noteOwnSocket("/run/user/1000/pardes-9p-demo.sock"); - defer own_name_len = 0; - // What the path names inside the tree, with the mount prefix taken off. - try std.testing.expectEqualStrings("index", ownMountSuffix("/mnt/9p/pardes/demo/index").?); - try std.testing.expectEqualStrings("pane/new", ownMountSuffix("/mnt/9p/pardes/demo/pane/new").?); - try std.testing.expectEqualStrings("/", ownMountSuffix("/mnt/9p/pardes/demo").?); - try std.testing.expectEqualStrings("/", ownMountSuffix("/mnt/9p/pardes/demo/").?); - // The registry posts the session there too, so that spelling counts. - try std.testing.expectEqualStrings("index", ownMountSuffix("/run/user/1000/9p/pardes/demo/index").?); - // Another session's mount is somebody else's to answer, and a name that - // merely STARTS with ours is a different name. - try std.testing.expect(ownMountSuffix("/mnt/9p/pardes/other/index") == null); - try std.testing.expect(ownMountSuffix("/mnt/9p/pardes/demo2/index") == null); - // An ordinary directory that reads like a mount is an ordinary directory. - // Serving the tree here would hand back the tree's README for the file on - // disk, and -- before `write` learned the same trick -- write the tree's - // bytes over it. - try std.testing.expect(ownMountSuffix("/home/goblin/src/pardes/demo/README") == null); - try std.testing.expect(ownMountSuffix("/home/goblin/src/pardes/demo.zig") == null); - // Relative paths never name a mount: they are resolved against a cwd first. - try std.testing.expect(ownMountSuffix("mnt/9p/pardes/demo/index") == null); - - // The syscall is the thing that never returns, so it is never made. - var out: [4096]u8 = undefined; - try std.testing.expect(resolveOs("/mnt/9p/pardes/demo/index", &out) == null); - - // A session with no listener has no name, so nothing is redirected. - noteOwnSocket("/tmp/not-a-pardes-socket"); - try std.testing.expect(ownMountSuffix("/mnt/9p/pardes/demo/index") == null); -} - -test "reading this session's own mount returns what the tree holds" { - const p = try pardes.Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 }); - defer p.deinit(); - noteOwnSocket("/run/user/1000/pardes-9p-selfread.sock"); - defer own_name_len = 0; - - const direct = try read(p, "/n/self/index"); - defer p.gpa.free(direct); - const mounted = try read(p, "/mnt/9p/pardes/selfread/index"); - defer p.gpa.free(mounted); - try std.testing.expectEqualStrings(direct, mounted); - try std.testing.expect(direct.len > 0); - - // A write goes to the same tree the read came from, not out through the - // mount: `/index` is 0400 there, and an OS write would instead try to - // create a file under a directory that does not exist. - try std.testing.expectError(error.ReadOnlyFilesystem, write(p, "/mnt/9p/pardes/selfread/index", "nope\n")); - try std.testing.expectError(error.ReadOnlyFilesystem, write(p, "/n/self/index", "nope\n")); -} - +/// Where a path really is on the host, and whether it is a directory. The +/// path may lie in a mount this editor serves, so the turn is given up for +/// the syscalls: another thread answers them. pub fn resolveOs(path: []const u8, out: *[4096]u8) ?Resolved { if (comptime !platform_has_fs) return null; - if (isOwnMount(path)) return null; var z: [4096]u8 = undefined; const path_z = std.fmt.bufPrintSentinel(&z, "{s}", .{path}, 0) catch return null; + pardes.turn.yield(); + defer pardes.turn.back(); const resolved = realpath(path_z, out) orelse return null; return .{ .path = std.mem.span(resolved), .dir = isDir(resolved) }; } @@ -818,13 +692,6 @@ pub fn read(p: *pardes.Pardes, path: []const u8) ![]u8 { } pub fn readLimit(p: *pardes.Pardes, path: []const u8, max_bytes: usize) ![]u8 { - // The same view, reached by a reader that never went through `resolve`. - // The rewritten path cannot contain the mount stem, so this recurses once. - if (ownMountSuffix(path)) |inner| { - var self_buf: [4096]u8 = undefined; - const internal = std.fmt.bufPrint(&self_buf, "/n/self/{s}", .{inner}) catch return error.FileTooLarge; - return readLimit(p, internal, max_bytes); - } const limit = @min(max_bytes, limits.max_file_bytes); if (std.mem.eql(u8, std.mem.trimEnd(u8, path, "/"), "/n")) { var out: std.Io.Writer.Allocating = .init(p.gpa); @@ -847,11 +714,8 @@ pub fn readLimit(p: *pardes.Pardes, path: []const u8, max_bytes: usize) ![]u8 { var native_buf: [4096]u8 = undefined; const native = resolveOs(remote_path, &native_buf) orelse return readFileLimit(p.gpa, path, limit); if (!native.dir) return readFileLimit(p.gpa, path, limit); - const saved_paths = p.fs.os_paths.items.len; - defer { - for (p.fs.os_paths.items[saved_paths..]) |temporary| p.gpa.free(temporary.path); - p.fs.os_paths.shrinkRetainingCapacity(saved_paths); - } + // The node stays in the table until no connection names it either + // (src/9p_io.zig, collectOs): a client may have walked to it too. const node = try osNode(p, native.path); return readNode(p, node, path, limit); } @@ -861,25 +725,10 @@ pub fn readLimit(p: *pardes.Pardes, path: []const u8, max_bytes: usize) ![]u8 { } for (p.fs.mounts.items) |mount| { if (!std.mem.eql(u8, name, mount.name)) continue; - if (ninep_io.Client.sameSession(mount.dial, p.fs.socket_path, p.fs.tcp_address, p.fs.quic_address)) { - const saved_paths = p.fs.os_paths.items.len; - defer { - for (p.fs.os_paths.items[saved_paths..]) |temporary| p.gpa.free(temporary.path); - p.fs.os_paths.shrinkRetainingCapacity(saved_paths); - } - var node = tree.root; - var directory = true; - var parts = std.mem.tokenizeScalar(u8, remote_path, '/'); - while (parts.next()) |part| { - if (!directory) return error.NotADirectory; - if (std.mem.eql(u8, part, ".")) continue; - const reply = tree.handle(p, .{ .tag = 0, .op = .lookup, .node = node, .data = part }); - if (reply.status != .ok) return error.FileNotFound; - node = reply.attr.node; - directory = reply.attr.dir; - } - return readNode(p, node, path, limit); - } + // A peer answers on its own time, and the peer may be this very + // editor: the turn goes out with the request. + pardes.turn.yield(); + defer pardes.turn.back(); return ninep_io.Client.readLimit(p.gpa, mount.dial, remote_path, path, limit); } return error.FileNotFound; @@ -940,68 +789,64 @@ fn readNode(p: *pardes.Pardes, initial_node: u64, path: []const u8, limit: usize } } +/// The editor's, between steps: a save or a dump the shell is performing, +/// never a step of the core. pub fn write(p: *pardes.Pardes, path: []const u8, bytes: []const u8) !void { - // The same view `readLimit` answers from the tree, so a write lands where - // the matching read came from -- and, just as importantly, never becomes - // an open(2) through a mount this loop is the one that answers. - if (ownMountSuffix(path)) |inner| { - var self_buf: [4096]u8 = undefined; - const internal = std.fmt.bufPrint(&self_buf, "/n/self/{s}", .{inner}) catch return error.PathTooLong; - return write(p, internal, bytes); - } if (std.mem.eql(u8, std.mem.trimEnd(u8, path, "/"), "/n")) return error.IsDirectory; - var self_path: ?[]const u8 = null; - if (std.mem.eql(u8, path, "/virtual")) self_path = ""; - if (std.mem.startsWith(u8, path, "/virtual/")) self_path = path[9..]; - if (std.mem.startsWith(u8, path, "/n/")) { - const explicit = path[3..]; - const cut = std.mem.indexOfScalar(u8, explicit, '/') orelse explicit.len; - const name = explicit[0..cut]; - const remote_path = if (cut < explicit.len) explicit[cut..] else "/"; - if (std.mem.eql(u8, name, "os")) return writeFile(remote_path, bytes); - if (std.mem.eql(u8, name, "self")) { - self_path = remote_path; - } else { - for (p.fs.mounts.items) |mount| { - if (!std.mem.eql(u8, name, mount.name)) continue; - if (ninep_io.Client.sameSession(mount.dial, p.fs.socket_path, p.fs.tcp_address, p.fs.quic_address)) { - var buf: [4096]u8 = undefined; - const local = try std.fmt.bufPrint(&buf, "/n{s}", .{remote_path}); - return write(p, local, bytes); - } - return ninep_io.Client.write(p.gpa, mount.dial, remote_path, bytes); - } - return error.FileNotFound; - } + if (std.mem.eql(u8, path, "/virtual")) return writeSelf(p, "", bytes); + if (std.mem.startsWith(u8, path, "/virtual/")) return writeSelf(p, path[9..], bytes); + if (!std.mem.startsWith(u8, path, "/n/")) return writeOut(p, null, path, bytes); + const explicit = path[3..]; + const cut = std.mem.indexOfScalar(u8, explicit, '/') orelse explicit.len; + const name = explicit[0..cut]; + const remote_path = if (cut < explicit.len) explicit[cut..] else "/"; + if (std.mem.eql(u8, name, "os")) return writeOut(p, null, remote_path, bytes); + if (std.mem.eql(u8, name, "self")) return writeSelf(p, remote_path, bytes); + for (p.fs.mounts.items) |mount| { + if (std.mem.eql(u8, name, mount.name)) return writeOut(p, mount.dial, remote_path, bytes); } - if (self_path) |name| { - var node = tree.resolveSelf(p, name) orelse return error.FileNotFound; - const attributes = tree.handle(p, .{ .tag = 0, .op = .getattr, .node = node }); - if (attributes.status != .ok) return error.FileNotFound; - if (attributes.attr.dir) return error.IsDirectory; - if (attributes.attr.mode & 0o200 == 0) return error.ReadOnlyFilesystem; - const opened = tree.handle(p, .{ .tag = 0, .op = .open, .node = node }); - if (opened.status != .ok) return error.OpenFailed; - if (opened.attr.node != 0) node = opened.attr.node; - defer _ = tree.handle(p, .{ .tag = 0, .op = .release, .node = node, .handle = opened.handle }); - var preserved: ?[]u8 = null; - defer if (preserved) |copy| p.gpa.free(copy); - const target = tree.Node.target(node); - if (target != null and target.? == .pane and target.?.pane.file == .body) { - preserved = try p.gpa.dupe(u8, bytes); - const trunc = tree.handle(p, .{ .tag = 0, .op = .setattr, .node = node, .truncate = true }); - if (trunc.status != .ok) return error.WriteFailed; - } - const contents = preserved orelse bytes; - var off: usize = 0; - while (off < contents.len) { - const reply = tree.handle(p, .{ .tag = 0, .op = .write, .node = node, .off = off, .data = contents[off..] }); - if (reply.status != .ok or reply.written == 0) return error.WriteFailed; - off += reply.written; - } - return; + return error.FileNotFound; +} + +/// The host, or the peer at `dial`, takes the bytes with the turn given up +/// entirely -- the peer may be this very editor, and a write it serves may +/// change any pane -- so they are copied first: `bytes` is usually a pane's +/// own text. +fn writeOut(p: *pardes.Pardes, dial: ?[]const u8, path: []const u8, bytes: []const u8) !void { + const copy = try p.gpa.dupe(u8, bytes); + defer p.gpa.free(copy); + pardes.turn.rest(); + defer pardes.turn.wake(); + if (dial) |d| return ninep_io.Client.write(p.gpa, d, path, copy); + return writeFile(path, copy); +} + +/// This editor's own tree, written in place. +fn writeSelf(p: *pardes.Pardes, name: []const u8, bytes: []const u8) !void { + var node = tree.resolveSelf(p, name) orelse return error.FileNotFound; + const attributes = tree.handle(p, .{ .tag = 0, .op = .getattr, .node = node }); + if (attributes.status != .ok) return error.FileNotFound; + if (attributes.attr.dir) return error.IsDirectory; + if (attributes.attr.mode & 0o200 == 0) return error.ReadOnlyFilesystem; + const opened = tree.handle(p, .{ .tag = 0, .op = .open, .node = node }); + if (opened.status != .ok) return error.OpenFailed; + if (opened.attr.node != 0) node = opened.attr.node; + defer _ = tree.handle(p, .{ .tag = 0, .op = .release, .node = node, .handle = opened.handle }); + var preserved: ?[]u8 = null; + defer if (preserved) |copy| p.gpa.free(copy); + const target = tree.Node.target(node); + if (target != null and target.? == .pane and target.?.pane.file == .body) { + preserved = try p.gpa.dupe(u8, bytes); + const trunc = tree.handle(p, .{ .tag = 0, .op = .setattr, .node = node, .truncate = true }); + if (trunc.status != .ok) return error.WriteFailed; + } + const contents = preserved orelse bytes; + var off: usize = 0; + while (off < contents.len) { + const reply = tree.handle(p, .{ .tag = 0, .op = .write, .node = node, .off = off, .data = contents[off..] }); + if (reply.status != .ok or reply.written == 0) return error.WriteFailed; + off += reply.written; } - return writeFile(path, bytes); } fn resolveEmbedded(word: []const u8, cwd: []const u8, scratch: *[4096]u8) ?Source { @@ -1069,6 +914,8 @@ pub fn find(arena: std.mem.Allocator, dir: []const u8, pat: []const u8, out: []u var hits: [find_max_hits][]const u8 = undefined; var hits_len: usize = 0; if (platform_has_fs) { + pardes.turn.yield(); + defer pardes.turn.back(); const io = std.Io.Threaded.global_single_threaded.io(); var root = try std.Io.Dir.cwd().openDir(io, dir, .{ .iterate = true }); defer root.close(io); @@ -1152,6 +999,9 @@ pub fn grep(arena: std.mem.Allocator, gpa: std.mem.Allocator, dir: []const u8, b const home = std.mem.trimEnd(u8, base, "/"); const files = try arena.alloc([]const u8, grep_max_files); var files_len: usize = 0; + // A walk and thousands of reads: the turn goes out for all of it. + pardes.turn.yield(); + defer pardes.turn.back(); { const io = std.Io.Threaded.global_single_threaded.io(); var root = try std.Io.Dir.cwd().openDir(io, dir, .{ .iterate = true }); @@ -1311,10 +1161,6 @@ test "Restore prefers default directory then falls back to original path" { fn readFileLimit(gpa: std.mem.Allocator, path: []const u8, limit: usize) ![]u8 { if (std.mem.indexOfScalar(u8, path, 0) != null) return error.OpenFailed; - // Same reason as `writeFile`: no core to answer from here, and the open is - // the call that never returns. Callers holding one use `readLimit`, which - // serves the tree instead. - if (isOwnMount(path)) return error.FileNotFound; if (!platform_has_fs or std.mem.startsWith(u8, path, "/virtual/")) { const archive_path = if (std.mem.startsWith(u8, path, "/virtual/")) path[9..] else path; var normalized_buf: [4096]u8 = undefined; @@ -1326,6 +1172,10 @@ fn readFileLimit(gpa: std.mem.Allocator, path: []const u8, limit: usize) ![]u8 { var pathbuf: [4096]u8 = undefined; const native = localPath(path) orelse return error.OpenFailed; const path_z = std.fmt.bufPrintSentinel(&pathbuf, "{s}", .{native}, 0) catch return error.PathTooLong; + // The path may be a mount this editor serves: the turn goes out with the + // syscalls, and the bytes come back into memory of the caller's own. + pardes.turn.yield(); + defer pardes.turn.back(); const fd = libc.open(path_z, .{ .ACCMODE = .RDONLY, .NONBLOCK = true }); if (fd < 0) return switch (libc.errno(fd)) { .ACCES, .PERM => error.PermissionDenied, diff --git a/src/gui/gui.zig b/src/gui/gui.zig index 3c2fd693..8da6f933 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -2422,6 +2422,7 @@ fn localSession( defer pardes.lsp.setStatusSink(null, null); while (!core.quit) { + pardes.turn.restoreSettled(); try core.pump(host); if (core.quit) break; // a session that ended does not restore into one if (core.takeAttach()) |req| { @@ -2465,7 +2466,7 @@ fn localSession( g.prepared_images.clearRetainingCapacity(); nc.native_images = true; nc.host = host; - if (fs) |f| f.reset(core); + if (fs) |f| f.reset(nc); core.deinit(); core = nc; shell.core = nc; @@ -2758,7 +2759,10 @@ const StdinFeed = struct { } var fds = [_]posix.pollfd{.{ .fd = 0, .events = posix.POLL.IN, .revents = 0 }}; - _ = posix.poll(&fds, 16) catch return out; + pardes.turn.rest(); + const polled = posix.poll(&fds, 16); + pardes.turn.wake(); + _ = polled catch return out; if ((fds[0].revents & posix.POLL.IN) == 0) { if ((fds[0].revents & (posix.POLL.HUP | posix.POLL.ERR)) != 0) out.eof = true; return out; @@ -3762,7 +3766,11 @@ fn waitInput(ctx: ?*anyopaque, timeout_ms: u32) void { if (s.gui) |g| { var sev = std.mem.zeroes(c.SDL_Event); const ms: c_int = if (timeout_ms != 0) @intCast(timeout_ms) else 16; - if (c.SDL_WaitEventTimeout(&sev, ms)) { + // The wait is the 9P connections' turn with the core. + pardes.turn.rest(); + const got = c.SDL_WaitEventTimeout(&sev, ms); + pardes.turn.wake(); + if (got) { dispatch(g, &in, &sev); while (c.SDL_PollEvent(&sev)) dispatch(g, &in, &sev); } @@ -3785,7 +3793,7 @@ fn pollFrame(ctx: ?*anyopaque) void { const s = shellOf(ctx); s.reconcilePtys(); const core = s.core; - if (s.fs) |f| if (f.tick(core).pending) s.queue.push(.fs_ready); + if (s.fs) |f| if (f.tick().pending) s.queue.push(.fs_ready); const g = s.gui orelse { if (core.settings.window_opacity_pending) { var unchanged_opacity: u8 = 100; @@ -3923,7 +3931,7 @@ fn gridPollFrame(ctx: ?*anyopaque) void { const s = shellOf(ctx); s.reconcilePtys(); if (s.fs) |f| { - if (f.tick(s.core).count != 0) s.saw_event = true; + if (f.tick().count != 0) s.saw_event = true; } pollCwds(s.core, s.ptys); if (s.core.animationActive()) { @@ -5077,6 +5085,13 @@ fn renderFrame( ); } } + // Body layers first: a notice chip over a tree-sitter context band + // is a tag layer, and instances paint in emission order. + for (surface.bodyLayers()) |*layer| { + if (layer.rows == 0) continue; + const batch_index = paintBatchAt(&paint_plan, layer.viewport.x, layer.viewport.y); + emitBodyLayer(g, instances, &cell_next[batch_index], layer, win_w, win_h, paint_plan.batches[batch_index].track, page, paint_plan.len == 1, false, topbar_pane_border_rgb); + } for (surface.tagLayers()) |*layer| { if (layer.cols == 0) continue; const batch_index = paintBatchAt(&paint_plan, layer.viewport.x, layer.viewport.y); @@ -5092,11 +5107,6 @@ fn renderFrame( emitTagLayer(g, instances, &cell_next[destination], layer, win_w, win_h, if (under) null else track, page, false, track.effect == .dissolve); } } - for (surface.bodyLayers()) |*layer| { - if (layer.rows == 0) continue; - const batch_index = paintBatchAt(&paint_plan, layer.viewport.x, layer.viewport.y); - emitBodyLayer(g, instances, &cell_next[batch_index], layer, win_w, win_h, paint_plan.batches[batch_index].track, page, paint_plan.len == 1, false, topbar_pane_border_rgb); - } for (paint_plan.batches[1..paint_plan.len], 1..) |batch, batch_index| { const track = batch.track.?; const under = track.effect == .vertical and track.phase == .opening; diff --git a/src/host_io.zig b/src/host_io.zig index a7babc74..72e149c9 100644 --- a/src/host_io.zig +++ b/src/host_io.zig @@ -955,6 +955,9 @@ pub fn forkShell( var cwd_buf: [4096]u8 = undefined; const cwd_z: ?[:0]const u8 = if (native_cwd.len == 0) null else dir: { const path = std.fmt.bufPrintSentinel(&cwd_buf, "{s}", .{native_cwd}, 0) catch return error.NameTooLong; + // A shell's directory may be inside a mount this editor serves. + pardes.turn.yield(); + defer pardes.turn.back(); const stat = try std.Io.Dir.cwd().statFile(std.Io.Threaded.global_single_threaded.io(), path, .{}); if (stat.kind != .directory) return error.NotDir; break :dir path; diff --git a/src/macos.zig b/src/macos.zig index d3b33c55..a7ee3164 100644 --- a/src/macos.zig +++ b/src/macos.zig @@ -773,6 +773,10 @@ fn initCore(runtime: ?*const Runtime, cols_arg: u16, rows_arg: u16) !void { for (&st.ptys, 0..) |*slot, id| if (slot.*) |*pt| startReader(st, pt, @intCast(id)); pardes.lsp.setStatusSink(st, lspStatusSink); + // From here the core is touched only inside the entry points above, + // each of which takes the turn for its own duration; between them the + // 9P connections have it. + pardes.turn.rest(); } fn wakeNinep(ctx: ?*anyopaque) void { @@ -781,6 +785,7 @@ fn wakeNinep(ctx: ?*anyopaque) void { } export fn pardes_deinit() void { + pardes.turn.wake(); const st = &(state orelse return); if (st.ninep) |listener| { listener.deinit(st.gpa); @@ -823,6 +828,8 @@ export fn pardes_deinit() void { } export fn pardes_should_quit() bool { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return true); return st.core.quit; } @@ -890,11 +897,15 @@ test "the animation clock spends real time, not callbacks" { } export fn pardes_animating() bool { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return false); return st.core.animationActive() or st.rotate_coasting or st.scroll_coasting; } export fn pardes_theme_bg() u32 { + pardes.turn.wake(); + defer pardes.turn.rest(); const th = if (state) |*st| st.core.theme() else &pardes.themes[0]; const bg = th.bg orelse return color_default; return @as(u32, bg[0]) << 16 | @as(u32, bg[1]) << 8 | bg[2]; @@ -913,6 +924,8 @@ export fn pardes_theme_bg() u32 { /// own (pardes_theme_bg == PARDES_COLOR_DEFAULT) drops the ground entirely, /// whatever percentage is set here. export fn pardes_window_opacity() u8 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return 100); st.core.settings.window_opacity_pending = false; return st.core.settings.window_opacity; @@ -920,6 +933,8 @@ export fn pardes_window_opacity() u8 { /// Public AppKit backdrop strength, independent of background paint opacity. export fn pardes_window_blur() u8 { + pardes.turn.wake(); + defer pardes.turn.rest(); return if (state) |st| st.core.settings.window_blur else 0; } @@ -928,10 +943,14 @@ fn taglineFontPercent(core: ?*const pardes.Pardes) u8 { } export fn pardes_gui_tagline_font_percent() u8 { + pardes.turn.wake(); + defer pardes.turn.rest(); return taglineFontPercent(if (state) |*st| st.core else null); } export fn pardes_tagline_band_offset(row: u16, canvas_h: f32, cell_h: u32, tagline_h: u32) u32 { + pardes.turn.wake(); + defer pardes.turn.rest(); return pardes.taglineBandOffset(row, canvas_h, cell_h, tagline_h, if (state) |*st| st.core.settings.workspace_tag else true); } @@ -940,16 +959,22 @@ export fn pardes_topbar_pane_border_px(cell_h: u32, tagline_h: u32) u32 { } export fn pardes_tagline_origin_col(col: u16, row: u16) f32 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return @floatFromInt(col)); return pardes.taglineOriginColForFrame(st.core, col, row); } export fn pardes_grid_col_at(x: f32, row: u16, body_w: f32, tagline_w: f32) u16 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return pardes.gridColAt(null, x, row, body_w, tagline_w)); return pardes.gridColAt(st.core, x, row, body_w, tagline_w); } export fn pardes_topbar_pane_border_rgb() u32 { + pardes.turn.wake(); + defer pardes.turn.rest(); const rgb = pardes.config.gui_topbar_pane_border_rgb orelse fromTheme: { const st = state orelse return color_default; break :fromTheme st.core.chromeTheme().border; @@ -958,11 +983,15 @@ export fn pardes_topbar_pane_border_rgb() u32 { } export fn pardes_tag_active_bg() u32 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = state orelse return color_default; const rgb = st.core.chromeTheme().tag_active_bg; return @as(u32, rgb[0]) << 16 | @as(u32, rgb[1]) << 8 | rgb[2]; } export fn pardes_tagline_bg() u32 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = state orelse return color_default; const rgb = st.core.chromeTheme().tag_bg; return @as(u32, rgb[0]) << 16 | @as(u32, rgb[1]) << 8 | rgb[2]; @@ -1008,6 +1037,8 @@ test "the fallback preference order crosses the ABI intact and ends at the bound } export fn pardes_scene() Scene { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return .{}); const seconds = @as(f64, @floatFromInt(st.scene_ns)) / @as(f64, std.time.ns_per_s); return .{ @@ -1018,6 +1049,8 @@ export fn pardes_scene() Scene { } export fn pardes_postprocessor_unavailable() void { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return); st.core.disableSceneEffects(); st.core.settings.panel_transition = .off; @@ -1026,6 +1059,8 @@ export fn pardes_postprocessor_unavailable() void { } export fn pardes_panel_animation_failed() void { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return); st.core.abandonPanelAnimations(); } @@ -1210,6 +1245,8 @@ fn reloadWatchedFile(st: *State, pane: u8, announce: bool) bool { } export fn pardes_watch_changed(pane: u8, generation: u32) void { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return); if (pane >= watch_slot_count) return; if (st.file_watches.notify(pane, generation)) wake(st); @@ -1265,11 +1302,13 @@ fn drainInbox(st: *State) bool { } export fn pardes_tick() bool { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return false); st.inbox.wake_pending.store(false, .release); var did = drainInbox(st); if (st.ninep) |listener| { - const drained = listener.tick(st.core); + const drained = listener.tick(); did = did or drained.count != 0; if (drained.pending) wake(st); } @@ -1277,7 +1316,9 @@ export fn pardes_tick() bool { did = true; st.core.perform(effect); } + pardes.turn.settle(); if (restoreCore(st)) did = true; + pardes.turn.restoreSettled(); return did; } @@ -1309,7 +1350,7 @@ fn restoreCore(st: *State) bool { const generation = st.file_watches.stop(st.gpa, id); hostWatchFile(id, generation, null, 0); }; - if (st.ninep) |listener| listener.reset(st.core); + if (st.ninep) |listener| listener.reset(replacement); replacement.host = hostFor(st); st.core.deinit(); st.core = replacement; @@ -1485,6 +1526,8 @@ test "mac Restore cancels a PTY reader waiting for output capacity" { } export fn pardes_animation_tick() bool { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return false); const now: u64 = @intCast(@max(0, monotonicNs())); @@ -1546,6 +1589,8 @@ export fn pardes_animation_tick() bool { } export fn pardes_key(cp_arg: u32, text_ptr: ?[*]const u8, len: usize, mods: u32) void { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return); if (cp_arg > std.math.maxInt(u21)) return; const text: []const u8 = if (text_ptr) |p| p[0..len] else ""; @@ -1559,16 +1604,22 @@ export fn pardes_key(cp_arg: u32, text_ptr: ?[*]const u8, len: usize, mods: u32) } export fn pardes_paste(text_ptr: ?[*]const u8, len: usize) void { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return); const text: []const u8 = if (text_ptr) |p| p[0..len] else ""; st.core.update(.{ .paste = text }); } export fn pardes_mouse(button_arg: c_int, kind_arg: c_int, col: u16, row: u16, mods: u32) void { + pardes.turn.wake(); + defer pardes.turn.rest(); mouseWithHit(button_arg, kind_arg, col, row, mods, null, null); } export fn pardes_mouse_pixel(button_arg: c_int, kind_arg: c_int, col: u16, row: u16, mods: u32, x: f32, y: f32, bw: f32, bh: f32, tw: f32, th: f32) void { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return); const source = st.core.presentation.pointerFractional(st.core.screen_w, st.core.screen_h, x / @max(1, bw), y / @max(1, bh)); var hit: ?pardes.Mouse.BodyHit = null; @@ -1620,11 +1671,15 @@ fn mouseWithHit(button_arg: c_int, kind_arg: c_int, col: u16, row: u16, mods: u3 } export fn pardes_pointer_leave() void { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return); st.core.update(.pointer_leave); } export fn pardes_scroll(delta_rows: f32, delta_cols: f32, col: u16, row: u16) void { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return); st.scroll_col = col; st.scroll_row = row; @@ -1636,6 +1691,8 @@ export fn pardes_scroll(delta_rows: f32, delta_cols: f32, col: u16, row: u16) vo /// spinning dial. Also drops whatever the last gesture left banked, so the /// first millimetre of a new swipe cannot inherit a nearly-complete row. export fn pardes_scroll_begin() void { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return); st.scroll_lag = 0; st.scroll_lag_x = 0; @@ -1655,6 +1712,8 @@ export fn pardes_scroll_begin() void { /// momentum simply takes the gesture over, and the tail of that momentum is /// below the fling floor, so its end arms nothing. export fn pardes_scroll_end() void { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return); const last = st.scroll_last_ns; st.scroll_last_ns = 0; @@ -1671,6 +1730,8 @@ export fn pardes_scroll_end() void { } export fn pardes_rotate(degrees: f32) void { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return); if (degrees == 0) { st.rotate_lag = 0; @@ -1684,6 +1745,8 @@ export fn pardes_rotate(degrees: f32) void { } export fn pardes_rotate_end() void { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return); const last = st.rotate_last_ns; st.rotate_last_ns = 0; @@ -1726,6 +1789,8 @@ fn spendRotation(st: *State, degrees: f32) void { } export fn pardes_command(text_ptr: ?[*]const u8, len: usize) void { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return); const text: []const u8 = if (text_ptr) |p| p[0..len] else ""; if (text.len == 0) return; @@ -1733,6 +1798,8 @@ export fn pardes_command(text_ptr: ?[*]const u8, len: usize) void { } export fn pardes_resize(cols_arg: u16, rows_arg: u16, cell_w: u16, cell_h: u16) void { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return); const cols = @max(1, cols_arg); const rows = @max(1, rows_arg); @@ -1747,6 +1814,8 @@ export fn pardes_resize(cols_arg: u16, rows_arg: u16, cell_w: u16, cell_h: u16) } export fn pardes_frame() u32 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return 0); const tz = tracy.zone(@src(), "pardes_frame"); defer tz.end(); @@ -1921,26 +1990,36 @@ fn collectImages(st: *State, surface: *const pardes.Surface) void { } export fn pardes_frame_images() u32 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return 0); return @intCast(st.images_len); } export fn pardes_frame_image_list() ?[*]const Image { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return null); return if (st.images_len == 0) null else st.images.ptr; } export fn pardes_frame_panel_tracks() u32 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return 0); return @intCast(st.panel_tracks_len); } export fn pardes_frame_panel_track_list() ?[*]const PanelTrack { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return null); return if (st.panel_tracks_len == 0) null else st.panel_tracks[0..].ptr; } export fn pardes_frame_presented(animated_panels: bool) bool { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return false); const was_animating = st.core.animationActive(); if (animated_panels) @@ -1951,11 +2030,15 @@ export fn pardes_frame_presented(animated_panels: bool) bool { } export fn pardes_frame_cells() ?[*]const Cell { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return null); return if (st.frame_len == 0) null else st.cells.ptr; } export fn pardes_frame_previous_cells() ?[*]const Cell { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return null); return if (st.panel_diff_len != st.frame_len or st.panel_diff_len == 0) null @@ -1964,6 +2047,8 @@ export fn pardes_frame_previous_cells() ?[*]const Cell { } export fn pardes_frame_changed_cells() ?[*]const u8 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return null); return if (st.panel_diff_len != st.frame_len or st.panel_diff_len == 0) null @@ -1972,16 +2057,22 @@ export fn pardes_frame_changed_cells() ?[*]const u8 { } export fn pardes_frame_cols() u16 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return 0); return st.frame_cols; } export fn pardes_frame_rows() u16 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return 0); return st.frame_rows; } export fn pardes_cursor_x() i32 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return -1); if (tagCursorCovered(st.core)) return -1; return if (st.core.surface.cursor) |c| c.x else -1; @@ -2000,6 +2091,8 @@ export fn pardes_tag_layer_limit() u32 { } export fn pardes_tag_layer_value(index: u32, field: u32) u32 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return 0); if (index >= pardes.MAX_TAG_LAYERS) return 0; const layer = &st.core.surface.tag_layers[index]; @@ -2025,6 +2118,8 @@ export fn pardes_tag_layer_value(index: u32, field: u32) u32 { } export fn pardes_tag_layer_cells(index: u32) ?[*]const Cell { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return null); if (index >= pardes.MAX_TAG_LAYERS) return null; const layer = &st.core.surface.tag_layers[index]; @@ -2036,6 +2131,8 @@ export fn pardes_tag_layer_cells(index: u32) ?[*]const Cell { } export fn pardes_body_layer_value(index: u32, field: u32) u32 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return 0); if (index >= pardes.MAX_PANES) return 0; const layer = &st.core.surface.body_layers[index]; @@ -2056,6 +2153,8 @@ export fn pardes_body_layer_value(index: u32, field: u32) u32 { } export fn pardes_body_layer_cells(index: u32) ?[*]const Cell { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return null); if (index >= pardes.MAX_PANES) return null; const layer = &st.core.surface.body_layers[index]; @@ -2071,27 +2170,37 @@ export fn pardes_body_layer_limit() u32 { } export fn pardes_row_metrics(body_w: u16, body_h: u16, tagline_w: u16, tagline_h: u16) void { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return); st.core.update(.{ .resize = .{ .cols = st.core.screen_w, .rows = st.core.screen_h, .cell_pixels = st.core.cell_pixels, .row_metrics = .{ .body_w = @max(1, body_w), .body_h = @max(1, body_h), .tagline_w = @max(1, tagline_w), .tagline_h = @max(1, tagline_h) } } }); } export fn pardes_pointer_shape() u32 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return 0); return @intFromEnum(st.core.surface.pointer_shape); } export fn pardes_cursor_y() i32 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return -1); if (tagCursorCovered(st.core)) return -1; return if (st.core.surface.cursor) |c| c.y else -1; } export fn pardes_cursor_bar() bool { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return false); return if (st.core.surface.cursor) |c| c.bar else false; } export fn pardes_take_haptic() c_int { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return 0); return switch (st.core.takeHaptic()) { .none => 0, @@ -2103,6 +2212,8 @@ export fn pardes_take_haptic() c_int { var font_path_z: [4096:0]u8 = undefined; export fn pardes_font_take(size_hundredths: *u16) ?[*:0]const u8 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return null); if (comptime !pardes.font_picker) return null; const want = st.core.takeFontRequest() orelse return null; @@ -2118,6 +2229,8 @@ export fn pardes_font_observe( len: usize, point_hundredths: u16, ) bool { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return false); const ptr = effective_name orelse return false; if (len == 0 or len > 255 or point_hundredths == 0) return false; @@ -2129,6 +2242,8 @@ export fn pardes_font_ack( len: usize, point_hundredths: u16, ) bool { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return false); const ptr = effective_name orelse return false; if (len == 0 or len > 255 or point_hundredths == 0) return false; @@ -2136,6 +2251,8 @@ export fn pardes_font_ack( } export fn pardes_font_reject() void { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return); st.core.rejectFont(); } @@ -2143,6 +2260,8 @@ export fn pardes_font_reject() void { var active_path_z: [4096:0]u8 = undefined; export fn pardes_active_path() ?[*:0]const u8 { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return null); const path = activeFilePath(st) orelse return null; if (path.len == 0 or path.len >= active_path_z.len) return null; @@ -2152,6 +2271,8 @@ export fn pardes_active_path() ?[*:0]const u8 { } export fn pardes_active_dirty() bool { + pardes.turn.wake(); + defer pardes.turn.rest(); const st = &(state orelse return false); const pane = st.core.panes[st.core.active] orelse return false; const f = if (pane.file) |*x| x else return false; diff --git a/src/memory.zig b/src/memory.zig index f30e4392..e5394b4f 100644 --- a/src/memory.zig +++ b/src/memory.zig @@ -44,7 +44,48 @@ pub const Allocators = struct { pdf: Allocator, }; -var pardes_fallback: std.heap.StackFallbackAllocator(limits.arena.pardes) = undefined; +/// `std.heap.StackFallbackAllocator` with the buffer taken through its +/// lock-free interface. The core's allocator is used from two threads: a 9P +/// connection task answers a request while the editor's own thread is out +/// in a syscall that allocates (`readFileLimit`, `grep`; see `pardes.turn`). +fn SharedStackFallback(comptime size: usize) type { + return struct { + buffer: [size]u8 = undefined, + fallback_allocator: Allocator = undefined, + fixed: std.heap.FixedBufferAllocator = undefined, + + fn get(self: *@This()) Allocator { + self.fixed = .init(self.buffer[0..]); + return .{ .ptr = self, .vtable = &.{ .alloc = alloc, .resize = resize, .remap = remap, .free = free } }; + } + + fn alloc(ctx: *anyopaque, len: usize, alignment: std.mem.Alignment, ra: usize) ?[*]u8 { + const self: *@This() = @ptrCast(@alignCast(ctx)); + return self.fixed.threadSafeAllocator().rawAlloc(len, alignment, ra) orelse + self.fallback_allocator.rawAlloc(len, alignment, ra); + } + + fn resize(ctx: *anyopaque, buf: []u8, alignment: std.mem.Alignment, new_len: usize, ra: usize) bool { + const self: *@This() = @ptrCast(@alignCast(ctx)); + if (self.fixed.ownsPtr(buf.ptr)) return self.fixed.threadSafeAllocator().rawResize(buf, alignment, new_len, ra); + return self.fallback_allocator.rawResize(buf, alignment, new_len, ra); + } + + fn remap(ctx: *anyopaque, buf: []u8, alignment: std.mem.Alignment, new_len: usize, ra: usize) ?[*]u8 { + const self: *@This() = @ptrCast(@alignCast(ctx)); + if (self.fixed.ownsPtr(buf.ptr)) return self.fixed.threadSafeAllocator().rawRemap(buf, alignment, new_len, ra); + return self.fallback_allocator.rawRemap(buf, alignment, new_len, ra); + } + + fn free(ctx: *anyopaque, buf: []u8, alignment: std.mem.Alignment, ra: usize) void { + const self: *@This() = @ptrCast(@alignCast(ctx)); + if (self.fixed.ownsPtr(buf.ptr)) return self.fixed.threadSafeAllocator().rawFree(buf, alignment, ra); + return self.fallback_allocator.rawFree(buf, alignment, ra); + } + }; +} + +var pardes_fallback: SharedStackFallback(limits.arena.pardes) = .{}; var frame_fallback: std.heap.StackFallbackAllocator(limits.arena.frame) = undefined; var tree_sitter_fallback: std.heap.StackFallbackAllocator(limits.arena.tree_sitter) = undefined; var image_fallback: std.heap.StackFallbackAllocator(limits.arena.image) = undefined; @@ -61,7 +102,6 @@ var pdf_debug: Debug = .init; // One session at a time; free its allocations before deinit. Concurrent LSP workers use the caller's allocator. pub fn init(fallback: Allocator) Allocators { pardes_fallback.fallback_allocator = fallback; - pardes_fallback.get_called = if (std.debug.runtime_safety) false else {}; frame_fallback.fallback_allocator = fallback; frame_fallback.get_called = if (std.debug.runtime_safety) false else {}; tree_sitter_fallback.fallback_allocator = fallback; @@ -112,12 +152,12 @@ test "fixed allocators are separate, spill, and restart" { var allocs = init(std.testing.allocator); const core = try allocs.pardes.alloc(u8, 32); const frame = try allocs.frame.alloc(u8, 32); - try std.testing.expect(pardes_fallback.fixed_buffer_allocator.ownsPtr(core.ptr)); + try std.testing.expect(pardes_fallback.fixed.ownsPtr(core.ptr)); try std.testing.expect(frame_fallback.fixed_buffer_allocator.ownsPtr(frame.ptr)); try std.testing.expect(core.ptr != frame.ptr); const spill = try allocs.pardes.alloc(u8, limits.arena.pardes + 1); - try std.testing.expect(!pardes_fallback.fixed_buffer_allocator.ownsPtr(spill.ptr)); + try std.testing.expect(!pardes_fallback.fixed.ownsPtr(spill.ptr)); allocs.pardes.free(spill); allocs.frame.free(frame); allocs.pardes.free(core); @@ -127,7 +167,7 @@ test "fixed allocators are separate, spill, and restart" { defer deinit(); const restarted = try allocs.pardes.alloc(u8, 32); defer allocs.pardes.free(restarted); - try std.testing.expect(pardes_fallback.fixed_buffer_allocator.ownsPtr(restarted.ptr)); + try std.testing.expect(pardes_fallback.fixed.ownsPtr(restarted.ptr)); } test "memory limits preserve desktop capacities" { diff --git a/src/ninep/testing.zig b/src/ninep/testing.zig index 44329eee..6ea40956 100644 --- a/src/ninep/testing.zig +++ b/src/ninep/testing.zig @@ -30,13 +30,10 @@ pub const Answer = struct { }; pub fn call(p: *Pardes, req: Req) Answer { - p.update(.{ .fs_req = req }); var ans: Answer = .{}; + ans.reply = p.serveFs(req); + ans.bytes = p.fsPayload(ans.reply); while (p.nextEffect()) |e| switch (e) { - .fs_reply => |r| { - ans.reply = r; - ans.bytes = p.fsPayload(r); - }, .save_file, .save_text => ans.saved = true, .watch => |w| ans.watch = w.on, .write => |w| { diff --git a/src/ninep/tree.zig b/src/ninep/tree.zig index 5a0c1e11..b13b1472 100644 --- a/src/ninep/tree.zig +++ b/src/ninep/tree.zig @@ -68,6 +68,22 @@ pub const e_bad_event = "bad event syntax"; /// everywhere, as it is in acme (editors/acme/fsys.c, fsyscreate). pub const features: cloud9.fs.Features = .{ .remove = true }; +/// Whether a request must wait until no step is out in a syscall +/// (`pardes.turn`): what would change a pane such a step still points into. +/// Making a pane and rendering a screen do not -- every yield sits before +/// the mutation of its own step, so the layout and the surface are whole +/// under it -- and a step out there is never waiting on a write of its own, +/// so what parks here is never the syscall's own request. +pub fn needsQuiet(req: Req) bool { + return switch (req.op) { + .write, .setattr => true, + .release => req.remove, + else => false, + }; +} + +/// `needsQuiet`, plus the open that makes a pane: what costs a frame and a +/// wake of the editor. pub fn changesPane(req: Req) bool { return switch (req.op) { .write, .setattr => true, diff --git a/src/panes.zig b/src/panes.zig index f995986b..b3424385 100644 --- a/src/panes.zig +++ b/src/panes.zig @@ -3324,11 +3324,28 @@ pub const Image = struct { /// Construct an image pane from a path and optionally transferred dump bytes. /// `raw` must be image_gpa-owned and ownership transfers only on success. + /// Without them the file is read here, not at the first draw: a draw + /// must not go out into the host (`pardes.turn`), and the path may be a + /// mount this editor serves. A file that cannot be read draws blank. pub fn create(p: *pardes.Pardes, id: usize, path: []const u8, raw: []u8) !*pardes.Pane { + var bytes = raw; + var read_here = false; + if (bytes.len == 0) { + // The slot stays ours across the read: another request may + // make a pane meanwhile. + p.reserved_slots[id] = true; + defer p.reserved_slots[id] = false; + if (filesystem.read(p, path)) |from_disk| { + defer p.gpa.free(from_disk); + bytes = try p.image_gpa.dupe(u8, from_disk); + read_here = true; + } else |_| {} + } + errdefer if (read_here) p.image_gpa.free(bytes); const path_copy = try p.image_gpa.dupe(u8, path); errdefer p.image_gpa.free(path_copy); const pane = try p.newDocPane(id); - pane.image = .{ .path = path_copy, .raw = raw }; + pane.image = .{ .path = path_copy, .raw = bytes }; return pane; } @@ -3427,12 +3444,8 @@ pub const Image = struct { fn ensureDecoded(p: *pardes.Pardes, state: *State) void { if (state.tried) return; state.tried = true; - const bytes: []const u8 = if (state.raw.len > 0) - state.raw - else - filesystem.read(p, state.path) catch &.{}; - defer if (state.raw.len == 0) p.gpa.free(bytes); - if (image.decode(p.image_gpa, bytes)) |decoded| { + if (state.raw.len == 0) return; // nothing was readable at open + if (image.decode(p.image_gpa, state.raw)) |decoded| { state.rgba = decoded.rgba; state.iw = decoded.w; state.ih = decoded.h; @@ -3771,9 +3784,15 @@ pub const Pdf = struct { sections_output: ?SectionsOutput = null, outline_reveal_pending: ?pdf.OutlineInternalDestination = null, + /// Read whole and opened from memory (the bridge copies), never from + /// the file itself: MuPDF reads a file lazily at every page, and the + /// path may be a mount this editor serves, which only a read that + /// gives the turn up can come back from (`filesystem.readFile`). pub fn open(gpa: std.mem.Allocator, path: []const u8, page_one_based: usize) !@This() { const local = filesystem.localPath(path) orelse return error.NonLocalPath; - return initDocument(gpa, path, try Document.open(local), page_one_based); + const bytes = try filesystem.readFile(gpa, local); + defer gpa.free(bytes); + return initDocument(gpa, path, try Document.openBytes(bytes), page_one_based); } pub fn openBytes(gpa: std.mem.Allocator, path: []const u8, bytes: []const u8, page_one_based: usize) !@This() { @@ -5219,6 +5238,10 @@ pub const Pdf = struct { page_one_based: usize, ) !*pardes.Pane { if (comptime !enabled) return error.PdfDisabled; + // The slot stays ours across the read: another request may make a + // pane meanwhile. + core.reserved_slots[id] = true; + defer core.reserved_slots[id] = false; var state = if (filesystem.localPath(path) != null) try State.open(core.pdf_gpa, path, page_one_based) else virtual: { @@ -5903,9 +5926,11 @@ pub const Pdf = struct { null, }, .x = text_x, - .y = core.bodyTop(rect), + // Below the notice chips, like an image: a placed page is + // drawn after the cells and would paint a chip out. + .y = core.bodyTop(rect) + pane.notices.len, .w = text_width, - .h = rect.h -| pardes.BOX_H, + .h = (rect.h -| pardes.BOX_H) -| pane.notices.len, .rgba = placed.rgba, .iw = placed.width, // The texture contains the retained band, not the full page. diff --git a/src/pardes.zig b/src/pardes.zig index 0ac16162..cc57127f 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -39,6 +39,148 @@ pub const font_picker = platform == .gui or platform == .macos; pub const hosted = platform == .tty or platform == .gui or platform == .macos; +/// Whose turn it is with the core. The core is single-threaded: the editor's +/// thread has it, and lets go of it in two kinds of gap -- while it waits for +/// input (`rest`, `wake`), and while it is out in the host filesystem in the +/// middle of a step (`yield`, `back`). A 9P connection task takes the turn +/// in those gaps to answer a request (`take`, `give`), which is what lets the +/// editor read its own tree through a mount: the syscall goes out, another +/// thread answers it, the syscall comes back. A step of a connection task's +/// own -- a Look written to `look` -- goes out the same way. +/// +/// `out` counts the steps that are out. While one is, the core reads +/// consistently but that step still holds pointers into it, so nothing may +/// change it: a request that would is parked in the engine (src/9p_io.zig) +/// and retried when the turn is next given up with nothing out, which +/// `parked` remembers to arrange; and the editor's own wake waits for the +/// count to reach zero, since a step of the editor's may change anything. +/// It is never a write of its own that a step waits on out there -- writes +/// come from a shell performing a save between steps -- so a parked request +/// is never the syscall's own. +/// +/// One per process, like the editor it belongs to. A process that never +/// starts it -- a test, the board, the browser -- has no second thread, and +/// every yield is a no-op. +pub var turn: Turn = .{}; + +pub const Turn = struct { + mutex: std.Io.Mutex = .init, + /// Set by `start`; a process that never starts the turn has none. + io: ?std.Io = null, + /// Steps out in a host syscall, from any thread. + out: u32 = 0, + /// A request that changes a pane was parked for want of quiet. + parked: bool = false, + wake_parked: ?*const fn (?*anyopaque) void = null, + wake_ctx: ?*anyopaque = null, + /// Bumped each time the editor has performed what the core asked of it, + /// so a request that asked for something -- a save, a shell -- can be + /// answered once it is done rather than merely queued, the way writing + /// `put` to acme's ctl returns after the file is written. + epoch: u64 = 0, + /// Bumped each time a shell has attempted the Restore the core asked for + /// (`takeRestore`), which lives after `pump` because it swaps the core + /// out from under it; a request that asked for one waits for this. + restores: u64 = 0, + /// Both of the above, and `out` reaching zero. + settled: std.Io.Condition = .init, + + /// The editor's thread takes the turn for good; it has it until `stop`. + pub fn start(t: *Turn, io: std.Io) void { + t.io = io; + t.mutex.lockUncancelable(io); + } + + pub fn stop(t: *Turn) void { + const io = t.io orelse return; + t.io = null; + t.parked = false; + t.mutex.unlock(io); + } + + /// The editor is about to wait for input: anyone may have the core. + pub fn rest(t: *Turn) void { + if (t.io == null) return; + t.release(); + } + + /// The editor takes the turn back -- once every step that is out in a + /// syscall has returned, since a step of the editor's may change what + /// those still point into. + pub fn wake(t: *Turn) void { + const io = t.io orelse return; + t.mutex.lockUncancelable(io); + while (t.out != 0) t.settled.waitUncancelable(io, &t.mutex); + } + + /// Whoever has the turn is about to block in the host in the middle of + /// a step. Nests: a directory listing that resolves each entry yields + /// inside a yield, and only the outermost one lets go. + pub fn yield(t: *Turn) void { + const io = t.io orelse return; + yield_depth += 1; + if (yield_depth != 1) return; + t.out += 1; + t.mutex.unlock(io); + } + + pub fn back(t: *Turn) void { + const io = t.io orelse return; + yield_depth -= 1; + if (yield_depth != 0) return; + t.mutex.lockUncancelable(io); + t.out -= 1; + if (t.out == 0) t.settled.broadcast(io); + } + + /// How many yields this thread is inside of. + threadlocal var yield_depth: u32 = 0; + + /// A connection task takes the turn; answers whether nothing is out + /// mid-step, which is what a request that changes a pane needs. + pub fn take(t: *Turn) bool { + t.mutex.lockUncancelable(t.io.?); + return t.out == 0; + } + + pub fn give(t: *Turn) void { + t.release(); + } + + /// The editor performed the core's effects. + pub fn settle(t: *Turn) void { + const io = t.io orelse return; + t.epoch +%= 1; + t.settled.broadcast(io); + } + + /// With the turn: waits, turn given up meanwhile, until the editor has + /// performed past `epoch`; stopping ends the wait early. + pub fn awaitSettled(t: *Turn, epoch: u64) void { + while (t.epoch == epoch) t.settled.wait(t.io.?, &t.mutex) catch return; + } + + /// The shell attempted the Restore the core asked for, whichever way it + /// went; called at the top of each loop step, when the previous step's + /// attempt is over. + pub fn restoreSettled(t: *Turn) void { + const io = t.io orelse return; + t.restores +%= 1; + t.settled.broadcast(io); + } + + pub fn awaitRestored(t: *Turn, restores: u64) void { + while (t.restores == restores) t.settled.wait(t.io.?, &t.mutex) catch return; + } + + fn release(t: *Turn) void { + const woken = t.out == 0 and t.parked; + if (woken) t.parked = false; + t.mutex.unlock(t.io.?); + if (woken) if (t.wake_parked) |f| f(t.wake_ctx); + } +}; + pub const can_attach = platform == .tty or platform == .gui; pub const terminal_panes = platform != .esp32p4; @@ -4754,7 +4896,6 @@ pub const Event = union(enum) { /// this must not clamp onto and preview the final grid cell. pointer_leave, tick, - fs_req: ctlfs.Req, }; pub const attach_name_max = 256; @@ -4792,7 +4933,6 @@ pub const Effect = union(enum) { /// Write the build-time theme ring below the per-user config directory. /// The pane receives the completion/error message from the native host. dump_themes: struct { pane: u8 }, - fs_reply: ctlfs.Reply, attach: struct { pane: u8, name: Buf(attach_name_max) }, detach: struct { pane: u8 }, quit, @@ -5910,11 +6050,6 @@ pub const Options = struct { ninep_name: []const u8 = "", ninep_tcp: ?[]const u8 = null, ninep_quic: ?[]const u8 = null, - ninep_identity: struct { - socket_path: []const u8 = "", - tcp_address: ?std.Io.net.IpAddress = null, - quic_address: ?std.Io.net.IpAddress = null, - } = .{}, mounts: []const filesystem.Mount = &.{}, config_dir: ?[]const u8 = null, startup_config_path: ?[]const u8 = null, @@ -6182,11 +6317,7 @@ pub const Pardes = struct { .pdf_gpa = pdf_gpa, .tree_sitter_gpa = tree_sitter_gpa, .opts = opts, - .fs = .{ - .socket_path = opts.ninep_identity.socket_path, - .tcp_address = opts.ninep_identity.tcp_address, - .quic_address = opts.ninep_identity.quic_address, - }, + .fs = .{}, .screen_w = opts.cols, .screen_h = opts.rows, .scratch = .init(gpa), @@ -6197,7 +6328,6 @@ pub const Pardes = struct { p.fs.started = ctlfs.events.now(); for (opts.mounts) |mount| try p.fs.mount(gpa, mount.name, mount.dial); p.opts.mounts = &.{}; - p.opts.ninep_identity = .{}; p.boot = Boot.of(opts); switch (p.boot) { .document => { @@ -6310,13 +6440,31 @@ pub const Pardes = struct { return @intCast(std.math.clamp(panes.File.displayWidth(text) + 2, 1, @as(usize, limit))); } + const Printed = struct { left: u16, dropped: usize }; + /// Prints `text` flush with the right edge of the band, and answers the - /// column it started at so a cursor can follow it. - fn printRight(s: *Surface, x: u16, row: u16, w: u16, text: []const u8, style: CellStyle) u16 { - const shown: u16 = @intCast(@min(@as(usize, w), panes.File.displayWidth(text))); - const left = x + w - shown; - _ = s.print(left, row, shown, text, style); - return left; + /// column it started at so a cursor can follow it. Text wider than the + /// band loses its HEAD: the end is the part that says something -- a + /// path's file name, an error's reason -- and `dropped` is how many + /// columns of it went. + fn printRight(s: *Surface, x: u16, row: u16, w: u16, text: []const u8, style: CellStyle) Printed { + const width = panes.File.displayWidth(text); + if (width <= w) { + const left: u16 = @intCast(x + w - width); + _ = s.print(left, row, @intCast(width), text, style); + return .{ .left = left, .dropped = 0 }; + } + // Whole glyphs only: a cut inside a wide one would leave the rest a + // column too wide and clip its LAST glyph instead of the first. + var dropped = width - w; + var start = panes.File.rawAtDisplay(text, dropped); + if (panes.File.rawDisplayCol(text, start) < dropped) { + dropped += 1; + start = panes.File.rawAtDisplay(text, dropped); + } + const left: u16 = @intCast(x + w - (width - dropped)); + _ = s.print(left, row, @intCast(width - dropped), text[start..], style); + return .{ .left = left, .dropped = dropped }; } /// The layout every single-pane boot starts from. @@ -6904,8 +7052,14 @@ pub const Pardes = struct { fn showMessage(p: *Pardes, id: usize, text: []const u8) void { if (id >= MAX_PANES) return; const pane = p.panes[id] orelse return; - pane.msg_len = @intCast(@min(text.len, pane.msg.len)); - @memcpy(pane.msg[0..pane.msg_len], text[0..pane.msg_len]); + // One row of printable text: a language server's multi-line report + // reads as one line, and the cut never leaves half a glyph behind. + var n: usize = @min(text.len, pane.msg.len); + if (n < text.len) { + while (n > 0 and text[n] & 0xC0 == 0x80) n -= 1; + } + for (text[0..n], pane.msg[0..n]) |c, *cell| cell.* = if (c < 0x20 or c == 0x7f) ' ' else c; + pane.msg_len = @intCast(n); } fn logMessage(p: *Pardes, id: usize, text: []const u8) void { @@ -7040,7 +7194,7 @@ pub const Pardes = struct { pub fn postEvent(p: *Pardes, ev: Event) void { switch (ev) { .key => |k| std.debug.assert(k.text.len == 0), - .output, .paste, .lsp_resp, .pipe_resp, .file_changed, .command, .fs_req => unreachable, + .output, .paste, .lsp_resp, .pipe_resp, .file_changed, .command => unreachable, else => {}, } if (p.in_len == p.in_q.len) return; @@ -7173,7 +7327,6 @@ pub const Pardes = struct { }, .theme_file => |t| if (v.watch_theme) |f| f(p.host.ctx, t.generation, t.on), .dump_themes => |d| if (v.dump_themes) |f| f(p.host.ctx, d.pane), - .fs_reply => {}, .attach => |a| { const name = a.name.slice(); @memcpy(p.attach_buf[0..name.len], name); @@ -7194,6 +7347,7 @@ pub const Pardes = struct { if (v.wait_input) |f| f(h.ctx, if (p.animationActive()) layout.Animation.frame_ms else 0); while (p.nextQueued()) |ev| p.update(ev); while (p.nextEffect()) |e| p.perform(e); + turn.settle(); // A quitting frame has already freed what it would draw. if (p.quit) return; if (v.poll_frame) |f| f(h.ctx); @@ -7208,24 +7362,35 @@ pub const Pardes = struct { p.needs_frame = false; } + /// One request of the control filesystem, from whichever thread has the + /// turn (`pardes.turn`). Not an event: it neither sweeps nor resets + /// anything the editor's own step may be in the middle of using, so it + /// can be answered while that step is out in a syscall. Only a request + /// that changes a pane costs a frame, which is why a round trip on a + /// local socket costs microseconds and not a vsync. + pub fn serveFs(p: *Pardes, req: ctlfs.Req) ctlfs.Reply { + if (!ctlfs.changesPane(req)) return ctlfs.handle(p, req); + p.needs_frame = true; + p.raw_hover_intent = false; + p.cancelLookHover(); + const reply = ctlfs.handle(p, req); + // The request was a whole step of its own, so it settles the way a + // step does: the cursor and scroll reconciled, the scripted panes + // told, and the panes it made announced to /log now rather than at + // the end of whatever the editor does next. + p.sync(); + p.fsReport(); + ctlfs.events.announce(p); + return reply; + } + pub fn update(p: *Pardes, ev: Event) void { - // Only two events cannot change the screen: a tick with nothing - // animating, and a filesystem request that only reads. The second is - // what 9P traffic overwhelmingly is, and answering it used to drag a - // whole vsync-blocked frame behind it -- which is why a round trip on - // a local socket cost a frame instead of a few microseconds. - p.needs_frame = p.needs_frame or switch (ev) { - .tick => false, - .fs_req => |req| ctlfs.changesPane(req), - else => true, - }; + // A tick with nothing animating is the one event that cannot change + // the screen. + p.needs_frame = p.needs_frame or ev != .tick; p.shell_rows.sweep(p.gpa); switch (ev) { .tick => {}, - .fs_req => |req| if (ctlfs.changesPane(req)) { - p.raw_hover_intent = false; - p.cancelLookHover(); - }, .mouse => |m| if (!(m.button == .none and m.kind == .motion)) { p.raw_hover_intent = false; p.cancelLookHover(); @@ -7324,7 +7489,6 @@ pub const Pardes = struct { }, .paste => |bytes| p.applyPaste(bytes), .command => |line| _ = p.executeBuiltinLine(p.active, line), - .fs_req => |r| p.emit(.{ .fs_reply = ctlfs.handle(p, r) }), .pinch => |scale| p.ov_pinch_scale = scale, .touch_scroll => |delta| p.ov_touch_scroll_delta = delta, .pointer_leave => { @@ -12915,11 +13079,7 @@ pub const Pardes = struct { .pdf_gpa = pdf_gpa, .tree_sitter_gpa = tree_sitter_gpa, .opts = opts, - .fs = .{ - .socket_path = opts.ninep_identity.socket_path, - .tcp_address = opts.ninep_identity.tcp_address, - .quic_address = opts.ninep_identity.quic_address, - }, + .fs = .{}, .screen_w = opts.cols, .screen_h = opts.rows, .scratch = .init(gpa), @@ -12934,13 +13094,9 @@ pub const Pardes = struct { p.cell_pixels = old.cell_pixels; p.row_metrics = old.row_metrics; p.native_images = old.native_images; - p.fs.socket_path = old.fs.socket_path; - p.fs.tcp_address = old.fs.tcp_address; - p.fs.quic_address = old.fs.quic_address; } for (opts.mounts) |mount| try p.fs.mount(gpa, mount.name, mount.dial); p.opts.mounts = &.{}; - p.opts.ninep_identity = .{}; var parsed = try dump.readZon(gpa, zon_bytes, "load"); defer parsed.deinit(); const st = parsed.value; @@ -13521,16 +13677,19 @@ pub const Pardes = struct { // right would put it past the pane, off the grid, and past what // the detached wire will encode -- which drops every frame for // as long as the prompt is up. - const left = printRight(s, cx, row, chip -| 1, text, msg_style); + const printed = printRight(s, cx, row, chip -| 1, text, msg_style); if (kind != .prompt or id != p.active) continue; const at = pane.promptAt() orelse continue; const prompt0 = (p.tagPrefix(pane) catch continue).len + at; const col = @as(usize, pane.tag_col); if (col < prompt0) continue; - // The cursor follows the text to wherever it landed. + // The cursor follows the text to wherever it landed; a caret + // in the part a narrow band dropped has nowhere to be. const prompt_col = panes.File.displayWidth(text[0..@min(col - prompt0, text.len)]); - if (left + prompt_col < tx + tw) - s.cursor = .{ .x = left + @as(u16, @intCast(prompt_col)), .y = row, .bar = pane.mode == .insert }; + if (prompt_col < printed.dropped) continue; + const caret = printed.left + (prompt_col - printed.dropped); + if (caret < tx + tw) + s.cursor = .{ .x = @intCast(caret), .y = row, .bar = pane.mode == .insert }; } } @@ -14018,12 +14177,19 @@ pub const Pardes = struct { const chip = r.x + r.w - cx; // Right aligned inside the chip, a blank cell short of its // edge: the same one the grid pass leaves for a prompt caret. + // Wider than the chip, the text loses its head, as on the grid. const room = p.tagCapacity(chip) -| 1; const shown = panes.File.displayWidth(text); - const pad = room -| shown; - const line = try arena.alloc(u8, pad + text.len); + var kept = text; + if (shown > room) { + var start = panes.File.rawAtDisplay(text, shown - room); + if (panes.File.rawDisplayCol(text, start) < shown - room) start = panes.File.rawAtDisplay(text, shown - room + 1); + kept = text[start..]; + } + const pad = room -| panes.File.displayWidth(kept); + const line = try arena.alloc(u8, pad + kept.len); @memset(line[0..pad], ' '); - @memcpy(line[pad..], text); + @memcpy(line[pad..], kept); try p.renderHeaderLayer(arena, NOTICE_LAYER_BASE + id * Pane.Notices.max + i, .notice, @intCast(id), .{ .x = cx, .y = first + @as(u16, @intCast(i)), @@ -14221,8 +14387,12 @@ pub const Pardes = struct { if (pane.hasPdf() and panes.Pdf.draw(p, pane, r, id, tx, tw)) return; if (pane.image) |*iv| { - const image_h = r.h -| BOX_H; - panes.Image.draw(p, iv, @intCast(id), pane.serial, tx, body_y, tw, image_h); + // Below the notice chips: a picture is drawn after the cells (the + // GUI's image pass, kitty's z-order), so a chip over it would be + // painted out. Text gets the overlay; a picture gives up the rows. + const shown = pane.notices.len; + const image_h = (r.h -| BOX_H) -| shown; + panes.Image.draw(p, iv, @intCast(id), pane.serial, tx, body_y + shown, tw, image_h); // thumbless, but the same one column as the real scrollbar below — // that is the whole point of drawing it, and like that one it runs // past the notice bands so the gutter has no notch in it diff --git a/src/tty/tty.zig b/src/tty/tty.zig index 23b7c09b..03ccd3e2 100644 --- a/src/tty/tty.zig +++ b/src/tty/tty.zig @@ -727,6 +727,7 @@ fn localSession( if (sh.inotify_fd >= 0) sh.watch_task = io.concurrent(watchFiles, .{ io, sh.inotify_fd, loop }) catch null; frames: while (!core.quit) { + pardes.turn.restoreSettled(); try core.pump(host); if (core.takeRestore()) |rp| blk: { const bytes = filesystem.readRestore(gpa, rp) catch |err| { @@ -760,7 +761,7 @@ fn localSession( _ = file_watch.applyThemeEffect(core, gpa, sh.inotify_fd, &sh.watches, 0, false, false); clearNativeImages(kitty_handles, vx, tty); nc.native_images = vx.caps.kitty_graphics; - if (fs) |f| f.reset(core); + if (fs) |f| f.reset(nc); core.deinit(); core = nc; sh.core = nc; @@ -871,15 +872,21 @@ const Shell = struct { fn waitInput(ctx: ?*anyopaque, timeout_ms: u32) void { const s = of(ctx); var batch: usize = 0; + // The wait is the 9P connections' turn with the core. if (timeout_ms == 0) { + pardes.turn.rest(); const first = s.loop.nextEvent() catch { + pardes.turn.wake(); s.core.quit = true; return s.reloadWatched(); }; + pardes.turn.wake(); batch = 1; if (s.apply(first)) return s.reloadWatched(); } else { + pardes.turn.rest(); std.Io.sleep(s.io, .fromMilliseconds(timeout_ms), .awake) catch {}; + pardes.turn.wake(); _ = s.apply(.tick); batch = 1; } @@ -994,7 +1001,7 @@ const Shell = struct { fn pollFrame(ctx: ?*anyopaque) void { const s = of(ctx); - if (s.fs) |f| if (f.tick(s.core).pending) { + if (s.fs) |f| if (f.tick().pending) { _ = s.loop.tryPostEvent(.fs_ready) catch {}; }; for (&s.ptys, 0..) |*slot, id| if (slot.*) |pt| { diff --git a/test/fs_namespace.zig b/test/fs_namespace.zig index 3eba6639..ec94b509 100644 --- a/test/fs_namespace.zig +++ b/test/fs_namespace.zig @@ -98,9 +98,6 @@ test "transactional restore preserves host capabilities and advances pane identi try std.testing.expect(restored.paneBySerial(pane.serial) == null); try std.testing.expectEqual(p.screen_w, restored.screen_w); try std.testing.expectEqual(p.screen_h, restored.screen_h); - try std.testing.expectEqualStrings(p.fs.socket_path, restored.fs.socket_path); - try std.testing.expectEqualDeep(p.fs.tcp_address, restored.fs.tcp_address); - try std.testing.expectEqualDeep(p.fs.quic_address, restored.fs.quic_address); try std.testing.expect(p.panes[0] == pane); try std.testing.expectEqualStrings("before\n", pane.file.?.content); try std.testing.expectError(error.BadDumpMagic, p.restore( @@ -112,27 +109,6 @@ test "transactional restore preserves host capabilities and advances pane identi try std.testing.expectEqualStrings("/tmp/session.sock", p.fs.socket_path); } -test "same-session identity is available before an initial mounted file is opened" { - if (!filesystem.platform_has_fs) return error.SkipZigTest; - const gpa = std.testing.allocator; - var tmp = std.testing.tmpDir(.{}); - defer tmp.cleanup(); - try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "file.txt", .data = "no socket required\n" }); - var buf: [4096]u8 = undefined; - const len = try tmp.dir.realPathFile(std.testing.io, "file.txt", &buf); - const path = try std.fmt.allocPrint(gpa, "/n/own/os{s}", .{buf[0..len]}); - defer gpa.free(path); - const p = try pardes.Pardes.init(gpa, .{ - .file = path, - .mounts = &.{.{ .name = "own", .dial = "/tmp/not-listening.sock" }}, - .ninep_identity = .{ .socket_path = "/tmp/not-listening.sock" }, - }); - defer p.deinit(); - try std.testing.expectEqualStrings(path, p.panes[0].?.file.?.path); - try std.testing.expectEqualStrings("no socket required\n", p.panes[0].?.file.?.content); - try std.testing.expectEqualStrings("", p.opts.ninep_identity.socket_path); -} - test "filesystem resolves OS first then virtual with explicit mounts and parent paths" { if (!filesystem.platform_has_fs) return error.SkipZigTest; const gpa = std.testing.allocator; diff --git a/test/selfmount.py b/test/selfmount.py new file mode 100644 index 00000000..cc889a93 --- /dev/null +++ b/test/selfmount.py @@ -0,0 +1,126 @@ +#!/usr/bin/env python3 +"""A session that opens, reads and saves its own 9P tree through a mount. + +The editor runs under `9ns --mntgen`, so /mnt/9p/pardes/ inside its +namespace is its own tree, and is driven over its socket from outside. This +used to hang the editor outright: the realpath, the stat and the read went +out through the mount and came back as 9P requests only the editor's loop +could answer, while that loop was blocked making them. Now the connection's +task answers them while the editor waits (pardes.turn). + +Needs 9ns (cloud9) on PATH or in ~/.local/bin, and a runtime directory; it +skips, loudly, without them. +""" +import fcntl +import os +from pathlib import Path +import pty +import shutil +import signal +import struct +import sys +import termios +import time + +sys.path.insert(0, str(Path(__file__).resolve().parent)) +from ninep import Client + + +def run(binary): + ns = shutil.which('9ns') or str(Path.home() / '.local/bin/9ns') + runtime = os.environ.get('XDG_RUNTIME_DIR') + if not os.path.exists(ns) or not runtime: + print('selfmount: skipped (needs 9ns and XDG_RUNTIME_DIR)') + return 0 + name = 'selfmount%d' % os.getpid() + sock = f'{runtime}/pardes-9p-{name}.sock' + fixture = Path(f'/tmp/{name}.txt') + fixture.write_bytes(b'initial\n') + env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_')} + env.update(PARDES_NOTIME='1', TERM='xterm-256color', PARDES_DUMP=f'/tmp/{name}.dump.zon') + for language in ['RS', 'C', 'GO', 'TS', 'PY']: + env['PARDES_LSP_' + language] = '' + pid, master = pty.fork() + if pid == 0: + os.execve(ns, ['9ns', '--mntgen', '--', binary, '--tty', '--9p=' + name, str(fixture)], env) + fcntl.ioctl(master, termios.TIOCSWINSZ, struct.pack('HHHH', 30, 100, 0, 0)) + os.set_blocking(master, False) + tail = bytearray() + + def drain(): + try: + while True: + chunk = os.read(master, 65536) + if not chunk: + return + tail.extend(chunk[-2000:]) + except OSError: + pass + + failures = [] + + def check(condition, what): + print(('ok ' if condition else 'FAIL ') + what) + if not condition: + failures.append(what) + + try: + deadline = time.monotonic() + 15 + while not os.path.exists(sock): + drain() + if time.monotonic() > deadline: + raise TimeoutError('socket never appeared: ' + tail.decode(errors='replace')[-400:]) + time.sleep(.02) + time.sleep(.3) + mount = f'/mnt/9p/pardes/{name}' + with Client(sock) as client: + index = client.read('/index').decode() + rows = [row.split(maxsplit=3) for row in index.splitlines()] + first = rows[0][0] + # A Look at the tree's own index: realpath, stat and read all go + # out through 9ns and back in, and the write returns when the + # pane is open. + started = time.monotonic() + client.write('/look', (mount + '/index\n').encode()) + took = time.monotonic() - started + check(took < 5, f'look at the mounted index returned ({took:.2f}s)') + rows = [row.split(maxsplit=3) for row in client.read('/index').decode().splitlines()] + opened = [row for row in rows if len(row) == 4 and row[3] == mount + '/index'] + check(len(opened) == 1, 'a pane opened on the mounted index') + if opened: + body = client.read(f'/pane/{opened[0][0]}/body').decode() + check(body.startswith(index.splitlines()[0]), 'its body is the index as served') + # A Look at pane 1's body through the mount, an edit of the copy, + # and a Save: the save writes back through the mount into pane 1, + # and the exec returns once it has. + client.write('/look', f'{mount}/pane/{first}/body\n'.encode()) + rows = [row.split(maxsplit=3) for row in client.read('/index').decode().splitlines()] + mirror = [row for row in rows if len(row) == 4 and row[3] == f'{mount}/pane/{first}/body'] + check(len(mirror) == 1, 'a pane opened on the mounted body') + if mirror: + pane = mirror[0][0] + client.write(f'/pane/{pane}/addr', b'#0,#0') + client.write(f'/pane/{pane}/data', b'HELLO ') + client.write(f'/pane/{pane}/exec', b'Save\n') + check(client.read(f'/pane/{first}/body') == b'HELLO initial\n', f'Save wrote back through the mount into pane {first}') + text = ''.join(cell[0] for cell in client.screen()['cells']) + check('saved ' + mount in text, 'the editor reported the save') + client.write('/exec', b'Msg still here\n') + text = ''.join(cell[0] for cell in client.screen()['cells']) + check('still here' in text, 'the editor answers after all of that') + finally: + os.kill(pid, signal.SIGTERM) + time.sleep(.2) + try: + os.kill(pid, signal.SIGKILL) + except ProcessLookupError: + pass + os.waitpid(pid, 0) + for path in (fixture, Path(f'/tmp/{name}.dump.zon')): + path.unlink(missing_ok=True) + print('selfmount: ' + ('ok' if not failures else f'{len(failures)} failed')) + return 0 if not failures else 1 + + +if __name__ == '__main__': + sys.exit(run(str(Path(sys.argv[1]).resolve()))) diff --git a/test/snapshots/images.golden b/test/snapshots/images.golden index a1b78556..74b5f873 100644 --- a/test/snapshots/images.golden +++ b/test/snapshots/images.golden @@ -54,29 +54,29 @@ == style term-palette grid=150x31 |3: 0-0 d,#608269, 1-1 d,#0d1410, 2-74 #e5eee5,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, |6: 0-1 #000000,#add38a, 2-2 d,#26362d, 3-72 #becfc4,#26362d, 73-74 #dfbce5,#26362d, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|7: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 p8,p5, 29-30 p8,p4, 31-31 p4,p8, 32-35 p8,p4, 36-37 p4,p8, 38-39 p8,p4, 40-40 p4,p8, 41-42 p8,p4, 43-43 p4,p8, 44-46 p8,p4, 47-47 p12,p8, 48-65 d,#0d1410, 66-66 d,#1d2824, 67-73 #b2c3b8,#1d2824, 74-74 d,#1d2824, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|8: 0-0 d,#152019, 1-27 d,#0d1410, 28-30 p8,p4, 31-33 p4,p8, 34-34 p8,p4, 35-36 p4,p8, 37-37 p8,p4, 38-41 p4,p8, 42-42 p8,p4, 43-43 p4,p8, 44-44 p8,p12, 45-46 p12,p8, 47-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|9: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 p8,p4, 29-29 p4,p8, 30-30 p8,p4, 31-31 p4,p8, 32-32 p8,p4, 33-33 p4,p8, 34-35 p8,p4, 36-37 p4,p8, 38-38 p8,p5, 39-41 p8,p4, 42-42 p4,p8, 43-44 p12,p8, 45-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|10: 0-0 d,#152019, 1-27 d,#0d1410, 28-29 p8,p4, 30-34 p4,p8, 35-36 p8,p4, 37-38 p4,p8, 39-39 p8,p4, 40-40 p4,p8, 41-41 p12,p8, 42-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|11: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 p4,p8, 29-29 p8,p4, 30-31 p4,p8, 32-32 p8,p4, 33-33 p4,p8, 34-34 p8,p4, 35-36 p4,p8, 37-37 p8,p4, 38-38 p8,p12, 39-39 p12,p8, 40-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|12: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 p8,p4, 29-31 p4,p8, 32-35 p8,p4, 36-36 p4,p8, 37-37 p12,p8, 38-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|13: 0-0 d,#152019, 1-27 d,#0d1410, 28-32 p8,p4, 33-33 p4,p8, 34-34 p8,p12, 35-36 p12,p8, 37-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|14: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 p8,p4, 29-29 p4,p8, 30-30 p8,p4, 31-32 p4,p8, 33-33 p12,p8, 34-34 p8,p12, 35-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|15: 0-0 d,#152019, 1-27 d,#0d1410, 28-29 p4,p8, 30-30 p8,p12, 31-32 p12,p8, 33-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, -|16: 0-0 d,#152019, 1-27 d,#0d1410, 28-28 p8,p12, 29-29 p12,p8, 30-47 p12,p12, 48-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|7: 0-0 d,#152019, 1-65 d,#0d1410, 66-66 d,#1d2824, 67-73 #b2c3b8,#1d2824, 74-74 d,#1d2824, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|8: 0-0 d,#152019, 1-28 d,#0d1410, 29-31 p8,p4, 32-33 p4,p8, 34-37 p8,p4, 38-38 p4,p8, 39-44 p8,p4, 45-45 p8,p12, 46-46 p12,p8, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|9: 0-0 d,#152019, 1-28 d,#0d1410, 29-29 p8,p4, 30-30 p4,p8, 31-35 p8,p4, 36-36 p5,p8, 37-37 p8,p4, 38-38 p4,p8, 39-41 p8,p4, 42-42 p4,p8, 43-43 p8,p12, 44-45 p12,p8, 46-46 p12,p12, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|10: 0-0 d,#152019, 1-28 d,#0d1410, 29-30 p8,p4, 31-32 p4,p8, 33-40 p8,p4, 41-41 p8,p12, 42-43 p12,p8, 44-46 p12,p12, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|11: 0-0 d,#152019, 1-28 d,#0d1410, 29-31 p8,p4, 32-32 p4,p8, 33-34 p8,p4, 35-37 p4,p8, 38-38 p8,p4, 39-39 p8,p12, 40-41 p12,p8, 42-46 p12,p12, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|12: 0-0 d,#152019, 1-28 d,#0d1410, 29-36 p8,p4, 37-37 p8,p12, 38-39 p12,p8, 40-46 p12,p12, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|13: 0-0 d,#152019, 1-28 d,#0d1410, 29-30 p4,p8, 31-34 p8,p4, 35-35 p8,p12, 36-36 p12,p8, 37-46 p12,p12, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|14: 0-0 d,#152019, 1-28 d,#0d1410, 29-29 p4,p8, 30-31 p8,p4, 32-32 p4,p8, 33-33 p8,p12, 34-35 p12,p8, 36-46 p12,p12, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|15: 0-0 d,#152019, 1-28 d,#0d1410, 29-29 p4,p8, 30-30 p8,p4, 31-31 p8,p12, 32-32 p12,p8, 33-46 p12,p12, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, +|16: 0-0 d,#152019, 1-28 d,#0d1410, 29-29 p8,p12, 30-30 p12,p8, 31-46 p12,p12, 47-74 d,#0d1410, 75-75 d,#608269, 76-76 d,#0d1410, 77-149 #e5eee5,#0d1410, == snap no-ascii grid=150x31 cursor=11,8 |3: ls ls |6: img petscii:off palette:terminal ascii:off /tmp/pardes-snap/images/cwd/p -|7: ███╱█🬻██🬺██🬻███╱██🬴▄ Ascii -|8: 🬬██╱███╱🬻🬝🬻🬬████🬝🬵█ -|9: █╲█🬴████╲╱█🬝██▟▄█ -|10: ██╲╱╲█🬝█████╱🬵 -|11: ╱█████████🬝▄ -|12: █│█████🬝🬝🬹 -|13: ██████🬝▄█ -|14: 🬜🬬██🬸▄╲ -|15: 🬺█🬝🬵█ -|16: 🬝▄ +|7: Ascii +|8: █🬝█╲███▙🬸🬬🬻█████🬝🬵 +|9: ███████🬻██🬸█🬝█🬝▄█ +|10: ████████████🬝▄█ +|11: ███🬸██████🬝▄█ +|12: ████████🬝🬵█ +|13: ╱█████🬝▄ +|14: █🬬█╲🬝🬵█ +|15: 🬺█🬝🬵 +|16: 🬝▄ == snap tag-edit grid=400x31 cursor=87,6 |Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Kill | New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol diff --git a/test/snapshots/msg.golden b/test/snapshots/msg.golden index 653e9772..1d5b4cc2 100644 --- a/test/snapshots/msg.golden +++ b/test/snapshots/msg.golden @@ -48,3 +48,7 @@ |2: /tmp/pardes-snap/msg/cwd/a.txt * Save Tty Collapse Del |3: 1 AGAIN hand-written report |5: 3 Msg hand-written report +== snap msgtail grid=70x17 cursor=32,7 +|3: 6789 0123456789 0123456789 0123456789 0123456789 0123456789 THE-END +|6: 4 Msg 0123456789 0123456789 0123456789 0123456789 0123456789 012↩ +|7: 3456789 0123456789 THE-END diff --git a/test/snapshots/msg.snap b/test/snapshots/msg.snap index c8a0a265..5252508a 100644 --- a/test/snapshots/msg.snap +++ b/test/snapshots/msg.snap @@ -89,3 +89,15 @@ key x key tab stable 700 15000 snap msgbuiltin +# A message wider than the pane keeps its TAIL, not its head: the end of a +# message is the part that says something -- a path's file name, an error's +# reason -- so the head is what a narrow pane goes without. +key j +key o +text Msg 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 THE-END +key esc +settle 100 +key x +key tab +stable 700 15000 +snap msgtail diff --git a/test/snapshots/tagbottomimage.golden b/test/snapshots/tagbottomimage.golden index e7100114..0136e1a0 100644 --- a/test/snapshots/tagbottomimage.golden +++ b/test/snapshots/tagbottomimage.golden @@ -35,30 +35,30 @@ |3: pic.ppm |4: |5: /tmp/pardes-snap/tagbottomimage/cwd Tty Save Mode Filter Collapse Del -|6: 4*🬹~F~N🬰|G🬏▚Y~KF🬴s>T&zZ/🬻iTY=`S~╳bkZR37v🬦🬵d4QHZ8X▛▟ -|8: ^🬪🬛$}DrydNU&wsz=`*r🬒🬓🬳🬟*Y🬴G6🬧f🬮/>t🬧u🬲1Rg1t🬝🬻█ -|9: ▖#_{🬗X@🬢&$s'C%*=w@🬆▀wq%🬡d┼a┼m─>🬭🬜A▀A🬲H]p🬝🬹 -|10: %?WX🬕f🬩*TA8n╱┼E▘🬭Y#qo~XVE▐(╳▀H4^[mj🬗=🬒🬕▟█ -|11: ]Z🬷eb~Oyl3=SL▙a🬱🬉~MPMz}FMu<🬝▚>3&▖🬷WS🬝~█ -|12: EF-🬑y🬔!r🬙🬐╳O🬩▐%Qj─4za/?/\a🬜"🬖🬈🬛🬟A🬙🬝▄ -|13: 🬃N@xzOnczIK=t0@🬖j5🬮🬧65▟{🬮🬉🬄🬩zQ9/🬝🬻 -|14: ╲${&%@"#ctt▀Cr5F;🬐ARM╱uej╳75🬹9▛🬻 -|15: h^🬜"🬈🬨▜╲|W🬊🬦k6^🬰🬶rZ─▄\z9🬎🬉4^🬎🬻 -|16: 🬆f│Q_V🬗wGx🬱=5▛5*&V🬟🬄ZrXGz2🬝🬻█ -|17: !🬷W🬐(🬭]7x_>▗er🬯~▚di🬬4jY:🬝▟ -|18: gU~🬧3▙bjr\C#kKMpffAjps🬝🬻 -|19: *🬯G"🬣▟d🬮▀zJ🬪EHV▟╳9}y▛▄ -|20: ``))~RyJ🬴jA~w=hLpX🬝🬻█ -|21: 4x▀J"TG7=y-QZ🬙╲~▛🬻 -|22: 🬯/+╳f9ZG🬕+{QN_🬝🬹 -|23: E<'─🬫pS!"n4&🬝~ -|24: m$dx"!2🬳&{🬝🬻 -|25: *8f🬩▙Jb🬒🬝🬻█ -|26: m🬩7CiN🬎🬹 -|27: pG╲L🬝🬻 -|28: 🬡L🬝▄ -|29: 🬝~ +|6: Tagbottom +|7: {DbgY🬲s▜M^#▐FUJ[zNq=🬝g/y╱?V@🬱🬙▌UK╱🬍("🬕KJ8hSo🬝🬻 +|8: tX🬆s>🬌`🬵 Date: Mon, 28 Sep 2026 10:33:40 -0300 Subject: A terminal pane that closes takes its shell and pty with it, in every front end The detached server closed a pane's pty only when the shell was respawned, hit EOF or the session shut down, so rmdir, Del or Delcol on a terminal left its shell running with nobody to read it; the tty front end and macOS did the same. Retiring a terminal pane now emits a close_pty effect, which each host that runs shells answers by hanging the pty up and ending the shell (the detached server's and the GUI's existing retire-and-reap path, and a close plus SIGHUP in the tty and macOS shells). Co-Authored-By: Claude Opus 5.5 --- src/detached/server.zig | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/gui/gui.zig | 5 +++++ src/host_io.zig | 1 + src/macos.zig | 10 ++++++++++ src/ninep/pty.zig | 12 ++++++++++++ src/ninep/testing.zig | 2 ++ src/pardes.zig | 5 +++++ src/tty/tty.zig | 15 +++++++++++++++ 8 files changed, 94 insertions(+) (limited to 'src/ninep/testing.zig') diff --git a/src/detached/server.zig b/src/detached/server.zig index a3694c57..0cf1729f 100644 --- a/src/detached/server.zig +++ b/src/detached/server.zig @@ -351,6 +351,7 @@ pub const Session = struct { .pty_write = ptyWrite, .pty_resize = ptyResize, .pty_signal = ptySignal, + .close_pty = closePaneShell, .tty_taken = ttyTaken, .write_file = writeFile, .write_dump = writeDump, @@ -606,6 +607,11 @@ pub const Session = struct { } } + fn closePaneShell(ctx: ?*anyopaque, pane: u8) void { + const s = of(ctx); + if (pane < s.ptys.len) s.closePty(pane); + } + fn closePty(s: *Session, pane: u8) void { const pt = &s.ptys[pane]; if (pt.fd < 0) return; @@ -1229,6 +1235,44 @@ test "detached queued results preserve current requests and are discarded before try std.testing.expect(s.core.lsp_wait == null); } +test "a detached session's terminal pane takes its shell with it when it closes" { + const gpa = std.testing.allocator; + var s: Session = .{ + .gpa = gpa, + .worker_gpa = gpa, + .io = std.testing.io, + .core = try pardes.Pardes.init(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 }), + .cols = 40, + .rows = 12, + }; + defer s.core.deinit(); + defer s.deinit(); + // A stand-in shell: it waits for a signal, and a hangup ends it. + const pid = libc.fork(); + if (pid == 0) while (true) { + _ = libc.poll(&[0]libc.pollfd{}, 0, -1); + }; + try std.testing.expect(pid > 0); + var fds: [2]c_int = undefined; + try std.testing.expectEqual(@as(c_int, 0), libc.pipe(&fds)); + defer _ = libc.close(fds[1]); + s.ptys[3] = .{ .fd = fds[0], .pid = pid }; + const host = s.host(); + host.vtable.close_pty.?(host.ctx, 3); + try std.testing.expect(s.ptys[3].fd < 0); + const deadline = monotonicMs() + 2000; + while (monotonicMs() < deadline) { + s.harvest(); + const running = s.ptys[3].pid != 0 or for (s.retired_shells) |shell| { + if (shell.pid == pid) break true; + } else false; + if (!running) break; + _ = libc.poll(&[0]libc.pollfd{}, 0, 5); + } + try std.testing.expect(s.ptys[3].pid == 0); + for (s.retired_shells) |shell| try std.testing.expect(shell.pid != pid); +} + test "detached worker setup failure completes requests without changing document bytes" { const gpa = std.testing.allocator; var failing = std.testing.FailingAllocator.init(gpa, .{ .fail_index = 0 }); diff --git a/src/gui/gui.zig b/src/gui/gui.zig index 415b21e8..1d5d3c05 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -3756,6 +3756,10 @@ const Shell = struct { }; } + fn closePaneShell(ctx: ?*anyopaque, pane: u8) void { + shellOf(ctx).closePty(pane); + } + fn closePty(s: *Shell, pane: u8) void { const pt = if (s.ptys[pane]) |*pt| pt else return; if (pt.fd < 0) return; @@ -3831,6 +3835,7 @@ const Shell = struct { .pty_write = ptyWrite, .pty_resize = ptyResize, .pty_signal = ptySignal, + .close_pty = closePaneShell, .tty_taken = ttyTaken, .write_file = writeFile, .write_dump = writeDump, diff --git a/src/host_io.zig b/src/host_io.zig index 959ce3bd..a5efc7d1 100644 --- a/src/host_io.zig +++ b/src/host_io.zig @@ -20,6 +20,7 @@ pub const Host = struct { pty_write: ?*const fn (ctx: ?*anyopaque, pane: u8, bytes: []const u8) void = null, pty_resize: ?*const fn (ctx: ?*anyopaque, pane: u8, cols: u16, rows: u16) void = null, pty_signal: ?*const fn (ctx: ?*anyopaque, pane: u8, sig: pardes.PtySignal) void = null, + close_pty: ?*const fn (ctx: ?*anyopaque, pane: u8) void = null, tty_taken: ?*const fn (ctx: ?*anyopaque, pane: u8) bool = null, gpio_toggle: ?*const fn (ctx: ?*anyopaque, pin: u16, was: *u8, now: *u8) bool = null, write_file: ?*const fn (ctx: ?*anyopaque, pane: u8, path: []const u8, bytes: []const u8) void = null, diff --git a/src/macos.zig b/src/macos.zig index c9c83a2d..a0abc119 100644 --- a/src/macos.zig +++ b/src/macos.zig @@ -2310,6 +2310,7 @@ const vtable: pardes.Host.VTable = .{ .pty_write = ptyWrite, .pty_resize = ptyResize, .pty_signal = ptySignal, + .close_pty = closePty, .tty_taken = ttyTaken, .write_file = writeFile, .write_dump = writeDump, @@ -2501,6 +2502,15 @@ fn startReader(st: *State, pt: *Pty, id: u8) void { }; } +/// The pane is gone: its shell goes with it. +fn closePty(ctx: ?*anyopaque, pane: u8) void { + const st = hostState(ctx); + const pt = st.ptys[pane] orelse return; + _ = libc.kill(pt.pid, posix.SIG.HUP); + reap(st, pane); + st.gens[pane] +%= 1; +} + fn reap(st: *State, pane: u8) void { var pt = st.ptys[pane] orelse return; st.ptys[pane] = null; diff --git a/src/ninep/pty.zig b/src/ninep/pty.zig index eda6e9d0..f788b4f8 100644 --- a/src/ninep/pty.zig +++ b/src/ninep/pty.zig @@ -806,6 +806,18 @@ test "a run's answer says cut when its output's start is gone, and reads a bound try testing.expectEqualStrings("error out of memory\n", sh.answered(p, node, h, into)); } +test "closing a terminal pane asks its shell to hang up the pty" { + const p = try withTerm(testing.allocator); + defer p.deinit(); + _ = try th.newPane(p); + const closed = th.rmdir(p, Node.of(serialOf(p), .dir)); + try testing.expectEqual(Status.ok, closed.reply.status); + try testing.expect(closed.closed); + // A text pane has no shell to end. + const text = try th.newPane(p); + try testing.expect(!th.rmdir(p, Node.of(text, .dir)).closed); +} + test "the pty queue drops the oldest at its cap" { const gpa = testing.allocator; const p = try withTerm(gpa); diff --git a/src/ninep/testing.zig b/src/ninep/testing.zig index 6ea40956..fce77f10 100644 --- a/src/ninep/testing.zig +++ b/src/ninep/testing.zig @@ -19,6 +19,7 @@ pub const Answer = struct { winsize: ?struct { cols: u16, rows: u16 } = null, signal: ?pardes.PtySignal = null, spawned: bool = false, + closed: bool = false, pub fn pty(a: *const Answer) []const u8 { return a.pty_buf[0..a.pty_len]; @@ -44,6 +45,7 @@ pub fn call(p: *Pardes, req: Req) Answer { }, .resize_pty => |r| ans.winsize = .{ .cols = r.cols, .rows = r.rows }, .signal_pty => |s| ans.signal = s.sig, + .close_pty => ans.closed = true, .spawn => ans.spawned = true, else => {}, }; diff --git a/src/pardes.zig b/src/pardes.zig index fbc3e119..442a3a30 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -3095,6 +3095,9 @@ pub const Effect = union(enum) { write: struct { pane: u8, bytes: Buf(64) }, resize_pty: struct { pane: u8, cols: u16, rows: u16 }, signal_pty: struct { pane: u8, sig: PtySignal }, + /// The terminal pane in this slot is gone: the shell hangs up its pty + /// and ends the shell, rather than leave it running with nobody to read. + close_pty: struct { pane: u8 }, open_link: Buf(256), /// write this pane's file content to its path; the shell reads both off /// the core (content is unbounded, effects are fixed-size values) @@ -4129,6 +4132,7 @@ pub const Pardes = struct { const watched = (if (pane.file) |f| f.output == null else false) or pane.hasPdf(); for (p.panes, 0..) |slot, id| if (slot == pane) { if (watched) p.emit(.{ .watch = .{ .pane = @intCast(id), .on = false } }); + if (pane.isTerminal()) p.emit(.{ .close_pty = .{ .pane = @intCast(id) } }); ctlfs.events.noteRetire(p, pane); // ...and so do bytes still queued for the pty it no longer has. p.dropPendingWrite(id); @@ -4522,6 +4526,7 @@ pub const Pardes = struct { .write => |w| if (v.pty_write) |f| f(p.host.ctx, w.pane, w.bytes.slice()), .resize_pty => |r| if (v.pty_resize) |f| f(p.host.ctx, r.pane, r.cols, r.rows), .signal_pty => |s| if (v.pty_signal) |f| f(p.host.ctx, s.pane, s.sig), + .close_pty => |c| if (v.close_pty) |f| f(p.host.ctx, c.pane), .open_link => |u| if (v.open_link) |f| f(p.host.ctx, u.slice()) else diff --git a/src/tty/tty.zig b/src/tty/tty.zig index 903c5c0c..b2768ed6 100644 --- a/src/tty/tty.zig +++ b/src/tty/tty.zig @@ -924,6 +924,7 @@ const Shell = struct { .pty_write = ptyWrite, .pty_resize = ptyResize, .pty_signal = ptySignal, + .close_pty = closePty, .tty_taken = ttyTaken, .write_file = writeFile, .write_dump = writeDump, @@ -1227,6 +1228,20 @@ const Shell = struct { if (s.ptys[pane]) |pt| host_io.signalTty(pt.pid, pt.file.handle, sig); } + /// The pane is gone: hang its pty up, which the kernel passes on to the + /// shell as SIGHUP, and say it too for a shell that ignores the tty's. + /// Output still in flight carries the old generation and is dropped. + fn closePty(ctx: ?*anyopaque, pane: u8) void { + const s = of(ctx); + var pt = s.ptys[pane] orelse return; + s.ptys[pane] = null; + s.gens[pane] +%= 1; + pt.reader.cancel(s.io) catch {}; + _ = libc.close(pt.file.handle); + _ = libc.kill(pt.pid, posix.SIG.HUP); + _ = libc.waitpid(pt.pid, null, posix.W.NOHANG); + } + fn ttyTaken(ctx: ?*anyopaque, pane: u8) bool { const s = of(ctx); const pt = s.ptys[pane] orelse return false; -- cgit v1.3 From 4793520998969439bb569c968c3143ae46aefc66 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 28 Sep 2026 22:17:49 -0300 Subject: A pane's question is logged as ask, and answer on its ctl answers it A script could not answer the several-REPLs question, which only a key could. Every question a pane asks on its notice band (which REPL takes an exec, Del's side from the keyboard) is now logged as `ask `, and `answer ` on the pane's ctl answers it as that key would, `answer -` taking it back as Esc does. One function answers for a key and for the ctl. Co-Authored-By: Claude Opus 5.5 --- .agents/skills/pardes-9p/SKILL.md | 5 ++- docs/fs.md | 13 ++++-- src/builtins.zig | 2 + src/exec.zig | 5 +++ src/ninep/ctl.zig | 8 ++++ src/ninep/testing.zig | 9 ++++ src/pardes.zig | 91 +++++++++++++++++++++++++++++++-------- 7 files changed, 110 insertions(+), 23 deletions(-) (limited to 'src/ninep/testing.zig') diff --git a/.agents/skills/pardes-9p/SKILL.md b/.agents/skills/pardes-9p/SKILL.md index 845326d2..0b1ef70e 100644 --- a/.agents/skills/pardes-9p/SKILL.md +++ b/.agents/skills/pardes-9p/SKILL.md @@ -142,7 +142,10 @@ but never a 9P write: a script sends code by writing the REPL pane's `pty/data`, and runs a command from such a file with `Exec ` or the tag. A bound terminal's `ctl` line ends with its id (`python-a`); an event record written back from such a file's body goes to its REPL, as the click -would. `Repl -` unbinds; a bare `Repl` says the binding. Multi-line code +would. `Repl -` unbinds; a bare `Repl` says the binding. With several +REPLs bound for a language an exec asks which, logged `ask repl a b` +(Del's side from the keyboard is `ask del k j`): answer with +`echo 'answer a' > $m/pane//ctl`, or `answer -` to send nothing. Multi-line code written to `pty/data` should be a bracketed paste, `\e[200~\e[201~` then `\r`, and a second `\r` when the code's last line is indented (a `def` or `for` body): one Enter leaves such a block open. Sent line by line, a blank line ends a Python block, and Python diff --git a/docs/fs.md b/docs/fs.md index 2dee3a49..bc48db2f 100644 --- a/docs/fs.md +++ b/docs/fs.md @@ -356,7 +356,13 @@ tab width — followed by rio's `current` or `notcurrent` (rio(4), `wctl`): whether the pane has the keyboard. It takes the pane's builtins (below), `get`, which reloads the buffer from the name it carries (unsaved edits are refused once, `: Modified (get again to -discard)`, as acme's get asks winclean, exec.c:513), and acme's `lock` and `unlock` (editors/acme/xfid.c:603-611), for an +discard)`, as acme's get asks winclean, exec.c:513), `answer ` +for the question the pane asks on its notice band, which the log names as +`ask ` -- `ask 4 del k j` for Del's side from the +keyboard (`k` the pane above takes the rows, `j` the one below), `ask 4 +repl a b` for which bound REPL takes an exec (a REPL's letter) -- `answer -` +taking it back as Esc does (with no question standing, `answer` is refused), +and acme's `lock` and `unlock` (editors/acme/xfid.c:603-611), for an edit of several writes to `addr` and `data` that another client must not land in the middle of. As in acme the lock binds only the clients that take it: a `lock` while another open holds it fails at once with `file in use` @@ -499,8 +505,9 @@ an open renders its frame; stat the entry. `/log` is one ring (64 KiB) that records whether or not anyone reads it: `new`, `del`, `rename` (a terminal's too, as its shell changes directory, since a terminal is named by its directory), `exit ` before -the `del` of a terminal whose shell exited by itself, and `save -`, +the `del` of a terminal whose shell exited by itself, `ask +` when a pane asks a question (answered by `answer` on its ctl), +and `save `, `dump ` when a Dump is written and `restore ` in a Restore's new log after its panes' `new`s, and `msg ` for every line the editor says, repeats included (with `verbose` on, that diff --git a/src/builtins.zig b/src/builtins.zig index 72df0271..1db010af 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -854,6 +854,8 @@ pub const Del = struct { { c.pane.prompt = .del_side; c.p.active = c.id; + var rec: [32]u8 = undefined; + pardes.ctlfs.events.notePath(c.p, "ask", std.fmt.bufPrint(&rec, "{d} del k j", .{c.pane.serial}) catch ""); // The question says Del already. if (c.pane.msg_announcement) c.pane.msg_len = 0; return; diff --git a/src/exec.zig b/src/exec.zig index 0c0930e2..2611162b 100644 --- a/src/exec.zig +++ b/src/exec.zig @@ -461,6 +461,11 @@ fn routeToRepl(p: *Pardes, from: usize, text: []const u8) Routed { src.question_len = @intCast(w.buffered().len); src.prompt = .repl_choice; p.active = from; + var rec: [96]u8 = undefined; + var rw = std.Io.Writer.fixed(&rec); + rw.print("{d} repl", .{src.serial}) catch {}; + for (bound[0..n]) |i| rw.print(" {c}", .{p.panes[i].?.repl.?.letter}) catch {}; + pardes.ctlfs.events.notePath(p, "ask", rw.buffered()); return .asked; } diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index edf81cd9..8ac60ec5 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -506,6 +506,14 @@ pub fn writePane(p: *Pardes, req: Req, pane: *Pane) Reply { if (!held) return tree.failText(req.tag, E.INVAL, e_not_locked); held = false; if (apply) pane.fs.lock = null; + } else if (std.mem.startsWith(u8, line, "answer ")) { + // The pane's question (its `ask` in the log), answered. + const choice = std.mem.trim(u8, line["answer ".len..], " "); + if (choice.len != 1) return refuse(p, req, "answer takes one choice, or -", line); + const id = p.paneBySerial(serial).?; + if (p.panes[id].?.prompt != .del_side and p.panes[id].?.prompt != .repl_choice) + return refuse(p, req, "no question asked", line); + if (apply) _ = p.answerQuestion(id, if (choice[0] == '-') null else choice[0]); } else if (!apply) { if (checkBuiltin(p, req, line, .pane)) |refusal| return refusal; } else if (runBuiltin(p, req, p.paneBySerial(serial).?, line)) |refusal| { diff --git a/src/ninep/testing.zig b/src/ninep/testing.zig index fce77f10..927552e2 100644 --- a/src/ninep/testing.zig +++ b/src/ninep/testing.zig @@ -56,6 +56,15 @@ pub fn rd(p: *Pardes, node: u64, off: u64, size: u32) Answer { return call(p, .{ .tag = 1, .op = .read, .node = node, .off = off, .size = size }); } +/// Whether the log, read whole from a fresh open, holds `needle`. +pub fn logHas(p: *Pardes, needle: []const u8) bool { + const log = @intFromEnum(tree.TopFile.log); + const h = call(p, .{ .tag = 1, .op = .open, .node = log }).reply.handle; + defer _ = call(p, .{ .tag = 3, .op = .release, .node = log, .handle = h }); + const text = call(p, .{ .tag = 2, .op = .read, .node = log, .handle = h, .size = 1 << 16 }).bytes; + return std.mem.indexOf(u8, text, needle) != null; +} + pub fn wr(p: *Pardes, node: u64, data: []const u8) Answer { return call(p, .{ .tag = 2, .op = .write, .node = node, .data = data }); } diff --git a/src/pardes.zig b/src/pardes.zig index e20eb17e..8a6fa589 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -1514,6 +1514,16 @@ test "a REPL bound for a language takes the exec made on a body in it; tags, Exe Sent.drain(p); try std.testing.expectEqualStrings("print(2)\r", Sent.said(2)); try std.testing.expect(Sent.len[1] == 0 and file.prompt == .none); + // The question is in the log, and a script answers it on the ctl. + { + const th = @import("ninep/testing.zig"); + _ = exec.executeFrom(p, 0, "print(5)", true); + var want: [32]u8 = undefined; + try std.testing.expect(th.logHas(p, try std.fmt.bufPrint(&want, "ask {d} repl a b\n", .{file.serial}))); + const answered = th.wr(p, ctlfs.Node.of(file.serial, .ctl), "answer a\n"); + try std.testing.expectEqual(ctlfs.Status.ok, answered.reply.status); + try std.testing.expectEqualStrings("print(5)\r", answered.pty()); + } _ = exec.executeFrom(p, 0, "print(3)", true); p.update(.{ .key = .{ .cp = Key.escape } }); Sent.drain(p); @@ -5295,6 +5305,42 @@ pub const Pardes = struct { } } + /// Answers the question pane `id` asks on its notice band, logged as + /// `ask `: Del's side (`k` above, `j` below) or + /// the REPL to send to (its letter). Null, or a choice not offered, + /// takes the question back. A key answers it, or `answer` on the pane's + /// ctl; false when the pane asks nothing. + pub fn answerQuestion(p: *Pardes, id: usize, choice: ?u8) bool { + const asked = p.panes[id] orelse return false; + switch (asked.prompt) { + .repl_choice => { + asked.prompt = .none; + const ask = p.repl_ask orelse return true; + p.repl_ask = null; + defer p.gpa.free(ask.text); + const letter = choice orelse return true; + if (letter < 'a' or letter > 'z') return true; + const serial = ask.offered[letter - 'a']; + if (serial == 0) return true; + // The pane offered, still that REPL and still running: it + // may have closed or been rebound while the question stood. + if (p.paneBySerial(serial)) |to| if (p.panes[to].?.repl) |r| + if (r.lang == ask.lang and r.letter == letter and exec.replLive(p, to)) { + exec.sendToRepl(p, id, to, ask.text); + return true; + }; + p.setMessage(id, "Repl: the REPL chosen is gone; nothing sent"); + }, + .del_side => { + asked.prompt = .none; + if (choice == 'k') exec.runBuiltin(p, .Del, id, "", "k"); + if (choice == 'j') exec.runBuiltin(p, .Del, id, "", "j"); + }, + else => return false, + } + return true; + } + fn handleKey(p: *Pardes, key: Key) void { // A double-click is two clicks with nothing between them. p.last_click = null; @@ -5303,27 +5349,12 @@ pub const Pardes = struct { // pane or a header edit is in: that key is its answer. for (p.panes, 0..) |slot, id| { const asked = slot orelse continue; - if (asked.prompt == .repl_choice) { - asked.prompt = .none; - const ask = p.repl_ask orelse return; - p.repl_ask = null; - defer p.gpa.free(ask.text); + switch (asked.prompt) { // Its letter sends it there; anything else takes it back. - if (key.ctrl or key.alt or key.cp > 'z' or key.cp < 'a') return; - const serial = ask.offered[key.cp - 'a']; - if (serial == 0) return; - // The pane offered, still that REPL and still running: it - // may have closed or been rebound while the question stood. - if (p.paneBySerial(serial)) |to| if (p.panes[to].?.repl) |r| - if (r.lang == ask.lang and r.letter == key.cp and exec.replLive(p, to)) - return exec.sendToRepl(p, id, to, ask.text); - p.setMessage(id, "Repl: the REPL chosen is gone; nothing sent"); - return; + .repl_choice => _ = p.answerQuestion(id, if (key.ctrl or key.alt or key.cp > 'z' or key.cp < 'a') null else @intCast(key.cp)), + .del_side => _ = p.answerQuestion(id, if (hit(key, config.del_above)) 'k' else if (hit(key, config.del_below)) 'j' else null), + else => continue, } - if (asked.prompt != .del_side) continue; - asked.prompt = .none; - if (hit(key, config.del_above)) exec.runBuiltin(p, .Del, id, "", "k"); - if (hit(key, config.del_below)) exec.runBuiltin(p, .Del, id, "", "j"); return; } const pane = p.panes[p.active] orelse return; @@ -6754,6 +6785,28 @@ test "Del from a key asks which neighbour takes the rows; nothing else asks" { try std.testing.expectEqual(top, p.active); try std.testing.expectEqual(h[2], p.rects[low].h); + // A script answers the question on the pane's ctl, as the log's `ask` + // names it: `answer -` takes it back, a side closes the pane toward it. + { + const th = @import("ninep/testing.zig"); + p.newScratchBelow(top); + const asked = p.active; + p.sync(); + const serial = p.panes[asked].?.serial; + const ctl = ctlfs.Node.of(serial, .ctl); + try std.testing.expectEqual(ctlfs.E.INVAL, th.wr(p, ctl, "answer k\n").errno()); + p.update(.{ .key = .{ .cp = ' ' } }); + p.update(.{ .key = .{ .cp = 'd' } }); + var want: [32]u8 = undefined; + try std.testing.expect(th.logHas(p, try std.fmt.bufPrint(&want, "ask {d} del k j\n", .{serial}))); + try std.testing.expectEqual(ctlfs.Status.ok, th.wr(p, ctl, "answer -\n").reply.status); + try std.testing.expect(p.panes[asked] != null and p.panes[asked].?.prompt == .none); + p.update(.{ .key = .{ .cp = ' ' } }); + p.update(.{ .key = .{ .cp = 'd' } }); + try std.testing.expectEqual(ctlfs.Status.ok, th.wr(p, ctl, "answer k\n").reply.status); + try std.testing.expect(p.paneBySerial(serial) == null); + } + // Bare Del from anything but a key closes at once and gives the rows up, // as it always has. p.newScratchBelow(top); -- cgit v1.3 From 09ef40318a3a3d1b9494e2a5fa41f71363929676 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 29 Sep 2026 18:13:43 -0300 Subject: One look logs one err: a file:addr whose file is not there is one miss quoting what was written, and a refused placement is the look's only failure A look at utf8txt:#3 from a terminal searched for utf8txt, missed, then found the terminal no text to address: two errs for one write. It is now looked for whole, as zzq:2 already was, so every form's miss reads no match for "". A look whose new pane was refused a place went on to settle its line in the pane it stayed on and logged has no line N after the placement failure; it now stops there. Co-Authored-By: Claude Opus 5.5 --- src/look.zig | 82 ++++++++++++++++++++++++++++++--------------------- src/ninep/ctl.zig | 33 +++++++++++++++++++++ src/ninep/testing.zig | 7 ++++- 3 files changed, 88 insertions(+), 34 deletions(-) (limited to 'src/ninep/testing.zig') diff --git a/src/look.zig b/src/look.zig index a29b27b5..fe5a3ac1 100644 --- a/src/look.zig +++ b/src/look.zig @@ -1302,6 +1302,41 @@ fn addressed(tok: []const u8) ?struct { path: []const u8, expr: []const u8 } { return .{ .path = tok[0..colon], .expr = expr }; } +/// A look at text that names nothing to open: a `./` name is a missing +/// file, anything else a search for the text as written. +fn lookUnresolved(p: *Pardes, id: usize, pane: *Pane, trimmed: []const u8) void { + // A `./` or `../` name opened nothing: said, ENOENT, not searched + // for as a word. What is missing is the pane's directory when + // that is gone, else the file named. + if (filesystem.dotRelative(trimmed)) { + const dir = Pardes.paneDir(pane); + var said: [4200]u8 = undefined; + const gone = if (comptime pardes.hosted) if (filesystem.localPath(dir)) |local| !exec.isDirectory(local) else false else true; + if (gone) return p.reportFailure(id, std.fmt.bufPrint(&said, "look: {s}: no such directory", .{dir[0..@min(dir.len, 4096)]}) catch "look: no such directory"); + var cut: [miss_path_cap + "…".len]u8 = undefined; + return p.reportFailure(id, std.fmt.bufPrint(&said, "look: {s}: no such file", .{missText(trimmed, &cut)}) catch "look: no such file"); + } + // A raw terminal's clicks are its program's; a look written over + // 9P is no keyboard input, and searches whatever the key mode. + if (pane.image != null or (pane.body.mode == .tty and !p.fs.serving)) return; + if (p.settings.look_word == .search and pane.file != null) return lookWord(p, id, pane, trimmed); + const rows = runSearch(p, id, trimmed, .text, .cursor, false) catch |err| { + p.reportError(id, "search", err); + return; + }; + if (rows == 0) { + var cut: [miss_path_cap + "…".len]u8 = undefined; + return missed(p, id, "no match for \"{s}\"", .{missText(trimmed, &cut)}); + } + clearNavigationSelection(p, pane); + const at = pane.search_row; + _ = searchStep(p, id, 1); + if (at != null and pane.search_row == at) { + pane.search_row = null; + _ = searchStep(p, id, 1); + } +} + /// Opens (or finds) `path` as Look would, `id`'s own pane when it is empty, /// and selects what `expr` addresses there from its dot. An address that /// does not evaluate moves nothing and says why (acme: no jump). @@ -1321,9 +1356,18 @@ fn lookAddress(p: *Pardes, id: usize, path: []const u8, expr: []const u8) void { const by_serial = std.mem.startsWith(u8, path, config.pane_addr); if (by_serial and open == null) return missed(p, id, "no pane {s}", .{path[0..@min(path.len, 32)]}); if (open) |o| target = o else if (path.len > 0) { + // A path that names nothing to open: the whole of what was written + // is looked for, as `zzq:2` is, and a miss quotes it as written. + if (!by_serial and resolveLookTarget(p, id, path, &realbuf) == .none) + return lookUnresolved(p, id, p.panes[id] orelse return, path.ptr[0 .. path.len + 1 + expr.len]); const before = p.active; + const failures = p.fs.failures; + const was_missed = p.look_missed; lookAt(p, id, path); target = p.active; + // Look said why it opened nothing (its placement refused, say): + // that one failure is the look's, no miss of the address after it. + if (p.fs.failures != failures or (p.look_missed and !was_missed)) return; // The path opened nothing (a search, or no such file): Look said so. if (target == before and target != id) return; } @@ -1484,39 +1528,7 @@ pub fn lookAt(p: *Pardes, id: usize, operand: []const u8) void { pane.sel = @splat(.{}); } switch (found) { - .none => { - // A `./` or `../` name opened nothing: said, ENOENT, not searched - // for as a word. What is missing is the pane's directory when - // that is gone, else the file named. - if (filesystem.dotRelative(trimmed)) { - const dir = Pardes.paneDir(pane); - var said: [4200]u8 = undefined; - const gone = if (comptime pardes.hosted) if (filesystem.localPath(dir)) |local| !exec.isDirectory(local) else false else true; - if (gone) return p.reportFailure(id, std.fmt.bufPrint(&said, "look: {s}: no such directory", .{dir[0..@min(dir.len, 4096)]}) catch "look: no such directory"); - var cut: [miss_path_cap + "…".len]u8 = undefined; - return p.reportFailure(id, std.fmt.bufPrint(&said, "look: {s}: no such file", .{missText(trimmed, &cut)}) catch "look: no such file"); - } - // A raw terminal's clicks are its program's; a look written over - // 9P is no keyboard input, and searches whatever the key mode. - if (pane.image != null or (pane.body.mode == .tty and !p.fs.serving)) return; - if (p.settings.look_word == .search and pane.file != null) return lookWord(p, id, pane, trimmed); - const rows = runSearch(p, id, trimmed, .text, .cursor, false) catch |err| { - p.reportError(id, "search", err); - return; - }; - if (rows == 0) { - var cut: [miss_path_cap + "…".len]u8 = undefined; - return missed(p, id, "no match for \"{s}\"", .{missText(trimmed, &cut)}); - } - clearNavigationSelection(p, pane); - const at = pane.search_row; - _ = searchStep(p, id, 1); - if (at != null and pane.search_row == at) { - pane.search_row = null; - _ = searchStep(p, id, 1); - } - - }, + .none => lookUnresolved(p, id, pane, trimmed), .pane => |t| { // `@p` names no open pane: a miss, said. if (t.id >= MAX_PANES or p.panes[t.id] == null) return missed(p, id, "no pane {s}", .{pl.path[0..@min(pl.path.len, 32)]}); @@ -1573,7 +1585,11 @@ pub fn lookAt(p: *Pardes, id: usize, operand: []const u8) void { const nt = panes.File.open(p, free, target.path, target.at.line) catch |err| return p.reportError(id, if (@import("Messages.zig").dialReason(err) != null) target.path else "look", err); if (target.at.col > 0) nt.body.cur_col = @intCast(target.at.col - 1); + const failures = p.fs.failures; exec.placeNew(p, id, id, free, .doc); + // Refused a place: that is the look's one failure, not a + // miss of its line too. + if (p.fs.failures != failures) return; layout.compute(p); nt.file.?.scroll -|= @max(1, p.rects[free].h -| BOX_H) / 2; if (target.at.end_line != 0) { diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 59a80f36..5bf354eb 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -1752,6 +1752,39 @@ test "a look after Newcol fills the empty column the keyboard is on" { try testing.expectEqual(p.active, p.col_panes[p.ncol - 1][0]); } +test "a look at file:addr whose file is not there is one miss, quoting what was written, in a terminal too" { + const p = try th.withTerm(testing.allocator); + defer p.deinit(); + const looked = Node.of(serialOf(p), .look); + for ([_][]const u8{ "zzq:#3", "zzq:2", "zzq:/re/" }) |written| { + var line: [64]u8 = undefined; + _ = wr(p, looked, try std.fmt.bufPrint(&line, "{s}\n", .{written})); + var want: [64]u8 = undefined; + try testing.expectEqual(@as(usize, 1), th.logCount(p, try std.fmt.bufPrint(&want, "look: no match for \"{s}\"\n", .{written}))); + } + try testing.expectEqual(@as(usize, 3), th.logCount(p, "\nerr ")); +} + +test "a look whose pane is refused a place fails with that alone, not a missing line too" { + const gpa = testing.allocator; + // A screen with rows for one pane only. + const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 5 }); + defer p.deinit(); + while (p.nextEffect()) |_| {} + _ = try p.setTestFile("x\n"); + while (p.nextEffect()) |_| {} + var tmp = testing.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.writeFile(testing.io, .{ .sub_path = "f.txt", .data = "one\ntwo\n" }); + var dir: [4096]u8 = undefined; + const at = dir[0..try tmp.dir.realPath(testing.io, &dir)]; + var line: [4200]u8 = undefined; + const r = wr(p, root_look, try std.fmt.bufPrint(&line, "{s}/f.txt:2\n", .{at})); + try testing.expectEqual(Status.err, r.reply.status); + try testing.expect(std.mem.indexOf(u8, r.reply.ename, "no space for a pane") != null); + try testing.expectEqual(@as(usize, 1), th.logCount(p, "\nerr ")); +} + test "a look under pardes's placement, from a pane pane/new made after Delcol, opens its file" { const gpa = testing.allocator; const p = try withFile(gpa, "x\n"); diff --git a/src/ninep/testing.zig b/src/ninep/testing.zig index 927552e2..b8eaa02b 100644 --- a/src/ninep/testing.zig +++ b/src/ninep/testing.zig @@ -58,11 +58,16 @@ pub fn rd(p: *Pardes, node: u64, off: u64, size: u32) Answer { /// Whether the log, read whole from a fresh open, holds `needle`. pub fn logHas(p: *Pardes, needle: []const u8) bool { + return logCount(p, needle) > 0; +} + +/// How many times the log, read whole from a fresh open, holds `needle`. +pub fn logCount(p: *Pardes, needle: []const u8) usize { const log = @intFromEnum(tree.TopFile.log); const h = call(p, .{ .tag = 1, .op = .open, .node = log }).reply.handle; defer _ = call(p, .{ .tag = 3, .op = .release, .node = log, .handle = h }); const text = call(p, .{ .tag = 2, .op = .read, .node = log, .handle = h, .size = 1 << 16 }).bytes; - return std.mem.indexOf(u8, text, needle) != null; + return std.mem.count(u8, text, needle); } pub fn wr(p: *Pardes, node: u64, data: []const u8) Answer { -- cgit v1.3 From 94f0c9359dc1b8ccd73bf58812bec9e78fb52073 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 1 Oct 2026 05:54:02 -0300 Subject: Every EINVAL or ENOENT refusal a unit test meets must say its errno in words a 9ns mount maps back: pardes re-pins cloud9, whose fs.enameErrno knows acme's address and argument refusals The tests' request helper asks cloud9's fs.enameErrno, the rules 9ns turns a refusal's words back into an errno with, for every EINVAL and ENOENT a request is refused with, and fails the test when a mount would hear another (EIO, mostly): "this pane has no text to address" was one. The re-pinned cloud9 maps acme's own refusals, which pardes keeps in acme's words: no match for regexp, address out of range, addresses out of order, range past end of body and the rest. Co-Authored-By: Claude Opus 5.5 --- build.zig.zon | 4 ++-- src/ninep/testing.zig | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src/ninep/testing.zig') diff --git a/build.zig.zon b/build.zig.zon index a478df6e..5efe9c28 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -9,8 +9,8 @@ // read-only HTTPS URL is what a manifest can carry. Re-pin with // `zig fetch --save=cloud9 git+https://git.sr.ht/~gbrls/cloud9#`. .cloud9 = .{ - .url = "git+https://git.sr.ht/~gbrls/cloud9#12d78be492351e29144daa379232bbd955b47631", - .hash = "cloud9-0.1.0-yt86qjoTHgAqXvz1h23WqTagtZNodmM5lkWFZ7Ld_880", + .url = "git+https://git.sr.ht/~gbrls/cloud9#552584ad79448988646231c7993a36e55b0e8c05", + .hash = "cloud9-0.1.0-yt86qlkdHgCC4CRZQA1ttzUYpZ07PoIxzIysTOSSbmqW", }, // Pinned to the exact libvaxis commit ghostty is built against, so it // is compatible with ghostty's uucode configuration (the one we share diff --git a/src/ninep/testing.zig b/src/ninep/testing.zig index b8eaa02b..a35a9cf0 100644 --- a/src/ninep/testing.zig +++ b/src/ninep/testing.zig @@ -3,6 +3,7 @@ const std = @import("std"); const pardes = @import("../pardes.zig"); const tree = @import("tree.zig"); +const cloud9 = @import("cloud9"); const Pardes = pardes.Pardes; pub const Req = tree.Req; @@ -33,6 +34,13 @@ pub const Answer = struct { pub fn call(p: *Pardes, req: Req) Answer { var ans: Answer = .{}; ans.reply = p.serveFs(req); + // An EINVAL or ENOENT refusal says so in words a 9ns mount maps back + // to it (cloud9's enameErrno), or a shell through the mount hears EIO. + const said = ans.reply; + if (said.status == .err and said.ename.len > 0 and (said.errno == E.INVAL or said.errno == E.NOENT) and cloud9.fs.enameErrno(said.ename) != said.errno) { + std.debug.print("a mount reads this refusal as errno {d}, not {d}: \"{s}\"\n", .{ cloud9.fs.enameErrno(said.ename), said.errno, said.ename }); + @panic("a refusal's words do not say its errno"); + } ans.bytes = p.fsPayload(ans.reply); while (p.nextEffect()) |e| switch (e) { .save_file, .save_text => ans.saved = true, -- cgit v1.3 From 23518c9d7c061f8a06f6632da8b64b37801b514f Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 21 Oct 2026 17:25:52 -0300 Subject: zig fmt for Zig 0.17 --- build.zig | 15 +- src/9p_io.zig | 2 +- src/Dir.zig | 4 +- src/File.zig | 12 +- src/Messages.zig | 2 +- src/Presentation.zig | 6 +- src/animation.zig | 11 +- src/builtins.zig | 22 +- src/detached/client.zig | 2 +- src/detached/server.zig | 4 +- src/detached/wire.zig | 82 +-- src/diff.zig | 4 +- src/draw.zig | 4 +- src/dump.zig | 4 +- src/edit_cmd.zig | 2 +- src/esp32p4.zig | 34 +- src/esp32p4/app.zig | 6 +- src/esp32p4_9p.zig | 2 +- src/fonts.zig | 2 +- src/gui/Post.zig | 19 +- src/gui/gui.zig | 32 +- src/host_io.zig | 20 +- src/linux/v9fs.zig | 6 +- src/look.zig | 2 +- src/macos.zig | 98 ++-- src/main.zig | 2 +- src/mini.zig | 10 +- src/mouse.zig | 18 +- src/ninep/addr.zig | 6 +- src/ninep/cols.zig | 54 +- src/ninep/ctl.zig | 168 +++--- src/ninep/events.zig | 30 +- src/ninep/pane.zig | 8 +- src/ninep/pty.zig | 5 +- src/ninep/screen.zig | 4 +- src/ninep/testing.zig | 4 +- src/ninep/tree.zig | 120 ++-- src/pager.zig | 4 +- src/pardes.zig | 10 +- src/pdf_view.zig | 2 +- src/syntax.zig | 82 +-- src/terminal.zig | 2 +- src/web.zig | 32 +- test/deck/buttons.zon | 158 ++--- test/deck/lpad-swipe.zon | 322 +++++------ test/deck/replay.zig | 36 +- test/deck/rpad-drag.zon | 442 +++++++------- test/deck/triggers.zon | 1148 ++++++++++++++++++------------------- test/fs_bench.zig | 6 +- test/lspfixture/broken.zig | 4 +- test/output.zig | 10 +- test/panes.zig | 2 +- test/pdf.zig | 6 +- test/pdf_scroll_bench.zig | 2 +- test/perf-baseline-gui-debug.json | 2 +- test/perf-baseline-tty-debug.json | 2 +- test/perf-baseline-tty-fast.json | 2 +- test/perf.zig | 6 +- test/unit_profile.zig | 4 +- 59 files changed, 1556 insertions(+), 1554 deletions(-) (limited to 'src/ninep/testing.zig') diff --git a/build.zig b/build.zig index ddd41a03..ca7b26af 100644 --- a/build.zig +++ b/build.zig @@ -39,10 +39,13 @@ pub const macos_min_version: std.SemanticVersion = .{ .major = 13, .minor = 0, . pub const TreeSitterGrammars = enum { disabled, zig, minimal, full }; const gui_shaders = [_][]const u8{ - "ui.vert", "ui.frag", + "ui.vert", + "ui.frag", "decor.frag", - "overlay.vert", "overlay.frag", - "image.vert", "image.frag", + "overlay.vert", + "overlay.frag", + "image.vert", + "image.frag", "post.vert", // The bundled post passes: shaders/post/.glsl behind the // Shadertoy prefix (shaderSource). @@ -843,7 +846,7 @@ pub fn build(b: *std.Build) void { const render_anchor = \\ if ((!self.refresh and \\ last.eql(cell) and - ; + ; if (std.mem.count(u8, render_src, render_anchor) != 1) std.debug.panic("vaxis's Vaxis.zig changed at `{s}`: redo its patch in build.zig", .{render_anchor}); render_src = std.mem.replaceOwned(u8, b.allocator, render_src, render_anchor, \\ if ((!self.refresh and @@ -924,7 +927,6 @@ pub fn build(b: *std.Build) void { .uucode = uucode_mod, }); - const iso_off = b.addOptions(); iso_off.addOption(bool, "isolated", false); const iso_on = b.addOptions(); @@ -1401,7 +1403,6 @@ pub fn build(b: *std.Build) void { const lspbench_check_step = b.step("lspbench-check", "require every configured language probe to complete correctly"); lspbench_check_step.dependOn(&run_lspbench_check.step); - const locations_bench_step = b.step("locations-bench", "measure cold/warm result formatting (-Doptimize=ReleaseFast; CSV on stderr)"); if (optimize != .fast) { locations_bench_step.dependOn(&b.addFail("locations-bench requires -Doptimize=ReleaseFast").step); @@ -2016,6 +2017,6 @@ fn wireCore(m: *std.Build.Module, d: struct { /// helper because `cpu_features_add` wants a set and there is no literal syntax for one. fn riscvFeatures(comptime features: []const std.Target.riscv.Feature) std.Target.Cpu.Feature.Set { var set = std.Target.Cpu.Feature.Set.empty; - for (features) |f| set.addFeature(@intFromEnum(f)); + for (features) |f| set.addFeature(@backingInt(f)); return set; } diff --git a/src/9p_io.zig b/src/9p_io.zig index 27d79b93..446c24de 100644 --- a/src/9p_io.zig +++ b/src/9p_io.zig @@ -1015,7 +1015,7 @@ pub fn sweepDeadSockets(io: std.Io, dir: [:0]const u8) void { i += 1 + name.len; const pid = deadSocketPid(name).?; if (pid == libc.getpid()) continue; - if (std.posix.errno(std.c.kill(pid, @enumFromInt(0))) != .SRCH) continue; + if (std.posix.errno(std.c.kill(pid, @fromBackingInt(@intCast(0)))) != .SRCH) continue; var path_buf: [sun_path_len:0]u8 = undefined; const path = std.fmt.bufPrintSentinel(&path_buf, "{s}/{s}", .{ dir, name }, 0) catch continue; const facts = statNoFollow(path) orelse continue; diff --git a/src/Dir.zig b/src/Dir.zig index 36895bda..b994bc06 100644 --- a/src/Dir.zig +++ b/src/Dir.zig @@ -463,10 +463,10 @@ test "over 9P a directory pane is a text pane whose name ends in /, its body the defer s.p.deinit(); const p = s.p; var line_buf: [4200]u8 = undefined; - _ = th.wr(p, @intFromEnum(tree.TopFile.look), try std.fmt.bufPrint(&line_buf, "{s}\n", .{s.dir})); + _ = th.wr(p, @backingInt(tree.TopFile.look), try std.fmt.bufPrint(&line_buf, "{s}\n", .{s.dir})); p.sync(); const pane = p.panes[p.active].?; - const index = th.rd(p, @intFromEnum(tree.TopFile.index), 0, 8192).bytes; + const index = th.rd(p, @backingInt(tree.TopFile.index), 0, 8192).bytes; try testing.expect(std.mem.indexOf(u8, index, try std.fmt.bufPrint(&line_buf, "{d} text 0 {s}/ ", .{ pane.serial, s.dir })) != null); try testing.expectEqualStrings(".dot sub/ top.txt\n", th.rd(p, tree.Node.of(pane.serial, .body), 0, 4096).bytes); var fields = std.mem.tokenizeScalar(u8, th.rd(p, tree.Node.of(pane.serial, .ctl), 0, 4096).bytes, ' '); diff --git a/src/File.zig b/src/File.zig index c42e39ec..59b04e3f 100644 --- a/src/File.zig +++ b/src/File.zig @@ -251,7 +251,7 @@ pub fn dumpPane( fn dumpLocationRows(arena: std.mem.Allocator, rows: []const locations.Row) ![]const dump.LocationRow { const saved = try arena.alloc(dump.LocationRow, rows.len); for (rows, saved) |row, *out| out.* = .{ - .kind = @enumFromInt(@intFromEnum(row.kind)), + .kind = @fromBackingInt(@intCast(@backingInt(row.kind))), .declaration = row.declaration, .mark_occurrence = row.mark_occurrence, .source_column = row.source_column, @@ -336,10 +336,10 @@ fn restoreOutputLocationRows(gpa: std.mem.Allocator, content: []const u8, saved: const colors = try dump.decodeBytes(gpa, row.colors_b64); errdefer gpa.free(colors); if (colors.len != 0 and colors.len != code_len) return error.InvalidLocationRows; - for (colors) |color| if (color > @intFromEnum(syntax.Syn.comment)) return error.InvalidLocationRows; + for (colors) |color| if (color > @backingInt(syntax.Syn.comment)) return error.InvalidLocationRows; const path = try gpa.dupe(u8, row.path); out.* = .{ - .kind = @enumFromInt(@intFromEnum(row.kind)), + .kind = @fromBackingInt(@intCast(@backingInt(row.kind))), .declaration = row.declaration, .mark_occurrence = row.mark_occurrence, .source_column = row.source_column, @@ -1028,7 +1028,7 @@ pub fn restore(p: *Pardes, id: usize, src: dump.Pane) !*Pane { const colors = try dump.decodeBytes(p.gpa, saved.mini_colors_b64); errdefer p.gpa.free(colors); if (colors.len != content.len or colors.len > Mini.max_output_bytes) return error.InvalidMini; - for (colors) |color| if (color > @intFromEnum(syntax.Syn.comment)) return error.InvalidMini; + for (colors) |color| if (color > @backingInt(syntax.Syn.comment)) return error.InvalidMini; mini = .{ .source = source, .colors = colors }; } else if (saved.mini_colors_b64.len > 0) return error.InvalidMini; @@ -1984,7 +1984,7 @@ pub fn recolorSyntax(p: *Pardes, s: *Surface, pane: *Pane, f: *State, r: pardes. if (if (tint != null and hs + c == 0) SynStyle{ .fg = tint.?.fg, .bold = true } else - synStyle(p, @enumFromInt(highlights[hidx] & syntax.syn_bits))) |ss| + synStyle(p, @fromBackingInt(@intCast(highlights[hidx] & syntax.syn_bits)))) |ss| { var fill: usize = 0; while (fill < cells and prefix_width + screen_c + fill < tw) : (fill += 1) { @@ -2189,7 +2189,7 @@ pub fn recolorDiffOutput(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, t // green is the tint's to say now: its code takes the page's ink. const paint: ?SynStyle = if (tint != null and prefix) .{ .fg = tint.?.fg, .bold = true } - else if (synStyle(p, @enumFromInt(style & syntax.syn_bits))) |ss| + else if (synStyle(p, @fromBackingInt(@intCast(style & syntax.syn_bits)))) |ss| ss else if (tint != null) .{ .fg = ink, .bold = false } diff --git a/src/Messages.zig b/src/Messages.zig index b67a8402..6d064c93 100644 --- a/src/Messages.zig +++ b/src/Messages.zig @@ -721,7 +721,7 @@ test "with no frontend attached a message goes once it has lingered, on the cloc // line above it with it. p.unattended = true; // A read served meanwhile changes nothing; the session's loop expires. - _ = p.serveFs(.{ .tag = 1, .op = .read, .node = @intFromEnum(ctlfs.TopFile.index), .size = 64 }); + _ = p.serveFs(.{ .tag = 1, .op = .read, .node = @backingInt(ctlfs.TopFile.index), .size = 64 }); try std.testing.expect(pane.msg_len > 0); expireUnattended(p); try std.testing.expectEqual(@as(u16, 0), pane.msg_len); diff --git a/src/Presentation.zig b/src/Presentation.zig index 5cec73e0..2a75b66d 100644 --- a/src/Presentation.zig +++ b/src/Presentation.zig @@ -226,7 +226,7 @@ fn stamp(p: *const Pardes, track: Track) Track { switch (track.effect) { .slide, .zoom, .vertical => { const motion = animation.Motion.of(p.settings.motion); - stamped.motion = @intFromEnum(p.settings.motion) + 1; + stamped.motion = @backingInt(p.settings.motion) + 1; stamped.frame_count = @intFromFloat(@max(2, @round(@as(f32, @floatFromInt(track.effect.frames())) * motion.span))); }, else => {}, @@ -741,7 +741,7 @@ test "a pane past its mark never takes a neighbour's click" { // Bouncy, at its peak: pane 0 slides right to 0..40 and swings past it, // over the neighbour at 40..80. var presentation: Presentation = .{}; - var track: Track = .{ .serial = 7, .effect = .slide, .motion = @intFromEnum(animation.Motion.Flavour.bouncy) + 1, .frame_count = 20, .from = .{ .x = -40, .y = 0, .w = 40, .h = 20 }, .to = .{ .x = 0, .y = 0, .w = 40, .h = 20 } }; + var track: Track = .{ .serial = 7, .effect = .slide, .motion = @backingInt(animation.Motion.Flavour.bouncy) + 1, .frame_count = 20, .from = .{ .x = -40, .y = 0, .w = 40, .h = 20 }, .to = .{ .x = 0, .y = 0, .w = 40, .h = 20 } }; var peak: u16 = 0; var furthest: f32 = -1e9; while (track.frame < track.frames()) : (track.frame += 1) { @@ -807,7 +807,7 @@ test "presentation snapshots own compact body and tag rows across later edits" { } test "a move retargeted mid-way carries its speed into the new one" { - const smooth = @intFromEnum(animation.Motion.Flavour.smooth) + 1; + const smooth = @backingInt(animation.Motion.Flavour.smooth) + 1; const first: Track = .{ .serial = 1, .phase = .moving, .effect = .slide, .motion = smooth, .frame = 4, .frame_count = 14, .from = .{ .x = 0, .y = 1, .w = 40, .h = 20 }, .to = .{ .x = 40, .y = 1, .w = 40, .h = 20 } }; const was = first.velocity(); try std.testing.expect(was.x > 0.5); diff --git a/src/animation.zig b/src/animation.zig index 19f7ce0b..547b9201 100644 --- a/src/animation.zig +++ b/src/animation.zig @@ -897,7 +897,7 @@ test "each flavour is its own motion: off lands at once, bouncy overshoots, play last = now; } try std.testing.expect(t < 1600 * ms); - settle[@intFromEnum(flavour)] = t; + settle[@backingInt(flavour)] = t; switch (flavour) { .crisp, .smooth => try std.testing.expect(peak <= 1.0005 and low >= 0), // Clearly past the mark, not a hint of it. @@ -909,8 +909,8 @@ test "each flavour is its own motion: off lands at once, bouncy overshoots, play // Smooth takes twice crisp's time and more: a character, not a tuning. // Yet as the default a pane's arrival (a slide's 12 frames, scaled) is // inside §8.1's 220 ms, and a lift is still before 300 ms. - try std.testing.expect(settle[@intFromEnum(Motion.Flavour.smooth)] > 2 * settle[@intFromEnum(Motion.Flavour.crisp)]); - try std.testing.expect(settle[@intFromEnum(Motion.Flavour.smooth)] <= 300 * ms); + try std.testing.expect(settle[@backingInt(Motion.Flavour.smooth)] > 2 * settle[@backingInt(Motion.Flavour.crisp)]); + try std.testing.expect(settle[@backingInt(Motion.Flavour.smooth)] <= 300 * ms); try std.testing.expect(@round(@as(f32, 12) * Motion.of(.smooth).span) * frame_ms <= 220); // A fixed-length move lands exactly on its mark, whatever the flavour. for (std.enums.values(Motion.Flavour)) |flavour| try std.testing.expectEqual(@as(f32, 1), Motion.of(flavour).ease(1)); @@ -920,7 +920,7 @@ test "a flavour's stretched pane lands exactly on its box, and a click finds the const from: Box = .{ .x = 0, .y = 2, .w = 30, .h = 10 }; const to: Box = .{ .x = 37.3, .y = 2, .w = 30, .h = 10 }; for (std.enums.values(Motion.Flavour)) |flavour| { - var track: Track = .{ .effect = .slide, .motion = @intFromEnum(flavour) + 1, .frame_count = 20, .from = from, .to = to }; + var track: Track = .{ .effect = .slide, .motion = @backingInt(flavour) + 1, .frame_count = 20, .from = from, .to = to }; track.frame = track.frames() - 1; const landed = track.presented(); // Bit for bit: no stretch or float residue once it lands. @@ -929,7 +929,7 @@ test "a flavour's stretched pane lands exactly on its box, and a click finds the // Playful at its most stretched: the pane is drawn wider than its box, // and the drawn place of a cell maps back to that cell (the pointer // inverts the same box: target + (x - shown.x) / shown.w * target.w). - var track: Track = .{ .effect = .slide, .motion = @intFromEnum(Motion.Flavour.playful) + 1, .frame_count = 20, .from = from, .to = to }; + var track: Track = .{ .effect = .slide, .motion = @backingInt(Motion.Flavour.playful) + 1, .frame_count = 20, .from = from, .to = to }; var most: u16 = 0; var widest: f32 = 0; while (track.frame < track.frames()) : (track.frame += 1) { @@ -1309,4 +1309,3 @@ test "retarget starts at the currently displayed value" { for (0..transition_steps) |_| tween.advance(); try std.testing.expectEqual(third, tween.displayed); } - diff --git a/src/builtins.zig b/src/builtins.zig index d9cef8c9..83966228 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -199,7 +199,7 @@ pub const registry = struct { pub fn takesArg(b: Builtin()) bool { inline for (manualBuiltinList(), 0..) |T, i| - if (@intFromEnum(b) == i) return @hasDecl(T, "takes_arg") and T.takes_arg; + if (@backingInt(b) == i) return @hasDecl(T, "takes_arg") and T.takes_arg; // Every setting takes its value, and a switch flips when bare. return true; } @@ -210,7 +210,7 @@ pub const registry = struct { /// may be in (`Dump+2024.zon` is a name, not Dump's argument). pub fn plusArg(b: Builtin()) bool { inline for (manualBuiltinList(), 0..) |T, i| - if (@intFromEnum(b) == i) return @hasDecl(T, "plus_arg") and T.plus_arg; + if (@backingInt(b) == i) return @hasDecl(T, "plus_arg") and T.plus_arg; return false; } @@ -223,15 +223,15 @@ pub const registry = struct { /// pane it is refused (exec.runBuiltinFrom), as Repl and Edit are. pub fn needs(b: Builtin()) ?PaneKind { inline for (manualBuiltinList(), 0..) |T, i| - if (@intFromEnum(b) == i) return if (@hasDecl(T, "needs")) T.needs else null; + if (@backingInt(b) == i) return if (@hasDecl(T, "needs")) T.needs else null; return null; } pub fn requiresArg(b: Builtin()) bool { inline for (manualBuiltinList(), 0..) |T, i| - if (@intFromEnum(b) == i) return @hasDecl(T, "requires_arg") and T.requires_arg; + if (@backingInt(b) == i) return @hasDecl(T, "requires_arg") and T.requires_arg; inline for (comptime settingList(), manualBuiltinCount()..) |setting, i| - if (@intFromEnum(b) == i) return switch (setting.action) { + if (@backingInt(b) == i) return switch (setting.action) { // a switch flips bare, a choice steps, and DumpDir and Shell bare // are the default .toggle, .transition, .scene, .dump_dir, .choice, .lift, .shader_animation, .motion, .shell => false, @@ -244,15 +244,15 @@ pub const registry = struct { pub fn scope(b: Builtin()) Scope { inline for (manualBuiltinList(), 0..) |T, i| - if (@intFromEnum(b) == i) return if (@hasDecl(T, "scope")) T.scope else .pane; + if (@backingInt(b) == i) return if (@hasDecl(T, "scope")) T.scope else .pane; return .session; // a setting } pub fn outputTraits(b: Builtin()) ?OutputTraits { inline for (manualBuiltinList(), 0..) |T, i| - if (@intFromEnum(b) == i) return if (@hasDecl(T, "output")) T.output else null; + if (@backingInt(b) == i) return if (@hasDecl(T, "output")) T.output else null; inline for (comptime settingList(), manualBuiltinCount()..) |_, i| - if (@intFromEnum(b) == i) return null; + if (@backingInt(b) == i) return null; unreachable; } @@ -260,15 +260,15 @@ pub const registry = struct { /// The ones that own that row themselves declare `quiet` and do not. pub fn announces(b: Builtin()) bool { inline for (manualBuiltinList(), 0..) |T, i| - if (@intFromEnum(b) == i) return !(@hasDecl(T, "quiet") and T.quiet); + if (@backingInt(b) == i) return !(@hasDecl(T, "quiet") and T.quiet); return true; // a setting builtin changes something invisible; say so } pub fn dispatch(b: Builtin(), c: Ctx) void { inline for (manualBuiltinList(), 0..) |T, i| - if (@intFromEnum(b) == i) return T.run(c); + if (@backingInt(b) == i) return T.run(c); inline for (comptime settingList(), manualBuiltinCount()..) |setting, i| - if (@intFromEnum(b) == i) return exec.applySettingBuiltin(c.p, setting, c.arg); + if (@backingInt(b) == i) return exec.applySettingBuiltin(c.p, setting, c.arg); unreachable; } }; diff --git a/src/detached/client.zig b/src/detached/client.zig index cf1842d9..60950208 100644 --- a/src/detached/client.zig +++ b/src/detached/client.zig @@ -1209,7 +1209,7 @@ test "detached session: a frontend is never asked to fork, write, or watch" { } const named = for (allowed) |ok| { const want = std.meta.stringToEnum(wire.ServerTag, ok).?; - if (@intFromEnum(want) == tag) break true; + if (@backingInt(want) == tag) break true; } else false; if (!named) { std.debug.print("tag 0x{x:0>2} is decodable by a frontend and is not one of the nine\n", .{tag}); diff --git a/src/detached/server.zig b/src/detached/server.zig index 79d1189a..41bc054f 100644 --- a/src/detached/server.zig +++ b/src/detached/server.zig @@ -1049,7 +1049,7 @@ pub const Session = struct { } fn apply(s: *Session, c: *Client, slot: u8, tag: u8, payload: []const u8) wire.Error!void { - if (tag == @intFromEnum(wire.ClientTag.hello)) { + if (tag == @backingInt(wire.ClientTag.hello)) { if (c.attached) return error.BadValue; const claimed = try wire.helloVersion(payload); if (claimed != wire.version) { @@ -1124,7 +1124,7 @@ pub const Session = struct { if (entry.scene == null) break true; } else false; const compiled = s.shaders.sync(s.gpa, s.io, s.core, if (files) s.inotify() else s.inotify_fd, &s.watches, .{ .ctx = &s.mailbox, .call = wakeForExit }); - const key = @as(u64, s.shaders.revision) << 8 | @intFromEnum(s.core.settings.shader_animation); + const key = @as(u64, s.shaders.revision) << 8 | @backingInt(s.core.settings.shader_animation); var chain: wire.Post = .{ .animation = s.core.settings.shader_animation, .len = s.core.settings.post.len }; _ = s.shaders.view(&s.core.settings.post, &chain.passes); for (&s.clients) |*c| { diff --git a/src/detached/wire.zig b/src/detached/wire.zig index f1b7a1b3..d57a28be 100644 --- a/src/detached/wire.zig +++ b/src/detached/wire.zig @@ -569,13 +569,13 @@ pub fn framed(buf: []const u8) Error!?Framed { fn putColor(w: *Writer, c: pardes.Color) Error!void { switch (c) { - .default => try w.putByte(@intFromEnum(ColorTag.default)), + .default => try w.putByte(@backingInt(ColorTag.default)), .index => |i| { - try w.putByte(@intFromEnum(ColorTag.index)); + try w.putByte(@backingInt(ColorTag.index)); try w.putByte(i); }, .rgb => |v| { - try w.putByte(@intFromEnum(ColorTag.rgb)); + try w.putByte(@backingInt(ColorTag.rgb)); try w.putBytes(&v); }, } @@ -606,7 +606,7 @@ const Ul = @FieldType(pardes.CellStyle, "ul"); /// the `inline else`, exactly as `clientTag` keeps the machine-local reports. fn putUl(w: *Writer, u: Ul) Error!void { try w.putByte(switch (u) { - inline else => |t| @intFromEnum(@field(UlTag, @tagName(t))), + inline else => |t| @backingInt(@field(UlTag, @tagName(t))), }); } @@ -618,7 +618,7 @@ fn getUl(r: *Reader) Error!Ul { fn putFont(w: *Writer, f: pardes.FontRole) Error!void { try w.putByte(switch (f) { - inline else => |t| @intFromEnum(@field(FontTag, @tagName(t))), + inline else => |t| @backingInt(@field(FontTag, @tagName(t))), }); } @@ -795,12 +795,12 @@ pub fn encodeFrameLayers(out: []u8, cols: u16, rows: u16, cursor: ?Cursor, point std.debug.assert(cells.len == @as(usize, cols) * @as(usize, rows)); const full = prev.len != cells.len; var w: Writer = .init(out); - const at = try beginMessage(&w, @intFromEnum(ServerTag.frame)); + const at = try beginMessage(&w, @backingInt(ServerTag.frame)); const header: FrameHeader = if (pointer_shape == .link) (if (full) .full_link else .diff_link) else (if (full) .full else .diff); - try w.putByte(@intFromEnum(header)); + try w.putByte(@backingInt(header)); try w.putU16(cols); try w.putU16(rows); try putCursor(&w, cursor, cols, rows); @@ -837,7 +837,7 @@ pub fn encodeFrameLayers(out: []u8, cols: u16, rows: u16, cursor: ?Cursor, point for (tags) |layer| { if (layer.rows == 0) continue; if (layer.cells.len != @as(usize, layer.cols) * layer.rows) return error.BadValue; - try w.putByte(@intFromEnum(layer.kind)); + try w.putByte(@backingInt(layer.kind)); try w.putU16(layer.id); try w.putU32(layer.serial); try w.putU16(layer.viewport.x); @@ -852,7 +852,7 @@ pub fn encodeFrameLayers(out: []u8, cols: u16, rows: u16, cursor: ?Cursor, point } try w.putU16(@intCast(regions.len)); for (regions) |region| { - try w.putByte(@intFromEnum(region.kind)); + try w.putByte(@backingInt(region.kind)); try w.putByte(region.owner); try w.putU32(region.serial); try w.putU16(region.rect.x); @@ -1003,7 +1003,7 @@ fn getBodyHit(r: *Reader) Error!?pardes.Mouse.BodyHit { fn putTagHit(w: *Writer, hit: ?pardes.TagHit) Error!void { try w.putBool(hit != null); if (hit) |h| { - try w.putByte(@intFromEnum(h.kind)); + try w.putByte(@backingInt(h.kind)); try w.putU16(h.id); try w.putU32(h.serial); try w.putU16(h.col); @@ -1030,7 +1030,7 @@ fn getTagHit(r: *Reader) Error!?pardes.TagHit { pub fn encodeClient(out: []u8, msg: ClientMsg) Error![]const u8 { var w: Writer = .init(out); - const at = try beginMessage(&w, @intFromEnum(clientTag(msg))); + const at = try beginMessage(&w, @backingInt(clientTag(msg))); switch (msg) { .hello => |h| { try w.putU16(h.version); @@ -1048,10 +1048,10 @@ pub fn encodeClient(out: []u8, msg: ClientMsg) Error![]const u8 { }, .mouse => |m| { try w.putByte(switch (m.button) { - inline else => |t| @intFromEnum(@field(ButtonTag, @tagName(t))), + inline else => |t| @backingInt(@field(ButtonTag, @tagName(t))), }); try w.putByte(switch (m.kind) { - inline else => |t| @intFromEnum(@field(KindTag, @tagName(t))), + inline else => |t| @backingInt(@field(KindTag, @tagName(t))), }); try w.putU16(m.col); try w.putU16(m.row); @@ -1164,7 +1164,7 @@ fn serverTag(msg: ServerMsg) ServerTag { /// payload is a walk of two grids rather than a value (see `encodeFrame`). pub fn encodeServer(out: []u8, msg: ServerMsg) Error![]const u8 { var w: Writer = .init(out); - const at = try beginMessage(&w, @intFromEnum(serverTag(msg))); + const at = try beginMessage(&w, @backingInt(serverTag(msg))); switch (msg) { .welcome => |v| { try w.putU16(v.version); @@ -1172,7 +1172,7 @@ pub fn encodeServer(out: []u8, msg: ServerMsg) Error![]const u8 { try w.putU16(v.cols); try w.putU16(v.rows); }, - .refuse => |why| try w.putByte(@intFromEnum(why)), + .refuse => |why| try w.putByte(@backingInt(why)), // A frame's runs are not a value this union can hold; the server calls // encodeFrame directly and this arm exists so the switch stays // exhaustive over ServerMsg. @@ -1182,11 +1182,11 @@ pub fn encodeServer(out: []u8, msg: ServerMsg) Error![]const u8 { .read_clipboard => {}, .open_link => |u| try w.putSlice16(u), .post => |p| { - try w.putByte(@intFromEnum(p.animation)); + try w.putByte(@backingInt(p.animation)); try w.putByte(p.len); for (p.list()) |pass| { // 0 a file, else a bundled scene and one. - try w.putByte(if (pass.scene) |scene| @as(u8, @intFromEnum(scene)) + 1 else 0); + try w.putByte(if (pass.scene) |scene| @as(u8, @backingInt(scene)) + 1 else 0); try w.putByte(pass.level); try w.putByte(@intFromBool(pass.animated)); try w.putU32(pass.revision); @@ -1341,9 +1341,9 @@ test "detached wire: every Event variant round-trips" { // The tag space is the protocol's own, so assert the numbers themselves: // a renumbering here breaks every deployed frontend and must be a diff // somebody reads, not a silent change. - try testing.expectEqual(@as(u8, 0x01), @intFromEnum(ClientTag.hello)); - try testing.expectEqual(@as(u8, 0x10), @intFromEnum(ClientTag.key)); - try testing.expectEqual(@as(u8, 0x1d), @intFromEnum(ClientTag.pointer_leave)); + try testing.expectEqual(@as(u8, 0x01), @backingInt(ClientTag.hello)); + try testing.expectEqual(@as(u8, 0x10), @backingInt(ClientTag.key)); + try testing.expectEqual(@as(u8, 0x1d), @backingInt(ClientTag.pointer_leave)); { const got = try roundClient(&buf, .{ .hello = .{ .cols = 80, .rows = 24 } }); @@ -1506,7 +1506,7 @@ test "detached wire: a session is never told to do a frontend's remembering" { } const named = for (allowed) |ok| { const want = std.meta.stringToEnum(ClientTag, ok).?; - if (@intFromEnum(want) == tag) break true; + if (@backingInt(want) == tag) break true; } else false; if (!named) { std.debug.print("tag 0x{x:0>2} is decodable by a session and is not something a human did\n", .{tag}); @@ -1752,8 +1752,8 @@ test "detached wire: a truncated frame is refused at every length" { for (0..header_len + 1) |cut| try testing.expectEqual(@as(?Framed, null), try framed(copy[0..cut])); // A payload with bytes LEFT OVER is refused too: it is not this message. - try testing.expectError(error.Trailing, decodeClient(@intFromEnum(ClientTag.pointer_leave), "x")); - try testing.expectError(error.Trailing, decodeServer(@intFromEnum(ServerTag.quit), "x")); + try testing.expectError(error.Trailing, decodeClient(@backingInt(ClientTag.pointer_leave), "x")); + try testing.expectError(error.Trailing, decodeServer(@backingInt(ServerTag.quit), "x")); } test "detached wire: an unknown tag is refused, never guessed" { @@ -1765,9 +1765,9 @@ test "detached wire: an unknown tag is refused, never guessed" { } // A tag NESTED in a payload gets the same treatment: a color, an // underline style, a mouse button, a refusal reason. - try testing.expectError(error.BadTag, decodeServer(@intFromEnum(ServerTag.refuse), &.{0x7f})); + try testing.expectError(error.BadTag, decodeServer(@backingInt(ServerTag.refuse), &.{0x7f})); try testing.expectError(error.BadTag, decodeClient( - @intFromEnum(ClientTag.mouse), + @backingInt(ClientTag.mouse), &.{ 0xff, 0x00, 0, 0, 0, 0, 0 }, )); } @@ -1775,7 +1775,7 @@ test "detached wire: an unknown tag is refused, never guessed" { test "detached wire: an over-long length prefix is refused before it is believed" { // The prefix a hostile or corrupt peer sends to make the receiver allocate // or index by it. `framed` must refuse rather than wait for 4 GiB. - var head: [header_len]u8 = .{ @intFromEnum(ClientTag.paste), 0, 0, 0, 0 }; + var head: [header_len]u8 = .{ @backingInt(ClientTag.paste), 0, 0, 0, 0 }; std.mem.writeInt(u32, head[1..5], max_payload + 1, .little); try testing.expectError(error.Overlong, framed(&head)); std.mem.writeInt(u32, head[1..5], std.math.maxInt(u32), .little); @@ -1789,10 +1789,10 @@ test "detached wire: an over-long length prefix is refused before it is believed var paste: [8]u8 = undefined; std.mem.writeInt(u32, paste[0..4], 4096, .little); @memcpy(paste[4..8], "abcd"); - try testing.expectError(error.Truncated, decodeClient(@intFromEnum(ClientTag.paste), &paste)); + try testing.expectError(error.Truncated, decodeClient(@backingInt(ClientTag.paste), &paste)); // ...and past the cap, which is refused rather than read. std.mem.writeInt(u32, paste[0..4], max_payload + 1, .little); - try testing.expectError(error.Overlong, decodeClient(@intFromEnum(ClientTag.paste), &paste)); + try testing.expectError(error.Overlong, decodeClient(@backingInt(ClientTag.paste), &paste)); } test "detached wire: a frame that lies about its runs cannot walk out of the grid" { @@ -1837,13 +1837,13 @@ test "detached wire: a frame that lies about its runs cannot walk out of the gri // it is used to bound the walk. var head: [frame_head]u8 = undefined; var w: Writer = .init(&head); - try w.putByte(@intFromEnum(FrameKind.diff)); + try w.putByte(@backingInt(FrameKind.diff)); try w.putU16(cols); try w.putU16(rows); try putCursor(&w, null, cols, rows); try w.putU32(0); // no body layers try w.putU32(9); - try testing.expectError(error.Overlong, decodeServer(@intFromEnum(ServerTag.frame), w.written())); + try testing.expectError(error.Overlong, decodeServer(@backingInt(ServerTag.frame), w.written())); // ...and a grid of the wrong size is the receiver's own bug, not a frame // it should paint half of. @@ -1885,7 +1885,7 @@ test "detached wire: a cursor outside the grid is refused, not painted" { var head: [frame_head]u8 = undefined; for ([_][2]u16{ .{ cols, 0 }, .{ 0, rows }, .{ 0xffff, 0xffff } }) |xy| { var w: Writer = .init(&head); - try w.putByte(@intFromEnum(FrameKind.diff)); + try w.putByte(@backingInt(FrameKind.diff)); try w.putU16(cols); try w.putU16(rows); // Written by hand: `putCursor` now refuses this too, which is the @@ -1897,19 +1897,19 @@ test "detached wire: a cursor outside the grid is refused, not painted" { try w.putU32(0); try testing.expectError( error.BadValue, - decodeServer(@intFromEnum(ServerTag.frame), w.written()), + decodeServer(@backingInt(ServerTag.frame), w.written()), ); } // The last cell IS in the grid, and a frame carrying it decodes. { var w: Writer = .init(&head); - try w.putByte(@intFromEnum(FrameKind.diff)); + try w.putByte(@backingInt(FrameKind.diff)); try w.putU16(cols); try w.putU16(rows); try putCursor(&w, .{ .x = cols - 1, .y = rows - 1, .bar = true }, cols, rows); try w.putU32(0); // no body layers try w.putU32(0); - const got = (try decodeServer(@intFromEnum(ServerTag.frame), w.written())).frame; + const got = (try decodeServer(@backingInt(ServerTag.frame), w.written())).frame; try testing.expectEqual(@as(u16, cols - 1), got.cursor.?.x); try testing.expectEqual(@as(u16, rows - 1), got.cursor.?.y); } @@ -1933,25 +1933,25 @@ test "detached wire: values a field cannot mean are refused" { // A bool is 0 or 1. `2` used to be "true" in every hand-written codec that // ever silently accepted a corrupt stream. try testing.expectError(error.BadValue, decodeClient( - @intFromEnum(ClientTag.key), + @backingInt(ClientTag.key), &.{ 'a', 0, 0, 0, 0, 0, 2, 0, 0 }, )); // A codepoint past Unicode's last: @intCast into Key.cp's u21 would panic. try testing.expectError(error.BadValue, decodeClient( - @intFromEnum(ClientTag.key), + @backingInt(ClientTag.key), &.{ 0x00, 0x00, 0x11, 0x00, 0, 0, 0, 0, 0 }, )); // A pane the core cannot index. `pdf_scroll` reads its pane byte before the // f32 that follows, so a one-byte payload reaches the check this is about // rather than tripping `Truncated` first. try testing.expectError(error.BadValue, decodeClient( - @intFromEnum(ClientTag.pdf_scroll), + @backingInt(ClientTag.pdf_scroll), &.{pardes.MAX_PANES}, )); // A zero-column grid would collapse a shared session; an over-wide one is // past what this protocol carries. try testing.expectError(error.BadValue, decodeClient( - @intFromEnum(ClientTag.hello), + @backingInt(ClientTag.hello), &.{ 1, 0, 0, 0, 24, 0 }, )); { @@ -1959,15 +1959,15 @@ test "detached wire: values a field cannot mean are refused" { std.mem.writeInt(u16, hello[0..2], version, .little); std.mem.writeInt(u16, hello[2..4], max_cols + 1, .little); std.mem.writeInt(u16, hello[4..6], 24, .little); - try testing.expectError(error.BadValue, decodeClient(@intFromEnum(ClientTag.hello), &hello)); + try testing.expectError(error.BadValue, decodeClient(@backingInt(ClientTag.hello), &hello)); } // A NaN scroll distance. `pinch` multiplies into a zoom the pane keeps. { var pinch: [4]u8 = undefined; std.mem.writeInt(u32, &pinch, @bitCast(std.math.nan(f32)), .little); - try testing.expectError(error.BadValue, decodeClient(@intFromEnum(ClientTag.pinch), &pinch)); + try testing.expectError(error.BadValue, decodeClient(@backingInt(ClientTag.pinch), &pinch)); std.mem.writeInt(u32, &pinch, @bitCast(std.math.inf(f32)), .little); - try testing.expectError(error.BadValue, decodeClient(@intFromEnum(ClientTag.touch_scroll), &pinch)); + try testing.expectError(error.BadValue, decodeClient(@backingInt(ClientTag.touch_scroll), &pinch)); } // A cell with the reserved attribute bit set, and one with an impossible // grapheme length. Both are bytes this protocol has no meaning for. diff --git a/src/diff.zig b/src/diff.zig index 362695d5..842a6b41 100644 --- a/src/diff.zig +++ b/src/diff.zig @@ -163,8 +163,8 @@ pub const Walk = struct { }; const meta_words = [_][]const u8{ - "index ", "new file mode ", "deleted file mode ", "old mode ", "new mode ", - "similarity index ", "rename from ", "rename to ", "copy from ", "copy to ", + "index ", "new file mode ", "deleted file mode ", "old mode ", "new mode ", + "similarity index ", "rename from ", "rename to ", "copy from ", "copy to ", "Binary files ", "dissimilarity ", }; diff --git a/src/draw.zig b/src/draw.zig index e6420ed4..22a8dc2a 100644 --- a/src/draw.zig +++ b/src/draw.zig @@ -564,7 +564,7 @@ pub fn render(p: *Pardes, arena: std.mem.Allocator) !*Surface { .accent = chrome.box, .sel_fg = p.theme().sel_fg, .sel_bg = p.theme().sel_bg, - .lift_style = @intFromEnum(liftStyle(p)), + .lift_style = @backingInt(liftStyle(p)), .rule_px = p.theme().rule_px orelse 2, .grip_border = boxBorder(p), .grip_focus_ring = chrome.box, @@ -1167,7 +1167,7 @@ fn renderHeaderLayer(p: *Pardes, arena: std.mem.Allocator, layer: *pardes.Layer, const start = modal.lineStartOffset(text, index + top); const end = start + shown.len; if (mine and swept.lo < swept.hi and swept.hi > start and swept.lo < end) { - const button = @intFromEnum(sweep.button); + const button = @backingInt(sweep.button); var col = panes.File.rawDisplayCol(shown, @max(swept.lo, start) - start) -| scroll; const stop = panes.File.rawDisplayCol(shown, @min(swept.hi, end) - start) -| scroll; while (col < stop and col < columns) : (col += 1) { diff --git a/src/dump.zig b/src/dump.zig index 545d09ec..76a6de85 100644 --- a/src/dump.zig +++ b/src/dump.zig @@ -1100,7 +1100,7 @@ test "a restored session's column and workspace tags take more than one selectio try std.testing.expect(restored.col_tags[0].reserveSels()); try std.testing.expect(restored.global_tag.reserveSels()); try std.testing.expect(restored.fs.started != 0); - const stat = th.call(restored, .{ .tag = 1, .op = .getattr, .node = @intFromEnum(pardes.ctlfs.TopFile.index) }); + const stat = th.call(restored, .{ .tag = 1, .op = .getattr, .node = @backingInt(pardes.ctlfs.TopFile.index) }); try std.testing.expect(stat.reply.attr.mtime != 0); } @@ -1146,7 +1146,7 @@ test "a pane restored with unsaved text is asked about by Exit, Restore, Del and const node = if (std.mem.eql(u8, word, "Del") or std.mem.eql(u8, word, "get")) ctlfs.Node.of(restored.panes[id].?.serial, .ctl) else - @intFromEnum(ctlfs.TopFile.ctl); + @backingInt(ctlfs.TopFile.ctl); const line = if (std.mem.eql(u8, word, "Restore")) try std.fmt.bufPrint(&restore_line, "Restore {s}/d.zon\n", .{dir}) else if (std.mem.eql(u8, word, "Exit")) "Exit\n" else if (std.mem.eql(u8, word, "Del")) "Del\n" else "get\n"; const answer = th.wr(restored, node, line); try std.testing.expectEqual(ctlfs.Status.err, answer.reply.status); diff --git a/src/edit_cmd.zig b/src/edit_cmd.zig index d3377e09..447ea66b 100644 --- a/src/edit_cmd.zig +++ b/src/edit_cmd.zig @@ -495,7 +495,7 @@ test "Edit , | sort runs off the loop, through the session's shell in the file's try testing.expectEqualStrings(@import("ninep/ctl.zig").e_after_edit, after.reply.ename); try testing.expect(p.pipe.edit_run == null and !th.logHas(p, "before")); } - try testing.expectEqual(tree.E.INVAL, th.wr(p, @intFromEnum(tree.TopFile.exec), "Msg before\nEdit , | sort\n").errno()); + try testing.expectEqual(tree.E.INVAL, th.wr(p, @backingInt(tree.TopFile.exec), "Msg before\nEdit , | sort\n").errno()); } test "the held write asked again is parked again, then answered once, and a flush stops the Edit" { diff --git a/src/esp32p4.zig b/src/esp32p4.zig index ed18efd9..683d19e1 100644 --- a/src/esp32p4.zig +++ b/src/esp32p4.zig @@ -134,19 +134,19 @@ pub const GpioFn = *const fn (ctx: ?*anyopaque, pin: u16, was: *u8, now: *u8) ca var host_alloc: Allocator = undefined; fn hostAlloc(_: *anyopaque, len: usize, alignment: std.mem.Alignment, _: usize) ?[*]u8 { - return host_alloc.alloc(host_alloc.ctx, len, @intFromEnum(alignment)); + return host_alloc.alloc(host_alloc.ctx, len, @backingInt(alignment)); } fn hostResize(_: *anyopaque, mem: []u8, alignment: std.mem.Alignment, new_len: usize, _: usize) bool { - return host_alloc.resize(host_alloc.ctx, mem.ptr, mem.len, @intFromEnum(alignment), new_len); + return host_alloc.resize(host_alloc.ctx, mem.ptr, mem.len, @backingInt(alignment), new_len); } fn hostRemap(_: *anyopaque, mem: []u8, alignment: std.mem.Alignment, new_len: usize, _: usize) ?[*]u8 { - return if (host_alloc.resize(host_alloc.ctx, mem.ptr, mem.len, @intFromEnum(alignment), new_len)) mem.ptr else null; + return if (host_alloc.resize(host_alloc.ctx, mem.ptr, mem.len, @backingInt(alignment), new_len)) mem.ptr else null; } fn hostFree(_: *anyopaque, mem: []u8, alignment: std.mem.Alignment, _: usize) void { - host_alloc.free(host_alloc.ctx, mem.ptr, mem.len, @intFromEnum(alignment)); + host_alloc.free(host_alloc.ctx, mem.ptr, mem.len, @backingInt(alignment)); } const host_vtable: std.mem.Allocator.VTable = .{ @@ -447,19 +447,21 @@ fn apply(c: *pardes.Pardes, ev: vaxis.Event) void { else => null, }; if (button) |b| { - c.update(.{ .mouse = .{ - .button = b, - .kind = switch (m.type) { - .press => .press, - .release => .release, - .motion => .motion, - .drag => .drag, + c.update(.{ + .mouse = .{ + .button = b, + .kind = switch (m.type) { + .press => .press, + .release => .release, + .motion => .motion, + .drag => .drag, + }, + // Before the first cell (a drag past the edge): the edge. + .col = @intCast(@max(0, m.col)), + .row = @intCast(@max(0, m.row)), + .ctrl = m.mods.ctrl, }, - // Before the first cell (a drag past the edge): the edge. - .col = @intCast(@max(0, m.col)), - .row = @intCast(@max(0, m.row)), - .ctrl = m.mods.ctrl, - } }); + }); dirty = true; } }, diff --git a/src/esp32p4/app.zig b/src/esp32p4/app.zig index 4ee131ec..800e7597 100644 --- a/src/esp32p4/app.zig +++ b/src/esp32p4/app.zig @@ -235,17 +235,17 @@ var gpa_heap: heapmod.Heap = undefined; fn cAlloc(_: ?*anyopaque, len: usize, log2_align: u8) callconv(.c) ?[*]u8 { const a = gpa_heap.allocator(); - return a.vtable.alloc(a.ptr, len, @enumFromInt(log2_align), @returnAddress()); + return a.vtable.alloc(a.ptr, len, @fromBackingInt(@intCast(log2_align)), @returnAddress()); } fn cResize(_: ?*anyopaque, ptr: [*]u8, len: usize, log2_align: u8, new_len: usize) callconv(.c) bool { const a = gpa_heap.allocator(); - return a.vtable.resize(a.ptr, ptr[0..len], @enumFromInt(log2_align), new_len, @returnAddress()); + return a.vtable.resize(a.ptr, ptr[0..len], @fromBackingInt(@intCast(log2_align)), new_len, @returnAddress()); } fn cFree(_: ?*anyopaque, ptr: [*]u8, len: usize, log2_align: u8) callconv(.c) void { const a = gpa_heap.allocator(); - a.vtable.free(a.ptr, ptr[0..len], @enumFromInt(log2_align), @returnAddress()); + a.vtable.free(a.ptr, ptr[0..len], @fromBackingInt(@intCast(log2_align)), @returnAddress()); } const editor_allocator: Allocator = .{ diff --git a/src/esp32p4_9p.zig b/src/esp32p4_9p.zig index cd59b9df..5fcab85b 100644 --- a/src/esp32p4_9p.zig +++ b/src/esp32p4_9p.zig @@ -103,7 +103,7 @@ fn die(msg: []const u8) noreturn { .{ .rerror = .{ .ename = msg[0..@min(msg.len, ninep.errmax)] } }, ninep.notag, &buf, - // unreachable: the message is cut to errmax and buf is sized to it + // unreachable: the message is cut to errmax and buf is sized to it ) catch unreachable; uart.write(bytes); while (true) {} diff --git a/src/fonts.zig b/src/fonts.zig index 098bf36f..88cde63a 100644 --- a/src/fonts.zig +++ b/src/fonts.zig @@ -324,7 +324,7 @@ fn sfntBase(head: []const u8) ?usize { fn scratchFont(buf: *[64:0]u8, ext: []const u8) [:0]const u8 { return std.fmt.bufPrintSentinel(buf, "/tmp/pardes-fonts-test-{d}{s}", .{ @as(u32, @intCast(libc.getpid())), ext, - // unreachable: 23 bytes, a u32 pid (10) and a short extension fit 64 + // unreachable: 23 bytes, a u32 pid (10) and a short extension fit 64 }, 0) catch unreachable; } diff --git a/src/gui/Post.zig b/src/gui/Post.zig index 8d0e14d9..17e8d7e9 100644 --- a/src/gui/Post.zig +++ b/src/gui/Post.zig @@ -623,15 +623,15 @@ test "the uniform block is ghostty's, offset for offset, and the prefix names it try std.testing.expectEqual(@offsetOf(GhosttyUniforms, "selection_background_color"), @offsetOf(Uniforms, "selection_foreground_color")); // The prefix's block, member by member, in ghostty's GLSL names and types. const glsl = [_]struct { []const u8, []const u8 }{ - .{ "vec3", "iResolution" }, .{ "float", "iTime" }, .{ "float", "iTimeDelta" }, - .{ "float", "iFrameRate" }, .{ "int", "iFrame" }, .{ "float", "iChannelTime[4]" }, - .{ "vec3", "iChannelResolution[4]" }, .{ "vec4", "iMouse" }, .{ "vec4", "iDate" }, - .{ "float", "iSampleRate" }, .{ "vec4", "iCurrentCursor" }, .{ "vec4", "iPreviousCursor" }, - .{ "vec4", "iCurrentCursorColor" }, .{ "vec4", "iPreviousCursorColor" }, .{ "int", "iCurrentCursorStyle" }, - .{ "int", "iPreviousCursorStyle" }, .{ "int", "iCursorVisible" }, .{ "float", "iTimeCursorChange" }, - .{ "float", "iTimeFocus" }, .{ "int", "iFocus" }, .{ "vec3", "iPalette[256]" }, - .{ "vec3", "iBackgroundColor" }, .{ "vec3", "iForegroundColor" }, .{ "vec3", "iCursorColor" }, - .{ "vec3", "iCursorText" }, .{ "vec3", "iSelectionForegroundColor" }, .{ "vec3", "iSelectionBackgroundColor" }, + .{ "vec3", "iResolution" }, .{ "float", "iTime" }, .{ "float", "iTimeDelta" }, + .{ "float", "iFrameRate" }, .{ "int", "iFrame" }, .{ "float", "iChannelTime[4]" }, + .{ "vec3", "iChannelResolution[4]" }, .{ "vec4", "iMouse" }, .{ "vec4", "iDate" }, + .{ "float", "iSampleRate" }, .{ "vec4", "iCurrentCursor" }, .{ "vec4", "iPreviousCursor" }, + .{ "vec4", "iCurrentCursorColor" }, .{ "vec4", "iPreviousCursorColor" }, .{ "int", "iCurrentCursorStyle" }, + .{ "int", "iPreviousCursorStyle" }, .{ "int", "iCursorVisible" }, .{ "float", "iTimeCursorChange" }, + .{ "float", "iTimeFocus" }, .{ "int", "iFocus" }, .{ "vec3", "iPalette[256]" }, + .{ "vec3", "iBackgroundColor" }, .{ "vec3", "iForegroundColor" }, .{ "vec3", "iCursorColor" }, + .{ "vec3", "iCursorText" }, .{ "vec3", "iSelectionForegroundColor" }, .{ "vec3", "iSelectionBackgroundColor" }, }; try std.testing.expectEqual(ours.field_names.len, glsl.len); // Its three blocks (Globals, Palette, Colors) read as one, in order. @@ -673,7 +673,6 @@ test "a moved cursor becomes the previous one, stamped with the time of the move try std.testing.expectEqual([4]f32{ 1.0 / 255.0, 2.0 / 255.0, 3.0 / 255.0, 1 }, post.uniforms.selection_foreground_color); } - test "a still pass asks for no idle frames; one that reads the clock does" { var post: Post = .{}; const fake: *Pipeline = @ptrFromInt(0x1000); diff --git a/src/gui/gui.zig b/src/gui/gui.zig index b8687fd3..f0dd0682 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -1888,7 +1888,6 @@ const Gui = struct { sel_glow: SelGlow = .{}, hover_glow: SelGlow = .{}, /// G14: the cells last drawn and when each last changed. - /// The cursor's blink (blinkNow): when the frame drawn last arrived, /// a redraw owed for an edge, and this frame's cursor mode and alpha. frame_arrival_ns: u64 = 0, @@ -2291,7 +2290,7 @@ fn setTransitionFields( instance.present_y0 = presented[1]; instance.present_x1 = presented[2]; instance.present_y1 = presented[3]; - instance.effect = @intFromEnum(active.effect); + instance.effect = @backingInt(active.effect); instance.progress_bits = @bitCast(active.amount()); instance.serial = active.serial; instance.cell_coord = cell_coord; @@ -3356,8 +3355,8 @@ fn setStdinRaw() !void { term.lflag.ICANON = false; term.lflag.IEXTEN = false; term.lflag.ISIG = false; - term.cc[@intFromEnum(posix.V.MIN)] = 1; - term.cc[@intFromEnum(posix.V.TIME)] = 0; + term.cc[@backingInt(posix.V.MIN)] = 1; + term.cc[@backingInt(posix.V.TIME)] = 0; try posix.tcsetattr(0, .NOW, term); } @@ -5484,7 +5483,6 @@ test "a notch scrolls the core at once and the picture glides after it, a wrappe try std.testing.expect(!g.glide.pending and !g.glide.moving()); } - fn resetScroll(g: *Gui) void { g.scroll_pane = null; g.scroll_delta = 0; @@ -5519,13 +5517,15 @@ fn stepScroll(g: *Gui, core: *pardes.Pardes, gpa: std.mem.Allocator) void { const down = left > 0; left += if (down) -1 else 1; const was = pane.scroll(); - core.update(.{ .mouse = .{ - .button = if (down) .wheel_down else .wheel_up, - .kind = .press, - .col = g.scroll_col, - .row = g.scroll_row, - .shift = true, // pardes's own scroll, never a program's wheel - } }); + core.update(.{ + .mouse = .{ + .button = if (down) .wheel_down else .wheel_up, + .kind = .press, + .col = g.scroll_col, + .row = g.scroll_row, + .shift = true, // pardes's own scroll, never a program's wheel + }, + }); if (pane.scroll() == was) { resetScroll(g); return; @@ -7251,7 +7251,7 @@ test "a rising pane past its mark stays inside its box" { var g: Gui = undefined; g.cell_w = 10; g.cell_h = 20; - var track: pardes.animation.Track = .{ .serial = 3, .phase = .opening, .effect = .vertical, .motion = @intFromEnum(pardes.animation.Motion.Flavour.bouncy) + 1, .frame_count = 20, .from = .{ .x = 0, .y = 10, .w = 40, .h = 10 }, .to = .{ .x = 0, .y = 0, .w = 40, .h = 10 } }; + var track: pardes.animation.Track = .{ .serial = 3, .phase = .opening, .effect = .vertical, .motion = @backingInt(pardes.animation.Motion.Flavour.bouncy) + 1, .frame_count = 20, .from = .{ .x = 0, .y = 10, .w = 40, .h = 10 }, .to = .{ .x = 0, .y = 0, .w = 40, .h = 10 } }; var peak: u16 = 0; var highest: f32 = 1e9; while (track.frame < track.frames()) : (track.frame += 1) { @@ -8788,7 +8788,6 @@ fn addPattern(g: *Gui, gpa: std.mem.Allocator, x0: f32, y0: f32, x1: f32, y1: f3 instance.effect |= checker_bit; } - /// How a lift of 0 to 1 stands off the page: the shadow's blur and offset /// in cell heights, and its darkest, where it leaves the caster's edge. /// Within §8.2's budget: sigma 0.4-0.8 cell, at most 30% darker at the edge. @@ -8926,7 +8925,6 @@ fn clipToBodies(g: *Gui, gpa: std.mem.Allocator, first: usize, bodies: []const [ }; } - /// Like shadowCeiling for a light colour laid over at `a` (sRGB blend, as /// the decor pipeline blends a colour that is not black): the largest `a` /// that keeps text and page apart by min(their contrast, 4.5). @@ -10099,7 +10097,7 @@ test "decor is read from the regions, each pane's in its own group" { try std.testing.expect(tracked.decor_count >= 4); try std.testing.expectEqual(still, groups.items[0].decor_count + tracked.decor_count); for (g.decor.items[tracked.decor_start..][0..tracked.decor_count]) |item| - try std.testing.expectEqual(@as(u32, @intFromEnum(pardes.animation.Transition.slide)), item.effect); + try std.testing.expectEqual(@as(u32, @backingInt(pardes.animation.Transition.slide)), item.effect); // Cursors stand still while panes move. try std.testing.expectEqual(@as(u32, 0), groups.items[groups.ink].decor_count); } @@ -10468,7 +10466,7 @@ fn appendCursorGlide(g: *Gui, surface: *const pardes.Surface, builder: *OverlayB fn appendWorkspacePet(g: *Gui, core: ?*const pardes.Pardes, surface: *const pardes.Surface, builder: *OverlayBuilder) void { const p = core orelse return; - const kind: pet.Kind = @enumFromInt(@intFromEnum(p.settings.pet)); + const kind: pet.Kind = @fromBackingInt(@intCast(@backingInt(p.settings.pet))); if (kind == .off or surface.rows == 0 or surface.cols == 0) { g.pet_state = .{}; return; diff --git a/src/host_io.zig b/src/host_io.zig index d789a77d..bef88172 100644 --- a/src/host_io.zig +++ b/src/host_io.zig @@ -572,7 +572,7 @@ pub const Shell = struct { const name = std.mem.sliceTo(@as([*:0]const u8, @ptrCast(&ent.name)), 0); const pid = rcPid(name) orelse continue; if (pid == std.c.getpid()) continue; - if (std.posix.errno(std.c.kill(pid, @enumFromInt(0))) != .SRCH) continue; + if (std.posix.errno(std.c.kill(pid, @fromBackingInt(@intCast(0)))) != .SRCH) continue; if (name.len >= 64 or n == dead.len) continue; @memcpy(dead[n][0..name.len], name); dead_len[n] = name.len; @@ -1236,8 +1236,8 @@ pub fn resetChildSignals() void { const default: posix.Sigaction = .{ .handler = .{ .handler = posix.SIG.DFL }, .mask = posix.sigemptyset(), .flags = 0 }; var sig: u8 = 1; while (sig < 65) : (sig += 1) { - if (sig == @intFromEnum(posix.SIG.KILL) or sig == @intFromEnum(posix.SIG.STOP)) continue; - _ = std.c.sigaction(@enumFromInt(sig), &default, null); + if (sig == @backingInt(posix.SIG.KILL) or sig == @backingInt(posix.SIG.STOP)) continue; + _ = std.c.sigaction(@fromBackingInt(@intCast(sig)), &default, null); } const none = posix.sigemptyset(); posix.sigprocmask(posix.SIG.SETMASK, &none, null); @@ -1620,13 +1620,13 @@ pub fn forkShell( if (pid == 0) { resetChildSignals(); if (cwd_z) |path| if (chdir(path.ptr) != 0) { - const why = [_]u8{ 'c', @truncate(@intFromEnum(libc.errno(@as(c_int, -1)))) }; + const why = [_]u8{ 'c', @truncate(@backingInt(libc.errno(@as(c_int, -1)))) }; _ = libc.write(told[1], &why, why.len); _exit(126); }; if (envp) |env| _ = execve(spawn.path, &spawn.argv, env); _ = execv(spawn.path, &spawn.argv); - const why = [_]u8{ 'x', @truncate(@intFromEnum(libc.errno(@as(c_int, -1)))) }; + const why = [_]u8{ 'x', @truncate(@backingInt(libc.errno(@as(c_int, -1)))) }; _ = libc.write(told[1], &why, why.len); _exit(127); } @@ -1643,7 +1643,7 @@ pub fn forkShell( if (failed) |why| { _ = libc.close(master); _ = libc.waitpid(pid, null, 0); - const e: libc.E = @enumFromInt(why[1]); + const e: libc.E = @fromBackingInt(@intCast(why[1])); if (why[0] == 'c') return if (e == .NOENT or e == .NOTDIR) error.FileNotFound else error.AccessDenied; return switch (e) { // Itself, or its script's interpreter: told apart by whether it @@ -2167,7 +2167,7 @@ pub fn reapExited(pid: libc.pid_t) ?struct { status: ?u8 } { if (got != pid) return .{ .status = null }; const s: u32 = @bitCast(status); if (libc.W.IFEXITED(s)) return .{ .status = @truncate(libc.W.EXITSTATUS(s)) }; - if (libc.W.IFSIGNALED(s)) return .{ .status = @truncate(128 + @as(u32, @intFromEnum(libc.W.TERMSIG(s)))) }; + if (libc.W.IFSIGNALED(s)) return .{ .status = @truncate(128 + @as(u32, @backingInt(libc.W.TERMSIG(s)))) }; return .{ .status = null }; } @@ -2194,7 +2194,7 @@ pub fn exitStatus(pid: libc.pid_t, wait_ms: u32) ?u8 { if (got == pid) { const s: u32 = @bitCast(status); if (libc.W.IFEXITED(s)) return @truncate(libc.W.EXITSTATUS(s)); - if (libc.W.IFSIGNALED(s)) return @truncate(128 + @as(u32, @intFromEnum(libc.W.TERMSIG(s)))); + if (libc.W.IFSIGNALED(s)) return @truncate(128 + @as(u32, @backingInt(libc.W.TERMSIG(s)))); return null; } if (got < 0 or waited >= wait_ms) return null; @@ -2722,8 +2722,8 @@ test "a retired shell that ignores the hangup is killed and reaped, not left a z retireShell(pid); // A zombie still answers kill(pid, 0); only a reaped pid is gone. var waited: i64 = 0; - while (libc.kill(pid, @enumFromInt(0)) == 0 and waited < 2000) : (waited += 10) sleepMs(10); - try std.testing.expect(libc.kill(pid, @enumFromInt(0)) != 0); + while (libc.kill(pid, @fromBackingInt(@intCast(0))) == 0 and waited < 2000) : (waited += 10) sleepMs(10); + try std.testing.expect(libc.kill(pid, @fromBackingInt(@intCast(0))) != 0); try std.testing.expect(waited >= 90); // it did ignore the hangup } diff --git a/src/linux/v9fs.zig b/src/linux/v9fs.zig index 15945e7b..0d1e2e33 100644 --- a/src/linux/v9fs.zig +++ b/src/linux/v9fs.zig @@ -89,7 +89,7 @@ var sudo_pid: std.atomic.Value(c_int) = .init(-1); fn forwardSignal(sig: std.posix.SIG) callconv(.c) void { const pid = sudo_pid.load(.monotonic); - if (pid > 0) _ = kill(pid, @intCast(@intFromEnum(sig))); + if (pid > 0) _ = kill(pid, @intCast(@backingInt(sig))); } fn launch(arena: std.mem.Allocator, args: []const [:0]const u8) !u8 { @@ -123,8 +123,8 @@ fn launch(arena: std.mem.Allocator, args: []const [:0]const u8) !u8 { const default: std.posix.Sigaction = .{ .handler = .{ .handler = std.posix.SIG.DFL }, .mask = std.posix.sigemptyset(), .flags = 0 }; var sig: u8 = 1; while (sig < 65) : (sig += 1) { - if (sig == @intFromEnum(std.posix.SIG.KILL) or sig == @intFromEnum(std.posix.SIG.STOP)) continue; - _ = std.c.sigaction(@enumFromInt(sig), &default, null); + if (sig == @backingInt(std.posix.SIG.KILL) or sig == @backingInt(std.posix.SIG.STOP)) continue; + _ = std.c.sigaction(@fromBackingInt(@intCast(sig)), &default, null); } const none = std.posix.sigemptyset(); std.posix.sigprocmask(std.posix.SIG.SETMASK, &none, null); diff --git a/src/look.zig b/src/look.zig index f9c470cf..f4fbe52e 100644 --- a/src/look.zig +++ b/src/look.zig @@ -2555,7 +2555,7 @@ test "every entry point to Look takes one expansion: a diff line and a file:12:5 const line = modal.lineSlice(case.text, case.row); // A diff line written whole; a place, as a script writes it. const written = if (std.mem.eql(u8, case.name, "change.diff")) line else line[case.sweep[0] .. case.sweep[1] + 1]; - _ = th.wr(p, @intFromEnum(pardes.ctlfs.TopFile.look), written); + _ = th.wr(p, @backingInt(pardes.ctlfs.TopFile.look), written); }, .event_write_back => { const body = pane.file.?.content; diff --git a/src/macos.zig b/src/macos.zig index 37db0abd..21af41ae 100644 --- a/src/macos.zig +++ b/src/macos.zig @@ -1717,18 +1717,20 @@ fn mouseWithHit(button_arg: c_int, kind_arg: c_int, col: u16, row: u16, mods: u3 3 => .drag, else => return, }; - st.core.update(.{ .mouse = .{ - .body_hit = hit, - .tag_hit = tag_hit, - .button = button, - .kind = kind, - .col = col, - .row = row, - .ctrl = mods & 1 != 0, - // Option-click is B2 and Cmd-click B3 (mouse.emulateButton). - .alt = mods & 2 != 0, - .super = mods & 8 != 0, - } }); + st.core.update(.{ + .mouse = .{ + .body_hit = hit, + .tag_hit = tag_hit, + .button = button, + .kind = kind, + .col = col, + .row = row, + .ctrl = mods & 1 != 0, + // Option-click is B2 and Cmd-click B3 (mouse.emulateButton). + .alt = mods & 2 != 0, + .super = mods & 8 != 0, + }, + }); } export fn pardes_pointer_leave() void { @@ -2156,7 +2158,7 @@ export fn pardes_tag_layer_value(index: u32, field: u32) u32 { const layer = &st.core.surface.tag_layers[index]; return switch (field) { 0 => layer.cols, - 1 => @intFromEnum(layer.kind), + 1 => @backingInt(layer.kind), 2 => layer.id, 3 => layer.serial, 4 => layer.viewport.x, @@ -2238,7 +2240,7 @@ export fn pardes_pointer_shape() u32 { pardes.turn.wake(); defer pardes.turn.rest(); const st = &(state orelse return 0); - return @intFromEnum(st.core.surface.pointer_shape); + return @backingInt(st.core.surface.pointer_shape); } export fn pardes_cursor_y() i32 { @@ -2646,7 +2648,7 @@ fn encodeAttrs(style: pardes.CellStyle) u16 { attrs |= @as(u16, @intFromBool(style.reverse)) << 4; attrs |= @as(u16, @intFromBool(style.invisible)) << 5; attrs |= @as(u16, @intFromBool(style.strikethrough)) << 6; - attrs |= @as(u16, @intFromEnum(style.ul)) << 8; + attrs |= @as(u16, @backingInt(style.ul)) << 8; return attrs; } @@ -2896,21 +2898,21 @@ test "pardes.h matches the Zig boundary" { try expectEqual(@as(u8, c.PARDES_CELL_HOVER), cell_flag_hover); try expectEqual(@as(u16, c.PARDES_TOPBAR_H), pardes.TOPBAR_H); try expectEqual(@as(u32, c.PARDES_SCENE_CRT), scene_flag_crt); - try expectEqual(@as(u8, c.PARDES_PANEL_OPENING), @intFromEnum(animation.Phase.opening)); - try expectEqual(@as(u8, c.PARDES_PANEL_MOVING), @intFromEnum(animation.Phase.moving)); - try expectEqual(@as(u8, c.PARDES_PANEL_CLOSING), @intFromEnum(animation.Phase.closing)); - try expectEqual(@as(u8, c.PARDES_PANEL_OFF), @intFromEnum(animation.Transition.off)); - try expectEqual(@as(u8, c.PARDES_PANEL_SLIDE), @intFromEnum(animation.Transition.slide)); - try expectEqual(@as(u8, c.PARDES_PANEL_ZOOM), @intFromEnum(animation.Transition.zoom)); - try expectEqual(@as(u8, c.PARDES_PANEL_DISSOLVE), @intFromEnum(animation.Transition.dissolve)); - try expectEqual(@as(u8, c.PARDES_PANEL_ASCII), @intFromEnum(animation.Transition.ascii)); - try expectEqual(@as(u8, c.PARDES_PANEL_VERTICAL), @intFromEnum(animation.Transition.vertical)); - try expectEqual(@as(u8, c.PARDES_PANEL_EDGES), @intFromEnum(animation.Transition.edges)); - try expectEqual(@as(u8, c.PARDES_PANEL_FALL), @intFromEnum(animation.Transition.fall)); - try expectEqual(@as(u8, c.PARDES_PANEL_WAVE), @intFromEnum(animation.Transition.wave)); - try expectEqual(@as(u8, c.PARDES_PANEL_CURTAIN), @intFromEnum(animation.Transition.curtain)); - try expectEqual(@as(u8, c.PARDES_PANEL_SCRAMBLE), @intFromEnum(animation.Transition.scramble)); - try expectEqual(@as(u8, c.PARDES_PANEL_TYPEWRITER), @intFromEnum(animation.Transition.typewriter)); + try expectEqual(@as(u8, c.PARDES_PANEL_OPENING), @backingInt(animation.Phase.opening)); + try expectEqual(@as(u8, c.PARDES_PANEL_MOVING), @backingInt(animation.Phase.moving)); + try expectEqual(@as(u8, c.PARDES_PANEL_CLOSING), @backingInt(animation.Phase.closing)); + try expectEqual(@as(u8, c.PARDES_PANEL_OFF), @backingInt(animation.Transition.off)); + try expectEqual(@as(u8, c.PARDES_PANEL_SLIDE), @backingInt(animation.Transition.slide)); + try expectEqual(@as(u8, c.PARDES_PANEL_ZOOM), @backingInt(animation.Transition.zoom)); + try expectEqual(@as(u8, c.PARDES_PANEL_DISSOLVE), @backingInt(animation.Transition.dissolve)); + try expectEqual(@as(u8, c.PARDES_PANEL_ASCII), @backingInt(animation.Transition.ascii)); + try expectEqual(@as(u8, c.PARDES_PANEL_VERTICAL), @backingInt(animation.Transition.vertical)); + try expectEqual(@as(u8, c.PARDES_PANEL_EDGES), @backingInt(animation.Transition.edges)); + try expectEqual(@as(u8, c.PARDES_PANEL_FALL), @backingInt(animation.Transition.fall)); + try expectEqual(@as(u8, c.PARDES_PANEL_WAVE), @backingInt(animation.Transition.wave)); + try expectEqual(@as(u8, c.PARDES_PANEL_CURTAIN), @backingInt(animation.Transition.curtain)); + try expectEqual(@as(u8, c.PARDES_PANEL_SCRAMBLE), @backingInt(animation.Transition.scramble)); + try expectEqual(@as(u8, c.PARDES_PANEL_TYPEWRITER), @backingInt(animation.Transition.typewriter)); try expectEqual(@as(u21, c.PARDES_KEY_ENTER), pardes.Key.enter); try expectEqual(@as(u21, c.PARDES_KEY_ESCAPE), pardes.Key.escape); @@ -2926,24 +2928,24 @@ test "pardes.h matches the Zig boundary" { try expectEqual(@as(u21, c.PARDES_KEY_PAGE_DOWN), pardes.Key.page_down); try expectEqual(@as(u21, c.PARDES_KEY_DELETE), pardes.Key.delete); - try expectEqual(c.PARDES_MOUSE_LEFT, @intFromEnum(pardes.Mouse.Button.left)); - try expectEqual(c.PARDES_MOUSE_MIDDLE, @intFromEnum(pardes.Mouse.Button.middle)); - try expectEqual(c.PARDES_MOUSE_RIGHT, @intFromEnum(pardes.Mouse.Button.right)); - try expectEqual(c.PARDES_MOUSE_WHEEL_UP, @intFromEnum(pardes.Mouse.Button.wheel_up)); - try expectEqual(c.PARDES_MOUSE_WHEEL_DOWN, @intFromEnum(pardes.Mouse.Button.wheel_down)); - try expectEqual(c.PARDES_MOUSE_WHEEL_LEFT, @intFromEnum(pardes.Mouse.Button.wheel_left)); - try expectEqual(c.PARDES_MOUSE_WHEEL_RIGHT, @intFromEnum(pardes.Mouse.Button.wheel_right)); - try expectEqual(c.PARDES_MOUSE_NONE, @intFromEnum(pardes.Mouse.Button.none)); - try expectEqual(c.PARDES_MOUSE_BACK, @intFromEnum(pardes.Mouse.Button.back)); - try expectEqual(c.PARDES_MOUSE_FORWARD, @intFromEnum(pardes.Mouse.Button.forward)); - try expectEqual(c.PARDES_MOUSE_PRESS, @intFromEnum(pardes.Mouse.Kind.press)); - try expectEqual(c.PARDES_MOUSE_RELEASE, @intFromEnum(pardes.Mouse.Kind.release)); - try expectEqual(c.PARDES_MOUSE_MOTION, @intFromEnum(pardes.Mouse.Kind.motion)); - try expectEqual(c.PARDES_MOUSE_DRAG, @intFromEnum(pardes.Mouse.Kind.drag)); - - try expectEqual(c.PARDES_HAPTIC_NONE, @intFromEnum(pardes.Haptic.none)); - try expectEqual(c.PARDES_HAPTIC_EXEC, @intFromEnum(pardes.Haptic.exec)); - try expectEqual(c.PARDES_HAPTIC_LOOK, @intFromEnum(pardes.Haptic.look)); + try expectEqual(c.PARDES_MOUSE_LEFT, @backingInt(pardes.Mouse.Button.left)); + try expectEqual(c.PARDES_MOUSE_MIDDLE, @backingInt(pardes.Mouse.Button.middle)); + try expectEqual(c.PARDES_MOUSE_RIGHT, @backingInt(pardes.Mouse.Button.right)); + try expectEqual(c.PARDES_MOUSE_WHEEL_UP, @backingInt(pardes.Mouse.Button.wheel_up)); + try expectEqual(c.PARDES_MOUSE_WHEEL_DOWN, @backingInt(pardes.Mouse.Button.wheel_down)); + try expectEqual(c.PARDES_MOUSE_WHEEL_LEFT, @backingInt(pardes.Mouse.Button.wheel_left)); + try expectEqual(c.PARDES_MOUSE_WHEEL_RIGHT, @backingInt(pardes.Mouse.Button.wheel_right)); + try expectEqual(c.PARDES_MOUSE_NONE, @backingInt(pardes.Mouse.Button.none)); + try expectEqual(c.PARDES_MOUSE_BACK, @backingInt(pardes.Mouse.Button.back)); + try expectEqual(c.PARDES_MOUSE_FORWARD, @backingInt(pardes.Mouse.Button.forward)); + try expectEqual(c.PARDES_MOUSE_PRESS, @backingInt(pardes.Mouse.Kind.press)); + try expectEqual(c.PARDES_MOUSE_RELEASE, @backingInt(pardes.Mouse.Kind.release)); + try expectEqual(c.PARDES_MOUSE_MOTION, @backingInt(pardes.Mouse.Kind.motion)); + try expectEqual(c.PARDES_MOUSE_DRAG, @backingInt(pardes.Mouse.Kind.drag)); + + try expectEqual(c.PARDES_HAPTIC_NONE, @backingInt(pardes.Haptic.none)); + try expectEqual(c.PARDES_HAPTIC_EXEC, @backingInt(pardes.Haptic.exec)); + try expectEqual(c.PARDES_HAPTIC_LOOK, @backingInt(pardes.Haptic.look)); try expectEqual(@as(u16, c.PARDES_ATTR_BOLD), encodeAttrs(.{ .bold = true })); try expectEqual(@as(u16, c.PARDES_ATTR_DIM), encodeAttrs(.{ .dim = true })); diff --git a/src/main.zig b/src/main.zig index e3bae75f..64614daa 100644 --- a/src/main.zig +++ b/src/main.zig @@ -499,7 +499,7 @@ fn nativeMain(init: std.process.Init) !void { if (!outside) { const owner = std.mem.span(std.c.getenv("PARDES_PID") orelse break :forwarding); const pid = std.fmt.parseInt(std.c.pid_t, owner, 10) catch break :forwarding; - if (pid <= 0 or std.c.kill(pid, @enumFromInt(0)) != 0) break :forwarding; + if (pid <= 0 or std.c.kill(pid, @fromBackingInt(@intCast(0))) != 0) break :forwarding; } // Can I reach it? That is the other two, and it is a separate answer. diff --git a/src/mini.zig b/src/mini.zig index 8af64201..ce291c99 100644 --- a/src/mini.zig +++ b/src/mini.zig @@ -130,7 +130,7 @@ pub fn generate(gpa: std.mem.Allocator, source: []const u8, styles: []const u8) if (source.len > max_input_bytes) return error.MiniTooLarge; if (!std.unicode.utf8ValidateSlice(source)) return error.InvalidUtf8; if (styles.len != 0 and styles.len != source.len) return error.InvalidMiniColors; - for (styles) |color| if (color > @intFromEnum(syntax.Syn.comment)) return error.InvalidMiniColors; + for (styles) |color| if (color > @backingInt(syntax.Syn.comment)) return error.InvalidMiniColors; const len = try render(null, source, styles); const content = try gpa.alloc(u8, len); errdefer gpa.free(content); @@ -248,17 +248,17 @@ test "Mini chooses highlighted dots over plain ink with stable color ties" { const gpa = std.testing.allocator; const source = "xx\nxx\nxx\nxx\n"; var styles: [source.len]u8 = @splat(0); - styles[0] = @intFromEnum(syntax.Syn.keyword); + styles[0] = @backingInt(syntax.Syn.keyword); const rare = try generate(gpa, source, &styles); defer rare.deinit(gpa); try std.testing.expectEqualStrings("⣿\n", rare.content); try std.testing.expectEqualSlices(u8, &.{ 1, 1, 1, 0 }, rare.colors); - styles[0] = @intFromEnum(syntax.Syn.string); - styles[1] = @intFromEnum(syntax.Syn.number); + styles[0] = @backingInt(syntax.Syn.string); + styles[1] = @backingInt(syntax.Syn.number); const tied = try generate(gpa, source, &styles); defer tied.deinit(gpa); try std.testing.expectEqualSlices(u8, &.{ 2, 2, 2, 0 }, tied.colors); - styles[3] = @intFromEnum(syntax.Syn.number); + styles[3] = @backingInt(syntax.Syn.number); const majority = try generate(gpa, source, &styles); defer majority.deinit(gpa); try std.testing.expectEqualSlices(u8, &.{ 3, 3, 3, 0 }, majority.colors); diff --git a/src/mouse.zig b/src/mouse.zig index 536a4fdb..43323f9a 100644 --- a/src/mouse.zig +++ b/src/mouse.zig @@ -379,7 +379,7 @@ fn programMouse(p: *Pardes, m: Mouse) bool { .none => null, else => return false, }; - const bit: u3 = if (button) |b| @as(u3, 1) << @intCast(@intFromEnum(b)) else 0; + const bit: u3 = if (button) |b| @as(u3, 1) << @intCast(@backingInt(b)) else 0; const at = p.presentation.pointer(p.screen_w, p.screen_h, @min(m.col, p.screen_w -| 1), @min(m.row, p.screen_h -| 1)); var mods: panes.terminal.MouseMods = .{ .shift = m.shift, .alt = m.alt, .ctrl = m.ctrl }; var buf: [64]u8 = undefined; @@ -701,7 +701,7 @@ pub fn handleMouse(p: *Pardes, event: Mouse) void { // look; the rest of the gesture is inert if (p.drag == .select and p.drag.select.button == config.look_button) { if (p.panes[p.drag.select.id]) |t| { - t.sel[@intFromEnum(config.look_button)].state = .none; + t.sel[@backingInt(config.look_button)].state = .none; if (comptime pdf_enabled) panes.Pdf.pointerCancel(t, p.drag.select.pdf); } @@ -812,7 +812,7 @@ pub fn handleMouse(p: *Pardes, event: Mouse) void { // an execute or look drag cancels it (textselect23's mask) if (p.drag == .select) { if (p.panes[p.drag.select.id]) |t| { - t.sel[@intFromEnum(p.drag.select.button)].state = .none; + t.sel[@backingInt(p.drag.select.button)].state = .none; if (comptime pdf_enabled) panes.Pdf.pointerCancel(t, p.drag.select.pdf); } @@ -833,8 +833,8 @@ pub fn handleMouse(p: *Pardes, event: Mouse) void { pane.scrollBy(if (m.button == config.look_button) local else -local); } else if (edit.pointerTextSelection(p, id, mcol, mrow, m.body_hit, p.pointer_tag_hit)) |pointed| { if (m.button == config.look_button) p.active = id; - pane.clearPointerSelection(@intFromEnum(m.button)); - pane.sel[@intFromEnum(m.button)] = pointed.sel; + pane.clearPointerSelection(@backingInt(m.button)); + pane.sel[@backingInt(m.button)] = pointed.sel; p.drag = .{ .select = .{ .id = id, @@ -906,7 +906,7 @@ pub fn dragUpdate(p: *Pardes, mcol: u16, mrow: u16, body_hit: ?Mouse.BodyHit) vo .select => |*s| { if (p.panes[s.id]) |pane| { const r = p.rects[s.id]; - const b = @intFromEnum(s.button); + const b = @backingInt(s.button); const tag_rows: i32 = pane.tag_rows; if (pane.body_rows > 0 and pane.sel[b].r0 >= tag_rows) if (body_hit) |supplied| { const mapped_hit = bodyHitForPane(p, s.id, supplied, true) orelse return; @@ -1235,10 +1235,10 @@ fn dragRelease(p: *Pardes, button: Mouse.Button) void { } if (s.chorded) { // a cut/paste chord consumed this drag; the release is inert - pane.sel[@intFromEnum(s.button)].state = .none; + pane.sel[@backingInt(s.button)].state = .none; return; } - const b = @intFromEnum(s.button); + const b = @backingInt(s.button); pane.sel[b].state = .done; if (s.button == config.select_button) { const sl = pane.sel[sel_slot]; @@ -1501,7 +1501,7 @@ test "plain left click clears explicit modal selection" { try std.testing.expectEqual(@as(i32, 3), pane.body.cur_col); try std.testing.expect(!pane.body.vsel.active); try std.testing.expect(!pane.body.msel.active); - try std.testing.expectEqual(.none, pane.sel[@intFromEnum(config.select_button)].state); + try std.testing.expectEqual(.none, pane.sel[@backingInt(config.select_button)].state); } test "selection drag and queued release do not enter panel pending state" { diff --git a/src/ninep/addr.zig b/src/ninep/addr.zig index 3feda5a2..86d2d49e 100644 --- a/src/ninep/addr.zig +++ b/src/ninep/addr.zig @@ -638,9 +638,9 @@ test "the address language, form by form" { } // Each failure says which it is. for ([_][2][]const u8{ - .{ "zzz", e_syntax }, .{ "/nomatch/", e_no_match }, .{ "99", e_range }, - .{ "#999", e_range }, .{ "/a[/", e_regexp }, .{ "/(a/", e_regexp }, - .{ "/*a/", e_regexp }, .{ "99:1", e_range }, .{ "2:0", e_col_zero }, + .{ "zzz", e_syntax }, .{ "/nomatch/", e_no_match }, .{ "99", e_range }, + .{ "#999", e_range }, .{ "/a[/", e_regexp }, .{ "/(a/", e_regexp }, + .{ "/*a/", e_regexp }, .{ "99:1", e_range }, .{ "2:0", e_col_zero }, }) |c| { _ = th.wr(p, addr, "#0"); try testing.expectEqualStrings(c[1], th.wr(p, addr, c[0]).reply.ename); diff --git a/src/ninep/cols.zig b/src/ninep/cols.zig index 59f6ae42..6f5bee23 100644 --- a/src/ninep/cols.zig +++ b/src/ninep/cols.zig @@ -34,7 +34,7 @@ pub fn writeLayout(p: *Pardes, w: *std.Io.Writer) !void { const active = activeColumn(p); for (0..p.ncol) |c| { try w.print("{d} {d} {d} {d} {s} {s}", .{ - layout.columnSerial(p, c), c, p.col_x[c], p.col_w[c], + layout.columnSerial(p, c), c, p.col_x[c], p.col_w[c], if (active == c) "current" else "notcurrent", if (p.col_n[c] == 0) "empty" else "full", }); for (p.col_panes[c][0..p.col_n[c]]) |id| if (p.panes[id]) |pane| try w.print(" {d}", .{pane.serial}); @@ -229,8 +229,8 @@ test "Joincol is refused when the joined column cannot give each pane its tag an const p = try pardes.Pardes.init(testing.allocator, .{ .tty_only = true, .cols = 160, .rows = 12 }); defer p.deinit(); while (p.nextEffect()) |_| {} - const ctl = @intFromEnum(tree.TopFile.ctl); - const focus = @intFromEnum(tree.TopFile.focus); + const ctl = @backingInt(tree.TopFile.ctl); + const focus = @backingInt(tree.TopFile.focus); // Two panes in the first column, then a second column of two. const a = try th.newPane(p); _ = a; @@ -257,10 +257,10 @@ test "pane/new takes rows from a pane in another column before refusing ENOSPC" while (p.nextEffect()) |_| {} const first = p.panes[p.active].?.serial; // A second column holding one tall pane. - try testing.expectEqual(tree.Status.ok, th.wr(p, @intFromEnum(tree.TopFile.ctl), "Newcol\n").reply.status); + try testing.expectEqual(tree.Status.ok, th.wr(p, @backingInt(tree.TopFile.ctl), "Newcol\n").reply.status); const tall = try th.newPane(p); const tall_col = layout.findPane(p, p.paneBySerial(tall).?).?.col; - const focus = @intFromEnum(tree.TopFile.focus); + const focus = @backingInt(tree.TopFile.focus); var digits: [16]u8 = undefined; // From the first column, until pane/new is refused. var moved = false; @@ -289,7 +289,7 @@ test "exactly 4096 bytes written with echo's newline after a truncation fit ever defer p.deinit(); const serial = th.serialOf(p); const text = &@as([4096]u8, @splat('w')) ++ "\n"; - for ([_]u64{ tree.Node.of(serial, .tag), tree.Node.ofCol(layout.columnSerial(p, 0), .tag), @intFromEnum(tree.TopFile.tag) }) |node| { + for ([_]u64{ tree.Node.of(serial, .tag), tree.Node.ofCol(layout.columnSerial(p, 0), .tag), @backingInt(tree.TopFile.tag) }) |node| { _ = th.call(p, .{ .tag = 1, .op = .setattr, .node = node, .truncate = true }); const h = th.call(p, .{ .tag = 2, .op = .open, .node = node, .omode = 1 }).reply.handle; const r = th.call(p, .{ .tag = 3, .op = .write, .node = node, .handle = h, .data = text }); @@ -320,8 +320,8 @@ test "a Newcol refused because the tags would not fit logs its err alone and spe } try testing.expect(p.col_n[col] >= 2); p.sync(); - const ctl = @intFromEnum(tree.TopFile.ctl); - const focus = @intFromEnum(tree.TopFile.focus); + const ctl = @backingInt(tree.TopFile.ctl); + const focus = @backingInt(tree.TopFile.focus); var digits: [16]u8 = undefined; const own = try std.fmt.bufPrint(&digits, "{d}\n", .{pane.serial}); var refused = false; @@ -349,7 +349,7 @@ test "a Newcol refused because the tags would not fit logs its err alone and spe test "a tagexec word that makes, acts on and focuses no pane reads back nothing" { const p = try th.withFile(testing.allocator, "x\n"); defer p.deinit(); - const tagexec = @intFromEnum(tree.TopFile.tagexec); + const tagexec = @backingInt(tree.TopFile.tagexec); try testing.expectEqual(tree.Status.ok, th.wr(p, tagexec, "Newcol\n").reply.status); try testing.expectEqualStrings("", th.rd(p, tagexec, 0, 64).bytes); // A column's New makes one, and answers it. @@ -362,7 +362,7 @@ test "a tagexec word that makes, acts on and focuses no pane reads back nothing" test "New written to a column's ctl reads back the new pane alone, as its exec does" { const p = try th.withFile(testing.allocator, "x\n"); defer p.deinit(); - const root_exec = @intFromEnum(tree.TopFile.exec); + const root_exec = @backingInt(tree.TopFile.exec); _ = th.wr(p, root_exec, "Msg before\n"); const ctl_node = tree.Node.ofCol(layout.columnSerial(p, 0), .ctl); try testing.expectEqual(tree.Status.ok, th.wr(p, ctl_node, "New\n").reply.status); @@ -390,7 +390,7 @@ test "a pane's word written to /tagexec or a column's exec is refused, and acts const p = try th.withFile(testing.allocator, "x\n"); defer p.deinit(); const col_exec = tree.Node.ofCol(layout.columnSerial(p, 0), .exec); - for ([_]u64{ @intFromEnum(tree.TopFile.tagexec), col_exec }) |node| { + for ([_]u64{ @backingInt(tree.TopFile.tagexec), col_exec }) |node| { for ([_][]const u8{ "Undo\n", "Msg hi\n", "Redo\n" }) |line| { const refused = th.wr(p, node, line); try testing.expectEqual(E.INVAL, refused.errno()); @@ -411,7 +411,7 @@ test "Help and Find at /tagexec act in the session's directory, not the keyboard const session = buf[0..try tmp.dir.realPath(testing.io, &buf)]; @memcpy(p.session_dir[0..session.len], session); p.session_dir_len = @intCast(session.len); - const tagexec = @intFromEnum(tree.TopFile.tagexec); + const tagexec = @backingInt(tree.TopFile.tagexec); for ([_][]const u8{ "Help\n", "Find needle\n" }) |line| { try testing.expectEqual(tree.Status.ok, th.wr(p, tagexec, line).reply.status); const made = p.panes[p.active].?.file.?.path; @@ -427,7 +427,7 @@ test "a shell command at /tagexec or a column's exec is a command pane in the se const term = p.panes[p.active].?; try testing.expect(pardes.exec.takesCommandLine(p, p.active)); const col_exec = tree.Node.ofCol(layout.columnSerial(p, 0), .exec); - for ([_]u64{ @intFromEnum(tree.TopFile.tagexec), col_exec }) |node| { + for ([_]u64{ @backingInt(tree.TopFile.tagexec), col_exec }) |node| { p.active = p.paneBySerial(term.serial).?; const before = p.next_serial; const r = th.wr(p, node, "echo from-the-tag\n"); @@ -443,7 +443,7 @@ test "a shell command at /tagexec or a column's exec is a command pane in the se test "New and Tty run at /tagexec and a column's exec, with no pane at all too" { const p = try th.withFile(testing.allocator, "x\n"); defer p.deinit(); - const tagexec = @intFromEnum(tree.TopFile.tagexec); + const tagexec = @backingInt(tree.TopFile.tagexec); const col_exec = tree.Node.ofCol(layout.columnSerial(p, 0), .exec); for ([_]u64{ tagexec, col_exec }) |node| for ([_][]const u8{ "New\n", "Tty\n" }) |line| { const before = p.next_serial; @@ -469,7 +469,7 @@ test "every pane word a tag no pane owns does not hold is refused there, Edit in const Builtin = pardes.builtins.registry.Builtin(); const col_exec = tree.Node.ofCol(layout.columnSerial(p, 0), .exec); for ([_]struct { node: u64, own: []const u8 }{ - .{ .node = @intFromEnum(tree.TopFile.tagexec), .own = pardes.config.topbar_str }, + .{ .node = @backingInt(tree.TopFile.tagexec), .own = pardes.config.topbar_str }, .{ .node = col_exec, .own = tagline.column_tag_default }, }) |tag_file| { var checked: usize = 0; @@ -517,7 +517,7 @@ test "layout lists each column's place, panes and state, and the active one" { const first_serial = layout.columnSerial(p, 0); const new_serial = layout.columnSerial(p, 1); try testing.expect(first_serial != new_serial); - const layout_node = @intFromEnum(tree.TopFile.layout); + const layout_node = @backingInt(tree.TopFile.layout); const text = th.rd(p, layout_node, 0, 4096).bytes; var want: [256]u8 = undefined; const first = try std.fmt.bufPrint(&want, "{d} 0 {d} {d} notcurrent full {d}\n", .{ first_serial, p.col_x[0], p.col_w[0], p.panes[0].?.serial }); @@ -528,19 +528,19 @@ test "layout lists each column's place, panes and state, and the active one" { try testing.expect(text.len > 0); try testing.expectEqual(@as(u64, 0), th.call(p, .{ .tag = 1, .op = .getattr, .node = layout_node }).reply.attr.size); // generated by each read // /index says which column each pane is in, by its serial, last. - try testing.expect(std.mem.endsWith(u8, th.rd(p, @intFromEnum(tree.TopFile.index), 0, 4096).bytes, try std.fmt.bufPrint(&want, " {d}\n", .{first_serial}))); + try testing.expect(std.mem.endsWith(u8, th.rd(p, @backingInt(tree.TopFile.index), 0, 4096).bytes, try std.fmt.bufPrint(&want, " {d}\n", .{first_serial}))); try testing.expect(th.logHas(p, try std.fmt.bufPrint(&want, "newcol {d}\n", .{new_serial}))); // A column that closes takes its name with it; the others keep theirs. try p.removeColumn(1); try testing.expect(th.logHas(p, try std.fmt.bufPrint(&want, "delcol {d}\n", .{new_serial}))); - try testing.expectEqual(E.NOENT, th.look_up(p, @intFromEnum(tree.TopFile.col), try std.fmt.bufPrint(&want, "{d}", .{new_serial})).errno()); + try testing.expectEqual(E.NOENT, th.look_up(p, @backingInt(tree.TopFile.col), try std.fmt.bufPrint(&want, "{d}", .{new_serial})).errno()); try testing.expectEqual(first_serial, layout.columnSerial(p, 0)); } test "a column's tag and the workspace's read, replace and append as a pane tag does, on one line" { const p = try th.withFile(testing.allocator, "x\n"); defer p.deinit(); - const col_dir = @intFromEnum(tree.TopFile.col); + const col_dir = @backingInt(tree.TopFile.col); const serial = layout.columnSerial(p, 0); var name: [16]u8 = undefined; try testing.expectEqual(tree.Status.ok, th.look_up(p, col_dir, try std.fmt.bufPrint(&name, "{d}", .{serial})).reply.status); @@ -557,7 +557,7 @@ test "a column's tag and the workspace's read, replace and append as a pane tag // `>>` appends; a newline in a one-line tag is a space. _ = th.wr(p, tag, " Lint\nNow"); try testing.expectEqualStrings("Make Lint Now", th.rd(p, tag, 0, 4096).bytes); - const top = @intFromEnum(tree.TopFile.tag); + const top = @backingInt(tree.TopFile.tag); _ = th.call(p, .{ .tag = 3, .op = .setattr, .node = top, .truncate = true }); _ = th.wr(p, top, "Newcol Exit\n"); try testing.expectEqualStrings("Newcol Exit", tagline.topbar(p)); @@ -574,11 +574,11 @@ test "a focus write makes its pane's column the active one: layout says so and p p.sync(); try testing.expectEqual(@as(usize, 1), layout.findPane(p, p.active).?.col); var digits: [16]u8 = undefined; - _ = th.wr(p, @intFromEnum(tree.TopFile.focus), try std.fmt.bufPrint(&digits, "{d}\n", .{left})); + _ = th.wr(p, @backingInt(tree.TopFile.focus), try std.fmt.bufPrint(&digits, "{d}\n", .{left})); var want: [32]u8 = undefined; - const text = th.rd(p, @intFromEnum(tree.TopFile.layout), 0, 4096).bytes; + const text = th.rd(p, @backingInt(tree.TopFile.layout), 0, 4096).bytes; try testing.expect(std.mem.endsWith(u8, text, try std.fmt.bufPrint(&want, "active {d}\n", .{layout.columnSerial(p, 0)}))); - const made = th.call(p, .{ .tag = 1, .op = .open, .node = @intFromEnum(tree.TopFile.new) }).reply.handle; + const made = th.call(p, .{ .tag = 1, .op = .open, .node = @backingInt(tree.TopFile.new) }).reply.handle; try testing.expectEqual(@as(usize, 0), layout.findPane(p, p.paneBySerial(made).?).?.col); } } @@ -590,7 +590,7 @@ test "a refused write after a truncation leaves every kind of tag as it was, and const col = layout.columnSerial(p, 0); const big = &@as([limits.max_tag_tail + 1]u8, @splat('w')); // Each tag: a truncating open, then a write too long: nothing changes. - for ([_]u64{ Node.of(serial, .tag), Node.ofCol(col, .tag), @intFromEnum(tree.TopFile.tag) }) |node| { + for ([_]u64{ Node.of(serial, .tag), Node.ofCol(col, .tag), @backingInt(tree.TopFile.tag) }) |node| { _ = th.wr(p, node, " Mine"); const before = try testing.allocator.dupe(u8, th.rd(p, node, 0, 1 << 16).bytes); defer testing.allocator.free(before); @@ -651,13 +651,13 @@ test "a column's ctl and exec act on it as its tag would, and rmdir closes it on try testing.expectEqual(@as(?usize, 0), layout.columnBySerial(p, right)); try testing.expect(std.mem.endsWith(u8, headerText(p, right).?, " Mine")); // The root's ctl points a column word at the column's own. - try testing.expect(std.mem.endsWith(u8, th.wr(p, @intFromEnum(tree.TopFile.ctl), "Delcol\n").reply.ename, "write it to col//ctl")); + try testing.expect(std.mem.endsWith(u8, th.wr(p, @backingInt(tree.TopFile.ctl), "Delcol\n").reply.ename, "write it to col//ctl")); } test "tagexec runs a word as a click in the workspace tag; exec files read back what they touched; their messages are the session's" { const p = try th.withFile(testing.allocator, "x\n"); defer p.deinit(); - const tagexec = @intFromEnum(tree.TopFile.tagexec); + const tagexec = @backingInt(tree.TopFile.tagexec); try testing.expectEqual(tree.Status.ok, th.look_up(p, tree.root, "tagexec").reply.status); try testing.expectEqual(tree.Status.ok, th.wr(p, tagexec, "Newcol\n").reply.status); try testing.expectEqual(@as(usize, 2), p.ncol); @@ -680,7 +680,7 @@ test "a word run from the workspace's or a column's tag runs in the session's di defer p.deinit(); const session = p.sessionDir(); try testing.expect(!std.mem.eql(u8, session, pardes.Pardes.paneDir(p.panes[0].?))); // the file is elsewhere - const dirs = [_]u64{ @intFromEnum(tree.TopFile.tagexec), Node.ofCol(layout.columnSerial(p, 0), .exec) }; + const dirs = [_]u64{ @backingInt(tree.TopFile.tagexec), Node.ofCol(layout.columnSerial(p, 0), .exec) }; for (dirs) |node| { try testing.expectEqual(tree.Status.ok, th.wr(p, node, "true\n").reply.status); const made = p.paneBySerial(p.fs.results[0]).?; diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 6b4bbafb..3e7c367b 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -1277,15 +1277,15 @@ const withFile = th.withFile; const serialOf = th.serialOf; const Node = tree.Node; const Status = tree.Status; -const root_status = @intFromEnum(tree.TopFile.status); -const root_look = @intFromEnum(tree.TopFile.look); -const root_exec = @intFromEnum(tree.TopFile.exec); +const root_status = @backingInt(tree.TopFile.status); +const root_look = @backingInt(tree.TopFile.look); +const root_exec = @backingInt(tree.TopFile.exec); test "a control character in a write to any ctl refuses the whole write, and a quoted line shows a tab as a blank" { const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); const col = layout.columnSerial(p, 0); - for ([_]u64{ @intFromEnum(tree.TopFile.ctl), Node.of(serialOf(p), .ctl), Node.ofCol(col, .ctl) }) |node| { + for ([_]u64{ @backingInt(tree.TopFile.ctl), Node.of(serialOf(p), .ctl), Node.ofCol(col, .ctl) }) |node| { const r = wr(p, node, "Wrap off\nbo\x01gus\n"); try testing.expectEqual(E.INVAL, r.errno()); try testing.expectEqualStrings(e_control, r.reply.ename); @@ -1325,7 +1325,7 @@ test "pane ctl read is acme's fields -- index's five, width in cells, font, tab test "commands lists every builtin with its argument and the ctl that takes it" { const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); - const node = @intFromEnum(tree.TopFile.commands); + const node = @backingInt(tree.TopFile.commands); const listed = rd(p, node, 0, 1 << 16); try testing.expectEqual(@as(u64, listed.bytes.len), call(p, .{ .tag = 1, .op = .getattr, .node = node }).reply.attr.size); try testing.expectEqual(E.PERM, wr(p, node, "Del\n").errno()); @@ -1372,7 +1372,7 @@ test "focus reads the pane with the keyboard, and a serial written to it moves t defer p.deinit(); const first = serialOf(p); const second = try th.newPane(p); - const focus = @intFromEnum(tree.TopFile.focus); + const focus = @backingInt(tree.TopFile.focus); var line: [16]u8 = undefined; try testing.expectEqualStrings(try std.fmt.bufPrint(&line, "{d}\n", .{second}), rd(p, focus, 0, 64).bytes); try testing.expectEqual(@as(u64, rd(p, focus, 0, 64).bytes.len), call(p, .{ .tag = 1, .op = .getattr, .node = focus }).reply.attr.size); @@ -1447,7 +1447,7 @@ test "the root ctl reads the settings as a write takes them, and takes the sessi const gpa = testing.allocator; const p = try withFile(gpa, "x\n"); defer p.deinit(); - const root_ctl = @intFromEnum(tree.TopFile.ctl); + const root_ctl = @backingInt(tree.TopFile.ctl); const first = rd(p, root_ctl, 0, 1 << 16); try testing.expectEqual(Status.ok, first.reply.status); const settings = try gpa.dupe(u8, first.bytes); @@ -1575,7 +1575,7 @@ test "a write of an Edit block carries it whole, to a pane's ctl, the root's ctl try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .ctl), "Edit ,x/foo/{\ni/[/\na/]/\n}\n").reply.status); try testing.expectEqualStrings("[foo] x\n[foo] y\n", rd(p, body, 0, 64).bytes); p.active = p.paneBySerial(serial).?; - try testing.expectEqual(Status.ok, wr(p, @intFromEnum(tree.TopFile.ctl), "Edit ,x/\\[/{\nc/ 0); - try testing.expectEqual(@as(u64, 0), call(p, .{ .tag = 1, .op = .getattr, .node = @intFromEnum(tree.TopFile.index) }).reply.attr.size); + try testing.expectEqual(@as(u64, 0), call(p, .{ .tag = 1, .op = .getattr, .node = @backingInt(tree.TopFile.index) }).reply.attr.size); // Its tag never carries the raw newline either. const tag = rd(p, Node.of(serialOf(p), .tag), 0, 4096).bytes; try testing.expect(std.mem.indexOf(u8, tag, "/tmp/two\\nlines") != null); // A backslash of the name's own is doubled: `\n` written in a name // reads back unlike a newline. p.setCwd(term, "/tmp/back\\nslash"); - try testing.expect(std.mem.indexOf(u8, rd(p, @intFromEnum(tree.TopFile.index), 0, 4096).bytes, "/tmp/back\\\\nslash") != null); + try testing.expect(std.mem.indexOf(u8, rd(p, @backingInt(tree.TopFile.index), 0, 4096).bytes, "/tmp/back\\\\nslash") != null); } test "a look at a ./ or ../ name that is not there is a miss naming the file; a plain one is looked for as text" { @@ -3766,7 +3766,7 @@ test "a served-tree pane spoils no Grep, and Look . from a gone directory is ENO test "a tag write refuses NUL and the other control characters" { const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); - for ([_]u64{ @intFromEnum(tree.TopFile.tag), tree.Node.ofCol(pardes.layout.columnSerial(p, 0), .tag), Node.of(serialOf(p), .tag) }) |node| { + for ([_]u64{ @backingInt(tree.TopFile.tag), tree.Node.ofCol(pardes.layout.columnSerial(p, 0), .tag), Node.of(serialOf(p), .tag) }) |node| { const refused = wr(p, node, " a\x00b"); try testing.expectEqual(E.INVAL, refused.errno()); try testing.expectStringStartsWith(refused.reply.ename, "invalid tag text"); @@ -3815,7 +3815,7 @@ test "a column takes panes until their documented minimums fill it, not until no const p = try Pardes.init(testing.allocator, .{ .tty_only = true, .cols = 160, .rows = 50 }); defer p.deinit(); while (p.nextEffect()) |_| {} - const new = @intFromEnum(tree.TopFile.new); + const new = @backingInt(tree.TopFile.new); while (call(p, .{ .tag = 1, .op = .open, .node = new }).reply.status == .ok) p.sync(); p.sync(); const avail = p.screen_h - (p.topBarHeight() + p.columnBarHeight()); @@ -3913,13 +3913,13 @@ test "a closed file is found again: Recent and /recent list it closed, a look at const opened = p.active; try testing.expectEqualStrings(a, p.panes[opened].?.file.?.path); var want: [4300]u8 = undefined; - try testing.expect(std.mem.indexOf(u8, rd(p, @intFromEnum(tree.TopFile.recent), 0, 8192).bytes, try std.fmt.bufPrint(&want, "open {s}\n", .{a})) != null); + try testing.expect(std.mem.indexOf(u8, rd(p, @backingInt(tree.TopFile.recent), 0, 8192).bytes, try std.fmt.bufPrint(&want, "open {s}\n", .{a})) != null); // Another file, so the jumplist has somewhere to come back from. try testing.expectEqual(Status.ok, wr(p, root_look, try std.fmt.bufPrint(&line, "{s}/b.txt\n", .{dir})).reply.status); p.sync(); try testing.expectEqual(Status.ok, wr(p, Node.of(p.panes[opened].?.serial, .ctl), "Del\n").reply.status); p.sync(); - try testing.expect(std.mem.indexOf(u8, rd(p, @intFromEnum(tree.TopFile.recent), 0, 8192).bytes, try std.fmt.bufPrint(&want, "closed {s}\n", .{a})) != null); + try testing.expect(std.mem.indexOf(u8, rd(p, @backingInt(tree.TopFile.recent), 0, 8192).bytes, try std.fmt.bufPrint(&want, "closed {s}\n", .{a})) != null); // Recent lists it, closed, at its dot; a look at the row opens it there. try testing.expectEqual(Status.ok, wr(p, root_exec, "Recent\n").reply.status); const rows = p.panes[p.paneBySerial(try std.fmt.parseInt(u32, std.mem.trimEnd(u8, rd(p, root_exec, 0, 64).bytes, "\n"), 10)).?].?; @@ -4045,8 +4045,8 @@ test "Back and Forward written to exec keep to the focused file, and JumpScope a .{ .word = "Forward", .file = "/b.txt", .line = 80 }, .{ .word = "Forward", .file = "/a.txt", .line = 80 }, }); - try testing.expectEqual(Status.ok, wr(p, @intFromEnum(tree.TopFile.ctl), "JumpScope all\n").reply.status); - try testing.expect(std.mem.indexOf(u8, rd(p, @intFromEnum(tree.TopFile.ctl), 0, 8192).bytes, "JumpScope all\n") != null); + try testing.expectEqual(Status.ok, wr(p, @backingInt(tree.TopFile.ctl), "JumpScope all\n").reply.status); + try testing.expect(std.mem.indexOf(u8, rd(p, @backingInt(tree.TopFile.ctl), 0, 8192).bytes, "JumpScope all\n") != null); try walk(p, &.{ .{ .word = "Back", .file = "/b.txt", .line = 80 }, .{ .word = "Back", .file = "/a.txt", .line = 40 }, @@ -4102,14 +4102,14 @@ test "a new file saved shows in /recent, open, while it is" { try testing.expectEqual(Status.ok, wr(p, Node.of(made, .ctl), "Save\n").reply.status); p.perform(.{ .save_file = .{ .pane = @intCast(p.paneBySerial(made).?) } }); var want: [4300]u8 = undefined; - try testing.expect(std.mem.indexOf(u8, rd(p, @intFromEnum(tree.TopFile.recent), 0, 8192).bytes, try std.fmt.bufPrint(&want, "open {s}\n", .{path})) != null); + try testing.expect(std.mem.indexOf(u8, rd(p, @backingInt(tree.TopFile.recent), 0, 8192).bytes, try std.fmt.bufPrint(&want, "open {s}\n", .{path})) != null); } test "/recent shows a name as /index does, a newline in it escaped" { const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); p.recent.opened(p.recentGpa(), "/tmp/a\nb\\c"); - const text = rd(p, @intFromEnum(tree.TopFile.recent), 0, 8192).bytes; + const text = rd(p, @backingInt(tree.TopFile.recent), 0, 8192).bytes; try testing.expect(std.mem.indexOf(u8, text, "closed /tmp/a\\nb\\\\c\n") != null); } @@ -4191,8 +4191,8 @@ test "size is monotonic: growing is never refused, and a size once taken is take defer p.deinit(); while (p.nextEffect()) |_| {} p.unattended = true; - const root_ctl = @intFromEnum(tree.TopFile.ctl); - const new = @intFromEnum(tree.TopFile.new); + const root_ctl = @backingInt(tree.TopFile.ctl); + const new = @backingInt(tree.TopFile.new); // The dogfood's repro: Newcol, three pane/new, a Tty, then pane/new // until a column has no room (ENOSPC). try testing.expectEqual(Status.ok, wr(p, root_ctl, "Newcol\n").reply.status); @@ -4283,7 +4283,7 @@ test "a file changed on disk under unsaved edits is not reloaded: it says so, ge var want: [32]u8 = undefined; try testing.expect(th.logHas(p, try std.fmt.bufPrint(&want, "changed {d}\n", .{serial}))); // Exit and get still ask about the edits. - try testing.expectEqual(Status.err, wr(p, @intFromEnum(tree.TopFile.ctl), "Exit\n").reply.status); + try testing.expectEqual(Status.err, wr(p, @backingInt(tree.TopFile.ctl), "Exit\n").reply.status); try testing.expect(std.mem.indexOf(u8, wr(p, Node.of(serial, .ctl), "get\n").reply.ename, "Modified") != null); // Save warns once before overwriting the newer file, then writes. const first = wr(p, Node.of(serial, .ctl), "Save\n"); @@ -4328,7 +4328,7 @@ test "a looked word is found in its own pane, next place after the dot, wrapping test "every word's /commands description is its own doc comment's first sentence, no citation" { const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); - const listed = rd(p, @intFromEnum(tree.TopFile.commands), 0, 1 << 16).bytes; + const listed = rd(p, @backingInt(tree.TopFile.commands), 0, 1 << 16).bytes; for ([_][]const u8{ "\nRepl arg pane -- Binds this terminal as a language's REPL, so an exec on that language's files is typed into it instead of run.\n", "\nJoincol root -- Fold the active pane's column into the one on its right, keeping its panes.\n", @@ -4374,7 +4374,7 @@ test "Newcol at the column cap fails the write and says the cap" { const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); p.update(.{ .resize = .{ .cols = 4000, .rows = 30 } }); - const root_ctl = @intFromEnum(tree.TopFile.ctl); + const root_ctl = @backingInt(tree.TopFile.ctl); while (p.ncol < pardes.MAX_COLS) { // From the widest column's tag, so no column gets too narrow first. p.sync(); @@ -4403,7 +4403,7 @@ test "Save on a terminal asked over 9P is an ask in the log, answered with a pat try testing.expect(p.panes[id].?.prompt == .save); // Again: the one open stands, one ask in the log. _ = wr(p, Node.of(serial, .tagexec), "Save\n"); - const log = @intFromEnum(tree.TopFile.log); + const log = @backingInt(tree.TopFile.log); const h = call(p, .{ .tag = 1, .op = .open, .node = log }).reply.handle; try testing.expectEqual(@as(usize, 1), std.mem.count(u8, call(p, .{ .tag = 2, .op = .read, .node = log, .handle = h, .size = 1 << 16 }).bytes, "save path\n")); _ = call(p, .{ .tag = 3, .op = .release, .node = log, .handle = h }); @@ -4429,7 +4429,7 @@ test "get names the path it could not read, logs the edits it threw away, and a pardes.panes.File.deleted(p, 0); pardes.panes.File.deleted(p, 0); var rec: [32]u8 = undefined; - const log = @intFromEnum(tree.TopFile.log); + const log = @backingInt(tree.TopFile.log); const h = call(p, .{ .tag = 1, .op = .open, .node = log }).reply.handle; try testing.expectEqual(@as(usize, 1), std.mem.count(u8, call(p, .{ .tag = 2, .op = .read, .node = log, .handle = h, .size = 1 << 16 }).bytes, try std.fmt.bufPrint(&rec, "changed {d} deleted\n", .{serial}))); _ = call(p, .{ .tag = 3, .op = .release, .node = log, .handle = h }); @@ -4441,12 +4441,12 @@ test "a builtin that fails through exec, tagexec or a column's exec fails the wr p.update(.tick); // the pane's `new` is logged first while (p.nextEffect()) |_| {} const serial = serialOf(p); - for ([_]u64{ root_exec, Node.of(serial, .exec), @intFromEnum(tree.TopFile.tagexec), Node.ofCol(pardes.layout.columnSerial(p, 0), .exec) }) |node| { + for ([_]u64{ root_exec, Node.of(serial, .exec), @backingInt(tree.TopFile.tagexec), Node.ofCol(pardes.layout.columnSerial(p, 0), .exec) }) |node| { const failed = wr(p, node, "Unmount zzz\n"); try testing.expectEqual(Status.err, failed.reply.status); try testing.expect(std.mem.indexOf(u8, failed.reply.ename, "Unmount: no such mount zzz") != null); } - const log = @intFromEnum(tree.TopFile.log); + const log = @backingInt(tree.TopFile.log); const h = call(p, .{ .tag = 1, .op = .open, .node = log }).reply.handle; const text = call(p, .{ .tag = 2, .op = .read, .node = log, .handle = h, .size = 1 << 16 }).bytes; try testing.expect(std.mem.indexOf(u8, text, "msg ") == null); @@ -4458,11 +4458,11 @@ test "a builtin that fails through exec, tagexec or a column's exec fails the wr // A control character is refused with its reason. try testing.expectEqualStrings(e_control, wr(p, root_exec, "Msg a\x01b\n").reply.ename); // A look miss: one err, no msg. - _ = wr(p, @intFromEnum(tree.TopFile.look), "zzqqnotthere\n"); + _ = wr(p, @backingInt(tree.TopFile.look), "zzqqnotthere\n"); try testing.expect(th.logHas(p, "look: no match for \"zzqqnotthere\"")); try testing.expect(!th.logHas(p, "msg 1 Look: no match")); // The same miss again is that record counted, as any repeated err is. - _ = wr(p, @intFromEnum(tree.TopFile.look), "zzqqnotthere\n"); + _ = wr(p, @backingInt(tree.TopFile.look), "zzqqnotthere\n"); try testing.expect(th.logHas(p, "look: no match for \"zzqqnotthere\" (x2)\n")); } @@ -4483,7 +4483,7 @@ test "@p:
takes any sam address; a miss and an unknown serial a const p = try withFile(testing.allocator, "foo x foo y\nbar\n"); defer p.deinit(); const serial = serialOf(p); - const root = @intFromEnum(tree.TopFile.look); + const root = @backingInt(tree.TopFile.look); const dot = Node.of(serial, .dot); const Case = struct { addr: []const u8, want: []const u8 }; for ([_]Case{ @@ -4544,7 +4544,7 @@ test "@p:
takes any address over the terminal's lines, select const id = p.paneBySerial(serial).?; p.update(.{ .output = .{ .pane = @intCast(id), .bytes = "one\r\ntwo MARK three\r\n" } }); const pane = p.panes[id].?; - const root = @intFromEnum(tree.TopFile.look); + const root = @backingInt(tree.TopFile.look); var line: [64]u8 = undefined; try testing.expectEqual(Status.ok, wr(p, root, try std.fmt.bufPrint(&line, "@p{d}:0/MARK/\n", .{serial})).reply.status); try testing.expectEqual(@as(i32, 1), pane.body.cur_row); @@ -4576,7 +4576,7 @@ test "a bad command inside an Edit block written whole is named, not the } after test "a refused Delcol changes nothing: no pane, no focus" { const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); - _ = wr(p, @intFromEnum(tree.TopFile.ctl), "Newcol\n"); + _ = wr(p, @backingInt(tree.TopFile.ctl), "Newcol\n"); const made = try th.newPane(p); _ = wr(p, Node.of(made, .name), "/tmp/pardes-delcol-refused.txt\n"); _ = wr(p, Node.of(made, .body), "edit\n"); @@ -4599,8 +4599,8 @@ test "a refused Delcol changes nothing: no pane, no focus" { test "pager answers its +Pager on the open that asked, whatever another client exec'd meanwhile" { const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); - const pager = @intFromEnum(tree.TopFile.pager); - const exec = @intFromEnum(tree.TopFile.exec); + const pager = @backingInt(tree.TopFile.pager); + const exec = @backingInt(tree.TopFile.exec); const asked = call(p, .{ .tag = 1, .op = .open, .node = pager, .omode = 2 }).reply.handle; try testing.expectEqual(Status.ok, call(p, .{ .tag = 2, .op = .write, .node = pager, .handle = asked, .data = "/tmp\n" }).reply.status); const paged = for (p.panes) |slot| { @@ -4653,7 +4653,7 @@ test "pager answers its +Pager on the open that asked, whatever another client e test "what a /pager open writes after its directory is the text: plain in the body, its colours the pane's, clean, in by the read" { const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); - const pager = @intFromEnum(tree.TopFile.pager); + const pager = @backingInt(tree.TopFile.pager); const asked = call(p, .{ .tag = 1, .op = .open, .node = pager, .omode = 2 }).reply.handle; // The directory and the text's start in one write, escapes and all, a // second line no directory; the rest in writes after it. @@ -4812,7 +4812,7 @@ test "a second LookWord list look in a directory refills its +Search rather than const path = try std.fmt.bufPrint(&path_buf, "{s}/words.txt", .{dir}); const p = try Pardes.init(gpa, .{ .file = path, .tty_only = true, .cols = 80, .rows = 30 }); defer p.deinit(); - _ = wr(p, @intFromEnum(tree.TopFile.ctl), "LookWord list\n"); + _ = wr(p, @backingInt(tree.TopFile.ctl), "LookWord list\n"); pardes.look.lookAt(p, 0, "alpha"); pardes.look.lookAt(p, 0, "beta"); var searches: usize = 0; @@ -4986,7 +4986,7 @@ test "DumpDir refuses a relative directory and one that may not be written, up f if (comptime !pardes.hosted) return; const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); - const root_ctl = @intFromEnum(tree.TopFile.ctl); + const root_ctl = @backingInt(tree.TopFile.ctl); try testing.expectEqual(E.INVAL, wr(p, root_ctl, "DumpDir dumps\n").errno()); try testing.expectEqual(E.INVAL, wr(p, root_ctl, "DumpDir /proc/1/root/dumps\n").errno()); try testing.expectEqual(Status.ok, wr(p, root_ctl, "DumpDir /tmp/pardes-dumps-test\n").reply.status); @@ -4998,7 +4998,7 @@ test "DumpDir refuses a relative directory and one that may not be written, up f test "a Mount dial with a network it does not know is a bad dial address, EINVAL" { const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); - const r = wr(p, @intFromEnum(tree.TopFile.ctl), "Mount peer nowhere!x\n"); + const r = wr(p, @backingInt(tree.TopFile.ctl), "Mount peer nowhere!x\n"); try testing.expectEqual(E.INVAL, r.errno()); try testing.expectStringStartsWith(r.reply.ename, "Mount: bad dial address: nowhere!x"); } @@ -5056,11 +5056,11 @@ test "a Mount of a socket path that is not there says no such socket, ENOENT" { if (comptime !pardes.hosted) return; const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); - const r = wr(p, @intFromEnum(tree.TopFile.ctl), "Mount peer unix!/tmp/pardes-surely-no-socket\n"); + const r = wr(p, @backingInt(tree.TopFile.ctl), "Mount peer unix!/tmp/pardes-surely-no-socket\n"); try testing.expectEqual(E.NOENT, r.errno()); try testing.expect(std.mem.indexOf(u8, r.reply.ename, "no such socket") != null); try testing.expectEqual(@as(usize, 0), p.fs.mounts.items.len); - try testing.expectEqual(E.INVAL, wr(p, @intFromEnum(tree.TopFile.ctl), "Mount peer rel/x.sock\n").errno()); + try testing.expectEqual(E.INVAL, wr(p, @backingInt(tree.TopFile.ctl), "Mount peer rel/x.sock\n").errno()); } test "the init file reads past a BOM, and every line it fails is a notice and an err, never silent" { diff --git a/src/ninep/events.zig b/src/ninep/events.zig index 7b73dc0e..78788c3c 100644 --- a/src/ninep/events.zig +++ b/src/ninep/events.zig @@ -542,7 +542,7 @@ pub const Action = enum(u8) { tag_exec = 'x', pub fn char(a: Action) u8 { - return @intFromEnum(a); + return @backingInt(a); } pub fn fromChar(c: u8) ?Action { @@ -550,7 +550,7 @@ pub const Action = enum(u8) { } pub fn onTag(a: Action) bool { - return @intFromEnum(a) >= 'a'; + return @backingInt(a) >= 'a'; } }; @@ -889,7 +889,7 @@ test "a stream read at an offset inside its last answer gets the rest of it agai defer p.deinit(); p.update(.tick); while (p.nextEffect()) |_| {} - const log = @intFromEnum(tree.TopFile.log); + const log = @backingInt(tree.TopFile.log); const f = call(p, .{ .tag = 1, .op = .open, .node = log }).reply.handle; const frozen: u64 = call(p, .{ .tag = 2, .op = .read, .node = log, .handle = f, .size = 8192 }).bytes.len; _ = call(p, .{ .tag = 3, .op = .write, .node = log, .handle = f, .data = "follow" }); @@ -897,7 +897,7 @@ test "a stream read at an offset inside its last answer gets the rest of it agai notePath(p, "dump", "/b"); const Read = struct { fn at(pp: *Pardes, h: u32, off: u64) []const u8 { - return call(pp, .{ .tag = 4, .op = .read, .node = @intFromEnum(tree.TopFile.log), .handle = h, .off = off, .size = 128 }).bytes; + return call(pp, .{ .tag = 4, .op = .read, .node = @backingInt(tree.TopFile.log), .handle = h, .off = off, .size = 128 }).bytes; } }; try testing.expectEqualStrings("dump /a\n", Read.at(p, f, frozen)); @@ -1130,7 +1130,7 @@ test "writing an event record back performs the action it names" { // A look written back sets what look reads back. _ = wr(p, event, "FL0 3\n"); var want_serial: [16]u8 = undefined; - try testing.expectEqualStrings(try std.fmt.bufPrint(&want_serial, "{d}\n", .{serial}), rd(p, @intFromEnum(tree.TopFile.look), 0, 64).bytes); + try testing.expectEqualStrings(try std.fmt.bufPrint(&want_serial, "{d}\n", .{serial}), rd(p, @backingInt(tree.TopFile.look), 0, 64).bytes); // Well formed but past the text: said so, not "bad event syntax". try testing.expectEqualStrings("range past end of body", wr(p, event, "MX0 999\n").reply.ename); @@ -1144,7 +1144,7 @@ test "the log records whether or not anyone reads, and an open that follows wait const gpa = testing.allocator; const p = try withFile(gpa, "logged\n"); defer p.deinit(); - const log = @intFromEnum(tree.TopFile.log); + const log = @backingInt(tree.TopFile.log); var expected: [4200]u8 = undefined; // Nobody holds /log open, and the pane is recorded anyway. @@ -1256,21 +1256,21 @@ test "a refused or failed write is an err record in the log, saying which file a p.update(.tick); // the pane's `new` is logged before the log is opened while (p.nextEffect()) |_| {} const serial = serialOf(p); - const log = @intFromEnum(tree.TopFile.log); + const log = @backingInt(tree.TopFile.log); const f = call(p, .{ .tag = 1, .op = .open, .node = log }).reply.handle; const frozen = call(p, .{ .tag = 2, .op = .read, .node = log, .handle = f, .size = 1 << 16 }).bytes.len; _ = call(p, .{ .tag = 3, .op = .write, .node = log, .handle = f, .data = "follow" }); var want: [128]u8 = undefined; const next = struct { fn record(pp: *Pardes, h: u32, off: usize) []const u8 { - return call(pp, .{ .tag = 4, .op = .read, .node = @intFromEnum(tree.TopFile.log), .handle = h, .off = off, .size = 4096 }).bytes; + return call(pp, .{ .tag = 4, .op = .read, .node = @backingInt(tree.TopFile.log), .handle = h, .off = off, .size = 4096 }).bytes; } }; _ = wr(p, Node.of(serial, .addr), "/nowhere/"); try testing.expectEqualStrings(try std.fmt.bufPrint(&want, "err {d} addr: no match for regexp\n", .{serial}), next.record(p, f, frozen)); - _ = wr(p, @intFromEnum(tree.TopFile.ctl), "Bogus"); + _ = wr(p, @backingInt(tree.TopFile.ctl), "Bogus"); try testing.expectEqualStrings("err - ctl: unknown control message \"Bogus\"\n", next.record(p, f, frozen)); - _ = wr(p, @intFromEnum(tree.TopFile.focus), "99999"); + _ = wr(p, @backingInt(tree.TopFile.focus), "99999"); try testing.expectEqualStrings("err - focus: no such pane\n", next.record(p, f, frozen)); // A write that succeeds says nothing. _ = wr(p, Node.of(serial, .addr), "#0"); @@ -1373,7 +1373,7 @@ test "opens of the log share the open records, and a closed one frees its record const gpa = testing.allocator; const p = try withFile(gpa, "x\n"); defer p.deinit(); - const log = @intFromEnum(tree.TopFile.log); + const log = @backingInt(tree.TopFile.log); var handles: [tree.open_slots]u32 = undefined; for (&handles) |*h| h.* = call(p, .{ .tag = 1, .op = .open, .node = log }).reply.handle; try testing.expectEqual(E.NFILE, call(p, .{ .tag = 2, .op = .open, .node = log }).errno()); @@ -1447,7 +1447,7 @@ test "follow new skips what the log held and waits for what comes after" { p.update(.tick); // the pane's `new` is logged first while (p.nextEffect()) |_| {} p.setMessage(0, "before the open"); - const log = @intFromEnum(tree.TopFile.log); + const log = @backingInt(tree.TopFile.log); const h = call(p, .{ .tag = 1, .op = .open, .node = log }).reply.handle; try testing.expectEqual(Status.ok, call(p, .{ .tag = 2, .op = .write, .node = log, .handle = h, .data = "follow new\n" }).reply.status); try testing.expectEqual(Status.again, call(p, .{ .tag = 3, .op = .read, .node = log, .handle = h, .size = 4096 }).reply.status); @@ -1461,7 +1461,7 @@ test "a long msg record is cut between words at its cap, with an ellipsis" { defer p.deinit(); const long = std.mem.asBytes(&@as([60][5]u8, @splat("word ".*))); // 300 bytes _ = wr(p, Node.of(serialOf(p), .ctl), "Msg " ++ long ++ "\n"); - const log = @intFromEnum(tree.TopFile.log); + const log = @backingInt(tree.TopFile.log); const h = call(p, .{ .tag = 1, .op = .open, .node = log }).reply.handle; const text = call(p, .{ .tag = 2, .op = .read, .node = log, .handle = h, .size = 1 << 16 }).bytes; const at = std.mem.lastIndexOf(u8, text, "msg ").?; @@ -1485,8 +1485,8 @@ test "a record is one line of UTF-8: DEL and C1 are spaces, bytes not UTF-8 are test "a long err record keeps its end, its middle given up to an ellipsis" { const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); - _ = wr(p, @intFromEnum(tree.TopFile.ctl), "Bogus" ++ std.mem.asBytes(&@as([40][8]u8, @splat("abcdefgh".*))) ++ "\n"); - const log = @intFromEnum(tree.TopFile.log); + _ = wr(p, @backingInt(tree.TopFile.ctl), "Bogus" ++ std.mem.asBytes(&@as([40][8]u8, @splat("abcdefgh".*))) ++ "\n"); + const log = @backingInt(tree.TopFile.log); const h = call(p, .{ .tag = 1, .op = .open, .node = log }).reply.handle; const text = call(p, .{ .tag = 2, .op = .read, .node = log, .handle = h, .size = 1 << 16 }).bytes; const at = std.mem.lastIndexOf(u8, text, "err - ctl: ").?; diff --git a/src/ninep/pane.zig b/src/ninep/pane.zig index 8605cab8..dc104e4b 100644 --- a/src/ninep/pane.zig +++ b/src/ninep/pane.zig @@ -1104,7 +1104,7 @@ test "index lists serial kind dirty flag and name, and stats 0, a view generated const p = try withFile(gpa, "hello\nthere\n"); defer p.deinit(); const pane = p.panes[0].?; - const index = @intFromEnum(tree.TopFile.index); + const index = @backingInt(tree.TopFile.index); const a = rd(p, index, 0, 4096); try testing.expectEqual(Status.ok, a.reply.status); @@ -1138,7 +1138,7 @@ test "a terminal is listed as term with its directory as name" { var want: [64]u8 = undefined; try testing.expect(std.mem.indexOf( u8, - rd(p, @intFromEnum(tree.TopFile.index), 0, 4096).bytes, + rd(p, @backingInt(tree.TopFile.index), 0, 4096).bytes, try std.fmt.bufPrint(&want, "{d} term 0 /work/dir {d}\n", .{ pane.serial, columnOf(p, 0) }), ) != null); try testing.expectEqualStrings("/work/dir\n", rd(p, Node.of(pane.serial, .name), 0, 4096).bytes); @@ -1751,8 +1751,8 @@ test "name refreshes cached syntax for unchanged contents" { try testing.expectEqual(Status.ok, wr(p, Node.of(pane.serial, .name), "renamed.zig\n").reply.status); panes.File.refreshHighlights(p); try testing.expect(pane.file.?.highlights.len >= 2); - try testing.expectEqual(@intFromEnum(pardes.syntax.Syn.keyword), pane.file.?.highlights[0]); - try testing.expectEqual(@intFromEnum(pardes.syntax.Syn.keyword), pane.file.?.highlights[1]); + try testing.expectEqual(@backingInt(pardes.syntax.Syn.keyword), pane.file.?.highlights[0]); + try testing.expectEqual(@backingInt(pardes.syntax.Syn.keyword), pane.file.?.highlights[1]); try testing.expectEqualStrings("fn check() void {}\n", pane.file.?.content); } diff --git a/src/ninep/pty.zig b/src/ninep/pty.zig index aeb57a00..d80f7175 100644 --- a/src/ninep/pty.zig +++ b/src/ninep/pty.zig @@ -893,7 +893,7 @@ test "a shell that exits under a run answers its status, and the log says exit b const prompt = "\x1b]133;A;cl=line;aid=pardes\x07$ \x1b]133;B;aid=pardes\x07"; p.update(.{ .output = .{ .pane = 0, .bytes = prompt } }); while (p.nextEffect()) |_| {} - const log = @intFromEnum(tree.TopFile.log); + const log = @backingInt(tree.TopFile.log); const f = call(p, .{ .tag = 1, .op = .open, .node = log }).reply.handle; const frozen = call(p, .{ .tag = 2, .op = .read, .node = log, .handle = f, .size = 1 << 16 }).bytes.len; _ = call(p, .{ .tag = 3, .op = .write, .node = log, .handle = f, .data = "follow" }); @@ -984,7 +984,6 @@ test "a run's answer says cut when its output's start is gone, and reads a bound var got = sh.answered(p, node, h, into); try testing.expectEqualStrings("exit 0\nafter\n", got); - // A resize between its start and end reflows the pins with the text. h = sh.send(p, node); sh.put(p, c ++ "one\r\ntwo\r\n"); @@ -1092,7 +1091,7 @@ test "a terminal's ctl counts its body, and a new directory is a rename in the l _ = fields.next(); try testing.expectEqual(body_len, try std.fmt.parseInt(usize, fields.next().?, 10)); - const log = @intFromEnum(tree.TopFile.log); + const log = @backingInt(tree.TopFile.log); const f = call(p, .{ .tag = 4, .op = .open, .node = log }).reply.handle; const frozen = call(p, .{ .tag = 5, .op = .read, .node = log, .handle = f, .size = 1 << 16 }).bytes.len; _ = call(p, .{ .tag = 6, .op = .write, .node = log, .handle = f, .data = "follow" }); diff --git a/src/ninep/screen.zig b/src/ninep/screen.zig index 8d4707e0..ba676ded 100644 --- a/src/ninep/screen.zig +++ b/src/ninep/screen.zig @@ -95,7 +95,7 @@ const withTerm = th.withTerm; const serialOf = th.serialOf; const Node = tree.Node; const Status = tree.Status; -const screen_node = @intFromEnum(tree.TopFile.screen); +const screen_node = @backingInt(tree.TopFile.screen); test "listener addresses are readable canonical dials with bounded partial reads" { const gpa = testing.allocator; @@ -111,7 +111,7 @@ test "listener addresses are readable canonical dials with bounded partial reads try testing.expectEqualStrings(expected, bytes); try testing.expectError(error.ReadOnlyFilesystem, fs.write(p, path, "")); } - const node = @intFromEnum(tree.TopFile.listeners); + const node = @backingInt(tree.TopFile.listeners); var off: usize = 0; while (off < expected.len) { const part = rd(p, node, off, 3); diff --git a/src/ninep/testing.zig b/src/ninep/testing.zig index a35a9cf0..ec665130 100644 --- a/src/ninep/testing.zig +++ b/src/ninep/testing.zig @@ -71,7 +71,7 @@ pub fn logHas(p: *Pardes, needle: []const u8) bool { /// How many times the log, read whole from a fresh open, holds `needle`. pub fn logCount(p: *Pardes, needle: []const u8) usize { - const log = @intFromEnum(tree.TopFile.log); + const log = @backingInt(tree.TopFile.log); const h = call(p, .{ .tag = 1, .op = .open, .node = log }).reply.handle; defer _ = call(p, .{ .tag = 3, .op = .release, .node = log, .handle = h }); const text = call(p, .{ .tag = 2, .op = .read, .node = log, .handle = h, .size = 1 << 16 }).bytes; @@ -95,7 +95,7 @@ pub fn look_up(p: *Pardes, dir: u64, name: []const u8) Answer { /// The open is what makes the pane; the handle it answers is the serial, which /// is also what a read of that fid reports. pub fn newPane(p: *Pardes) !u32 { - const made = call(p, .{ .tag = 8, .op = .open, .node = @intFromEnum(tree.TopFile.new) }); + const made = call(p, .{ .tag = 8, .op = .open, .node = @backingInt(tree.TopFile.new) }); if (made.reply.status != .ok or made.reply.handle == 0) return error.NoPane; return made.reply.handle; } diff --git a/src/ninep/tree.zig b/src/ninep/tree.zig index 5678832b..9aa0225a 100644 --- a/src/ninep/tree.zig +++ b/src/ninep/tree.zig @@ -115,7 +115,7 @@ pub fn changesPane(p: *Pardes, req: Req) bool { return switch (req.op) { .write => true, .setattr => truncates(req), - .open => req.node == @intFromEnum(TopFile.new), + .open => req.node == @backingInt(TopFile.new), .release => req.remove or holdsLines(p, req) or holdsPage(p, req), .read => holdsPage(p, req), .lookup, .getattr, .readdir => false, @@ -279,7 +279,7 @@ pub const TopFile = enum(u5) { } }; -pub const root: u64 = @intFromEnum(TopFile.root); +pub const root: u64 = @backingInt(TopFile.root); /// Declaration order is readdir order. pub const PaneFile = enum(u5) { @@ -363,11 +363,11 @@ pub const Node = packed struct(u64) { pub fn of(serial: u32, file: PaneFile) u64 { std.debug.assert(serial != 0); - return @bitCast(Node{ .file = @intFromEnum(file), .serial = serial }); + return @bitCast(Node{ .file = @backingInt(file), .serial = serial }); } pub fn ofCol(serial: u32, file: ColFile) u64 { - return @bitCast(Node{ .file = @intFromEnum(file), .serial = col_bit | @as(u59, serial) }); + return @bitCast(Node{ .file = @backingInt(file), .serial = col_bit | @as(u59, serial) }); } pub fn target(node: u64) ?Target { @@ -424,9 +424,9 @@ pub fn resolveSelf(p: *Pardes, path: []const u8) ?u64 { // `new` is reached in /pane, where the panes it makes are. const top = std.meta.stringToEnum(TopFile, first) orelse return sources.node(normalized); if (top == .root or top == .new or top == .pane or parts.next() != null) return null; - return @intFromEnum(top); + return @backingInt(top); } - const next = parts.next() orelse return @intFromEnum(TopFile.pane); + const next = parts.next() orelse return @backingInt(TopFile.pane); // `new` is served on the wire but deliberately unreachable from an editor // path: this resolves Look targets and hover previews, and a preview that // opened `new` to see what was there would make a pane per hover. @@ -606,7 +606,7 @@ fn attrOf(p: *Pardes, target: Target) ?Reply.Attr { switch (target) { .top => |f| return .{ .name = f.fileName(), - .node = @intFromEnum(f), + .node = @backingInt(f), .dir = f.dir(), .mode = f.mode(), .size = topSize(p, f), @@ -695,11 +695,11 @@ fn lookup(p: *Pardes, req: Req, target: Target) Reply { const parent: u64 = switch (target) { .top => |top| if (top.dir()) root else return Reply.fail(req.tag, E.NOTDIR), .pane => |t| switch (t.file) { - .dir => @intFromEnum(TopFile.pane), + .dir => @backingInt(TopFile.pane), .pty => Node.of(t.serial, .dir), else => return Reply.fail(req.tag, E.NOTDIR), }, - .col => |c| if (c.file == .dir) @intFromEnum(TopFile.col) else return Reply.fail(req.tag, E.NOTDIR), + .col => |c| if (c.file == .dir) @backingInt(TopFile.col) else return Reply.fail(req.tag, E.NOTDIR), }; return handle(p, .{ .tag = req.tag, .op = .getattr, .node = parent }); } @@ -709,12 +709,12 @@ fn lookup(p: *Pardes, req: Req, target: Target) Reply { .root => root: { if (std.mem.eql(u8, name, "os")) return fs.osHandle(p, .{ .tag = req.tag, .op = .getattr, .node = fs.os_root }); // `new` is reached in /pane, where the panes it makes are. - if (std.meta.stringToEnum(TopFile, name)) |t| if (t != .root and t != .new) break :root @intFromEnum(t); + if (std.meta.stringToEnum(TopFile, name)) |t| if (t != .root and t != .new) break :root @backingInt(t); if (sources.node(name)) |n| return sources.handle(p, .{ .tag = req.tag, .op = .getattr, .node = n }); return Reply.fail(req.tag, E.NOENT); }, .pane => pane: { - if (std.mem.eql(u8, name, new_pane)) break :pane @intFromEnum(TopFile.new); + if (std.mem.eql(u8, name, new_pane)) break :pane @backingInt(TopFile.new); // A pane directory is its serial, in decimal digits and never 0. if (name.len > 10) return Reply.fail(req.tag, E.NOENT); for (name) |c| if (c < '0' or c > '9') return Reply.fail(req.tag, E.NOENT); @@ -778,13 +778,13 @@ fn readdir(p: *Pardes, req: Req, target: Target) Reply { // The guide, then what describes the session, then the // files that act, then the directories. inline for (.{ TopFile.README, TopFile.index, TopFile.status, TopFile.focus, TopFile.ctl, TopFile.commands, TopFile.recent, TopFile.look, TopFile.exec, TopFile.pager, TopFile.log, TopFile.screen, TopFile.listeners, TopFile.layout, TopFile.tag, TopFile.tagexec, TopFile.pane, TopFile.col }) |t| { - if (skip > 0) skip -= 1 else stageDirent(out, p.gpa, @intFromEnum(t), t.dir(), t.fileName()); + if (skip > 0) skip -= 1 else stageDirent(out, p.gpa, @backingInt(t), t.dir(), t.fileName()); } if (skip > 0) skip -= 1 else stageDirent(out, p.gpa, fs.os_root, true, "os"); sources.stage(p, out, "", &skip); }, .pane => { - if (skip > 0) skip -= 1 else stageDirent(out, p.gpa, @intFromEnum(TopFile.new), false, TopFile.new.fileName()); + if (skip > 0) skip -= 1 else stageDirent(out, p.gpa, @backingInt(TopFile.new), false, TopFile.new.fileName()); var last: u32 = 0; while (nextSerialAfter(p, last)) |serial| { last = serial; @@ -1378,7 +1378,7 @@ test "a listing read in chunks is what it was at the open, however the panes cha const p = try th.withFile(testing.allocator, "x\n"); defer p.deinit(); for ([_]TopFile{ .index, .layout, .recent, .ctl }) |file| { - const node = @intFromEnum(file); + const node = @backingInt(file); const whole = try testing.allocator.dupe(u8, th.rd(p, node, 0, 1 << 16).bytes); defer testing.allocator.free(whole); const h = th.call(p, .{ .tag = 1, .op = .open, .node = node }).reply.handle; @@ -1389,7 +1389,7 @@ test "a listing read in chunks is what it was at the open, however the panes cha // Something changes between the chunks. const made = try th.newPane(p); _ = th.wr(p, Node.of(made, .name), "/tmp/pardes-frozen-listing.txt\n"); - _ = th.wr(p, @intFromEnum(TopFile.ctl), "Verbose off\n"); + _ = th.wr(p, @backingInt(TopFile.ctl), "Verbose off\n"); while (true) { const more = th.call(p, .{ .tag = 2, .op = .read, .node = node, .handle = h, .off = got.items.len, .size = 7 }).bytes; if (more.len == 0) break; @@ -1397,7 +1397,7 @@ test "a listing read in chunks is what it was at the open, however the panes cha } _ = th.call(p, .{ .tag = 3, .op = .release, .node = node, .handle = h, .opened = true }); try testing.expectEqualStrings(whole, got.items); - _ = th.wr(p, @intFromEnum(TopFile.ctl), "Verbose on\n"); + _ = th.wr(p, @backingInt(TopFile.ctl), "Verbose on\n"); } } @@ -1418,7 +1418,7 @@ test "filesystem inspection preserves pending and displayed Look hover" { } }); try testing.expect(p.look_hover_wait != null); const body = Node.of(serialOf(p), .body); - const screen_node = @intFromEnum(TopFile.screen); + const screen_node = @backingInt(TopFile.screen); for (0..2) |phase| { if (phase == 1) { for (0..delay) |_| p.update(.tick); @@ -1429,7 +1429,7 @@ test "filesystem inspection preserves pending and displayed Look hover" { const requests = [_]Req{ .{ .tag = 1, .op = .lookup, .node = root, .data = "screen" }, .{ .tag = 1, .op = .lookup, .node = root, .data = "status" }, - .{ .tag = 1, .op = .getattr, .node = @intFromEnum(TopFile.pane) }, + .{ .tag = 1, .op = .getattr, .node = @backingInt(TopFile.pane) }, .{ .tag = 2, .op = .getattr, .node = body }, .{ .tag = 3, .op = .open, .node = body }, .{ .tag = 4, .op = .read, .node = body, .size = 5 }, @@ -1458,14 +1458,14 @@ test "log stats 0 however much it holds, a stream as acme's generated files are" defer p.deinit(); _ = th.wr(p, Node.of(th.serialOf(p), .exec), "Msg a record for the log\n"); try testing.expect(th.logHas(p, "a record for the log")); - try testing.expectEqual(@as(u64, 0), call(p, .{ .tag = 1, .op = .getattr, .node = @intFromEnum(TopFile.log) }).reply.attr.size); + try testing.expectEqual(@as(u64, 0), call(p, .{ .tag = 1, .op = .getattr, .node = @backingInt(TopFile.log) }).reply.attr.size); } test "filesystem pane creation and truncation cancel Look hover" { const requests = [_]Req{ // Opening `new` is what makes a pane now; walking to it makes none, // and so must leave a pending hover alone. - .{ .tag = 2, .op = .open, .node = @intFromEnum(TopFile.new) }, + .{ .tag = 2, .op = .open, .node = @backingInt(TopFile.new) }, .{ .tag = 3, .op = .setattr, .node = 0, .truncate = true }, }; for (requests) |request| { @@ -1493,16 +1493,16 @@ test "README names every file the tree serves" { } }; inline for (@typeInfo(TopFile).@"enum".field_values) |value| { - const t: TopFile = @enumFromInt(value); + const t: TopFile = @fromBackingInt(@intCast(value)); if (t != .root and !words.has(t.fileName())) { std.debug.print("README does not mention /{s}\n", .{t.fileName()}); return error.Undocumented; } } inline for (@typeInfo(PaneFile).@"enum".field_values) |value| { - const t: PaneFile = @enumFromInt(value); + const t: PaneFile = @fromBackingInt(@intCast(value)); const ok = if (t == .dir) true else if (t.inPty() and t != .pty) - std.mem.indexOf(u8, fs.help, "pty/" ++ comptime @as(PaneFile, @enumFromInt(value)).fileName()) != null + std.mem.indexOf(u8, fs.help, "pty/" ++ comptime @as(PaneFile, @fromBackingInt(@intCast(value))).fileName()) != null else words.has(t.fileName()); if (!ok) { @@ -1530,8 +1530,8 @@ test "readdir lists the root and a pane directory without creating anything" { try testing.expectEqualStrings(name, top[i].name); try testing.expectEqual(i >= 16, top[i].dir); } - try testing.expectEqual(@intFromEnum(TopFile.pane), top[16].node); - try testing.expectEqual(@intFromEnum(TopFile.col), top[17].node); + try testing.expectEqual(@backingInt(TopFile.pane), top[16].node); + try testing.expectEqual(@backingInt(TopFile.col), top[17].node); try testing.expectEqual(fs.os_root, top[18].node); var idbuf: [16]u8 = undefined; try testing.expect(th.nameAt(top, try std.fmt.bufPrint(&idbuf, "{d}", .{serial})) == null); @@ -1554,7 +1554,7 @@ test "readdir lists the root and a pane directory without creating anything" { try testing.expectEqual(Status.ok, call(p, .{ .tag = 1, .op = .getattr, .node = entry.node }).reply.status); try testing.expectEqual(before, p.next_serial); } - const panes_dir = rdir(p, @intFromEnum(TopFile.pane), 0); + const panes_dir = rdir(p, @backingInt(TopFile.pane), 0); const listed = th.dirents(panes_dir.bytes, &buf); var idname: [16]u8 = undefined; const own = th.nameAt(listed, try std.fmt.bufPrint(&idname, "{d}", .{serial})).?; @@ -1565,16 +1565,16 @@ test "readdir lists the root and a pane directory without creating anything" { // client that stats every name a listing gave it inert. const shown = th.nameAt(listed, new_pane).?; try testing.expect(!shown.dir); - try testing.expectEqual(Status.ok, look_up(p, @intFromEnum(TopFile.pane), new_pane).reply.status); - try testing.expectEqual(Status.ok, call(p, .{ .tag = 1, .op = .getattr, .node = @intFromEnum(TopFile.new) }).reply.status); + try testing.expectEqual(Status.ok, look_up(p, @backingInt(TopFile.pane), new_pane).reply.status); + try testing.expectEqual(Status.ok, call(p, .{ .tag = 1, .op = .getattr, .node = @backingInt(TopFile.new) }).reply.status); try testing.expectEqual(before, p.next_serial); const dir = rdir(p, Node.of(serial, .dir), 0); const files = th.dirents(dir.bytes, &buf); try testing.expectEqual(@as(usize, 18), files.len); for ([_][]const u8{ - "name", "body", "tag", "ctl", "addr", "dot", "limit", "data", "xdata", - "sel", "dirty", "mark", "scroll", "errors", "event", "look", "exec", "tagexec", + "name", "body", "tag", "ctl", "addr", "dot", "limit", "data", "xdata", + "sel", "dirty", "mark", "scroll", "errors", "event", "look", "exec", "tagexec", }, 0..) |name, i| try testing.expectEqualStrings(name, files[i].name); try testing.expect(th.nameAt(files, ".") == null); @@ -1588,7 +1588,7 @@ test "readdir lists the root and a pane directory without creating anything" { try testing.expectEqual(before, p.next_serial); try testing.expectEqual(E.NOTDIR, rdir(p, Node.of(serial, .body), 0).errno()); - try testing.expectEqual(E.NOTDIR, rdir(p, @intFromEnum(TopFile.index), 0).errno()); + try testing.expectEqual(E.NOTDIR, rdir(p, @backingInt(TopFile.index), 0).errno()); } test "lookup resolves top files, pane serials and pane files" { @@ -1597,7 +1597,7 @@ test "lookup resolves top files, pane serials and pane files" { defer p.deinit(); const serial = serialOf(p); - try testing.expectEqual(@as(u64, @intFromEnum(TopFile.index)), look_up(p, root, "index").reply.attr.node); + try testing.expectEqual(@as(u64, @backingInt(TopFile.index)), look_up(p, root, "index").reply.attr.node); try testing.expect(!look_up(p, root, "status").reply.attr.dir); try testing.expectEqual(@as(u16, 0o444), look_up(p, root, "status").reply.attr.mode); try testing.expectEqual(@as(u16, 0o666), look_up(p, root, "look").reply.attr.mode); @@ -1607,17 +1607,17 @@ test "lookup resolves top files, pane serials and pane files" { try testing.expectEqual(E.NOENT, look_up(p, root, "nosuchthing").errno()); try testing.expectEqual(E.NOENT, look_up(p, root, "self").errno()); try testing.expectEqual(E.NOENT, look_up(p, root, "cons").errno()); - try testing.expectEqual(E.NOTDIR, look_up(p, @intFromEnum(TopFile.index), "x").errno()); + try testing.expectEqual(E.NOTDIR, look_up(p, @backingInt(TopFile.index), "x").errno()); var idbuf: [16]u8 = undefined; const serial_name = try std.fmt.bufPrint(&idbuf, "{d}", .{serial}); try testing.expectEqual(E.NOENT, look_up(p, root, serial_name).errno()); - const dir = look_up(p, @intFromEnum(TopFile.pane), serial_name); + const dir = look_up(p, @backingInt(TopFile.pane), serial_name); try testing.expectEqual(Node.of(serial, .dir), dir.reply.attr.node); try testing.expect(dir.reply.attr.dir); try testing.expectEqualStrings(serial_name, dir.reply.attr.name); - try testing.expectEqual(E.NOENT, look_up(p, @intFromEnum(TopFile.pane), "99999").errno()); - try testing.expectEqual(E.NOENT, look_up(p, @intFromEnum(TopFile.pane), "0").errno()); + try testing.expectEqual(E.NOENT, look_up(p, @backingInt(TopFile.pane), "99999").errno()); + try testing.expectEqual(E.NOENT, look_up(p, @backingInt(TopFile.pane), "0").errno()); const body = look_up(p, Node.of(serial, .dir), "body"); try testing.expectEqual(Node.of(serial, .body), body.reply.attr.node); @@ -1634,19 +1634,19 @@ test "opening /pane/new makes a pane and removing one closes it" { const p = try withFile(gpa, "first\n"); defer p.deinit(); const before = p.next_serial; - const panes_dir = @intFromEnum(TopFile.pane); + const panes_dir = @backingInt(TopFile.pane); // Browsing /pane creates nothing, and neither does walking or stat-ing // `new` itself: only an open does. That is what lets `new` be listed at // all, since `ls -l` stats every name a listing handed it. try testing.expectEqual(Status.ok, rdir(p, panes_dir, 0).reply.status); try testing.expectEqual(Status.ok, look_up(p, panes_dir, new_pane).reply.status); - try testing.expectEqual(Status.ok, call(p, .{ .tag = 1, .op = .getattr, .node = @intFromEnum(TopFile.new) }).reply.status); + try testing.expectEqual(Status.ok, call(p, .{ .tag = 1, .op = .getattr, .node = @backingInt(TopFile.new) }).reply.status); try testing.expectEqual(before, p.next_serial); // The open makes the pane and hands back its serial; the read only // observes, so two reads of one fid answer the same pane. - const made = call(p, .{ .tag = 2, .op = .open, .node = @intFromEnum(TopFile.new) }); + const made = call(p, .{ .tag = 2, .op = .open, .node = @backingInt(TopFile.new) }); try testing.expectEqual(Status.ok, made.reply.status); try testing.expectEqual(before + 1, p.next_serial); const serial = before + 1; @@ -1654,7 +1654,7 @@ test "opening /pane/new makes a pane and removing one closes it" { var expected: [16]u8 = undefined; const want = try std.fmt.bufPrint(&expected, "{d}\n", .{serial}); for (0..2) |_| { - const answer = call(p, .{ .tag = 3, .op = .read, .node = @intFromEnum(TopFile.new), .handle = made.reply.handle, .size = 64 }); + const answer = call(p, .{ .tag = 3, .op = .read, .node = @backingInt(TopFile.new), .handle = made.reply.handle, .size = 64 }); try testing.expectEqualStrings(want, answer.bytes); } @@ -1668,10 +1668,10 @@ test "opening /pane/new makes a pane and removing one closes it" { // A second open is a second pane, and releasing a clone fid leaves the // pane it made standing. - const second = call(p, .{ .tag = 4, .op = .open, .node = @intFromEnum(TopFile.new) }); + const second = call(p, .{ .tag = 4, .op = .open, .node = @backingInt(TopFile.new) }); try testing.expectEqual(Status.ok, second.reply.status); try testing.expect(second.reply.handle != made.reply.handle); - _ = call(p, .{ .tag = 5, .op = .release, .node = @intFromEnum(TopFile.new), .handle = made.reply.handle, .opened = true }); + _ = call(p, .{ .tag = 5, .op = .release, .node = @backingInt(TopFile.new), .handle = made.reply.handle, .opened = true }); try testing.expect(p.paneBySerial(serial) != null); try testing.expectEqualStrings("hi", p.panes[id].?.file.?.content); @@ -1689,7 +1689,7 @@ test "opening /pane/new makes a pane and removing one closes it" { // Tremove closes the pane it names, and nothing else in the tree. try testing.expectEqual(E.PERM, th.rmdir(p, Node.of(serial, .body)).errno()); - try testing.expectEqual(E.PERM, th.rmdir(p, @intFromEnum(TopFile.index)).errno()); + try testing.expectEqual(E.PERM, th.rmdir(p, @backingInt(TopFile.index)).errno()); try testing.expect(p.paneBySerial(serial) != null); try testing.expectEqual(Status.ok, th.rmdir(p, Node.of(serial, .dir)).reply.status); try testing.expect(p.paneBySerial(serial) == null); @@ -1700,7 +1700,7 @@ test "every open that holds something is one record, named by its handle only on const p = try th.withTerm(testing.allocator); defer p.deinit(); const serial = serialOf(p); - const log = @intFromEnum(TopFile.log); + const log = @backingInt(TopFile.log); const event = Node.of(serial, .event); const run = Node.of(serial, .pty_run); const logged = call(p, .{ .tag = 1, .op = .open, .node = log }).reply.handle; @@ -1729,15 +1729,15 @@ test "directories walk to their parents" { defer p.deinit(); for ([_]struct { node: u64, parent: u64 }{ .{ .node = root, .parent = root }, - .{ .node = @intFromEnum(TopFile.pane), .parent = root }, - .{ .node = Node.of(serialOf(p), .dir), .parent = @intFromEnum(TopFile.pane) }, + .{ .node = @backingInt(TopFile.pane), .parent = root }, + .{ .node = Node.of(serialOf(p), .dir), .parent = @backingInt(TopFile.pane) }, .{ .node = fs.os_root, .parent = root }, }) |case| { const result = look_up(p, case.node, ".."); try testing.expectEqual(Status.ok, result.reply.status); try testing.expectEqual(case.parent, result.reply.attr.node); } - try testing.expectEqual(E.NOTDIR, look_up(p, @intFromEnum(TopFile.index), "..").errno()); + try testing.expectEqual(E.NOTDIR, look_up(p, @backingInt(TopFile.index), "..").errno()); try testing.expectEqual(E.NOTDIR, look_up(p, Node.of(serialOf(p), .body), "..").errno()); } @@ -1748,10 +1748,10 @@ test "editor paths resolve to the same nodes the wire serves" { var path: [64]u8 = undefined; try testing.expectEqual(root, resolveSelf(p, "").?); try testing.expectEqual(root, resolveSelf(p, "/./pane/../").?); - try testing.expectEqual(@intFromEnum(TopFile.index), resolveSelf(p, "index").?); - try testing.expectEqual(@intFromEnum(TopFile.status), resolveSelf(p, "status").?); + try testing.expectEqual(@backingInt(TopFile.index), resolveSelf(p, "index").?); + try testing.expectEqual(@backingInt(TopFile.status), resolveSelf(p, "status").?); try testing.expect(resolveSelf(p, "new") == null); - try testing.expectEqual(@intFromEnum(TopFile.pane), resolveSelf(p, "pane").?); + try testing.expectEqual(@backingInt(TopFile.pane), resolveSelf(p, "pane").?); try testing.expectEqual(Node.of(serial, .dir), resolveSelf(p, try std.fmt.bufPrint(&path, "pane/{d}", .{serial})).?); try testing.expectEqual(Node.of(serial, .sel), resolveSelf(p, try std.fmt.bufPrint(&path, "pane/{d}/sel", .{serial})).?); try testing.expect(resolveSelf(p, try std.fmt.bufPrint(&path, "pane/{d}/pty/ctl", .{serial})) == null); @@ -1800,7 +1800,7 @@ test "random placements, refused or not, leave no pane under its tag and two row const action = r.uintLessThan(u8, 8); switch (action) { 0 => _ = th.wr(p, Node.of(at, .exec), "New\n"), - 1 => _ = call(p, .{ .tag = 1, .op = .open, .node = @intFromEnum(TopFile.new) }), + 1 => _ = call(p, .{ .tag = 1, .op = .open, .node = @backingInt(TopFile.new) }), 2 => _ = th.wr(p, Node.of(at, .exec), "Newcol\n"), 3 => _ = th.wr(p, Node.of(at, .exec), "Edit =\n"), 4 => _ = th.wr(p, Node.of(at, .exec), "Tty\n"), @@ -1823,7 +1823,7 @@ test "at the pane cap, pane/new, look and New each say so, and look reads back e // Tall enough that the column holds every pane at its tag and two rows, // and wide enough that each tag, the session directory's +New, is one. p.update(.{ .resize = .{ .cols = 400, .rows = pardes.MAX_PANES * 4 } }); - const new = @intFromEnum(TopFile.new); + const new = @backingInt(TopFile.new); while (p.freeSlot() != null) try testing.expectEqual(Status.ok, call(p, .{ .tag = 1, .op = .open, .node = new }).reply.status); var want: [64]u8 = undefined; const said = try std.fmt.bufPrint(&want, "no space for a pane: {d} max", .{pardes.MAX_PANES}); @@ -1840,7 +1840,7 @@ test "at the pane cap, pane/new, look and New each say so, and look reads back e var dir_buf: [4096]u8 = undefined; const dir = dir_buf[0..try tmp.dir.realPath(testing.io, &dir_buf)]; var line: [4200]u8 = undefined; - const look_node = @intFromEnum(TopFile.look); + const look_node = @backingInt(TopFile.look); const looked = th.wr(p, look_node, try std.fmt.bufPrint(&line, "{s}/f.txt\n", .{dir})); try testing.expect(looked.errno() != 0); try testing.expect(std.mem.indexOf(u8, looked.reply.ename, said) != null); @@ -1857,7 +1857,7 @@ test "at the pane cap, pane/new, look and New each say so, and look reads back e test "nothing a mount's close or a no-op truncate sends waits on the editor: a held line runs at its next step" { const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); - const exec = @intFromEnum(TopFile.exec); + const exec = @backingInt(TopFile.exec); // `> exec` truncates nothing; `> body` does. try testing.expect(!needsQuiet(p, .{ .tag = 1, .op = .setattr, .node = exec, .truncate = true })); try testing.expect(!changesPane(p, .{ .tag = 1, .op = .setattr, .node = exec, .truncate = true })); @@ -1875,7 +1875,7 @@ test "nothing a mount's close or a no-op truncate sends waits on the editor: a h test "a command line cut across writes runs once whole, and the last runs at release; an Edit block waits for its end" { const p = try th.withFile(testing.allocator, "x\n"); defer p.deinit(); - const exec = @intFromEnum(TopFile.exec); + const exec = @backingInt(TopFile.exec); const h = call(p, .{ .tag = 1, .op = .open, .node = exec, .omode = 1 }).reply.handle; try testing.expect(h != 0); // Each piece fills its Twrite (a client's one write cut at msize). @@ -1906,12 +1906,12 @@ test "a refused open, create or remove says why in words and logs no err; a refu const serial = serialOf(p); // pane/new is read, never written: a write is refused, and is no // failure the log tells of. - const new = th.wr(p, @intFromEnum(TopFile.new), "x\n"); + const new = th.wr(p, @backingInt(TopFile.new), "x\n"); try testing.expectEqual(Status.err, new.reply.status); try testing.expectEqualStrings("permission denied", new.reply.ename); const made = call(p, .{ .tag = 2, .op = .open, .node = Node.of(serial, .body), .create = true }); try testing.expectEqualStrings("permission denied", made.reply.ename); - const gone = th.rmdir(p, @intFromEnum(TopFile.index)); + const gone = th.rmdir(p, @backingInt(TopFile.index)); try testing.expectEqual(Status.err, gone.reply.status); try testing.expect(gone.reply.ename.len > 0 and !std.ascii.isUpper(gone.reply.ename[0])); // An OTRUNC open's truncation of data after a failed addr: refused, no err. @@ -1961,7 +1961,7 @@ test "a write with no newline waits for its newline or the close, whatever its s test "look and exec read back what their own open's write touched; a fresh open reads the session's last" { const p = try th.withFile(testing.allocator, "x\n"); defer p.deinit(); - const exec = @intFromEnum(TopFile.exec); + const exec = @backingInt(TopFile.exec); const first = p.panes[0].?.serial; const mine = call(p, .{ .tag = 1, .op = .open, .node = exec, .omode = 2 }).reply.handle; const theirs = call(p, .{ .tag = 2, .op = .open, .node = exec, .omode = 2 }).reply.handle; @@ -2013,7 +2013,7 @@ test "a rename of a pane's directory or file is refused as not permitted" { test "no placement leaves a pane shorter than its tag and two rows; a full column refuses the next" { const p = try th.withFile(testing.allocator, "x\n"); defer p.deinit(); - const new = @intFromEnum(TopFile.new); + const new = @backingInt(TopFile.new); var made: usize = 1; const refused = while (made < pardes.MAX_PANES) : (made += 1) { const a = call(p, .{ .tag = 1, .op = .open, .node = new }); @@ -2078,7 +2078,7 @@ test "a pane made from pane/new goes last in its column, even when the last pane const p = try th.withFile(testing.allocator, "x\n"); defer p.deinit(); for (0..3) |_| { - const made = call(p, .{ .tag = 1, .op = .open, .node = @intFromEnum(TopFile.new) }).reply.handle; + const made = call(p, .{ .tag = 1, .op = .open, .node = @backingInt(TopFile.new) }).reply.handle; p.sync(); try testing.expectEqual(made, p.panes[p.col_panes[0][p.col_n[0] - 1]].?.serial); } diff --git a/src/pager.zig b/src/pager.zig index feabd194..aba73d43 100644 --- a/src/pager.zig +++ b/src/pager.zig @@ -240,8 +240,8 @@ const Handler = struct { .reset_strikethrough => s.strikethrough = false, .direct_color_fg => |c| s.fg = .{ .rgb = .{ c.r, c.g, c.b } }, .direct_color_bg => |c| s.bg = .{ .rgb = .{ c.r, c.g, c.b } }, - .@"8_fg", .@"8_bright_fg" => |name| s.fg = .{ .index = @intFromEnum(name) }, - .@"8_bg", .@"8_bright_bg" => |name| s.bg = .{ .index = @intFromEnum(name) }, + .@"8_fg", .@"8_bright_fg" => |name| s.fg = .{ .index = @backingInt(name) }, + .@"8_bg", .@"8_bright_bg" => |name| s.bg = .{ .index = @backingInt(name) }, .@"256_fg" => |i| s.fg = .{ .index = i }, .@"256_bg" => |i| s.bg = .{ .index = i }, .reset_fg => s.fg = .default, diff --git a/src/pardes.zig b/src/pardes.zig index 8da0922d..7e166847 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -924,7 +924,7 @@ test "Filter is ordered after Del and toggles only its terminal or +Pager pane" const testing = std.testing; const del = std.meta.stringToEnum(Builtin, "Del") orelse return error.MissingDelBuiltin; const filter = std.meta.stringToEnum(Builtin, "Filter") orelse return error.MissingFilterBuiltin; - try testing.expectEqual(@intFromEnum(del) + 1, @intFromEnum(filter)); + try testing.expectEqual(@backingInt(del) + 1, @backingInt(filter)); const p = try Pardes.init(testing.allocator, .{ .tty_only = true }); defer p.deinit(); @@ -3308,8 +3308,8 @@ test "tabbed file aligns syntax cursor and mouse at the nearest insertion gap" { const pane = try p.setTestFile("\treturn x\n"); const f = &pane.file.?; f.highlights = try p.tree_sitter_gpa.alloc(u8, f.content.len); - @memset(f.highlights, @intFromEnum(syntax.Syn.none)); - @memset(f.highlights[1..7], @intFromEnum(syntax.Syn.keyword)); + @memset(f.highlights, @backingInt(syntax.Syn.none)); + @memset(f.highlights[1..7], @backingInt(syntax.Syn.keyword)); f.syntax_dirty = false; pane.body.cur_row = 0; pane.body.cur_col = 1; @@ -3721,7 +3721,7 @@ pub fn hit(key: Key, binding: []const config.Chord) bool { return false; } -pub const sel_slot = @intFromEnum(config.select_button); +pub const sel_slot = @backingInt(config.select_button); /// Pixel dimensions are meaningful only to the native PDF placement path. /// Keep resize events layout-only when that path is not part of the build. @@ -6040,7 +6040,7 @@ pub const Pardes = struct { // The one-failure rule is a write's: a refused open (its OTRUNC's // truncation, a setattr, too), create or remove is its Rerror alone, // no err, as is a write to pane/new, which is only ever read. - const ruled = req.op == .write and req.node != @intFromEnum(ctlfs.TopFile.new); + const ruled = req.op == .write and req.node != @backingInt(ctlfs.TopFile.new); if (reply.status == .err and ruled) ctlfs.events.noteError(p, req, reply); // The request was a whole step of its own, so it settles the way a // step does: the cursor and scroll reconciled, the scripted panes diff --git a/src/pdf_view.zig b/src/pdf_view.zig index 567117bb..500f05f3 100644 --- a/src/pdf_view.zig +++ b/src/pdf_view.zig @@ -2604,7 +2604,7 @@ pub fn pointerRelease( ) PointerRelease { if (comptime !enabled) return .{}; const state = &(pane.pdf orelse return .{}); - const slot = @intFromEnum(button); + const slot = @backingInt(button); const grid_selection = pane.sel[slot]; pane.sel[slot].state = .none; // native quads, not projected text cells diff --git a/src/syntax.zig b/src/syntax.zig index fa212ca7..1c09c9f3 100644 --- a/src/syntax.zig +++ b/src/syntax.zig @@ -214,7 +214,7 @@ fn ensure(spec: *Spec) !Selected { const capture_styles = spec.capture_styles[0..query.captureCount()]; for (capture_styles, 0..) |*style, id| { const name = query.captureNameForId(@intCast(id)) orelse ""; - style.* = @intFromEnum(synFor(name)); + style.* = @backingInt(synFor(name)); if (style.* == 0) query.disableCapture(name); } const parser = ts.Parser.create(); @@ -965,11 +965,11 @@ test "syntax formatted locations color hidden context and preserve multiline sou const styles = try highlightLocationRows(gpa, content, &rows); defer gpa.free(styles); const body = std.mem.indexOf(u8, content, "comment body").?; - try std.testing.expectEqual(@intFromEnum(Syn.comment), styles[body]); - try std.testing.expectEqual(@intFromEnum(Syn.none), styles[body - 1]); + try std.testing.expectEqual(@backingInt(Syn.comment), styles[body]); + try std.testing.expectEqual(@backingInt(Syn.none), styles[body - 1]); const number = std.mem.indexOf(u8, content, "42").?; - try std.testing.expectEqual(@intFromEnum(Syn.number), styles[number]); - try std.testing.expectEqual(@intFromEnum(Syn.none), styles[0]); + try std.testing.expectEqual(@backingInt(Syn.number), styles[number]); + try std.testing.expectEqual(@backingInt(Syn.none), styles[0]); } test "syntax formatted locations separate alignment from Markdown indentation" { @@ -985,8 +985,8 @@ test "syntax formatted locations separate alignment from Markdown indentation" { }; const styles = try highlightLocationRows(gpa, content, &rows); defer gpa.free(styles); - try std.testing.expectEqual(@intFromEnum(Syn.keyword), styles[std.mem.indexOf(u8, content, "Heading").?]); - try std.testing.expectEqual(@intFromEnum(Syn.string), styles[std.mem.indexOf(u8, content, "Code").?]); + try std.testing.expectEqual(@backingInt(Syn.keyword), styles[std.mem.indexOf(u8, content, "Heading").?]); + try std.testing.expectEqual(@backingInt(Syn.string), styles[std.mem.indexOf(u8, content, "Code").?]); } fn inject(styles: []u8, source: []const u8, node: ts.Node, markdown: bool) void { const kind = node.kind(); @@ -1149,7 +1149,7 @@ pub fn highlightDiffRows(gpa: std.mem.Allocator, content: []const u8, start_raw: .meta, .old_path, .new_path => .comment, else => .none, }; - if (style != .none) window.fill(at, nl - at, @intFromEnum(style)); + if (style != .none) window.fill(at, nl - at, @backingInt(style)); } if (nl >= content.len) break; at = nl + 1; @@ -1192,10 +1192,10 @@ fn paintDiffPiece(gpa: std.mem.Allocator, window: anytype, bytes: []const u8, at for (kinds) |kind| { const line = lines.next() orelse break; const style: u8 = switch (kind) { - .added => @intFromEnum(Syn.string) | diff_added, - .removed => @intFromEnum(Syn.number) | diff_removed, - .no_newline => @intFromEnum(Syn.comment), - .hunk => @intFromEnum(Syn.keyword), + .added => @backingInt(Syn.string) | diff_added, + .removed => @backingInt(Syn.number) | diff_removed, + .no_newline => @backingInt(Syn.comment), + .hunk => @backingInt(Syn.keyword), else => 0, }; if (style != 0) window.fill(at + offset, line.len, style); @@ -1273,8 +1273,8 @@ fn paintHunk(gpa: std.mem.Allocator, out: []u8, bytes: []const u8, kinds: []cons .removed => @memcpy(dst, old_colors[old_at..][0..code_len]), .added => @memcpy(dst, new_colors[new_at..][0..code_len]), .context => @memcpy(dst, if (context_new) new_colors[new_at..][0..code_len] else old_colors[old_at..][0..code_len]), - .no_newline => @memset(out[offset..][0..line.len], @intFromEnum(Syn.comment)), - .hunk => @memset(out[offset..][0..line.len], @intFromEnum(Syn.keyword)), + .no_newline => @memset(out[offset..][0..line.len], @backingInt(Syn.comment)), + .hunk => @memset(out[offset..][0..line.len], @backingInt(Syn.keyword)), else => {}, } if (kind == .context or kind == .removed) old_at += code_len + 1; @@ -1322,8 +1322,8 @@ test "syntax a results row is coloured by the file its location names" { try std.testing.expectEqual(content.len, styles.len); for (styles[0.."src/a.zig:1:1".len]) |b| try std.testing.expectEqual(@as(u8, 0), b); const zig_kw = std.mem.indexOf(u8, content, "struct").?; - try std.testing.expectEqual(@intFromEnum(Syn.keyword), styles[zig_kw]); - try std.testing.expectEqual(@intFromEnum(Syn.keyword), styles[zig_kw + 5]); + try std.testing.expectEqual(@backingInt(Syn.keyword), styles[zig_kw]); + try std.testing.expectEqual(@backingInt(Syn.keyword), styles[zig_kw + 5]); const prose = std.mem.indexOf(u8, content, "just some prose").?; for (styles[prose .. prose + 14]) |b| try std.testing.expectEqual(@as(u8, 0), b); const bare = std.mem.indexOf(u8, content, "src/c.zig").?; @@ -1371,14 +1371,14 @@ test "syntax default full grammar set highlights Typst source" { const keyword_at = std.mem.indexOf(u8, source, "let").?; const number_at = std.mem.indexOf(u8, source, "42").?; const string_at = std.mem.indexOf(u8, source, "\"hello\"").?; - try std.testing.expectEqual(Syn.comment, @as(Syn, @enumFromInt(styles[comment_at]))); - try std.testing.expectEqual(Syn.keyword, @as(Syn, @enumFromInt(styles[keyword_at]))); - try std.testing.expectEqual(Syn.number, @as(Syn, @enumFromInt(styles[number_at]))); - try std.testing.expectEqual(Syn.string, @as(Syn, @enumFromInt(styles[string_at]))); + try std.testing.expectEqual(Syn.comment, @as(Syn, @fromBackingInt(@intCast(styles[comment_at])))); + try std.testing.expectEqual(Syn.keyword, @as(Syn, @fromBackingInt(@intCast(styles[keyword_at])))); + try std.testing.expectEqual(Syn.number, @as(Syn, @fromBackingInt(@intCast(styles[number_at])))); + try std.testing.expectEqual(Syn.string, @as(Syn, @fromBackingInt(@intCast(styles[string_at])))); const short_ext = try highlightFileRange(std.testing.allocator, "paper.typ", source, 0, source.len); defer std.testing.allocator.free(short_ext); - try std.testing.expectEqual(Syn.keyword, @as(Syn, @enumFromInt(short_ext[keyword_at]))); + try std.testing.expectEqual(Syn.keyword, @as(Syn, @fromBackingInt(@intCast(short_ext[keyword_at])))); } test "syntax Typst markup constructs paint and raw blocks inject their language" { @@ -1403,7 +1403,7 @@ test "syntax Typst markup constructs paint and raw blocks inject their language" const synAt = struct { fn f(s: []const u8, src: []const u8, needle: []const u8, offset: usize) Syn { - return @enumFromInt(s[std.mem.indexOf(u8, src, needle).? + offset]); + return @fromBackingInt(@intCast(s[std.mem.indexOf(u8, src, needle).? + offset])); } }.f; try std.testing.expectEqual(Syn.keyword, synAt(styles, source, "= Heading", 0)); @@ -1443,7 +1443,7 @@ test "syntax markdown highlights markup, injects inline spans and fenced code bl const synAt = struct { fn f(s: []const u8, src: []const u8, needle: []const u8, offset: usize) Syn { - return @enumFromInt(s[std.mem.indexOf(u8, src, needle).? + offset]); + return @fromBackingInt(@intCast(s[std.mem.indexOf(u8, src, needle).? + offset])); } }.f; try std.testing.expectEqual(Syn.keyword, synAt(styles, source, "Title", 0)); @@ -1471,8 +1471,8 @@ test "syntax inline fast path agrees with full Markdown query" { const actual = try std.testing.allocator.alloc(u8, source.len); defer std.testing.allocator.free(actual); for ([_]Syn{ .none, .keyword }) |background| { - @memset(expected, @intFromEnum(background)); - @memset(actual, @intFromEnum(background)); + @memset(expected, @backingInt(background)); + @memset(actual, @backingInt(background)); runQuery(expected, sel, tree, 0); inject(actual, source, tree.rootNode(), true); if (!std.mem.eql(u8, expected, actual)) std.debug.print("inline mismatch: {s}\n", .{source}); @@ -1511,9 +1511,9 @@ test "syntax plain Markdown keeps block styles without starting the inline parse const source = "# Heading\n\nPlain prose.\n\n indented code\n"; const styles = try highlightFileRange(std.testing.allocator, "a.md", source, 0, source.len); defer std.testing.allocator.free(styles); - try std.testing.expectEqual(@intFromEnum(Syn.keyword), styles[2]); - try std.testing.expectEqual(@intFromEnum(Syn.none), styles[std.mem.indexOf(u8, source, "Plain").?]); - try std.testing.expectEqual(@intFromEnum(Syn.string), styles[std.mem.indexOf(u8, source, "indented").?]); + try std.testing.expectEqual(@backingInt(Syn.keyword), styles[2]); + try std.testing.expectEqual(@backingInt(Syn.none), styles[std.mem.indexOf(u8, source, "Plain").?]); + try std.testing.expectEqual(@backingInt(Syn.string), styles[std.mem.indexOf(u8, source, "indented").?]); for (specs) |spec| { if (std.mem.eql(u8, spec.name, "markdown_inline")) try std.testing.expect(spec.selected == null); } @@ -1544,7 +1544,7 @@ test "syntax highlightDiff colors unified diff lines by prefix" { } fn diffSynAt(styles: []const u8, text: []const u8, needle: []const u8, offset: usize) Syn { - return @enumFromInt(styles[std.mem.indexOf(u8, text, needle).? + offset] & syn_bits); + return @fromBackingInt(@intCast(styles[std.mem.indexOf(u8, text, needle).? + offset] & syn_bits)); } test "syntax a Zig hunk is coloured as Zig, each side parsed whole" { @@ -1715,7 +1715,7 @@ test "syntax a hunk painted once is kept, and a long one is parsed in pieces" { const at = std.mem.indexOf(u8, content, "+const v1000 ").?; const window = try highlightDiff(gpa, content, at, at + 200); defer gpa.free(window); - try std.testing.expectEqual(Syn.number, @as(Syn, @enumFromInt(window["+const v1000 = ".len] & syn_bits))); + try std.testing.expectEqual(Syn.number, @as(Syn, @fromBackingInt(@intCast(window["+const v1000 = ".len] & syn_bits)))); var cached: usize = 0; for (diff_pieces) |slot| if (slot) |piece| { cached += 1; @@ -1780,7 +1780,7 @@ test "syntax query filtering preserves upstream colors" { reference.query = raw_query; reference.capture_styles = try std.testing.allocator.alloc(u8, raw_query.captureCount()); defer std.testing.allocator.free(reference.capture_styles); - for (reference.capture_styles, 0..) |*style, id| style.* = @intFromEnum(synFor(raw_query.captureNameForId(@intCast(id)) orelse "")); + for (reference.capture_styles, 0..) |*style, id| style.* = @backingInt(synFor(raw_query.captureNameForId(@intCast(id)) orelse "")); const tree = selected.parser.parseString(source, null) orelse return error.ParseFailed; defer tree.destroy(); var expected: [source.len]u8 = @splat(0); @@ -1806,8 +1806,8 @@ test "syntax Zig keyword captures cover both bytes beyond line ten thousand" { defer std.testing.allocator.free(styles); for ([_][]const u8{ "fn", "if" }) |keyword| { const at = std.mem.indexOf(u8, code, keyword).?; - try std.testing.expectEqual(@intFromEnum(Syn.keyword), styles[at]); - try std.testing.expectEqual(@intFromEnum(Syn.keyword), styles[at + 1]); + try std.testing.expectEqual(@backingInt(Syn.keyword), styles[at]); + try std.testing.expectEqual(@backingInt(Syn.keyword), styles[at + 1]); } } @@ -1823,8 +1823,8 @@ test "syntax allocator switching clears default-runtime caches" { const restored = try highlightFileRange(std.testing.allocator, "a.zig", source, 0, source.len); defer std.testing.allocator.free(restored); defer stop(); - try std.testing.expectEqual(@intFromEnum(Syn.keyword), restored[0]); - try std.testing.expectEqual(@intFromEnum(Syn.keyword), restored[1]); + try std.testing.expectEqual(@backingInt(Syn.keyword), restored[0]); + try std.testing.expectEqual(@backingInt(Syn.keyword), restored[1]); } test "syntax location context snapshots retain omitted multiline comment scope" { @@ -1848,8 +1848,8 @@ test "syntax location context snapshots retain omitted multiline comment scope" const styles = try highlightLocationRows(gpa, content, &rows); defer gpa.free(styles); for (styles[rows[0].code_start..][0..code.len]) |style| - try std.testing.expectEqual(@intFromEnum(Syn.comment), style); - try std.testing.expectEqual(@intFromEnum(Syn.none), styles[0]); + try std.testing.expectEqual(@backingInt(Syn.comment), style); + try std.testing.expectEqual(@backingInt(Syn.none), styles[0]); } test "syntax declaration locations clear snapshots without muting ordinary context" { @@ -1875,7 +1875,7 @@ test "syntax declaration locations clear snapshots without muting ordinary conte const styles = try highlightLocationRows(gpa, content, &rows); defer gpa.free(styles); for (styles[3..][0..header.len]) |style| try std.testing.expectEqual(@as(u8, 0), style); - try std.testing.expectEqual(@intFromEnum(Syn.number), styles[std.mem.indexOf(u8, content, "42").?]); + try std.testing.expectEqual(@backingInt(Syn.number), styles[std.mem.indexOf(u8, content, "42").?]); } test "syntax stacked addresses do not split multiline source groups" { @@ -1895,11 +1895,11 @@ test "syntax stacked addresses do not split multiline source groups" { }; const styles = try highlightLocationRows(gpa, content, &rows); defer gpa.free(styles); - try std.testing.expectEqual(@intFromEnum(Syn.comment), styles[std.mem.indexOf(u8, content, "42").?]); - try std.testing.expectEqual(@intFromEnum(Syn.number), styles[std.mem.indexOf(u8, content, "7;").?]); + try std.testing.expectEqual(@backingInt(Syn.comment), styles[std.mem.indexOf(u8, content, "42").?]); + try std.testing.expectEqual(@backingInt(Syn.number), styles[std.mem.indexOf(u8, content, "7;").?]); for ([_][]const u8{ "a.c:1:1", "a.c:2:1", "a.c:3:1" }) |label| { const at = std.mem.indexOf(u8, content, label).?; - for (styles[at..][0..label.len]) |style| try std.testing.expectEqual(@intFromEnum(Syn.none), style); + for (styles[at..][0..label.len]) |style| try std.testing.expectEqual(@backingInt(Syn.none), style); } } diff --git a/src/terminal.zig b/src/terminal.zig index a8e7931c..33ad22e6 100644 --- a/src/terminal.zig +++ b/src/terminal.zig @@ -1347,7 +1347,7 @@ pub fn forwardKey(p: *Pardes, id: usize, key: Key) void { pub fn enterTty(p: *Pardes, id: usize) void { const pane = p.panes[id] orelse return; - const selected = pane.rawPointerText(pane.sel[@intFromEnum(config.select_button)]) != null; + const selected = pane.rawPointerText(pane.sel[@backingInt(config.select_button)]) != null; if (comptime enabled) if (!selected and pane.terminal != null and pane.body.cur_pinned and pane.terminal.?.vt.cursorIsAtPrompt()) handoff: { const screen = pane.terminal.?.vt.screens.active; const goff: i32 = @intCast(screen.pages.scrollbar().offset); diff --git a/src/web.zig b/src/web.zig index fed2ba5a..f89aa7e9 100644 --- a/src/web.zig +++ b/src/web.zig @@ -258,18 +258,20 @@ fn mouseWithHit(button_arg: u32, kind_arg: u32, col_arg: u32, row_arg: u32, mods 3 => .drag, else => return, }; - s.core.update(.{ .mouse = .{ - .body_hit = hit, - .tag_hit = tag_hit, - .button = button, - .kind = kind, - .col = @intCast(@min(col_arg, std.math.maxInt(u16))), - .row = @intCast(@min(row_arg, std.math.maxInt(u16))), - .ctrl = mods & 1 != 0, - // Alt-click is B2 and Cmd/Super-click B3 (mouse.emulateButton). - .alt = mods & 2 != 0, - .super = mods & 8 != 0, - } }); + s.core.update(.{ + .mouse = .{ + .body_hit = hit, + .tag_hit = tag_hit, + .button = button, + .kind = kind, + .col = @intCast(@min(col_arg, std.math.maxInt(u16))), + .row = @intCast(@min(row_arg, std.math.maxInt(u16))), + .ctrl = mods & 1 != 0, + // Alt-click is B2 and Cmd/Super-click B3 (mouse.emulateButton). + .alt = mods & 2 != 0, + .super = mods & 8 != 0, + }, + }); } export fn pardes_touch_scroll(delta: f32) void { @@ -347,7 +349,7 @@ export fn pardes_tag_layer_value(index: u32, field: u32) u32 { if (layer.rows == 0) return 0; return switch (field) { 0 => layer.cols, - 1 => @intFromEnum(layer.kind), + 1 => @backingInt(layer.kind), 2 => layer.id, 3 => layer.serial, 4 => layer.viewport.x, @@ -421,7 +423,7 @@ export fn pardes_row_metrics(body_w: u16, body_h: u16, tagline_w: u16, tagline_h export fn pardes_pointer_shape() u32 { const s = &(state orelse return 0); - return @intFromEnum(s.core.surface.pointer_shape); + return @backingInt(s.core.surface.pointer_shape); } export fn pardes_cursor_y() i32 { @@ -557,6 +559,6 @@ fn encodeAttrs(style: pardes.CellStyle) u16 { attrs |= @as(u16, @intFromBool(style.invisible)) << 5; attrs |= @as(u16, @intFromBool(style.strikethrough)) << 6; attrs |= @as(u16, @intFromBool(style.font_role == .tagline)) * attr_tagline; - attrs |= @as(u16, @intFromEnum(style.ul)) << 8; + attrs |= @as(u16, @backingInt(style.ul)) << 8; return attrs; } diff --git a/test/deck/buttons.zon b/test/deck/buttons.zon index 8b3ae7f8..50d9c70c 100644 --- a/test/deck/buttons.zon +++ b/test/deck/buttons.zon @@ -1,81 +1,81 @@ .{ .version = 1, .events = .{ -.{.t=3700753450,.pad=2,.ev=.{.button=.{.idx=10,.down=true}}}, -.{.t=3900818994,.pad=2,.ev=.{.button=.{.idx=10,.down=false}}}, -.{.t=3956546622,.pad=2,.ev=.{.button=.{.idx=9,.down=true}}}, -.{.t=4123264775,.pad=2,.ev=.{.button=.{.idx=9,.down=false}}}, -.{.t=4930702402,.pad=2,.ev=.{.button=.{.idx=8,.down=true}}}, -.{.t=5145495294,.pad=2,.ev=.{.button=.{.idx=8,.down=false}}}, -.{.t=5256748340,.pad=2,.ev=.{.button=.{.idx=7,.down=true}}}, -.{.t=5467530268,.pad=2,.ev=.{.button=.{.idx=7,.down=false}}}, -.{.t=6756403713,.pad=2,.ev=.{.button=.{.idx=2,.down=true}}}, -.{.t=6911854483,.pad=2,.ev=.{.button=.{.idx=2,.down=false}}}, -.{.t=7211860980,.pad=2,.ev=.{.button=.{.idx=3,.down=true}}}, -.{.t=7389532087,.pad=2,.ev=.{.button=.{.idx=3,.down=false}}}, -.{.t=8133944867,.pad=2,.ev=.{.button=.{.idx=3,.down=true}}}, -.{.t=8289426557,.pad=2,.ev=.{.button=.{.idx=3,.down=false}}}, -.{.t=9089438184,.pad=2,.ev=.{.button=.{.idx=5,.down=true}}}, -.{.t=9234016011,.pad=2,.ev=.{.button=.{.idx=2,.down=true}}}, -.{.t=9356447170,.pad=2,.ev=.{.button=.{.idx=2,.down=false}}}, -.{.t=9500690066,.pad=2,.ev=.{.button=.{.idx=5,.down=false}}}, -.{.t=10234132592,.pad=2,.ev=.{.button=.{.idx=5,.down=true}}}, -.{.t=10389693142,.pad=2,.ev=.{.button=.{.idx=2,.down=true}}}, -.{.t=10500635738,.pad=2,.ev=.{.button=.{.idx=2,.down=false}}}, -.{.t=10600562571,.pad=2,.ev=.{.button=.{.idx=5,.down=false}}}, -.{.t=11211884827,.pad=2,.ev=.{.button=.{.idx=3,.down=true}}}, -.{.t=11333789807,.pad=2,.ev=.{.button=.{.idx=3,.down=false}}}, -.{.t=11622673840,.pad=2,.ev=.{.button=.{.idx=3,.down=true}}}, -.{.t=11778210450,.pad=2,.ev=.{.button=.{.idx=3,.down=false}}}, -.{.t=12056066449,.pad=2,.ev=.{.button=.{.idx=0,.down=true}}}, -.{.t=12200470216,.pad=2,.ev=.{.button=.{.idx=0,.down=false}}}, -.{.t=13122626673,.pad=2,.ev=.{.button=.{.idx=1,.down=true}}}, -.{.t=13256318175,.pad=2,.ev=.{.button=.{.idx=1,.down=false}}}, -.{.t=30877608417,.pad=2,.ev=.{.button=.{.idx=13,.down=true}}}, -.{.t=30932947265,.pad=2,.ev=.{.button=.{.idx=13,.down=false}}}, -.{.t=31188916557,.pad=2,.ev=.{.button=.{.idx=14,.down=true}}}, -.{.t=31344392047,.pad=2,.ev=.{.button=.{.idx=14,.down=false}}}, -.{.t=31355303161,.pad=2,.ev=.{.button=.{.idx=11,.down=true}}}, -.{.t=31377574308,.pad=2,.ev=.{.button=.{.idx=11,.down=false}}}, -.{.t=31377580618,.pad=2,.ev=.{.button=.{.idx=11,.down=true}}}, -.{.t=31533158438,.pad=2,.ev=.{.button=.{.idx=11,.down=false}}}, -.{.t=31599806330,.pad=2,.ev=.{.button=.{.idx=12,.down=true}}}, -.{.t=31699701622,.pad=2,.ev=.{.button=.{.idx=14,.down=true}}}, -.{.t=31699711442,.pad=2,.ev=.{.button=.{.idx=12,.down=false}}}, -.{.t=31833163995,.pad=2,.ev=.{.button=.{.idx=14,.down=false}}}, -.{.t=31844214668,.pad=2,.ev=.{.button=.{.idx=11,.down=true}}}, -.{.t=31933218167,.pad=2,.ev=.{.button=.{.idx=11,.down=false}}}, -.{.t=31944106321,.pad=2,.ev=.{.button=.{.idx=13,.down=true}}}, -.{.t=31944118861,.pad=2,.ev=.{.button=.{.idx=13,.down=false}}}, -.{.t=32577585424,.pad=2,.ev=.{.button=.{.idx=7,.down=true}}}, -.{.t=32777404849,.pad=2,.ev=.{.button=.{.idx=7,.down=false}}}, -.{.t=32932893939,.pad=2,.ev=.{.button=.{.idx=8,.down=true}}}, -.{.t=33122371409,.pad=2,.ev=.{.button=.{.idx=8,.down=false}}}, -.{.t=34899667922,.pad=2,.ev=.{.button=.{.idx=10,.down=true}}}, -.{.t=35143908581,.pad=2,.ev=.{.button=.{.idx=10,.down=false}}}, -.{.t=35143918751,.pad=2,.ev=.{.button=.{.idx=9,.down=true}}}, -.{.t=35299532711,.pad=2,.ev=.{.button=.{.idx=9,.down=false}}}, -.{.t=36188307687,.pad=2,.ev=.{.button=.{.idx=10,.down=true}}}, -.{.t=36351697335,.pad=2,.ev=.{.button=.{.idx=9,.down=true}}}, -.{.t=36399712574,.pad=2,.ev=.{.button=.{.idx=10,.down=false}}}, -.{.t=36521680424,.pad=2,.ev=.{.button=.{.idx=10,.down=true}}}, -.{.t=36543814231,.pad=2,.ev=.{.button=.{.idx=9,.down=false}}}, -.{.t=36688528867,.pad=2,.ev=.{.button=.{.idx=10,.down=false}}}, -.{.t=38810548641,.pad=2,.ev=.{.button=.{.idx=8,.down=true}}}, -.{.t=38988265258,.pad=2,.ev=.{.button=.{.idx=8,.down=false}}}, -.{.t=39421485428,.pad=2,.ev=.{.button=.{.idx=7,.down=true}}}, -.{.t=39521563760,.pad=2,.ev=.{.button=.{.idx=8,.down=true}}}, -.{.t=39543869347,.pad=2,.ev=.{.button=.{.idx=7,.down=false}}}, -.{.t=39654975672,.pad=2,.ev=.{.button=.{.idx=8,.down=false}}}, -.{.t=40199575307,.pad=2,.ev=.{.button=.{.idx=0,.down=true}}}, -.{.t=40388115109,.pad=2,.ev=.{.button=.{.idx=0,.down=false}}}, -.{.t=40810375225,.pad=2,.ev=.{.button=.{.idx=2,.down=true}}}, -.{.t=40976868838,.pad=2,.ev=.{.button=.{.idx=2,.down=false}}}, -.{.t=41032455046,.pad=2,.ev=.{.button=.{.idx=3,.down=true}}}, -.{.t=41243668724,.pad=2,.ev=.{.button=.{.idx=3,.down=false}}}, -.{.t=42565700760,.pad=2,.ev=.{.button=.{.idx=2,.down=true}}}, -.{.t=42743538487,.pad=2,.ev=.{.button=.{.idx=2,.down=false}}}, -.{.t=43676697498,.pad=2,.ev=.{.button=.{.idx=5,.down=true}}}, -.{.t=43932510879,.pad=2,.ev=.{.button=.{.idx=5,.down=false}}}, -.{.t=43943745523,.pad=2,.ev=.{.button=.{.idx=1,.down=true}}}, -.{.t=44021582808,.pad=2,.ev=.{.button=.{.idx=1,.down=false}}}, -.{.t=44599100514,.pad=2,.ev=.{.button=.{.idx=1,.down=true}}}, + .{ .t = 3700753450, .pad = 2, .ev = .{ .button = .{ .idx = 10, .down = true } } }, + .{ .t = 3900818994, .pad = 2, .ev = .{ .button = .{ .idx = 10, .down = false } } }, + .{ .t = 3956546622, .pad = 2, .ev = .{ .button = .{ .idx = 9, .down = true } } }, + .{ .t = 4123264775, .pad = 2, .ev = .{ .button = .{ .idx = 9, .down = false } } }, + .{ .t = 4930702402, .pad = 2, .ev = .{ .button = .{ .idx = 8, .down = true } } }, + .{ .t = 5145495294, .pad = 2, .ev = .{ .button = .{ .idx = 8, .down = false } } }, + .{ .t = 5256748340, .pad = 2, .ev = .{ .button = .{ .idx = 7, .down = true } } }, + .{ .t = 5467530268, .pad = 2, .ev = .{ .button = .{ .idx = 7, .down = false } } }, + .{ .t = 6756403713, .pad = 2, .ev = .{ .button = .{ .idx = 2, .down = true } } }, + .{ .t = 6911854483, .pad = 2, .ev = .{ .button = .{ .idx = 2, .down = false } } }, + .{ .t = 7211860980, .pad = 2, .ev = .{ .button = .{ .idx = 3, .down = true } } }, + .{ .t = 7389532087, .pad = 2, .ev = .{ .button = .{ .idx = 3, .down = false } } }, + .{ .t = 8133944867, .pad = 2, .ev = .{ .button = .{ .idx = 3, .down = true } } }, + .{ .t = 8289426557, .pad = 2, .ev = .{ .button = .{ .idx = 3, .down = false } } }, + .{ .t = 9089438184, .pad = 2, .ev = .{ .button = .{ .idx = 5, .down = true } } }, + .{ .t = 9234016011, .pad = 2, .ev = .{ .button = .{ .idx = 2, .down = true } } }, + .{ .t = 9356447170, .pad = 2, .ev = .{ .button = .{ .idx = 2, .down = false } } }, + .{ .t = 9500690066, .pad = 2, .ev = .{ .button = .{ .idx = 5, .down = false } } }, + .{ .t = 10234132592, .pad = 2, .ev = .{ .button = .{ .idx = 5, .down = true } } }, + .{ .t = 10389693142, .pad = 2, .ev = .{ .button = .{ .idx = 2, .down = true } } }, + .{ .t = 10500635738, .pad = 2, .ev = .{ .button = .{ .idx = 2, .down = false } } }, + .{ .t = 10600562571, .pad = 2, .ev = .{ .button = .{ .idx = 5, .down = false } } }, + .{ .t = 11211884827, .pad = 2, .ev = .{ .button = .{ .idx = 3, .down = true } } }, + .{ .t = 11333789807, .pad = 2, .ev = .{ .button = .{ .idx = 3, .down = false } } }, + .{ .t = 11622673840, .pad = 2, .ev = .{ .button = .{ .idx = 3, .down = true } } }, + .{ .t = 11778210450, .pad = 2, .ev = .{ .button = .{ .idx = 3, .down = false } } }, + .{ .t = 12056066449, .pad = 2, .ev = .{ .button = .{ .idx = 0, .down = true } } }, + .{ .t = 12200470216, .pad = 2, .ev = .{ .button = .{ .idx = 0, .down = false } } }, + .{ .t = 13122626673, .pad = 2, .ev = .{ .button = .{ .idx = 1, .down = true } } }, + .{ .t = 13256318175, .pad = 2, .ev = .{ .button = .{ .idx = 1, .down = false } } }, + .{ .t = 30877608417, .pad = 2, .ev = .{ .button = .{ .idx = 13, .down = true } } }, + .{ .t = 30932947265, .pad = 2, .ev = .{ .button = .{ .idx = 13, .down = false } } }, + .{ .t = 31188916557, .pad = 2, .ev = .{ .button = .{ .idx = 14, .down = true } } }, + .{ .t = 31344392047, .pad = 2, .ev = .{ .button = .{ .idx = 14, .down = false } } }, + .{ .t = 31355303161, .pad = 2, .ev = .{ .button = .{ .idx = 11, .down = true } } }, + .{ .t = 31377574308, .pad = 2, .ev = .{ .button = .{ .idx = 11, .down = false } } }, + .{ .t = 31377580618, .pad = 2, .ev = .{ .button = .{ .idx = 11, .down = true } } }, + .{ .t = 31533158438, .pad = 2, .ev = .{ .button = .{ .idx = 11, .down = false } } }, + .{ .t = 31599806330, .pad = 2, .ev = .{ .button = .{ .idx = 12, .down = true } } }, + .{ .t = 31699701622, .pad = 2, .ev = .{ .button = .{ .idx = 14, .down = true } } }, + .{ .t = 31699711442, .pad = 2, .ev = .{ .button = .{ .idx = 12, .down = false } } }, + .{ .t = 31833163995, .pad = 2, .ev = .{ .button = .{ .idx = 14, .down = false } } }, + .{ .t = 31844214668, .pad = 2, .ev = .{ .button = .{ .idx = 11, .down = true } } }, + .{ .t = 31933218167, .pad = 2, .ev = .{ .button = .{ .idx = 11, .down = false } } }, + .{ .t = 31944106321, .pad = 2, .ev = .{ .button = .{ .idx = 13, .down = true } } }, + .{ .t = 31944118861, .pad = 2, .ev = .{ .button = .{ .idx = 13, .down = false } } }, + .{ .t = 32577585424, .pad = 2, .ev = .{ .button = .{ .idx = 7, .down = true } } }, + .{ .t = 32777404849, .pad = 2, .ev = .{ .button = .{ .idx = 7, .down = false } } }, + .{ .t = 32932893939, .pad = 2, .ev = .{ .button = .{ .idx = 8, .down = true } } }, + .{ .t = 33122371409, .pad = 2, .ev = .{ .button = .{ .idx = 8, .down = false } } }, + .{ .t = 34899667922, .pad = 2, .ev = .{ .button = .{ .idx = 10, .down = true } } }, + .{ .t = 35143908581, .pad = 2, .ev = .{ .button = .{ .idx = 10, .down = false } } }, + .{ .t = 35143918751, .pad = 2, .ev = .{ .button = .{ .idx = 9, .down = true } } }, + .{ .t = 35299532711, .pad = 2, .ev = .{ .button = .{ .idx = 9, .down = false } } }, + .{ .t = 36188307687, .pad = 2, .ev = .{ .button = .{ .idx = 10, .down = true } } }, + .{ .t = 36351697335, .pad = 2, .ev = .{ .button = .{ .idx = 9, .down = true } } }, + .{ .t = 36399712574, .pad = 2, .ev = .{ .button = .{ .idx = 10, .down = false } } }, + .{ .t = 36521680424, .pad = 2, .ev = .{ .button = .{ .idx = 10, .down = true } } }, + .{ .t = 36543814231, .pad = 2, .ev = .{ .button = .{ .idx = 9, .down = false } } }, + .{ .t = 36688528867, .pad = 2, .ev = .{ .button = .{ .idx = 10, .down = false } } }, + .{ .t = 38810548641, .pad = 2, .ev = .{ .button = .{ .idx = 8, .down = true } } }, + .{ .t = 38988265258, .pad = 2, .ev = .{ .button = .{ .idx = 8, .down = false } } }, + .{ .t = 39421485428, .pad = 2, .ev = .{ .button = .{ .idx = 7, .down = true } } }, + .{ .t = 39521563760, .pad = 2, .ev = .{ .button = .{ .idx = 8, .down = true } } }, + .{ .t = 39543869347, .pad = 2, .ev = .{ .button = .{ .idx = 7, .down = false } } }, + .{ .t = 39654975672, .pad = 2, .ev = .{ .button = .{ .idx = 8, .down = false } } }, + .{ .t = 40199575307, .pad = 2, .ev = .{ .button = .{ .idx = 0, .down = true } } }, + .{ .t = 40388115109, .pad = 2, .ev = .{ .button = .{ .idx = 0, .down = false } } }, + .{ .t = 40810375225, .pad = 2, .ev = .{ .button = .{ .idx = 2, .down = true } } }, + .{ .t = 40976868838, .pad = 2, .ev = .{ .button = .{ .idx = 2, .down = false } } }, + .{ .t = 41032455046, .pad = 2, .ev = .{ .button = .{ .idx = 3, .down = true } } }, + .{ .t = 41243668724, .pad = 2, .ev = .{ .button = .{ .idx = 3, .down = false } } }, + .{ .t = 42565700760, .pad = 2, .ev = .{ .button = .{ .idx = 2, .down = true } } }, + .{ .t = 42743538487, .pad = 2, .ev = .{ .button = .{ .idx = 2, .down = false } } }, + .{ .t = 43676697498, .pad = 2, .ev = .{ .button = .{ .idx = 5, .down = true } } }, + .{ .t = 43932510879, .pad = 2, .ev = .{ .button = .{ .idx = 5, .down = false } } }, + .{ .t = 43943745523, .pad = 2, .ev = .{ .button = .{ .idx = 1, .down = true } } }, + .{ .t = 44021582808, .pad = 2, .ev = .{ .button = .{ .idx = 1, .down = false } } }, + .{ .t = 44599100514, .pad = 2, .ev = .{ .button = .{ .idx = 1, .down = true } } }, } } diff --git a/test/deck/lpad-swipe.zon b/test/deck/lpad-swipe.zon index 33a17751..d5b5049a 100644 --- a/test/deck/lpad-swipe.zon +++ b/test/deck/lpad-swipe.zon @@ -1,163 +1,163 @@ .{ .version = 1, .events = .{ -.{.t=28555347100,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.29483032,.y=0.24435425,.pressure=0.0022583008}}}, -.{.t=28555355490,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.2937622,.y=0.24847412,.pressure=0.0015563965}}}, -.{.t=28566662333,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.2920227,.y=0.25350952,.pressure=0.00048828125}}}, -.{.t=28566669273,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.up,.x=0.28912354,.y=0.25863647,.pressure=0}}}, -.{.t=28633190705,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.down,.x=0.26437378,.y=0.44036865,.pressure=0.0008239746}}}, -.{.t=28644226129,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.2635193,.y=0.44857788,.pressure=0.0008239746}}}, -.{.t=28644235079,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.26348877,.y=0.4538269,.pressure=0.0015563965}}}, -.{.t=28644241049,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.26272583,.y=0.45950317,.pressure=0.003692627}}}, -.{.t=28655363472,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.26229858,.y=0.46218872,.pressure=0.0047912598}}}, -.{.t=28655373032,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.26153564,.y=0.46594238,.pressure=0.005493164}}}, -.{.t=28666533886,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.2607727,.y=0.46810913,.pressure=0.008026123}}}, -.{.t=28666541736,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.26037598,.y=0.46969604,.pressure=0.00982666}}}, -.{.t=28666544986,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.26004028,.y=0.47079468,.pressure=0.010894775}}}, -.{.t=28677510399,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.25985718,.y=0.47192383,.pressure=0.011962891}}}, -.{.t=28677516759,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.25924683,.y=0.47277832,.pressure=0.013061523}}}, -.{.t=28677520229,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.25894165,.y=0.47366333,.pressure=0.01449585}}}, -.{.t=28688736483,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.25906372,.y=0.47409058,.pressure=0.015197754}}}, -.{.t=28688747523,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.25872803,.y=0.47351074,.pressure=0.013061523}}}, -.{.t=28688752063,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.25827026,.y=0.4732666,.pressure=0.013397217}}}, -.{.t=28699780696,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.2581787,.y=0.47317505,.pressure=0.014129639}}}, -.{.t=28699788576,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.25759888,.y=0.47305298,.pressure=0.014831543}}}, -.{.t=28699792416,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.25787354,.y=0.47280884,.pressure=0.01449585}}}, -.{.t=28711058720,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.25784302,.y=0.47225952,.pressure=0.013763428}}}, -.{.t=28711073040,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.25738525,.y=0.472229,.pressure=0.014129639}}}, -.{.t=28722312593,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.25720215,.y=0.4717102,.pressure=0.013763428}}}, -.{.t=28722328533,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.2572937,.y=0.47213745,.pressure=0.012329102}}}, -.{.t=28722335123,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.2576294,.y=0.4721985,.pressure=0.01449585}}}, -.{.t=28733104547,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.25784302,.y=0.4718933,.pressure=0.013763428}}}, -.{.t=28733113157,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.2571411,.y=0.472229,.pressure=0.013763428}}}, -.{.t=28733116517,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.256958,.y=0.47235107,.pressure=0.010894775}}}, -.{.t=28744542840,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.25598145,.y=0.47323608,.pressure=0.011962891}}}, -.{.t=28744554360,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.25558472,.y=0.47372437,.pressure=0.012329102}}}, -.{.t=28744558310,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.25463867,.y=0.47329712,.pressure=0.013061523}}}, -.{.t=28755164615,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.2541809,.y=0.4736023,.pressure=0.013397217}}}, -.{.t=28755173055,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.2536316,.y=0.47485352,.pressure=0.013397217}}}, -.{.t=28766369408,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.2527771,.y=0.4749756,.pressure=0.011962891}}}, -.{.t=28766376998,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.2524109,.y=0.47543335,.pressure=0.011962891}}}, -.{.t=28766380848,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.2518921,.y=0.4761963,.pressure=0.011962891}}}, -.{.t=28777479342,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.25073242,.y=0.4764099,.pressure=0.013397217}}}, -.{.t=28777487702,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.24984741,.y=0.4772644,.pressure=0.015197754}}}, -.{.t=28777491542,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.24942017,.y=0.47872925,.pressure=0.015563965}}}, -.{.t=28788858885,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.24816895,.y=0.47982788,.pressure=0.016296387}}}, -.{.t=28788869705,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.247406,.y=0.48181152,.pressure=0.016998291}}}, -.{.t=28788873665,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.24645996,.y=0.48260498,.pressure=0.015563965}}}, -.{.t=28800073548,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.2456665,.y=0.48516846,.pressure=0.01663208}}}, -.{.t=28800082148,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.24414062,.y=0.48757935,.pressure=0.018432617}}}, -.{.t=28800086718,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.2437439,.y=0.48986816,.pressure=0.019165039}}}, -.{.t=28810881362,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.2432251,.y=0.49273682,.pressure=0.017730713}}}, -.{.t=28810890602,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.24337769,.y=0.4951172,.pressure=0.018432617}}}, -.{.t=28822223135,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.24224854,.y=0.49868774,.pressure=0.018066406}}}, -.{.t=28822236725,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.2409668,.y=0.5030823,.pressure=0.018432617}}}, -.{.t=28822243035,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.24002075,.y=0.5093689,.pressure=0.017364502}}}, -.{.t=28833221849,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.23800659,.y=0.52023315,.pressure=0.017364502}}}, -.{.t=28833234799,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.23648071,.y=0.5312195,.pressure=0.018066406}}}, -.{.t=28833241859,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.23449707,.y=0.54260254,.pressure=0.018432617}}}, -.{.t=28844533292,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.23208618,.y=0.5539551,.pressure=0.019165039}}}, -.{.t=28844544902,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.22930908,.y=0.5640869,.pressure=0.020599365}}}, -.{.t=28844549012,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.22769165,.y=0.5701294,.pressure=0.022399902}}}, -.{.t=28855315576,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.22613525,.y=0.57528687,.pressure=0.023468018}}}, -.{.t=28855325516,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.22503662,.y=0.5812073,.pressure=0.02420044}}}, -.{.t=28866614540,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.22335815,.y=0.5848694,.pressure=0.02420044}}}, -.{.t=28866626480,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.22390747,.y=0.5887146,.pressure=0.024536133}}}, -.{.t=28866629910,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.22283936,.y=0.59265137,.pressure=0.024536133}}}, -.{.t=28877415724,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.22262573,.y=0.59625244,.pressure=0.025268555}}}, -.{.t=28877428004,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.22128296,.y=0.6008606,.pressure=0.025268555}}}, -.{.t=28888551597,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.2204895,.y=0.60409546,.pressure=0.025268555}}}, -.{.t=28888564767,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.21896362,.y=0.61083984,.pressure=0.025634766}}}, -.{.t=28888571967,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.21774292,.y=0.6156006,.pressure=0.025970459}}}, -.{.t=28899744701,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.21542358,.y=0.62112427,.pressure=0.02633667}}}, -.{.t=28899757861,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.21438599,.y=0.62576294,.pressure=0.027435303}}}, -.{.t=28899764601,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.21298218,.y=0.63223267,.pressure=0.027069092}}}, -.{.t=28910731865,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.21209717,.y=0.63708496,.pressure=0.02633667}}}, -.{.t=28910746485,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.21133423,.y=0.6419983,.pressure=0.02670288}}}, -.{.t=28921990138,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.21032715,.y=0.64730835,.pressure=0.027435303}}}, -.{.t=28922004158,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.2090149,.y=0.65237427,.pressure=0.027069092}}}, -.{.t=28922010498,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.20770264,.y=0.6588135,.pressure=0.02670288}}}, -.{.t=28932967412,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.20559692,.y=0.6654968,.pressure=0.025970459}}}, -.{.t=28932979792,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.20404053,.y=0.67285156,.pressure=0.025634766}}}, -.{.t=28932983492,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.20187378,.y=0.6821594,.pressure=0.024536133}}}, -.{.t=28944345285,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.19940186,.y=0.6911926,.pressure=0.02420044}}}, -.{.t=28944363135,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.19662476,.y=0.703949,.pressure=0.022033691}}}, -.{.t=28944369185,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.19250488,.y=0.71707153,.pressure=0.02130127}}}, -.{.t=28955070939,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.18859863,.y=0.7327881,.pressure=0.020599365}}}, -.{.t=28955080209,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.18469238,.y=0.7469177,.pressure=0.018798828}}}, -.{.t=28966644072,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.1803894,.y=0.76065063,.pressure=0.018066406}}}, -.{.t=28966660132,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.17681885,.y=0.7729492,.pressure=0.019165039}}}, -.{.t=28966666102,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.17303467,.y=0.78430176,.pressure=0.01953125}}}, -.{.t=28977523276,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.17047119,.y=0.79385376,.pressure=0.019165039}}}, -.{.t=28977533506,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.16790771,.y=0.8000183,.pressure=0.019866943}}}, -.{.t=28977538756,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.16583252,.y=0.8055115,.pressure=0.018798828}}}, -.{.t=28988801809,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.16448975,.y=0.8109131,.pressure=0.01953125}}}, -.{.t=28988815059,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.16299438,.y=0.81552124,.pressure=0.02130127}}}, -.{.t=28988820159,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.16275024,.y=0.8183899,.pressure=0.02166748}}}, -.{.t=29000005933,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.16235352,.y=0.8191223,.pressure=0.022399902}}}, -.{.t=29000020133,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.16220093,.y=0.820343,.pressure=0.023468018}}}, -.{.t=29000023943,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.16268921,.y=0.8208618,.pressure=0.023834229}}}, -.{.t=29010879647,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.1618042,.y=0.82214355,.pressure=0.025634766}}}, -.{.t=29010893477,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.16238403,.y=0.82196045,.pressure=0.02633667}}}, -.{.t=29022239700,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.16329956,.y=0.82180786,.pressure=0.027069092}}}, -.{.t=29022255010,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.16305542,.y=0.8227539,.pressure=0.027069092}}}, -.{.t=29022260530,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.16360474,.y=0.8215027,.pressure=0.02670288}}}, -.{.t=29033423863,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.16390991,.y=0.8215637,.pressure=0.02670288}}}, -.{.t=29033439393,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.16513062,.y=0.820282,.pressure=0.02633667}}}, -.{.t=29033446553,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.16571045,.y=0.82003784,.pressure=0.027069092}}}, -.{.t=29044100787,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.16552734,.y=0.81985474,.pressure=0.024536133}}}, -.{.t=29044110747,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.16653442,.y=0.8192444,.pressure=0.023468018}}}, -.{.t=29044114927,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.16690063,.y=0.81710815,.pressure=0.023101807}}}, -.{.t=29055305531,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.16772461,.y=0.81536865,.pressure=0.022766113}}}, -.{.t=29055315751,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.16854858,.y=0.81365967,.pressure=0.022399902}}}, -.{.t=29066613054,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.16940308,.y=0.811615,.pressure=0.02166748}}}, -.{.t=29066629614,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.17041016,.y=0.80908203,.pressure=0.02130127}}}, -.{.t=29066636804,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.17147827,.y=0.8067322,.pressure=0.02130127}}}, -.{.t=29077513018,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.17288208,.y=0.8036804,.pressure=0.019165039}}}, -.{.t=29077525768,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.17391968,.y=0.8003235,.pressure=0.015197754}}}, -.{.t=29077531158,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.17553711,.y=0.7965088,.pressure=0.014831543}}}, -.{.t=29088910511,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.17697144,.y=0.7913208,.pressure=0.015563965}}}, -.{.t=29088924801,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.17819214,.y=0.78622437,.pressure=0.01449585}}}, -.{.t=29088930391,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.17999268,.y=0.7813721,.pressure=0.013397217}}}, -.{.t=29100047575,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.18148804,.y=0.7752991,.pressure=0.014129639}}}, -.{.t=29100061535,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.1831665,.y=0.76898193,.pressure=0.014129639}}}, -.{.t=29100068045,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.184906,.y=0.7624817,.pressure=0.013763428}}}, -.{.t=29111067488,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.18692017,.y=0.7561035,.pressure=0.013061523}}}, -.{.t=29111083948,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.18884277,.y=0.7487488,.pressure=0.01449585}}}, -.{.t=29122288972,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.19082642,.y=0.7409973,.pressure=0.01449585}}}, -.{.t=29122305542,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.19223022,.y=0.73428345,.pressure=0.014831543}}}, -.{.t=29122313342,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.19274902,.y=0.7257385,.pressure=0.014831543}}}, -.{.t=29133328146,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.19299316,.y=0.714447,.pressure=0.015197754}}}, -.{.t=29133345356,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.1928711,.y=0.7018738,.pressure=0.01449585}}}, -.{.t=29133350306,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.19335938,.y=0.6808777,.pressure=0.014831543}}}, -.{.t=29144200749,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.19464111,.y=0.65582275,.pressure=0.014831543}}}, -.{.t=29144216579,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.19668579,.y=0.63186646,.pressure=0.01449585}}}, -.{.t=29144223419,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.19927979,.y=0.6045227,.pressure=0.013763428}}}, -.{.t=29154998954,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.20211792,.y=0.57891846,.pressure=0.0126953125}}}, -.{.t=29155006203,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.20501709,.y=0.551239,.pressure=0.0126953125}}}, -.{.t=29166393667,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.20880127,.y=0.5248718,.pressure=0.012329102}}}, -.{.t=29166404147,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.21270752,.y=0.499115,.pressure=0.013397217}}}, -.{.t=29166409197,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.21655273,.y=0.47366333,.pressure=0.013763428}}}, -.{.t=29177500380,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.2204895,.y=0.45114136,.pressure=0.0101623535}}}, -.{.t=29177510970,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.22451782,.y=0.4290161,.pressure=0.0101623535}}}, -.{.t=29177516230,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.2286377,.y=0.40975952,.pressure=0.0101623535}}}, -.{.t=29188832983,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.23208618,.y=0.39212036,.pressure=0.010528564}}}, -.{.t=29188846483,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.23532104,.y=0.375885,.pressure=0.007293701}}}, -.{.t=29188851103,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.23809814,.y=0.35943604,.pressure=0.009460449}}}, -.{.t=29200021967,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.24072266,.y=0.34292603,.pressure=0.011260986}}}, -.{.t=29200037067,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.24298096,.y=0.32809448,.pressure=0.011962891}}}, -.{.t=29200042877,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.24493408,.y=0.3138733,.pressure=0.010528564}}}, -.{.t=29210884631,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.24728394,.y=0.29989624,.pressure=0.012329102}}}, -.{.t=29221881625,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.24908447,.y=0.2866516,.pressure=0.011962891}}}, -.{.t=29221891355,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.250885,.y=0.2755432,.pressure=0.010528564}}}, -.{.t=29221896615,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.252594,.y=0.26571655,.pressure=0.011962891}}}, -.{.t=29233293918,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.25378418,.y=0.2571106,.pressure=0.0126953125}}}, -.{.t=29233306418,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.25476074,.y=0.24942017,.pressure=0.0126953125}}}, -.{.t=29233312238,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.25534058,.y=0.24307251,.pressure=0.011260986}}}, -.{.t=29244359261,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.25610352,.y=0.23760986,.pressure=0.0101623535}}}, -.{.t=29244375081,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.25680542,.y=0.23291016,.pressure=0.0101623535}}}, -.{.t=29244383211,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.25750732,.y=0.22824097,.pressure=0.0101623535}}}, -.{.t=29255381715,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.25823975,.y=0.22570801,.pressure=0.007659912}}}, -.{.t=29255392615,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.25909424,.y=0.2234497,.pressure=0.007293701}}}, -.{.t=29266740458,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.2599182,.y=0.22180176,.pressure=0.006225586}}}, -.{.t=29266753748,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.26089478,.y=0.22140503,.pressure=0.0051574707}}}, -.{.t=29266758978,.pad=2,.ev=.{.touch=.{.touchpad=0,.finger=0,.phase=.motion,.x=0.26275635,.y=0.22149658,.pressure=0.0033569336}}}, + .{ .t = 28555347100, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.29483032, .y = 0.24435425, .pressure = 0.0022583008 } } }, + .{ .t = 28555355490, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.2937622, .y = 0.24847412, .pressure = 0.0015563965 } } }, + .{ .t = 28566662333, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.2920227, .y = 0.25350952, .pressure = 0.00048828125 } } }, + .{ .t = 28566669273, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .up, .x = 0.28912354, .y = 0.25863647, .pressure = 0 } } }, + .{ .t = 28633190705, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .down, .x = 0.26437378, .y = 0.44036865, .pressure = 0.0008239746 } } }, + .{ .t = 28644226129, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.2635193, .y = 0.44857788, .pressure = 0.0008239746 } } }, + .{ .t = 28644235079, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.26348877, .y = 0.4538269, .pressure = 0.0015563965 } } }, + .{ .t = 28644241049, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.26272583, .y = 0.45950317, .pressure = 0.003692627 } } }, + .{ .t = 28655363472, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.26229858, .y = 0.46218872, .pressure = 0.0047912598 } } }, + .{ .t = 28655373032, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.26153564, .y = 0.46594238, .pressure = 0.005493164 } } }, + .{ .t = 28666533886, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.2607727, .y = 0.46810913, .pressure = 0.008026123 } } }, + .{ .t = 28666541736, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.26037598, .y = 0.46969604, .pressure = 0.00982666 } } }, + .{ .t = 28666544986, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.26004028, .y = 0.47079468, .pressure = 0.010894775 } } }, + .{ .t = 28677510399, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.25985718, .y = 0.47192383, .pressure = 0.011962891 } } }, + .{ .t = 28677516759, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.25924683, .y = 0.47277832, .pressure = 0.013061523 } } }, + .{ .t = 28677520229, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.25894165, .y = 0.47366333, .pressure = 0.01449585 } } }, + .{ .t = 28688736483, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.25906372, .y = 0.47409058, .pressure = 0.015197754 } } }, + .{ .t = 28688747523, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.25872803, .y = 0.47351074, .pressure = 0.013061523 } } }, + .{ .t = 28688752063, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.25827026, .y = 0.4732666, .pressure = 0.013397217 } } }, + .{ .t = 28699780696, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.2581787, .y = 0.47317505, .pressure = 0.014129639 } } }, + .{ .t = 28699788576, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.25759888, .y = 0.47305298, .pressure = 0.014831543 } } }, + .{ .t = 28699792416, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.25787354, .y = 0.47280884, .pressure = 0.01449585 } } }, + .{ .t = 28711058720, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.25784302, .y = 0.47225952, .pressure = 0.013763428 } } }, + .{ .t = 28711073040, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.25738525, .y = 0.472229, .pressure = 0.014129639 } } }, + .{ .t = 28722312593, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.25720215, .y = 0.4717102, .pressure = 0.013763428 } } }, + .{ .t = 28722328533, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.2572937, .y = 0.47213745, .pressure = 0.012329102 } } }, + .{ .t = 28722335123, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.2576294, .y = 0.4721985, .pressure = 0.01449585 } } }, + .{ .t = 28733104547, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.25784302, .y = 0.4718933, .pressure = 0.013763428 } } }, + .{ .t = 28733113157, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.2571411, .y = 0.472229, .pressure = 0.013763428 } } }, + .{ .t = 28733116517, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.256958, .y = 0.47235107, .pressure = 0.010894775 } } }, + .{ .t = 28744542840, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.25598145, .y = 0.47323608, .pressure = 0.011962891 } } }, + .{ .t = 28744554360, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.25558472, .y = 0.47372437, .pressure = 0.012329102 } } }, + .{ .t = 28744558310, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.25463867, .y = 0.47329712, .pressure = 0.013061523 } } }, + .{ .t = 28755164615, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.2541809, .y = 0.4736023, .pressure = 0.013397217 } } }, + .{ .t = 28755173055, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.2536316, .y = 0.47485352, .pressure = 0.013397217 } } }, + .{ .t = 28766369408, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.2527771, .y = 0.4749756, .pressure = 0.011962891 } } }, + .{ .t = 28766376998, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.2524109, .y = 0.47543335, .pressure = 0.011962891 } } }, + .{ .t = 28766380848, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.2518921, .y = 0.4761963, .pressure = 0.011962891 } } }, + .{ .t = 28777479342, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.25073242, .y = 0.4764099, .pressure = 0.013397217 } } }, + .{ .t = 28777487702, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.24984741, .y = 0.4772644, .pressure = 0.015197754 } } }, + .{ .t = 28777491542, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.24942017, .y = 0.47872925, .pressure = 0.015563965 } } }, + .{ .t = 28788858885, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.24816895, .y = 0.47982788, .pressure = 0.016296387 } } }, + .{ .t = 28788869705, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.247406, .y = 0.48181152, .pressure = 0.016998291 } } }, + .{ .t = 28788873665, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.24645996, .y = 0.48260498, .pressure = 0.015563965 } } }, + .{ .t = 28800073548, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.2456665, .y = 0.48516846, .pressure = 0.01663208 } } }, + .{ .t = 28800082148, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.24414062, .y = 0.48757935, .pressure = 0.018432617 } } }, + .{ .t = 28800086718, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.2437439, .y = 0.48986816, .pressure = 0.019165039 } } }, + .{ .t = 28810881362, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.2432251, .y = 0.49273682, .pressure = 0.017730713 } } }, + .{ .t = 28810890602, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.24337769, .y = 0.4951172, .pressure = 0.018432617 } } }, + .{ .t = 28822223135, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.24224854, .y = 0.49868774, .pressure = 0.018066406 } } }, + .{ .t = 28822236725, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.2409668, .y = 0.5030823, .pressure = 0.018432617 } } }, + .{ .t = 28822243035, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.24002075, .y = 0.5093689, .pressure = 0.017364502 } } }, + .{ .t = 28833221849, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.23800659, .y = 0.52023315, .pressure = 0.017364502 } } }, + .{ .t = 28833234799, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.23648071, .y = 0.5312195, .pressure = 0.018066406 } } }, + .{ .t = 28833241859, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.23449707, .y = 0.54260254, .pressure = 0.018432617 } } }, + .{ .t = 28844533292, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.23208618, .y = 0.5539551, .pressure = 0.019165039 } } }, + .{ .t = 28844544902, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.22930908, .y = 0.5640869, .pressure = 0.020599365 } } }, + .{ .t = 28844549012, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.22769165, .y = 0.5701294, .pressure = 0.022399902 } } }, + .{ .t = 28855315576, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.22613525, .y = 0.57528687, .pressure = 0.023468018 } } }, + .{ .t = 28855325516, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.22503662, .y = 0.5812073, .pressure = 0.02420044 } } }, + .{ .t = 28866614540, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.22335815, .y = 0.5848694, .pressure = 0.02420044 } } }, + .{ .t = 28866626480, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.22390747, .y = 0.5887146, .pressure = 0.024536133 } } }, + .{ .t = 28866629910, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.22283936, .y = 0.59265137, .pressure = 0.024536133 } } }, + .{ .t = 28877415724, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.22262573, .y = 0.59625244, .pressure = 0.025268555 } } }, + .{ .t = 28877428004, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.22128296, .y = 0.6008606, .pressure = 0.025268555 } } }, + .{ .t = 28888551597, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.2204895, .y = 0.60409546, .pressure = 0.025268555 } } }, + .{ .t = 28888564767, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.21896362, .y = 0.61083984, .pressure = 0.025634766 } } }, + .{ .t = 28888571967, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.21774292, .y = 0.6156006, .pressure = 0.025970459 } } }, + .{ .t = 28899744701, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.21542358, .y = 0.62112427, .pressure = 0.02633667 } } }, + .{ .t = 28899757861, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.21438599, .y = 0.62576294, .pressure = 0.027435303 } } }, + .{ .t = 28899764601, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.21298218, .y = 0.63223267, .pressure = 0.027069092 } } }, + .{ .t = 28910731865, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.21209717, .y = 0.63708496, .pressure = 0.02633667 } } }, + .{ .t = 28910746485, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.21133423, .y = 0.6419983, .pressure = 0.02670288 } } }, + .{ .t = 28921990138, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.21032715, .y = 0.64730835, .pressure = 0.027435303 } } }, + .{ .t = 28922004158, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.2090149, .y = 0.65237427, .pressure = 0.027069092 } } }, + .{ .t = 28922010498, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.20770264, .y = 0.6588135, .pressure = 0.02670288 } } }, + .{ .t = 28932967412, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.20559692, .y = 0.6654968, .pressure = 0.025970459 } } }, + .{ .t = 28932979792, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.20404053, .y = 0.67285156, .pressure = 0.025634766 } } }, + .{ .t = 28932983492, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.20187378, .y = 0.6821594, .pressure = 0.024536133 } } }, + .{ .t = 28944345285, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.19940186, .y = 0.6911926, .pressure = 0.02420044 } } }, + .{ .t = 28944363135, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.19662476, .y = 0.703949, .pressure = 0.022033691 } } }, + .{ .t = 28944369185, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.19250488, .y = 0.71707153, .pressure = 0.02130127 } } }, + .{ .t = 28955070939, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.18859863, .y = 0.7327881, .pressure = 0.020599365 } } }, + .{ .t = 28955080209, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.18469238, .y = 0.7469177, .pressure = 0.018798828 } } }, + .{ .t = 28966644072, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.1803894, .y = 0.76065063, .pressure = 0.018066406 } } }, + .{ .t = 28966660132, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.17681885, .y = 0.7729492, .pressure = 0.019165039 } } }, + .{ .t = 28966666102, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.17303467, .y = 0.78430176, .pressure = 0.01953125 } } }, + .{ .t = 28977523276, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.17047119, .y = 0.79385376, .pressure = 0.019165039 } } }, + .{ .t = 28977533506, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.16790771, .y = 0.8000183, .pressure = 0.019866943 } } }, + .{ .t = 28977538756, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.16583252, .y = 0.8055115, .pressure = 0.018798828 } } }, + .{ .t = 28988801809, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.16448975, .y = 0.8109131, .pressure = 0.01953125 } } }, + .{ .t = 28988815059, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.16299438, .y = 0.81552124, .pressure = 0.02130127 } } }, + .{ .t = 28988820159, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.16275024, .y = 0.8183899, .pressure = 0.02166748 } } }, + .{ .t = 29000005933, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.16235352, .y = 0.8191223, .pressure = 0.022399902 } } }, + .{ .t = 29000020133, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.16220093, .y = 0.820343, .pressure = 0.023468018 } } }, + .{ .t = 29000023943, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.16268921, .y = 0.8208618, .pressure = 0.023834229 } } }, + .{ .t = 29010879647, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.1618042, .y = 0.82214355, .pressure = 0.025634766 } } }, + .{ .t = 29010893477, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.16238403, .y = 0.82196045, .pressure = 0.02633667 } } }, + .{ .t = 29022239700, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.16329956, .y = 0.82180786, .pressure = 0.027069092 } } }, + .{ .t = 29022255010, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.16305542, .y = 0.8227539, .pressure = 0.027069092 } } }, + .{ .t = 29022260530, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.16360474, .y = 0.8215027, .pressure = 0.02670288 } } }, + .{ .t = 29033423863, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.16390991, .y = 0.8215637, .pressure = 0.02670288 } } }, + .{ .t = 29033439393, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.16513062, .y = 0.820282, .pressure = 0.02633667 } } }, + .{ .t = 29033446553, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.16571045, .y = 0.82003784, .pressure = 0.027069092 } } }, + .{ .t = 29044100787, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.16552734, .y = 0.81985474, .pressure = 0.024536133 } } }, + .{ .t = 29044110747, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.16653442, .y = 0.8192444, .pressure = 0.023468018 } } }, + .{ .t = 29044114927, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.16690063, .y = 0.81710815, .pressure = 0.023101807 } } }, + .{ .t = 29055305531, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.16772461, .y = 0.81536865, .pressure = 0.022766113 } } }, + .{ .t = 29055315751, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.16854858, .y = 0.81365967, .pressure = 0.022399902 } } }, + .{ .t = 29066613054, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.16940308, .y = 0.811615, .pressure = 0.02166748 } } }, + .{ .t = 29066629614, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.17041016, .y = 0.80908203, .pressure = 0.02130127 } } }, + .{ .t = 29066636804, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.17147827, .y = 0.8067322, .pressure = 0.02130127 } } }, + .{ .t = 29077513018, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.17288208, .y = 0.8036804, .pressure = 0.019165039 } } }, + .{ .t = 29077525768, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.17391968, .y = 0.8003235, .pressure = 0.015197754 } } }, + .{ .t = 29077531158, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.17553711, .y = 0.7965088, .pressure = 0.014831543 } } }, + .{ .t = 29088910511, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.17697144, .y = 0.7913208, .pressure = 0.015563965 } } }, + .{ .t = 29088924801, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.17819214, .y = 0.78622437, .pressure = 0.01449585 } } }, + .{ .t = 29088930391, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.17999268, .y = 0.7813721, .pressure = 0.013397217 } } }, + .{ .t = 29100047575, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.18148804, .y = 0.7752991, .pressure = 0.014129639 } } }, + .{ .t = 29100061535, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.1831665, .y = 0.76898193, .pressure = 0.014129639 } } }, + .{ .t = 29100068045, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.184906, .y = 0.7624817, .pressure = 0.013763428 } } }, + .{ .t = 29111067488, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.18692017, .y = 0.7561035, .pressure = 0.013061523 } } }, + .{ .t = 29111083948, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.18884277, .y = 0.7487488, .pressure = 0.01449585 } } }, + .{ .t = 29122288972, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.19082642, .y = 0.7409973, .pressure = 0.01449585 } } }, + .{ .t = 29122305542, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.19223022, .y = 0.73428345, .pressure = 0.014831543 } } }, + .{ .t = 29122313342, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.19274902, .y = 0.7257385, .pressure = 0.014831543 } } }, + .{ .t = 29133328146, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.19299316, .y = 0.714447, .pressure = 0.015197754 } } }, + .{ .t = 29133345356, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.1928711, .y = 0.7018738, .pressure = 0.01449585 } } }, + .{ .t = 29133350306, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.19335938, .y = 0.6808777, .pressure = 0.014831543 } } }, + .{ .t = 29144200749, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.19464111, .y = 0.65582275, .pressure = 0.014831543 } } }, + .{ .t = 29144216579, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.19668579, .y = 0.63186646, .pressure = 0.01449585 } } }, + .{ .t = 29144223419, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.19927979, .y = 0.6045227, .pressure = 0.013763428 } } }, + .{ .t = 29154998954, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.20211792, .y = 0.57891846, .pressure = 0.0126953125 } } }, + .{ .t = 29155006203, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.20501709, .y = 0.551239, .pressure = 0.0126953125 } } }, + .{ .t = 29166393667, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.20880127, .y = 0.5248718, .pressure = 0.012329102 } } }, + .{ .t = 29166404147, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.21270752, .y = 0.499115, .pressure = 0.013397217 } } }, + .{ .t = 29166409197, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.21655273, .y = 0.47366333, .pressure = 0.013763428 } } }, + .{ .t = 29177500380, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.2204895, .y = 0.45114136, .pressure = 0.0101623535 } } }, + .{ .t = 29177510970, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.22451782, .y = 0.4290161, .pressure = 0.0101623535 } } }, + .{ .t = 29177516230, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.2286377, .y = 0.40975952, .pressure = 0.0101623535 } } }, + .{ .t = 29188832983, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.23208618, .y = 0.39212036, .pressure = 0.010528564 } } }, + .{ .t = 29188846483, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.23532104, .y = 0.375885, .pressure = 0.007293701 } } }, + .{ .t = 29188851103, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.23809814, .y = 0.35943604, .pressure = 0.009460449 } } }, + .{ .t = 29200021967, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.24072266, .y = 0.34292603, .pressure = 0.011260986 } } }, + .{ .t = 29200037067, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.24298096, .y = 0.32809448, .pressure = 0.011962891 } } }, + .{ .t = 29200042877, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.24493408, .y = 0.3138733, .pressure = 0.010528564 } } }, + .{ .t = 29210884631, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.24728394, .y = 0.29989624, .pressure = 0.012329102 } } }, + .{ .t = 29221881625, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.24908447, .y = 0.2866516, .pressure = 0.011962891 } } }, + .{ .t = 29221891355, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.250885, .y = 0.2755432, .pressure = 0.010528564 } } }, + .{ .t = 29221896615, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.252594, .y = 0.26571655, .pressure = 0.011962891 } } }, + .{ .t = 29233293918, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.25378418, .y = 0.2571106, .pressure = 0.0126953125 } } }, + .{ .t = 29233306418, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.25476074, .y = 0.24942017, .pressure = 0.0126953125 } } }, + .{ .t = 29233312238, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.25534058, .y = 0.24307251, .pressure = 0.011260986 } } }, + .{ .t = 29244359261, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.25610352, .y = 0.23760986, .pressure = 0.0101623535 } } }, + .{ .t = 29244375081, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.25680542, .y = 0.23291016, .pressure = 0.0101623535 } } }, + .{ .t = 29244383211, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.25750732, .y = 0.22824097, .pressure = 0.0101623535 } } }, + .{ .t = 29255381715, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.25823975, .y = 0.22570801, .pressure = 0.007659912 } } }, + .{ .t = 29255392615, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.25909424, .y = 0.2234497, .pressure = 0.007293701 } } }, + .{ .t = 29266740458, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.2599182, .y = 0.22180176, .pressure = 0.006225586 } } }, + .{ .t = 29266753748, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.26089478, .y = 0.22140503, .pressure = 0.0051574707 } } }, + .{ .t = 29266758978, .pad = 2, .ev = .{ .touch = .{ .touchpad = 0, .finger = 0, .phase = .motion, .x = 0.26275635, .y = 0.22149658, .pressure = 0.0033569336 } } }, } } diff --git a/test/deck/replay.zig b/test/deck/replay.zig index 49614b46..778f4191 100644 --- a/test/deck/replay.zig +++ b/test/deck/replay.zig @@ -45,12 +45,12 @@ fn replay(src: [:0]const u8) !Tally { tally.max_step = @max(tally.max_step, @max(@abs(mv.dx), @abs(mv.dy))); }, .click => |ck| if (ck.down) { - tally.click_down[@intFromEnum(ck.which)] += 1; + tally.click_down[@backingInt(ck.which)] += 1; } else { - tally.click_up[@intFromEnum(ck.which)] += 1; + tally.click_up[@backingInt(ck.which)] += 1; }, .wheel => |ticks| tally.wheel += ticks, - .key => |k| tally.keys[@intFromEnum(k)] += 1, + .key => |k| tally.keys[@backingInt(k)] += 1, .rumble => tally.rumbles += 1, }; } @@ -72,7 +72,7 @@ test "right-pad drag moves the pointer, fresh touches don't jump" { try std.testing.expectEqual(0, t.wheel); // a light-touch drag stays well under the click threshold — no phantom // select clicks (nor their rumble) - try std.testing.expectEqual(0, t.click_down[@intFromEnum(deck.Click.select)]); + try std.testing.expectEqual(0, t.click_down[@backingInt(deck.Click.select)]); try std.testing.expectEqual(0, t.rumbles); } @@ -82,11 +82,11 @@ test "trigger pull+release clicks exactly once each" { // through dozens of intermediate values, interleaved with ~500 stick // axis events: hysteresis must yield exactly one click apiece, only // the execute pull rumbles, and the sticks produce nothing - try std.testing.expectEqual(1, t.click_down[@intFromEnum(deck.Click.select)]); - try std.testing.expectEqual(1, t.click_up[@intFromEnum(deck.Click.select)]); - try std.testing.expectEqual(1, t.click_down[@intFromEnum(deck.Click.execute)]); - try std.testing.expectEqual(1, t.click_up[@intFromEnum(deck.Click.execute)]); - try std.testing.expectEqual(0, t.click_down[@intFromEnum(deck.Click.look)]); + try std.testing.expectEqual(1, t.click_down[@backingInt(deck.Click.select)]); + try std.testing.expectEqual(1, t.click_up[@backingInt(deck.Click.select)]); + try std.testing.expectEqual(1, t.click_down[@backingInt(deck.Click.execute)]); + try std.testing.expectEqual(1, t.click_up[@backingInt(deck.Click.execute)]); + try std.testing.expectEqual(0, t.click_down[@backingInt(deck.Click.look)]); try std.testing.expectEqual(1, t.rumbles); try std.testing.expectEqual(0, t.moves); } @@ -100,7 +100,7 @@ test "left-pad swipe scrolls" { try std.testing.expectEqual(5, t.wheel); try std.testing.expectEqual(0, t.moves); // the swipe presses lightly — no phantom look clicks - try std.testing.expectEqual(0, t.click_down[@intFromEnum(deck.Click.look)]); + try std.testing.expectEqual(0, t.click_down[@backingInt(deck.Click.look)]); try std.testing.expectEqual(0, t.rumbles); } @@ -166,15 +166,15 @@ test "buttons: dpad n/N, A Enter, Y Tab, L1 look + rumble" { const t = try replay(@embedFile("buttons.zon")); // every button press of a real all-buttons sweep: dpad-down x1, // dpad-up x3, A x2, Y x5, L1 x3; the other buttons map to nothing - try std.testing.expectEqual(1, t.keys[@intFromEnum(deck.Keytap.n)]); - try std.testing.expectEqual(3, t.keys[@intFromEnum(deck.Keytap.cap_n)]); - try std.testing.expectEqual(2, t.keys[@intFromEnum(deck.Keytap.enter)]); - try std.testing.expectEqual(5, t.keys[@intFromEnum(deck.Keytap.tab)]); - try std.testing.expectEqual(3, t.click_down[@intFromEnum(deck.Click.look)]); - try std.testing.expectEqual(3, t.click_up[@intFromEnum(deck.Click.look)]); + try std.testing.expectEqual(1, t.keys[@backingInt(deck.Keytap.n)]); + try std.testing.expectEqual(3, t.keys[@backingInt(deck.Keytap.cap_n)]); + try std.testing.expectEqual(2, t.keys[@backingInt(deck.Keytap.enter)]); + try std.testing.expectEqual(5, t.keys[@backingInt(deck.Keytap.tab)]); + try std.testing.expectEqual(3, t.click_down[@backingInt(deck.Click.look)]); + try std.testing.expectEqual(3, t.click_up[@backingInt(deck.Click.look)]); try std.testing.expectEqual(3, t.rumbles); - try std.testing.expectEqual(0, t.click_down[@intFromEnum(deck.Click.select)]); - try std.testing.expectEqual(0, t.click_down[@intFromEnum(deck.Click.execute)]); + try std.testing.expectEqual(0, t.click_down[@backingInt(deck.Click.select)]); + try std.testing.expectEqual(0, t.click_down[@backingInt(deck.Click.execute)]); try std.testing.expectEqual(0, t.moves); try std.testing.expectEqual(0, t.wheel); } diff --git a/test/deck/rpad-drag.zon b/test/deck/rpad-drag.zon index 20dea6ef..c7a82db9 100644 --- a/test/deck/rpad-drag.zon +++ b/test/deck/rpad-drag.zon @@ -1,223 +1,223 @@ .{ .version = 1, .events = .{ -.{.t=1557743788,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.down,.x=0.48794556,.y=0.3156128,.pressure=0.0004272461}}}, -.{.t=1557747308,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.49105835,.y=0.31570435,.pressure=0.0015563965}}}, -.{.t=1568667061,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.49325562,.y=0.31576538,.pressure=0.004638672}}}, -.{.t=1568677161,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.49591064,.y=0.31585693,.pressure=0.0035095215}}}, -.{.t=1568682171,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.4988098,.y=0.31588745,.pressure=0.0026855469}}}, -.{.t=1579851545,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.50076294,.y=0.31607056,.pressure=0.004638672}}}, -.{.t=1579859265,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.50289917,.y=0.31637573,.pressure=0.0063171387}}}, -.{.t=1579863375,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.5050354,.y=0.31655884,.pressure=0.008026123}}}, -.{.t=1590959349,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.50717163,.y=0.31655884,.pressure=0.0063171387}}}, -.{.t=1590970369,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.50927734,.y=0.31698608,.pressure=0.0040893555}}}, -.{.t=1590975739,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.5108948,.y=0.31750488,.pressure=0.0038146973}}}, -.{.t=1601902982,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.5126953,.y=0.31808472,.pressure=0.005218506}}}, -.{.t=1601911482,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.51400757,.y=0.318573,.pressure=0.0066223145}}}, -.{.t=1613345665,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.51571655,.y=0.31878662,.pressure=0.007171631}}}, -.{.t=1613352235,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.51660156,.y=0.31936646,.pressure=0.0068969727}}}, -.{.t=1613356725,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.5178528,.y=0.3199463,.pressure=0.0066223145}}}, -.{.t=1624412039,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.5187378,.y=0.3206787,.pressure=0.0057678223}}}, -.{.t=1624425589,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.52023315,.y=0.32138062,.pressure=0.0043640137}}}, -.{.t=1624432009,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.5215454,.y=0.3218689,.pressure=0.0040893555}}}, -.{.t=1635289123,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.5227356,.y=0.3222351,.pressure=0.0018310547}}}, -.{.t=1635297503,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.52371216,.y=0.3229065,.pressure=0.0026855469}}}, -.{.t=1635301553,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.5246887,.y=0.3234558,.pressure=0.002105713}}}, -.{.t=1646425097,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.52545166,.y=0.323761,.pressure=0.0007019043}}}, -.{.t=1646433957,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.up,.x=0.5263977,.y=0.3241577,.pressure=0}}}, -.{.t=1657611170,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.down,.x=0.52749634,.y=0.32489014,.pressure=0.0004272461}}}, -.{.t=1657620700,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.up,.x=0.52893066,.y=0.32543945,.pressure=0}}}, -.{.t=2568455904,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.down,.x=0.71746826,.y=0.4960022,.pressure=0.0026855469}}}, -.{.t=2568464274,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.72143555,.y=0.49996948,.pressure=0.0032348633}}}, -.{.t=2568468384,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.72436523,.y=0.5033264,.pressure=0.004638672}}}, -.{.t=2579442397,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7271118,.y=0.5065918,.pressure=0.0066223145}}}, -.{.t=2579450697,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.73065186,.y=0.51031494,.pressure=0.008850098}}}, -.{.t=2579455357,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7350464,.y=0.5145569,.pressure=0.010253906}}}, -.{.t=2590631621,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.74017334,.y=0.51916504,.pressure=0.012512207}}}, -.{.t=2590639051,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7455139,.y=0.52420044,.pressure=0.014190674}}}, -.{.t=2601728264,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7537842,.y=0.5307617,.pressure=0.01727295}}}, -.{.t=2601737594,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.76501465,.y=0.5390625,.pressure=0.017852783}}}, -.{.t=2601745184,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7758789,.y=0.54782104,.pressure=0.017578125}}}, -.{.t=2612868798,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.78726196,.y=0.55740356,.pressure=0.018676758}}}, -.{.t=2612877548,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.79766846,.y=0.56655884,.pressure=0.016998291}}}, -.{.t=2612881858,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.8077698,.y=0.57421875,.pressure=0.016174316}}}, -.{.t=2624096121,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.81689453,.y=0.5804138,.pressure=0.0184021}}}, -.{.t=2624103861,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.8230896,.y=0.58462524,.pressure=0.017578125}}}, -.{.t=2624108371,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.8291321,.y=0.58810425,.pressure=0.016448975}}}, -.{.t=2635100225,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.8328247,.y=0.5901184,.pressure=0.015594482}}}, -.{.t=2635107345,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.835022,.y=0.59017944,.pressure=0.016174316}}}, -.{.t=2635111905,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.83724976,.y=0.5899353,.pressure=0.016174316}}}, -.{.t=2646151229,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.8390808,.y=0.5890198,.pressure=0.014770508}}}, -.{.t=2646160149,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.8404541,.y=0.58709717,.pressure=0.014190674}}}, -.{.t=2657358812,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.8408203,.y=0.58535767,.pressure=0.016448975}}}, -.{.t=2657364952,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.8411865,.y=0.5831604,.pressure=0.015045166}}}, -.{.t=2657368602,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.84106445,.y=0.5809021,.pressure=0.0184021}}}, -.{.t=2668497496,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.84155273,.y=0.5791321,.pressure=0.018676758}}}, -.{.t=2668503176,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.84198,.y=0.5767517,.pressure=0.0184021}}}, -.{.t=2679574619,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.8413696,.y=0.5749817,.pressure=0.01727295}}}, -.{.t=2679583429,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.8410034,.y=0.57302856,.pressure=0.015594482}}}, -.{.t=2679588959,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.8402405,.y=0.57077026,.pressure=0.016998291}}}, -.{.t=2690585493,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.83987427,.y=0.5680237,.pressure=0.017578125}}}, -.{.t=2690591573,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.8392639,.y=0.5658264,.pressure=0.016998291}}}, -.{.t=2701710277,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.8384094,.y=0.56329346,.pressure=0.015045166}}}, -.{.t=2701715427,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.8366089,.y=0.5602722,.pressure=0.012512207}}}, -.{.t=2701719287,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.8343506,.y=0.55578613,.pressure=0.013641357}}}, -.{.t=2712932260,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.8309326,.y=0.5510254,.pressure=0.012512207}}}, -.{.t=2712941600,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.8270569,.y=0.54504395,.pressure=0.013641357}}}, -.{.t=2712946870,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.82263184,.y=0.53845215,.pressure=0.012786865}}}, -.{.t=2724074464,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.8186035,.y=0.5309448,.pressure=0.012237549}}}, -.{.t=2724081034,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.8176575,.y=0.5210266,.pressure=0.011383057}}}, -.{.t=2724085114,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.8161926,.y=0.5109863,.pressure=0.010253906}}}, -.{.t=2735041467,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.81481934,.y=0.49887085,.pressure=0.008575439}}}, -.{.t=2735049697,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.8135681,.y=0.48706055,.pressure=0.0066223145}}}, -.{.t=2735053437,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.8110962,.y=0.47451782,.pressure=0.0066223145}}}, -.{.t=2746200461,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.8079529,.y=0.46011353,.pressure=0.008300781}}}, -.{.t=2746207531,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.8046875,.y=0.44818115,.pressure=0.008850098}}}, -.{.t=2757301144,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.8004761,.y=0.4363098,.pressure=0.010253906}}}, -.{.t=2757308574,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.796051,.y=0.4248352,.pressure=0.009979248}}}, -.{.t=2757312724,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.79104614,.y=0.4133911,.pressure=0.013366699}}}, -.{.t=2775948317,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.78637695,.y=0.4032898,.pressure=0.012237549}}}, -.{.t=2775958817,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.78131104,.y=0.39471436,.pressure=0.015045166}}}, -.{.t=2775962507,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7763977,.y=0.38796997,.pressure=0.016723633}}}, -.{.t=2775966007,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.77178955,.y=0.38198853,.pressure=0.018127441}}}, -.{.t=2775969667,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.76724243,.y=0.37753296,.pressure=0.019805908}}}, -.{.t=2779448262,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7628784,.y=0.37338257,.pressure=0.018127441}}}, -.{.t=2790559265,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.75909424,.y=0.36990356,.pressure=0.020935059}}}, -.{.t=2790566225,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.75512695,.y=0.36654663,.pressure=0.021484375}}}, -.{.t=2801688299,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7513733,.y=0.36395264,.pressure=0.020385742}}}, -.{.t=2801695099,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7475891,.y=0.36190796,.pressure=0.020385742}}}, -.{.t=2801697739,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.74487305,.y=0.35958862,.pressure=0.020385742}}}, -.{.t=2812906962,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.74191284,.y=0.3572998,.pressure=0.022888184}}}, -.{.t=2812918202,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7388611,.y=0.35458374,.pressure=0.022338867}}}, -.{.t=2812924662,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7357178,.y=0.35250854,.pressure=0.021209717}}}, -.{.t=2824054786,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7324829,.y=0.3503418,.pressure=0.021484375}}}, -.{.t=2824059786,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7289429,.y=0.3484497,.pressure=0.022888184}}}, -.{.t=2824063716,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.72506714,.y=0.34591675,.pressure=0.022613525}}}, -.{.t=2835063039,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7218323,.y=0.34277344,.pressure=0.02319336}}}, -.{.t=2835070099,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7174072,.y=0.34020996,.pressure=0.020080566}}}, -.{.t=2835075929,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.71273804,.y=0.33743286,.pressure=0.020080566}}}, -.{.t=2846116163,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7079773,.y=0.3343506,.pressure=0.018676758}}}, -.{.t=2846123943,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7023926,.y=0.33081055,.pressure=0.019805908}}}, -.{.t=2857453356,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.6963806,.y=0.32598877,.pressure=0.019805908}}}, -.{.t=2857460036,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.6892395,.y=0.32144165,.pressure=0.020935059}}}, -.{.t=2857466116,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.6821289,.y=0.31661987,.pressure=0.018127441}}}, -.{.t=2868624580,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.6739197,.y=0.31192017,.pressure=0.018676758}}}, -.{.t=2868632160,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.6664429,.y=0.3072815,.pressure=0.018981934}}}, -.{.t=2868637550,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.6587219,.y=0.30307007,.pressure=0.017578125}}}, -.{.t=2879637654,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.65133667,.y=0.29888916,.pressure=0.017852783}}}, -.{.t=2879646144,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.6444702,.y=0.29452515,.pressure=0.017852783}}}, -.{.t=2879653574,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.6372986,.y=0.29092407,.pressure=0.016174316}}}, -.{.t=2890493398,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.6305542,.y=0.28729248,.pressure=0.016448975}}}, -.{.t=2890500368,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.62493896,.y=0.28427124,.pressure=0.016448975}}}, -.{.t=2901904031,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.6192627,.y=0.28234863,.pressure=0.015594482}}}, -.{.t=2901913451,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.61428833,.y=0.27990723,.pressure=0.014190674}}}, -.{.t=2901920201,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.6097412,.y=0.277771,.pressure=0.013641357}}}, -.{.t=2913077524,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.6056824,.y=0.27627563,.pressure=0.013641357}}}, -.{.t=2913084054,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.6019287,.y=0.27560425,.pressure=0.012512207}}}, -.{.t=2913088274,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.5984192,.y=0.27441406,.pressure=0.011657715}}}, -.{.t=2924138128,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.59536743,.y=0.27404785,.pressure=0.011962891}}}, -.{.t=2924146018,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.5923767,.y=0.27398682,.pressure=0.013641357}}}, -.{.t=2924151648,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.5900574,.y=0.2736206,.pressure=0.013366699}}}, -.{.t=2935179332,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.5883484,.y=0.27407837,.pressure=0.014465332}}}, -.{.t=2935187861,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.5866394,.y=0.27478027,.pressure=0.01586914}}}, -.{.t=2935191171,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.58551025,.y=0.2756958,.pressure=0.015045166}}}, -.{.t=2946370475,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.5841675,.y=0.27648926,.pressure=0.01727295}}}, -.{.t=2946379375,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.5830078,.y=0.27764893,.pressure=0.0184021}}}, -.{.t=2957467849,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.5821533,.y=0.278656,.pressure=0.01953125}}}, -.{.t=2957477449,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.5817566,.y=0.28030396,.pressure=0.016998291}}}, -.{.t=2957483529,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.58148193,.y=0.28225708,.pressure=0.015319824}}}, -.{.t=2968627182,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.5809021,.y=0.2843933,.pressure=0.01586914}}}, -.{.t=2968643772,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.580719,.y=0.28659058,.pressure=0.014190674}}}, -.{.t=2979684996,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.5805969,.y=0.28967285,.pressure=0.013641357}}}, -.{.t=2979694336,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.58026123,.y=0.29241943,.pressure=0.010559082}}}, -.{.t=2979699086,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.57995605,.y=0.29571533,.pressure=0.008575439}}}, -.{.t=2990715289,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.57958984,.y=0.29934692,.pressure=0.010253906}}}, -.{.t=2990723719,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.5793457,.y=0.30322266,.pressure=0.008300781}}}, -.{.t=3002153093,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.5791931,.y=0.30700684,.pressure=0.0060424805}}}, -.{.t=3002161152,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.5791931,.y=0.3117981,.pressure=0.0060424805}}}, -.{.t=3002165632,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.57958984,.y=0.3164673,.pressure=0.00491333}}}, -.{.t=3012982186,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.5806885,.y=0.3215027,.pressure=0.0068969727}}}, -.{.t=3012991236,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.5819702,.y=0.32669067,.pressure=0.0057678223}}}, -.{.t=3012998166,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.5845032,.y=0.3322754,.pressure=0.007446289}}}, -.{.t=3024201460,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.5869446,.y=0.33740234,.pressure=0.008026123}}}, -.{.t=3024208990,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.59017944,.y=0.34225464,.pressure=0.009155273}}}, -.{.t=3024211980,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.5932617,.y=0.34698486,.pressure=0.012237549}}}, -.{.t=3035025244,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.59643555,.y=0.3517456,.pressure=0.013366699}}}, -.{.t=3035031374,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.6001282,.y=0.35601807,.pressure=0.016998291}}}, -.{.t=3035034874,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.60409546,.y=0.3600464,.pressure=0.019805908}}}, -.{.t=3046541367,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.60775757,.y=0.36398315,.pressure=0.022338867}}}, -.{.t=3046548887,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.61169434,.y=0.36740112,.pressure=0.022613525}}}, -.{.t=3057532891,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.6154785,.y=0.37051392,.pressure=0.025146484}}}, -.{.t=3057540471,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.6194763,.y=0.37329102,.pressure=0.025421143}}}, -.{.t=3057545781,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.6232605,.y=0.3761902,.pressure=0.026000977}}}, -.{.t=3068735374,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.62753296,.y=0.3789673,.pressure=0.025421143}}}, -.{.t=3068748304,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.6313782,.y=0.3816223,.pressure=0.024017334}}}, -.{.t=3068754594,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.63513184,.y=0.38391113,.pressure=0.023742676}}}, -.{.t=3079554878,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.6390991,.y=0.38616943,.pressure=0.023468018}}}, -.{.t=3079563518,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.6433716,.y=0.38833618,.pressure=0.02178955}}}, -.{.t=3079568338,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.64767456,.y=0.39031982,.pressure=0.02319336}}}, -.{.t=3090741042,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.65234375,.y=0.3919983,.pressure=0.02319336}}}, -.{.t=3090749882,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.65689087,.y=0.39379883,.pressure=0.021209717}}}, -.{.t=3101724975,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.6610718,.y=0.39520264,.pressure=0.022888184}}}, -.{.t=3101732005,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.66574097,.y=0.39642334,.pressure=0.021484375}}}, -.{.t=3101735255,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.6701355,.y=0.3973999,.pressure=0.019805908}}}, -.{.t=3113361458,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.6748352,.y=0.39767456,.pressure=0.0206604}}}, -.{.t=3113368498,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.67944336,.y=0.39797974,.pressure=0.022613525}}}, -.{.t=3113372028,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.6838379,.y=0.39785767,.pressure=0.022338867}}}, -.{.t=3123796833,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.6879883,.y=0.3970642,.pressure=0.01953125}}}, -.{.t=3123803053,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.69177246,.y=0.39624023,.pressure=0.018127441}}}, -.{.t=3123806563,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.69555664,.y=0.39569092,.pressure=0.016998291}}}, -.{.t=3134998596,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.69888306,.y=0.3942871,.pressure=0.016998291}}}, -.{.t=3135007066,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7023926,.y=0.39257812,.pressure=0.017578125}}}, -.{.t=3135011336,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7060852,.y=0.39056396,.pressure=0.017578125}}}, -.{.t=3146195970,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7102051,.y=0.38861084,.pressure=0.015594482}}}, -.{.t=3146202620,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.715271,.y=0.386261,.pressure=0.014190674}}}, -.{.t=3157408853,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7234802,.y=0.38327026,.pressure=0.01586914}}}, -.{.t=3157418073,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.730896,.y=0.38006592,.pressure=0.01586914}}}, -.{.t=3157423313,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.73880005,.y=0.37652588,.pressure=0.016448975}}}, -.{.t=3168334437,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.74557495,.y=0.37350464,.pressure=0.017578125}}}, -.{.t=3168341357,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.75097656,.y=0.37020874,.pressure=0.016723633}}}, -.{.t=3168344697,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7561035,.y=0.36791992,.pressure=0.013916016}}}, -.{.t=3179518520,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.75982666,.y=0.36517334,.pressure=0.013061523}}}, -.{.t=3179524910,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7633362,.y=0.3623352,.pressure=0.013061523}}}, -.{.t=3179530860,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.765625,.y=0.35949707,.pressure=0.013641357}}}, -.{.t=3190702424,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7669678,.y=0.3564453,.pressure=0.012786865}}}, -.{.t=3190710904,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.76849365,.y=0.3536682,.pressure=0.011383057}}}, -.{.t=3201886237,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7687378,.y=0.35095215,.pressure=0.010559082}}}, -.{.t=3201895897,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7681885,.y=0.34838867,.pressure=0.009155273}}}, -.{.t=3201900097,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7668457,.y=0.34570312,.pressure=0.009155273}}}, -.{.t=3212919591,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7654724,.y=0.34277344,.pressure=0.008850098}}}, -.{.t=3212927311,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7631836,.y=0.34002686,.pressure=0.0066223145}}}, -.{.t=3212932591,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7612915,.y=0.3373413,.pressure=0.0040893555}}}, -.{.t=3224127654,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7590027,.y=0.33529663,.pressure=0.0043640137}}}, -.{.t=3224134564,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7567444,.y=0.33319092,.pressure=0.0024108887}}}, -.{.t=3224138834,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7541809,.y=0.3307495,.pressure=0.00491333}}}, -.{.t=3234961798,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.75216675,.y=0.32843018,.pressure=0.0038146973}}}, -.{.t=3234967628,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7489929,.y=0.32583618,.pressure=0.0038146973}}}, -.{.t=3234971398,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7467346,.y=0.32296753,.pressure=0.005218506}}}, -.{.t=3246367272,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7436218,.y=0.32019043,.pressure=0.0043640137}}}, -.{.t=3246376701,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7402649,.y=0.3173523,.pressure=0.0038146973}}}, -.{.t=3257870675,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.73721313,.y=0.31466675,.pressure=0.0018310547}}}, -.{.t=3257881104,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7336731,.y=0.31219482,.pressure=0.0024108887}}}, -.{.t=3257886264,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.73062134,.y=0.3100891,.pressure=0.0015563965}}}, -.{.t=3268291019,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.72720337,.y=0.30807495,.pressure=0.0007019043}}}, -.{.t=3268298969,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7241516,.y=0.30593872,.pressure=0.0015563965}}}, -.{.t=3268303569,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7213135,.y=0.30371094,.pressure=0.0035095215}}}, -.{.t=3279746522,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.71810913,.y=0.302063,.pressure=0.002960205}}}, -.{.t=3279757542,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.7147217,.y=0.30056763,.pressure=0.00491333}}}, -.{.t=3279762862,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.71087646,.y=0.29907227,.pressure=0.00491333}}}, -.{.t=3290574016,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.70751953,.y=0.29745483,.pressure=0.0040893555}}}, -.{.t=3290581596,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.70376587,.y=0.29592896,.pressure=0.0040893555}}}, -.{.t=3301750300,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.6994934,.y=0.2951355,.pressure=0.0038146973}}}, -.{.t=3301760370,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.6951904,.y=0.29397583,.pressure=0.005218506}}}, -.{.t=3301767410,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.6905823,.y=0.29284668,.pressure=0.00491333}}}, -.{.t=3312951293,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.685791,.y=0.29266357,.pressure=0.0068969727}}}, -.{.t=3312959893,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.68136597,.y=0.29257202,.pressure=0.005493164}}}, -.{.t=3312965373,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.6772461,.y=0.29229736,.pressure=0.0068969727}}}, -.{.t=3324079267,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.672699,.y=0.29318237,.pressure=0.004638672}}}, -.{.t=3324090337,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.66882324,.y=0.294281,.pressure=0.004638672}}}, -.{.t=3324095997,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.66537476,.y=0.29525757,.pressure=0.004638672}}}, -.{.t=3335061800,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.6620178,.y=0.2966919,.pressure=0.002960205}}}, -.{.t=3335068160,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.6590576,.y=0.29788208,.pressure=0.0007019043}}}, -.{.t=3335073750,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.up,.x=0.6562805,.y=0.29956055,.pressure=0}}}, -.{.t=3390587188,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.down,.x=0.6447449,.y=0.33596802,.pressure=0.0007019043}}}, -.{.t=3390593138,.pad=2,.ev=.{.touch=.{.touchpad=1,.finger=0,.phase=.motion,.x=0.6447754,.y=0.3406067,.pressure=0.0035095215}}}, + .{ .t = 1557743788, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .down, .x = 0.48794556, .y = 0.3156128, .pressure = 0.0004272461 } } }, + .{ .t = 1557747308, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.49105835, .y = 0.31570435, .pressure = 0.0015563965 } } }, + .{ .t = 1568667061, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.49325562, .y = 0.31576538, .pressure = 0.004638672 } } }, + .{ .t = 1568677161, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.49591064, .y = 0.31585693, .pressure = 0.0035095215 } } }, + .{ .t = 1568682171, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.4988098, .y = 0.31588745, .pressure = 0.0026855469 } } }, + .{ .t = 1579851545, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.50076294, .y = 0.31607056, .pressure = 0.004638672 } } }, + .{ .t = 1579859265, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.50289917, .y = 0.31637573, .pressure = 0.0063171387 } } }, + .{ .t = 1579863375, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.5050354, .y = 0.31655884, .pressure = 0.008026123 } } }, + .{ .t = 1590959349, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.50717163, .y = 0.31655884, .pressure = 0.0063171387 } } }, + .{ .t = 1590970369, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.50927734, .y = 0.31698608, .pressure = 0.0040893555 } } }, + .{ .t = 1590975739, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.5108948, .y = 0.31750488, .pressure = 0.0038146973 } } }, + .{ .t = 1601902982, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.5126953, .y = 0.31808472, .pressure = 0.005218506 } } }, + .{ .t = 1601911482, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.51400757, .y = 0.318573, .pressure = 0.0066223145 } } }, + .{ .t = 1613345665, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.51571655, .y = 0.31878662, .pressure = 0.007171631 } } }, + .{ .t = 1613352235, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.51660156, .y = 0.31936646, .pressure = 0.0068969727 } } }, + .{ .t = 1613356725, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.5178528, .y = 0.3199463, .pressure = 0.0066223145 } } }, + .{ .t = 1624412039, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.5187378, .y = 0.3206787, .pressure = 0.0057678223 } } }, + .{ .t = 1624425589, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.52023315, .y = 0.32138062, .pressure = 0.0043640137 } } }, + .{ .t = 1624432009, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.5215454, .y = 0.3218689, .pressure = 0.0040893555 } } }, + .{ .t = 1635289123, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.5227356, .y = 0.3222351, .pressure = 0.0018310547 } } }, + .{ .t = 1635297503, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.52371216, .y = 0.3229065, .pressure = 0.0026855469 } } }, + .{ .t = 1635301553, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.5246887, .y = 0.3234558, .pressure = 0.002105713 } } }, + .{ .t = 1646425097, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.52545166, .y = 0.323761, .pressure = 0.0007019043 } } }, + .{ .t = 1646433957, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .up, .x = 0.5263977, .y = 0.3241577, .pressure = 0 } } }, + .{ .t = 1657611170, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .down, .x = 0.52749634, .y = 0.32489014, .pressure = 0.0004272461 } } }, + .{ .t = 1657620700, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .up, .x = 0.52893066, .y = 0.32543945, .pressure = 0 } } }, + .{ .t = 2568455904, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .down, .x = 0.71746826, .y = 0.4960022, .pressure = 0.0026855469 } } }, + .{ .t = 2568464274, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.72143555, .y = 0.49996948, .pressure = 0.0032348633 } } }, + .{ .t = 2568468384, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.72436523, .y = 0.5033264, .pressure = 0.004638672 } } }, + .{ .t = 2579442397, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7271118, .y = 0.5065918, .pressure = 0.0066223145 } } }, + .{ .t = 2579450697, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.73065186, .y = 0.51031494, .pressure = 0.008850098 } } }, + .{ .t = 2579455357, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7350464, .y = 0.5145569, .pressure = 0.010253906 } } }, + .{ .t = 2590631621, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.74017334, .y = 0.51916504, .pressure = 0.012512207 } } }, + .{ .t = 2590639051, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7455139, .y = 0.52420044, .pressure = 0.014190674 } } }, + .{ .t = 2601728264, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7537842, .y = 0.5307617, .pressure = 0.01727295 } } }, + .{ .t = 2601737594, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.76501465, .y = 0.5390625, .pressure = 0.017852783 } } }, + .{ .t = 2601745184, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7758789, .y = 0.54782104, .pressure = 0.017578125 } } }, + .{ .t = 2612868798, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.78726196, .y = 0.55740356, .pressure = 0.018676758 } } }, + .{ .t = 2612877548, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.79766846, .y = 0.56655884, .pressure = 0.016998291 } } }, + .{ .t = 2612881858, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.8077698, .y = 0.57421875, .pressure = 0.016174316 } } }, + .{ .t = 2624096121, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.81689453, .y = 0.5804138, .pressure = 0.0184021 } } }, + .{ .t = 2624103861, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.8230896, .y = 0.58462524, .pressure = 0.017578125 } } }, + .{ .t = 2624108371, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.8291321, .y = 0.58810425, .pressure = 0.016448975 } } }, + .{ .t = 2635100225, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.8328247, .y = 0.5901184, .pressure = 0.015594482 } } }, + .{ .t = 2635107345, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.835022, .y = 0.59017944, .pressure = 0.016174316 } } }, + .{ .t = 2635111905, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.83724976, .y = 0.5899353, .pressure = 0.016174316 } } }, + .{ .t = 2646151229, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.8390808, .y = 0.5890198, .pressure = 0.014770508 } } }, + .{ .t = 2646160149, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.8404541, .y = 0.58709717, .pressure = 0.014190674 } } }, + .{ .t = 2657358812, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.8408203, .y = 0.58535767, .pressure = 0.016448975 } } }, + .{ .t = 2657364952, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.8411865, .y = 0.5831604, .pressure = 0.015045166 } } }, + .{ .t = 2657368602, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.84106445, .y = 0.5809021, .pressure = 0.0184021 } } }, + .{ .t = 2668497496, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.84155273, .y = 0.5791321, .pressure = 0.018676758 } } }, + .{ .t = 2668503176, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.84198, .y = 0.5767517, .pressure = 0.0184021 } } }, + .{ .t = 2679574619, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.8413696, .y = 0.5749817, .pressure = 0.01727295 } } }, + .{ .t = 2679583429, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.8410034, .y = 0.57302856, .pressure = 0.015594482 } } }, + .{ .t = 2679588959, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.8402405, .y = 0.57077026, .pressure = 0.016998291 } } }, + .{ .t = 2690585493, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.83987427, .y = 0.5680237, .pressure = 0.017578125 } } }, + .{ .t = 2690591573, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.8392639, .y = 0.5658264, .pressure = 0.016998291 } } }, + .{ .t = 2701710277, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.8384094, .y = 0.56329346, .pressure = 0.015045166 } } }, + .{ .t = 2701715427, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.8366089, .y = 0.5602722, .pressure = 0.012512207 } } }, + .{ .t = 2701719287, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.8343506, .y = 0.55578613, .pressure = 0.013641357 } } }, + .{ .t = 2712932260, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.8309326, .y = 0.5510254, .pressure = 0.012512207 } } }, + .{ .t = 2712941600, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.8270569, .y = 0.54504395, .pressure = 0.013641357 } } }, + .{ .t = 2712946870, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.82263184, .y = 0.53845215, .pressure = 0.012786865 } } }, + .{ .t = 2724074464, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.8186035, .y = 0.5309448, .pressure = 0.012237549 } } }, + .{ .t = 2724081034, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.8176575, .y = 0.5210266, .pressure = 0.011383057 } } }, + .{ .t = 2724085114, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.8161926, .y = 0.5109863, .pressure = 0.010253906 } } }, + .{ .t = 2735041467, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.81481934, .y = 0.49887085, .pressure = 0.008575439 } } }, + .{ .t = 2735049697, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.8135681, .y = 0.48706055, .pressure = 0.0066223145 } } }, + .{ .t = 2735053437, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.8110962, .y = 0.47451782, .pressure = 0.0066223145 } } }, + .{ .t = 2746200461, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.8079529, .y = 0.46011353, .pressure = 0.008300781 } } }, + .{ .t = 2746207531, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.8046875, .y = 0.44818115, .pressure = 0.008850098 } } }, + .{ .t = 2757301144, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.8004761, .y = 0.4363098, .pressure = 0.010253906 } } }, + .{ .t = 2757308574, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.796051, .y = 0.4248352, .pressure = 0.009979248 } } }, + .{ .t = 2757312724, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.79104614, .y = 0.4133911, .pressure = 0.013366699 } } }, + .{ .t = 2775948317, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.78637695, .y = 0.4032898, .pressure = 0.012237549 } } }, + .{ .t = 2775958817, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.78131104, .y = 0.39471436, .pressure = 0.015045166 } } }, + .{ .t = 2775962507, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7763977, .y = 0.38796997, .pressure = 0.016723633 } } }, + .{ .t = 2775966007, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.77178955, .y = 0.38198853, .pressure = 0.018127441 } } }, + .{ .t = 2775969667, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.76724243, .y = 0.37753296, .pressure = 0.019805908 } } }, + .{ .t = 2779448262, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7628784, .y = 0.37338257, .pressure = 0.018127441 } } }, + .{ .t = 2790559265, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.75909424, .y = 0.36990356, .pressure = 0.020935059 } } }, + .{ .t = 2790566225, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.75512695, .y = 0.36654663, .pressure = 0.021484375 } } }, + .{ .t = 2801688299, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7513733, .y = 0.36395264, .pressure = 0.020385742 } } }, + .{ .t = 2801695099, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7475891, .y = 0.36190796, .pressure = 0.020385742 } } }, + .{ .t = 2801697739, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.74487305, .y = 0.35958862, .pressure = 0.020385742 } } }, + .{ .t = 2812906962, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.74191284, .y = 0.3572998, .pressure = 0.022888184 } } }, + .{ .t = 2812918202, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7388611, .y = 0.35458374, .pressure = 0.022338867 } } }, + .{ .t = 2812924662, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7357178, .y = 0.35250854, .pressure = 0.021209717 } } }, + .{ .t = 2824054786, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7324829, .y = 0.3503418, .pressure = 0.021484375 } } }, + .{ .t = 2824059786, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7289429, .y = 0.3484497, .pressure = 0.022888184 } } }, + .{ .t = 2824063716, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.72506714, .y = 0.34591675, .pressure = 0.022613525 } } }, + .{ .t = 2835063039, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7218323, .y = 0.34277344, .pressure = 0.02319336 } } }, + .{ .t = 2835070099, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7174072, .y = 0.34020996, .pressure = 0.020080566 } } }, + .{ .t = 2835075929, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.71273804, .y = 0.33743286, .pressure = 0.020080566 } } }, + .{ .t = 2846116163, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7079773, .y = 0.3343506, .pressure = 0.018676758 } } }, + .{ .t = 2846123943, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7023926, .y = 0.33081055, .pressure = 0.019805908 } } }, + .{ .t = 2857453356, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.6963806, .y = 0.32598877, .pressure = 0.019805908 } } }, + .{ .t = 2857460036, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.6892395, .y = 0.32144165, .pressure = 0.020935059 } } }, + .{ .t = 2857466116, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.6821289, .y = 0.31661987, .pressure = 0.018127441 } } }, + .{ .t = 2868624580, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.6739197, .y = 0.31192017, .pressure = 0.018676758 } } }, + .{ .t = 2868632160, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.6664429, .y = 0.3072815, .pressure = 0.018981934 } } }, + .{ .t = 2868637550, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.6587219, .y = 0.30307007, .pressure = 0.017578125 } } }, + .{ .t = 2879637654, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.65133667, .y = 0.29888916, .pressure = 0.017852783 } } }, + .{ .t = 2879646144, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.6444702, .y = 0.29452515, .pressure = 0.017852783 } } }, + .{ .t = 2879653574, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.6372986, .y = 0.29092407, .pressure = 0.016174316 } } }, + .{ .t = 2890493398, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.6305542, .y = 0.28729248, .pressure = 0.016448975 } } }, + .{ .t = 2890500368, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.62493896, .y = 0.28427124, .pressure = 0.016448975 } } }, + .{ .t = 2901904031, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.6192627, .y = 0.28234863, .pressure = 0.015594482 } } }, + .{ .t = 2901913451, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.61428833, .y = 0.27990723, .pressure = 0.014190674 } } }, + .{ .t = 2901920201, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.6097412, .y = 0.277771, .pressure = 0.013641357 } } }, + .{ .t = 2913077524, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.6056824, .y = 0.27627563, .pressure = 0.013641357 } } }, + .{ .t = 2913084054, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.6019287, .y = 0.27560425, .pressure = 0.012512207 } } }, + .{ .t = 2913088274, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.5984192, .y = 0.27441406, .pressure = 0.011657715 } } }, + .{ .t = 2924138128, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.59536743, .y = 0.27404785, .pressure = 0.011962891 } } }, + .{ .t = 2924146018, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.5923767, .y = 0.27398682, .pressure = 0.013641357 } } }, + .{ .t = 2924151648, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.5900574, .y = 0.2736206, .pressure = 0.013366699 } } }, + .{ .t = 2935179332, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.5883484, .y = 0.27407837, .pressure = 0.014465332 } } }, + .{ .t = 2935187861, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.5866394, .y = 0.27478027, .pressure = 0.01586914 } } }, + .{ .t = 2935191171, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.58551025, .y = 0.2756958, .pressure = 0.015045166 } } }, + .{ .t = 2946370475, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.5841675, .y = 0.27648926, .pressure = 0.01727295 } } }, + .{ .t = 2946379375, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.5830078, .y = 0.27764893, .pressure = 0.0184021 } } }, + .{ .t = 2957467849, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.5821533, .y = 0.278656, .pressure = 0.01953125 } } }, + .{ .t = 2957477449, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.5817566, .y = 0.28030396, .pressure = 0.016998291 } } }, + .{ .t = 2957483529, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.58148193, .y = 0.28225708, .pressure = 0.015319824 } } }, + .{ .t = 2968627182, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.5809021, .y = 0.2843933, .pressure = 0.01586914 } } }, + .{ .t = 2968643772, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.580719, .y = 0.28659058, .pressure = 0.014190674 } } }, + .{ .t = 2979684996, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.5805969, .y = 0.28967285, .pressure = 0.013641357 } } }, + .{ .t = 2979694336, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.58026123, .y = 0.29241943, .pressure = 0.010559082 } } }, + .{ .t = 2979699086, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.57995605, .y = 0.29571533, .pressure = 0.008575439 } } }, + .{ .t = 2990715289, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.57958984, .y = 0.29934692, .pressure = 0.010253906 } } }, + .{ .t = 2990723719, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.5793457, .y = 0.30322266, .pressure = 0.008300781 } } }, + .{ .t = 3002153093, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.5791931, .y = 0.30700684, .pressure = 0.0060424805 } } }, + .{ .t = 3002161152, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.5791931, .y = 0.3117981, .pressure = 0.0060424805 } } }, + .{ .t = 3002165632, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.57958984, .y = 0.3164673, .pressure = 0.00491333 } } }, + .{ .t = 3012982186, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.5806885, .y = 0.3215027, .pressure = 0.0068969727 } } }, + .{ .t = 3012991236, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.5819702, .y = 0.32669067, .pressure = 0.0057678223 } } }, + .{ .t = 3012998166, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.5845032, .y = 0.3322754, .pressure = 0.007446289 } } }, + .{ .t = 3024201460, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.5869446, .y = 0.33740234, .pressure = 0.008026123 } } }, + .{ .t = 3024208990, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.59017944, .y = 0.34225464, .pressure = 0.009155273 } } }, + .{ .t = 3024211980, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.5932617, .y = 0.34698486, .pressure = 0.012237549 } } }, + .{ .t = 3035025244, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.59643555, .y = 0.3517456, .pressure = 0.013366699 } } }, + .{ .t = 3035031374, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.6001282, .y = 0.35601807, .pressure = 0.016998291 } } }, + .{ .t = 3035034874, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.60409546, .y = 0.3600464, .pressure = 0.019805908 } } }, + .{ .t = 3046541367, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.60775757, .y = 0.36398315, .pressure = 0.022338867 } } }, + .{ .t = 3046548887, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.61169434, .y = 0.36740112, .pressure = 0.022613525 } } }, + .{ .t = 3057532891, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.6154785, .y = 0.37051392, .pressure = 0.025146484 } } }, + .{ .t = 3057540471, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.6194763, .y = 0.37329102, .pressure = 0.025421143 } } }, + .{ .t = 3057545781, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.6232605, .y = 0.3761902, .pressure = 0.026000977 } } }, + .{ .t = 3068735374, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.62753296, .y = 0.3789673, .pressure = 0.025421143 } } }, + .{ .t = 3068748304, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.6313782, .y = 0.3816223, .pressure = 0.024017334 } } }, + .{ .t = 3068754594, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.63513184, .y = 0.38391113, .pressure = 0.023742676 } } }, + .{ .t = 3079554878, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.6390991, .y = 0.38616943, .pressure = 0.023468018 } } }, + .{ .t = 3079563518, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.6433716, .y = 0.38833618, .pressure = 0.02178955 } } }, + .{ .t = 3079568338, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.64767456, .y = 0.39031982, .pressure = 0.02319336 } } }, + .{ .t = 3090741042, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.65234375, .y = 0.3919983, .pressure = 0.02319336 } } }, + .{ .t = 3090749882, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.65689087, .y = 0.39379883, .pressure = 0.021209717 } } }, + .{ .t = 3101724975, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.6610718, .y = 0.39520264, .pressure = 0.022888184 } } }, + .{ .t = 3101732005, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.66574097, .y = 0.39642334, .pressure = 0.021484375 } } }, + .{ .t = 3101735255, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.6701355, .y = 0.3973999, .pressure = 0.019805908 } } }, + .{ .t = 3113361458, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.6748352, .y = 0.39767456, .pressure = 0.0206604 } } }, + .{ .t = 3113368498, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.67944336, .y = 0.39797974, .pressure = 0.022613525 } } }, + .{ .t = 3113372028, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.6838379, .y = 0.39785767, .pressure = 0.022338867 } } }, + .{ .t = 3123796833, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.6879883, .y = 0.3970642, .pressure = 0.01953125 } } }, + .{ .t = 3123803053, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.69177246, .y = 0.39624023, .pressure = 0.018127441 } } }, + .{ .t = 3123806563, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.69555664, .y = 0.39569092, .pressure = 0.016998291 } } }, + .{ .t = 3134998596, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.69888306, .y = 0.3942871, .pressure = 0.016998291 } } }, + .{ .t = 3135007066, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7023926, .y = 0.39257812, .pressure = 0.017578125 } } }, + .{ .t = 3135011336, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7060852, .y = 0.39056396, .pressure = 0.017578125 } } }, + .{ .t = 3146195970, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7102051, .y = 0.38861084, .pressure = 0.015594482 } } }, + .{ .t = 3146202620, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.715271, .y = 0.386261, .pressure = 0.014190674 } } }, + .{ .t = 3157408853, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7234802, .y = 0.38327026, .pressure = 0.01586914 } } }, + .{ .t = 3157418073, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.730896, .y = 0.38006592, .pressure = 0.01586914 } } }, + .{ .t = 3157423313, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.73880005, .y = 0.37652588, .pressure = 0.016448975 } } }, + .{ .t = 3168334437, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.74557495, .y = 0.37350464, .pressure = 0.017578125 } } }, + .{ .t = 3168341357, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.75097656, .y = 0.37020874, .pressure = 0.016723633 } } }, + .{ .t = 3168344697, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7561035, .y = 0.36791992, .pressure = 0.013916016 } } }, + .{ .t = 3179518520, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.75982666, .y = 0.36517334, .pressure = 0.013061523 } } }, + .{ .t = 3179524910, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7633362, .y = 0.3623352, .pressure = 0.013061523 } } }, + .{ .t = 3179530860, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.765625, .y = 0.35949707, .pressure = 0.013641357 } } }, + .{ .t = 3190702424, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7669678, .y = 0.3564453, .pressure = 0.012786865 } } }, + .{ .t = 3190710904, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.76849365, .y = 0.3536682, .pressure = 0.011383057 } } }, + .{ .t = 3201886237, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7687378, .y = 0.35095215, .pressure = 0.010559082 } } }, + .{ .t = 3201895897, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7681885, .y = 0.34838867, .pressure = 0.009155273 } } }, + .{ .t = 3201900097, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7668457, .y = 0.34570312, .pressure = 0.009155273 } } }, + .{ .t = 3212919591, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7654724, .y = 0.34277344, .pressure = 0.008850098 } } }, + .{ .t = 3212927311, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7631836, .y = 0.34002686, .pressure = 0.0066223145 } } }, + .{ .t = 3212932591, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7612915, .y = 0.3373413, .pressure = 0.0040893555 } } }, + .{ .t = 3224127654, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7590027, .y = 0.33529663, .pressure = 0.0043640137 } } }, + .{ .t = 3224134564, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7567444, .y = 0.33319092, .pressure = 0.0024108887 } } }, + .{ .t = 3224138834, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7541809, .y = 0.3307495, .pressure = 0.00491333 } } }, + .{ .t = 3234961798, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.75216675, .y = 0.32843018, .pressure = 0.0038146973 } } }, + .{ .t = 3234967628, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7489929, .y = 0.32583618, .pressure = 0.0038146973 } } }, + .{ .t = 3234971398, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7467346, .y = 0.32296753, .pressure = 0.005218506 } } }, + .{ .t = 3246367272, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7436218, .y = 0.32019043, .pressure = 0.0043640137 } } }, + .{ .t = 3246376701, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7402649, .y = 0.3173523, .pressure = 0.0038146973 } } }, + .{ .t = 3257870675, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.73721313, .y = 0.31466675, .pressure = 0.0018310547 } } }, + .{ .t = 3257881104, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7336731, .y = 0.31219482, .pressure = 0.0024108887 } } }, + .{ .t = 3257886264, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.73062134, .y = 0.3100891, .pressure = 0.0015563965 } } }, + .{ .t = 3268291019, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.72720337, .y = 0.30807495, .pressure = 0.0007019043 } } }, + .{ .t = 3268298969, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7241516, .y = 0.30593872, .pressure = 0.0015563965 } } }, + .{ .t = 3268303569, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7213135, .y = 0.30371094, .pressure = 0.0035095215 } } }, + .{ .t = 3279746522, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.71810913, .y = 0.302063, .pressure = 0.002960205 } } }, + .{ .t = 3279757542, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.7147217, .y = 0.30056763, .pressure = 0.00491333 } } }, + .{ .t = 3279762862, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.71087646, .y = 0.29907227, .pressure = 0.00491333 } } }, + .{ .t = 3290574016, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.70751953, .y = 0.29745483, .pressure = 0.0040893555 } } }, + .{ .t = 3290581596, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.70376587, .y = 0.29592896, .pressure = 0.0040893555 } } }, + .{ .t = 3301750300, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.6994934, .y = 0.2951355, .pressure = 0.0038146973 } } }, + .{ .t = 3301760370, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.6951904, .y = 0.29397583, .pressure = 0.005218506 } } }, + .{ .t = 3301767410, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.6905823, .y = 0.29284668, .pressure = 0.00491333 } } }, + .{ .t = 3312951293, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.685791, .y = 0.29266357, .pressure = 0.0068969727 } } }, + .{ .t = 3312959893, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.68136597, .y = 0.29257202, .pressure = 0.005493164 } } }, + .{ .t = 3312965373, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.6772461, .y = 0.29229736, .pressure = 0.0068969727 } } }, + .{ .t = 3324079267, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.672699, .y = 0.29318237, .pressure = 0.004638672 } } }, + .{ .t = 3324090337, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.66882324, .y = 0.294281, .pressure = 0.004638672 } } }, + .{ .t = 3324095997, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.66537476, .y = 0.29525757, .pressure = 0.004638672 } } }, + .{ .t = 3335061800, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.6620178, .y = 0.2966919, .pressure = 0.002960205 } } }, + .{ .t = 3335068160, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.6590576, .y = 0.29788208, .pressure = 0.0007019043 } } }, + .{ .t = 3335073750, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .up, .x = 0.6562805, .y = 0.29956055, .pressure = 0 } } }, + .{ .t = 3390587188, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .down, .x = 0.6447449, .y = 0.33596802, .pressure = 0.0007019043 } } }, + .{ .t = 3390593138, .pad = 2, .ev = .{ .touch = .{ .touchpad = 1, .finger = 0, .phase = .motion, .x = 0.6447754, .y = 0.3406067, .pressure = 0.0035095215 } } }, } } diff --git a/test/deck/triggers.zon b/test/deck/triggers.zon index ad5f7656..8cac4b66 100644 --- a/test/deck/triggers.zon +++ b/test/deck/triggers.zon @@ -1,576 +1,576 @@ .{ .version = 1, .events = .{ -.{.t=3100837937,.pad=2,.ev=.{.axis=.{.idx=3,.value=997}}}, -.{.t=3100845387,.pad=2,.ev=.{.axis=.{.idx=0,.value=-829}}}, -.{.t=3100845387,.pad=2,.ev=.{.axis=.{.idx=1,.value=-1441}}}, -.{.t=3100845387,.pad=2,.ev=.{.axis=.{.idx=3,.value=1027}}}, -.{.t=3100849157,.pad=2,.ev=.{.axis=.{.idx=0,.value=-802}}}, -.{.t=3100849157,.pad=2,.ev=.{.axis=.{.idx=1,.value=-1411}}}, -.{.t=3100849157,.pad=2,.ev=.{.axis=.{.idx=3,.value=1057}}}, -.{.t=3111923010,.pad=2,.ev=.{.axis=.{.idx=0,.value=-829}}}, -.{.t=3111923010,.pad=2,.ev=.{.axis=.{.idx=1,.value=-1529}}}, -.{.t=3111923010,.pad=2,.ev=.{.axis=.{.idx=3,.value=1027}}}, -.{.t=3111936310,.pad=2,.ev=.{.axis=.{.idx=0,.value=-802}}}, -.{.t=3111936310,.pad=2,.ev=.{.axis=.{.idx=1,.value=-1323}}}, -.{.t=3111941850,.pad=2,.ev=.{.axis=.{.idx=1,.value=-1558}}}, -.{.t=3111941850,.pad=2,.ev=.{.axis=.{.idx=3,.value=997}}}, -.{.t=3123013224,.pad=2,.ev=.{.axis=.{.idx=0,.value=-829}}}, -.{.t=3123013224,.pad=2,.ev=.{.axis=.{.idx=1,.value=-1294}}}, -.{.t=3123013224,.pad=2,.ev=.{.axis=.{.idx=3,.value=1027}}}, -.{.t=3123021794,.pad=2,.ev=.{.axis=.{.idx=0,.value=-802}}}, -.{.t=3123021794,.pad=2,.ev=.{.axis=.{.idx=1,.value=-941}}}, -.{.t=3123021794,.pad=2,.ev=.{.axis=.{.idx=3,.value=997}}}, -.{.t=3134267607,.pad=2,.ev=.{.axis=.{.idx=5,.value=0}}}, -.{.t=3134267607,.pad=2,.ev=.{.axis=.{.idx=5,.value=214}}}, -.{.t=3134267607,.pad=2,.ev=.{.axis=.{.idx=0,.value=-829}}}, -.{.t=3134267607,.pad=2,.ev=.{.axis=.{.idx=1,.value=-647}}}, -.{.t=3134277137,.pad=2,.ev=.{.axis=.{.idx=5,.value=2674}}}, -.{.t=3134277137,.pad=2,.ev=.{.axis=.{.idx=0,.value=-802}}}, -.{.t=3134277137,.pad=2,.ev=.{.axis=.{.idx=1,.value=-500}}}, -.{.t=3134280727,.pad=2,.ev=.{.axis=.{.idx=5,.value=5436}}}, -.{.t=3134280727,.pad=2,.ev=.{.axis=.{.idx=0,.value=-829}}}, -.{.t=3134280727,.pad=2,.ev=.{.axis=.{.idx=1,.value=-206}}}, -.{.t=3134280727,.pad=2,.ev=.{.axis=.{.idx=3,.value=1027}}}, -.{.t=3146260210,.pad=2,.ev=.{.axis=.{.idx=5,.value=8198}}}, -.{.t=3146260210,.pad=2,.ev=.{.axis=.{.idx=0,.value=-774}}}, -.{.t=3146260210,.pad=2,.ev=.{.axis=.{.idx=1,.value=-176}}}, -.{.t=3146260210,.pad=2,.ev=.{.axis=.{.idx=3,.value=997}}}, -.{.t=3146270520,.pad=2,.ev=.{.axis=.{.idx=5,.value=11211}}}, -.{.t=3146270520,.pad=2,.ev=.{.axis=.{.idx=0,.value=-802}}}, -.{.t=3146270520,.pad=2,.ev=.{.axis=.{.idx=1,.value=-29}}}, -.{.t=3146274870,.pad=2,.ev=.{.axis=.{.idx=5,.value=13671}}}, -.{.t=3146274870,.pad=2,.ev=.{.axis=.{.idx=1,.value=86}}}, -.{.t=3146274870,.pad=2,.ev=.{.axis=.{.idx=3,.value=1027}}}, -.{.t=3156416215,.pad=2,.ev=.{.axis=.{.idx=5,.value=16432}}}, -.{.t=3156416215,.pad=2,.ev=.{.axis=.{.idx=0,.value=-829}}}, -.{.t=3156416215,.pad=2,.ev=.{.axis=.{.idx=1,.value=288}}}, -.{.t=3156416215,.pad=2,.ev=.{.axis=.{.idx=3,.value=997}}}, -.{.t=3156435465,.pad=2,.ev=.{.axis=.{.idx=5,.value=18893}}}, -.{.t=3156435465,.pad=2,.ev=.{.axis=.{.idx=0,.value=-802}}}, -.{.t=3156435465,.pad=2,.ev=.{.axis=.{.idx=1,.value=462}}}, -.{.t=3156441825,.pad=2,.ev=.{.axis=.{.idx=5,.value=21504}}}, -.{.t=3156441825,.pad=2,.ev=.{.axis=.{.idx=1,.value=491}}}, -.{.t=3156441825,.pad=2,.ev=.{.axis=.{.idx=3,.value=1057}}}, -.{.t=3167440508,.pad=2,.ev=.{.axis=.{.idx=5,.value=23915}}}, -.{.t=3167440508,.pad=2,.ev=.{.axis=.{.idx=1,.value=664}}}, -.{.t=3167440508,.pad=2,.ev=.{.axis=.{.idx=3,.value=1027}}}, -.{.t=3167449678,.pad=2,.ev=.{.axis=.{.idx=5,.value=26224}}}, -.{.t=3167449678,.pad=2,.ev=.{.axis=.{.idx=0,.value=-829}}}, -.{.t=3167449678,.pad=2,.ev=.{.axis=.{.idx=1,.value=779}}}, -.{.t=3167449678,.pad=2,.ev=.{.axis=.{.idx=3,.value=997}}}, -.{.t=3178634312,.pad=2,.ev=.{.axis=.{.idx=5,.value=28384}}}, -.{.t=3178634312,.pad=2,.ev=.{.axis=.{.idx=0,.value=-802}}}, -.{.t=3178634312,.pad=2,.ev=.{.axis=.{.idx=1,.value=837}}}, -.{.t=3178634312,.pad=2,.ev=.{.axis=.{.idx=3,.value=1027}}}, -.{.t=3178646332,.pad=2,.ev=.{.axis=.{.idx=5,.value=30593}}}, -.{.t=3178646332,.pad=2,.ev=.{.axis=.{.idx=0,.value=-829}}}, -.{.t=3178646332,.pad=2,.ev=.{.axis=.{.idx=3,.value=997}}}, -.{.t=3178651472,.pad=2,.ev=.{.axis=.{.idx=5,.value=32702}}}, -.{.t=3178651472,.pad=2,.ev=.{.axis=.{.idx=0,.value=-802}}}, -.{.t=3189737565,.pad=2,.ev=.{.axis=.{.idx=5,.value=32766}}}, -.{.t=3189737565,.pad=2,.ev=.{.axis=.{.idx=1,.value=924}}}, -.{.t=3189737565,.pad=2,.ev=.{.axis=.{.idx=3,.value=1027}}}, -.{.t=3189748175,.pad=2,.ev=.{.axis=.{.idx=3,.value=1057}}}, -.{.t=3189751215,.pad=2,.ev=.{.axis=.{.idx=1,.value=953}}}, -.{.t=3189751215,.pad=2,.ev=.{.axis=.{.idx=3,.value=1027}}}, -.{.t=3200899959,.pad=2,.ev=.{.axis=.{.idx=3,.value=997}}}, -.{.t=3200909349,.pad=2,.ev=.{.axis=.{.idx=0,.value=-774}}}, -.{.t=3200909349,.pad=2,.ev=.{.axis=.{.idx=1,.value=924}}}, -.{.t=3200914229,.pad=2,.ev=.{.axis=.{.idx=0,.value=-802}}}, -.{.t=3200914229,.pad=2,.ev=.{.axis=.{.idx=1,.value=953}}}, -.{.t=3200914229,.pad=2,.ev=.{.axis=.{.idx=3,.value=1027}}}, -.{.t=3212027402,.pad=2,.ev=.{.axis=.{.idx=0,.value=-829}}}, -.{.t=3212027402,.pad=2,.ev=.{.axis=.{.idx=1,.value=1010}}}, -.{.t=3212027402,.pad=2,.ev=.{.axis=.{.idx=3,.value=997}}}, -.{.t=3212033902,.pad=2,.ev=.{.axis=.{.idx=3,.value=1027}}}, -.{.t=3222960156,.pad=2,.ev=.{.axis=.{.idx=1,.value=981}}}, -.{.t=3222960156,.pad=2,.ev=.{.axis=.{.idx=3,.value=997}}}, -.{.t=3222967916,.pad=2,.ev=.{.axis=.{.idx=0,.value=-802}}}, -.{.t=3222967916,.pad=2,.ev=.{.axis=.{.idx=1,.value=953}}}, -.{.t=3222967916,.pad=2,.ev=.{.axis=.{.idx=3,.value=1087}}}, -.{.t=3234186130,.pad=2,.ev=.{.axis=.{.idx=0,.value=-857}}}, -.{.t=3234186130,.pad=2,.ev=.{.axis=.{.idx=1,.value=981}}}, -.{.t=3234186130,.pad=2,.ev=.{.axis=.{.idx=3,.value=1027}}}, -.{.t=3234194710,.pad=2,.ev=.{.axis=.{.idx=0,.value=-802}}}, -.{.t=3234194710,.pad=2,.ev=.{.axis=.{.idx=1,.value=953}}}, -.{.t=3234194710,.pad=2,.ev=.{.axis=.{.idx=3,.value=997}}}, -.{.t=3234198480,.pad=2,.ev=.{.axis=.{.idx=0,.value=-829}}}, -.{.t=3234198480,.pad=2,.ev=.{.axis=.{.idx=1,.value=1097}}}, -.{.t=3245272663,.pad=2,.ev=.{.axis=.{.idx=1,.value=1126}}}, -.{.t=3245272663,.pad=2,.ev=.{.axis=.{.idx=3,.value=1057}}}, -.{.t=3245280873,.pad=2,.ev=.{.axis=.{.idx=0,.value=-802}}}, -.{.t=3245280873,.pad=2,.ev=.{.axis=.{.idx=3,.value=997}}}, -.{.t=3245284263,.pad=2,.ev=.{.axis=.{.idx=1,.value=1097}}}, -.{.t=3245284263,.pad=2,.ev=.{.axis=.{.idx=3,.value=1027}}}, -.{.t=3256351647,.pad=2,.ev=.{.axis=.{.idx=0,.value=-829}}}, -.{.t=3256351647,.pad=2,.ev=.{.axis=.{.idx=3,.value=997}}}, -.{.t=3256361897,.pad=2,.ev=.{.axis=.{.idx=1,.value=1126}}}, -.{.t=3256361897,.pad=2,.ev=.{.axis=.{.idx=3,.value=1027}}}, -.{.t=3256366557,.pad=2,.ev=.{.axis=.{.idx=0,.value=-857}}}, -.{.t=3267453910,.pad=2,.ev=.{.axis=.{.idx=0,.value=-829}}}, -.{.t=3267461450,.pad=2,.ev=.{.axis=.{.idx=0,.value=-802}}}, -.{.t=3267461450,.pad=2,.ev=.{.axis=.{.idx=1,.value=1097}}}, -.{.t=3267461450,.pad=2,.ev=.{.axis=.{.idx=3,.value=1057}}}, -.{.t=3278671394,.pad=2,.ev=.{.axis=.{.idx=3,.value=1027}}}, -.{.t=3278679494,.pad=2,.ev=.{.axis=.{.idx=0,.value=-829}}}, -.{.t=3278679494,.pad=2,.ev=.{.axis=.{.idx=1,.value=1126}}}, -.{.t=3278679494,.pad=2,.ev=.{.axis=.{.idx=3,.value=997}}}, -.{.t=3278684284,.pad=2,.ev=.{.axis=.{.idx=1,.value=1097}}}, -.{.t=3289747017,.pad=2,.ev=.{.axis=.{.idx=0,.value=-802}}}, -.{.t=3289757957,.pad=2,.ev=.{.axis=.{.idx=0,.value=-774}}}, -.{.t=3289757957,.pad=2,.ev=.{.axis=.{.idx=1,.value=1068}}}, -.{.t=3289757957,.pad=2,.ev=.{.axis=.{.idx=3,.value=1057}}}, -.{.t=3289764977,.pad=2,.ev=.{.axis=.{.idx=0,.value=-829}}}, -.{.t=3289764977,.pad=2,.ev=.{.axis=.{.idx=3,.value=1027}}}, -.{.t=3300894251,.pad=2,.ev=.{.axis=.{.idx=0,.value=-802}}}, -.{.t=3300894251,.pad=2,.ev=.{.axis=.{.idx=3,.value=1057}}}, -.{.t=3300904161,.pad=2,.ev=.{.axis=.{.idx=0,.value=-829}}}, -.{.t=3300904161,.pad=2,.ev=.{.axis=.{.idx=3,.value=1027}}}, -.{.t=3300908771,.pad=2,.ev=.{.axis=.{.idx=3,.value=1057}}}, -.{.t=3312130554,.pad=2,.ev=.{.axis=.{.idx=0,.value=-802}}}, -.{.t=3312130554,.pad=2,.ev=.{.axis=.{.idx=1,.value=1039}}}, -.{.t=3312130554,.pad=2,.ev=.{.axis=.{.idx=3,.value=1027}}}, -.{.t=3312142164,.pad=2,.ev=.{.axis=.{.idx=3,.value=1057}}}, -.{.t=3312145624,.pad=2,.ev=.{.axis=.{.idx=0,.value=-829}}}, -.{.t=3312145624,.pad=2,.ev=.{.axis=.{.idx=1,.value=1068}}}, -.{.t=3312145624,.pad=2,.ev=.{.axis=.{.idx=3,.value=1027}}}, -.{.t=3323185928,.pad=2,.ev=.{.axis=.{.idx=0,.value=-802}}}, -.{.t=3323185928,.pad=2,.ev=.{.axis=.{.idx=1,.value=1039}}}, -.{.t=3323197438,.pad=2,.ev=.{.axis=.{.idx=1,.value=1010}}}, -.{.t=3334415941,.pad=2,.ev=.{.axis=.{.idx=0,.value=-829}}}, -.{.t=3334415941,.pad=2,.ev=.{.axis=.{.idx=3,.value=1057}}}, -.{.t=3334428191,.pad=2,.ev=.{.axis=.{.idx=0,.value=-802}}}, -.{.t=3334428191,.pad=2,.ev=.{.axis=.{.idx=3,.value=1027}}}, -.{.t=3334433441,.pad=2,.ev=.{.axis=.{.idx=0,.value=-829}}}, -.{.t=3345319335,.pad=2,.ev=.{.axis=.{.idx=0,.value=-802}}}, -.{.t=3345319335,.pad=2,.ev=.{.axis=.{.idx=1,.value=1039}}}, -.{.t=3345329665,.pad=2,.ev=.{.axis=.{.idx=0,.value=-774}}}, -.{.t=3345329665,.pad=2,.ev=.{.axis=.{.idx=1,.value=1010}}}, -.{.t=3345329665,.pad=2,.ev=.{.axis=.{.idx=3,.value=997}}}, -.{.t=3345334835,.pad=2,.ev=.{.axis=.{.idx=0,.value=-802}}}, -.{.t=3356434069,.pad=2,.ev=.{.axis=.{.idx=0,.value=-829}}}, -.{.t=3356434069,.pad=2,.ev=.{.axis=.{.idx=1,.value=1039}}}, -.{.t=3356434069,.pad=2,.ev=.{.axis=.{.idx=3,.value=1027}}}, -.{.t=3356449919,.pad=2,.ev=.{.axis=.{.idx=0,.value=-802}}}, -.{.t=3356449919,.pad=2,.ev=.{.axis=.{.idx=1,.value=1010}}}, -.{.t=3356449919,.pad=2,.ev=.{.axis=.{.idx=3,.value=997}}}, -.{.t=3367716072,.pad=2,.ev=.{.axis=.{.idx=0,.value=-857}}}, -.{.t=3367716072,.pad=2,.ev=.{.axis=.{.idx=1,.value=1068}}}, -.{.t=3367728332,.pad=2,.ev=.{.axis=.{.idx=0,.value=-829}}}, -.{.t=3367728332,.pad=2,.ev=.{.axis=.{.idx=1,.value=1039}}}, -.{.t=3367728332,.pad=2,.ev=.{.axis=.{.idx=3,.value=1027}}}, -.{.t=3367733692,.pad=2,.ev=.{.axis=.{.idx=0,.value=-802}}}, -.{.t=3367733692,.pad=2,.ev=.{.axis=.{.idx=1,.value=1010}}}, -.{.t=3367733692,.pad=2,.ev=.{.axis=.{.idx=3,.value=1057}}}, -.{.t=3378615526,.pad=2,.ev=.{.axis=.{.idx=3,.value=997}}}, -.{.t=3389836929,.pad=2,.ev=.{.axis=.{.idx=0,.value=-774}}}, -.{.t=3389836929,.pad=2,.ev=.{.axis=.{.idx=1,.value=981}}}, -.{.t=3389836929,.pad=2,.ev=.{.axis=.{.idx=3,.value=1027}}}, -.{.t=3389847129,.pad=2,.ev=.{.axis=.{.idx=5,.value=31648}}}, -.{.t=3389847129,.pad=2,.ev=.{.axis=.{.idx=0,.value=-802}}}, -.{.t=3389847129,.pad=2,.ev=.{.axis=.{.idx=1,.value=1010}}}, -.{.t=3389852719,.pad=2,.ev=.{.axis=.{.idx=5,.value=29137}}}, -.{.t=3389852719,.pad=2,.ev=.{.axis=.{.idx=1,.value=1039}}}, -.{.t=3401186593,.pad=2,.ev=.{.axis=.{.idx=5,.value=26074}}}, -.{.t=3401186593,.pad=2,.ev=.{.axis=.{.idx=0,.value=-829}}}, -.{.t=3401194003,.pad=2,.ev=.{.axis=.{.idx=5,.value=23262}}}, -.{.t=3401194003,.pad=2,.ev=.{.axis=.{.idx=0,.value=-802}}}, -.{.t=3401194003,.pad=2,.ev=.{.axis=.{.idx=1,.value=1010}}}, -.{.t=3401194003,.pad=2,.ev=.{.axis=.{.idx=3,.value=1057}}}, -.{.t=3401198713,.pad=2,.ev=.{.axis=.{.idx=5,.value=20349}}}, -.{.t=3401198713,.pad=2,.ev=.{.axis=.{.idx=3,.value=997}}}, -.{.t=3411932407,.pad=2,.ev=.{.axis=.{.idx=5,.value=17587}}}, -.{.t=3411932407,.pad=2,.ev=.{.axis=.{.idx=0,.value=-829}}}, -.{.t=3411932407,.pad=2,.ev=.{.axis=.{.idx=1,.value=1039}}}, -.{.t=3411941077,.pad=2,.ev=.{.axis=.{.idx=5,.value=15127}}}, -.{.t=3411941077,.pad=2,.ev=.{.axis=.{.idx=0,.value=-802}}}, -.{.t=3411941077,.pad=2,.ev=.{.axis=.{.idx=3,.value=1027}}}, -.{.t=3411944947,.pad=2,.ev=.{.axis=.{.idx=5,.value=12617}}}, -.{.t=3411944947,.pad=2,.ev=.{.axis=.{.idx=0,.value=-829}}}, -.{.t=3411944947,.pad=2,.ev=.{.axis=.{.idx=1,.value=953}}}, -.{.t=3411944947,.pad=2,.ev=.{.axis=.{.idx=3,.value=997}}}, -.{.t=3423178470,.pad=2,.ev=.{.axis=.{.idx=5,.value=10307}}}, -.{.t=3423178470,.pad=2,.ev=.{.axis=.{.idx=0,.value=-802}}}, -.{.t=3423178470,.pad=2,.ev=.{.axis=.{.idx=1,.value=924}}}, -.{.t=3423187080,.pad=2,.ev=.{.axis=.{.idx=5,.value=8298}}}, -.{.t=3423187080,.pad=2,.ev=.{.axis=.{.idx=1,.value=981}}}, -.{.t=3423187080,.pad=2,.ev=.{.axis=.{.idx=3,.value=1027}}}, -.{.t=3434307174,.pad=2,.ev=.{.axis=.{.idx=5,.value=6340}}}, -.{.t=3434307174,.pad=2,.ev=.{.axis=.{.idx=1,.value=924}}}, -.{.t=3434315334,.pad=2,.ev=.{.axis=.{.idx=5,.value=4532}}}, -.{.t=3434315334,.pad=2,.ev=.{.axis=.{.idx=3,.value=997}}}, -.{.t=3434318744,.pad=2,.ev=.{.axis=.{.idx=5,.value=2975}}}, -.{.t=3434318744,.pad=2,.ev=.{.axis=.{.idx=1,.value=866}}}, -.{.t=3445336427,.pad=2,.ev=.{.axis=.{.idx=5,.value=1067}}}, -.{.t=3445336427,.pad=2,.ev=.{.axis=.{.idx=1,.value=635}}}, -.{.t=3445344507,.pad=2,.ev=.{.axis=.{.idx=4,.value=446}}}, -.{.t=3445344507,.pad=2,.ev=.{.axis=.{.idx=5,.value=0}}}, -.{.t=3445344507,.pad=2,.ev=.{.axis=.{.idx=1,.value=346}}}, -.{.t=3445344507,.pad=2,.ev=.{.axis=.{.idx=3,.value=1027}}}, -.{.t=3445348567,.pad=2,.ev=.{.axis=.{.idx=4,.value=1854}}}, -.{.t=3445348567,.pad=2,.ev=.{.axis=.{.idx=1,.value=-59}}}, -.{.t=3456475621,.pad=2,.ev=.{.axis=.{.idx=4,.value=3310}}}, -.{.t=3456475621,.pad=2,.ev=.{.axis=.{.idx=1,.value=-176}}}, -.{.t=3456475621,.pad=2,.ev=.{.axis=.{.idx=3,.value=997}}}, -.{.t=3456483971,.pad=2,.ev=.{.axis=.{.idx=4,.value=4436}}}, -.{.t=3456483971,.pad=2,.ev=.{.axis=.{.idx=1,.value=-441}}}, -.{.t=3456487161,.pad=2,.ev=.{.axis=.{.idx=4,.value=5891}}}, -.{.t=3456487161,.pad=2,.ev=.{.axis=.{.idx=1,.value=-558}}}, -.{.t=22900269279,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1493}}}, -.{.t=22900269279,.pad=2,.ev=.{.axis=.{.idx=1,.value=981}}}, -.{.t=22900269279,.pad=2,.ev=.{.axis=.{.idx=3,.value=1087}}}, -.{.t=22900282319,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1465}}}, -.{.t=22900282319,.pad=2,.ev=.{.axis=.{.idx=1,.value=953}}}, -.{.t=22900282319,.pad=2,.ev=.{.axis=.{.idx=2,.value=-469}}}, -.{.t=22900282319,.pad=2,.ev=.{.axis=.{.idx=3,.value=1118}}}, -.{.t=22900288339,.pad=2,.ev=.{.axis=.{.idx=1,.value=981}}}, -.{.t=22900288339,.pad=2,.ev=.{.axis=.{.idx=2,.value=-439}}}, -.{.t=22900288339,.pad=2,.ev=.{.axis=.{.idx=3,.value=1087}}}, -.{.t=22911078513,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1438}}}, -.{.t=22911078513,.pad=2,.ev=.{.axis=.{.idx=1,.value=953}}}, -.{.t=22911078513,.pad=2,.ev=.{.axis=.{.idx=2,.value=-469}}}, -.{.t=22911090183,.pad=2,.ev=.{.axis=.{.idx=2,.value=-498}}}, -.{.t=22922174447,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1465}}}, -.{.t=22922174447,.pad=2,.ev=.{.axis=.{.idx=2,.value=-527}}}, -.{.t=22922174447,.pad=2,.ev=.{.axis=.{.idx=3,.value=1148}}}, -.{.t=22922182927,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1493}}}, -.{.t=22922182927,.pad=2,.ev=.{.axis=.{.idx=1,.value=981}}}, -.{.t=22922182927,.pad=2,.ev=.{.axis=.{.idx=2,.value=-498}}}, -.{.t=22922182927,.pad=2,.ev=.{.axis=.{.idx=3,.value=1118}}}, -.{.t=22922186907,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1465}}}, -.{.t=22933453380,.pad=2,.ev=.{.axis=.{.idx=2,.value=-469}}}, -.{.t=22933463530,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1438}}}, -.{.t=22933463530,.pad=2,.ev=.{.axis=.{.idx=1,.value=924}}}, -.{.t=22933463530,.pad=2,.ev=.{.axis=.{.idx=2,.value=-498}}}, -.{.t=22933463530,.pad=2,.ev=.{.axis=.{.idx=3,.value=1148}}}, -.{.t=22933469520,.pad=2,.ev=.{.axis=.{.idx=1,.value=953}}}, -.{.t=22933469520,.pad=2,.ev=.{.axis=.{.idx=2,.value=-469}}}, -.{.t=22933469520,.pad=2,.ev=.{.axis=.{.idx=3,.value=1118}}}, -.{.t=22944601464,.pad=2,.ev=.{.axis=.{.idx=2,.value=-439}}}, -.{.t=22944601464,.pad=2,.ev=.{.axis=.{.idx=3,.value=1087}}}, -.{.t=22944613874,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1465}}}, -.{.t=22944613874,.pad=2,.ev=.{.axis=.{.idx=2,.value=-469}}}, -.{.t=22944613874,.pad=2,.ev=.{.axis=.{.idx=3,.value=1118}}}, -.{.t=22944619754,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1438}}}, -.{.t=22955633677,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1493}}}, -.{.t=22955633677,.pad=2,.ev=.{.axis=.{.idx=1,.value=981}}}, -.{.t=22955633677,.pad=2,.ev=.{.axis=.{.idx=2,.value=-439}}}, -.{.t=22955633677,.pad=2,.ev=.{.axis=.{.idx=3,.value=1087}}}, -.{.t=22955647207,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1465}}}, -.{.t=22955647207,.pad=2,.ev=.{.axis=.{.idx=1,.value=953}}}, -.{.t=22955647207,.pad=2,.ev=.{.axis=.{.idx=2,.value=-498}}}, -.{.t=22955647207,.pad=2,.ev=.{.axis=.{.idx=3,.value=1148}}}, -.{.t=22955652047,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1438}}}, -.{.t=22955652047,.pad=2,.ev=.{.axis=.{.idx=3,.value=1118}}}, -.{.t=22966619841,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1465}}}, -.{.t=22966619841,.pad=2,.ev=.{.axis=.{.idx=2,.value=-469}}}, -.{.t=22966628121,.pad=2,.ev=.{.axis=.{.idx=1,.value=924}}}, -.{.t=22966628121,.pad=2,.ev=.{.axis=.{.idx=3,.value=1087}}}, -.{.t=22977745245,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1438}}}, -.{.t=22977745245,.pad=2,.ev=.{.axis=.{.idx=1,.value=953}}}, -.{.t=22977745245,.pad=2,.ev=.{.axis=.{.idx=2,.value=-498}}}, -.{.t=22977745245,.pad=2,.ev=.{.axis=.{.idx=3,.value=1148}}}, -.{.t=22977753905,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1465}}}, -.{.t=22977753905,.pad=2,.ev=.{.axis=.{.idx=2,.value=-469}}}, -.{.t=22977753905,.pad=2,.ev=.{.axis=.{.idx=3,.value=1118}}}, -.{.t=22977757525,.pad=2,.ev=.{.axis=.{.idx=2,.value=-439}}}, -.{.t=22988922908,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1438}}}, -.{.t=22988922908,.pad=2,.ev=.{.axis=.{.idx=1,.value=981}}}, -.{.t=22988936008,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1465}}}, -.{.t=22988936008,.pad=2,.ev=.{.axis=.{.idx=2,.value=-469}}}, -.{.t=22988940638,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1438}}}, -.{.t=22988940638,.pad=2,.ev=.{.axis=.{.idx=1,.value=953}}}, -.{.t=23000140672,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1465}}}, -.{.t=23000140672,.pad=2,.ev=.{.axis=.{.idx=2,.value=-498}}}, -.{.t=23000152872,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1438}}}, -.{.t=23000152872,.pad=2,.ev=.{.axis=.{.idx=1,.value=924}}}, -.{.t=23000152872,.pad=2,.ev=.{.axis=.{.idx=2,.value=-439}}}, -.{.t=23000152872,.pad=2,.ev=.{.axis=.{.idx=3,.value=1087}}}, -.{.t=23000158442,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1493}}}, -.{.t=23000158442,.pad=2,.ev=.{.axis=.{.idx=1,.value=953}}}, -.{.t=23000158442,.pad=2,.ev=.{.axis=.{.idx=2,.value=-410}}}, -.{.t=23011247285,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1438}}}, -.{.t=23011247285,.pad=2,.ev=.{.axis=.{.idx=2,.value=-439}}}, -.{.t=23011247285,.pad=2,.ev=.{.axis=.{.idx=3,.value=1057}}}, -.{.t=23011260265,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1465}}}, -.{.t=23011260265,.pad=2,.ev=.{.axis=.{.idx=2,.value=-469}}}, -.{.t=23011260265,.pad=2,.ev=.{.axis=.{.idx=3,.value=1118}}}, -.{.t=23022366569,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1438}}}, -.{.t=23022366569,.pad=2,.ev=.{.axis=.{.idx=1,.value=924}}}, -.{.t=23022366569,.pad=2,.ev=.{.axis=.{.idx=2,.value=-498}}}, -.{.t=23022366569,.pad=2,.ev=.{.axis=.{.idx=3,.value=1148}}}, -.{.t=23022380099,.pad=2,.ev=.{.axis=.{.idx=2,.value=-439}}}, -.{.t=23022380099,.pad=2,.ev=.{.axis=.{.idx=3,.value=1087}}}, -.{.t=23022385329,.pad=2,.ev=.{.axis=.{.idx=2,.value=-469}}}, -.{.t=23022385329,.pad=2,.ev=.{.axis=.{.idx=3,.value=1118}}}, -.{.t=23033207513,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1465}}}, -.{.t=23033207513,.pad=2,.ev=.{.axis=.{.idx=1,.value=953}}}, -.{.t=23033215483,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1438}}}, -.{.t=23033215483,.pad=2,.ev=.{.axis=.{.idx=1,.value=924}}}, -.{.t=23033215483,.pad=2,.ev=.{.axis=.{.idx=2,.value=-439}}}, -.{.t=23033215483,.pad=2,.ev=.{.axis=.{.idx=3,.value=1087}}}, -.{.t=23033219653,.pad=2,.ev=.{.axis=.{.idx=1,.value=953}}}, -.{.t=23044563226,.pad=2,.ev=.{.axis=.{.idx=1,.value=924}}}, -.{.t=23044563226,.pad=2,.ev=.{.axis=.{.idx=2,.value=-469}}}, -.{.t=23044563226,.pad=2,.ev=.{.axis=.{.idx=3,.value=1118}}}, -.{.t=23044572856,.pad=2,.ev=.{.axis=.{.idx=2,.value=-410}}}, -.{.t=23044572856,.pad=2,.ev=.{.axis=.{.idx=3,.value=1087}}}, -.{.t=23044576806,.pad=2,.ev=.{.axis=.{.idx=1,.value=953}}}, -.{.t=23044576806,.pad=2,.ev=.{.axis=.{.idx=2,.value=-469}}}, -.{.t=23044576806,.pad=2,.ev=.{.axis=.{.idx=3,.value=1118}}}, -.{.t=23055818709,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1465}}}, -.{.t=23055818709,.pad=2,.ev=.{.axis=.{.idx=3,.value=1087}}}, -.{.t=23055828779,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1438}}}, -.{.t=23055828779,.pad=2,.ev=.{.axis=.{.idx=1,.value=924}}}, -.{.t=23055828779,.pad=2,.ev=.{.axis=.{.idx=3,.value=1118}}}, -.{.t=23055832789,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1410}}}, -.{.t=23055832789,.pad=2,.ev=.{.axis=.{.idx=3,.value=1087}}}, -.{.t=23066680603,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1465}}}, -.{.t=23066680603,.pad=2,.ev=.{.axis=.{.idx=1,.value=953}}}, -.{.t=23066680603,.pad=2,.ev=.{.axis=.{.idx=3,.value=1118}}}, -.{.t=23066690143,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1493}}}, -.{.t=23066690143,.pad=2,.ev=.{.axis=.{.idx=1,.value=981}}}, -.{.t=23066690143,.pad=2,.ev=.{.axis=.{.idx=2,.value=-439}}}, -.{.t=23066690143,.pad=2,.ev=.{.axis=.{.idx=3,.value=1087}}}, -.{.t=23077703397,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1438}}}, -.{.t=23077703397,.pad=2,.ev=.{.axis=.{.idx=1,.value=924}}}, -.{.t=23077703397,.pad=2,.ev=.{.axis=.{.idx=3,.value=1118}}}, -.{.t=23077711687,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1465}}}, -.{.t=23077711687,.pad=2,.ev=.{.axis=.{.idx=1,.value=953}}}, -.{.t=23077711687,.pad=2,.ev=.{.axis=.{.idx=2,.value=-469}}}, -.{.t=23077715567,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1493}}}, -.{.t=23077715567,.pad=2,.ev=.{.axis=.{.idx=1,.value=981}}}, -.{.t=23077715567,.pad=2,.ev=.{.axis=.{.idx=2,.value=-439}}}, -.{.t=23077715567,.pad=2,.ev=.{.axis=.{.idx=3,.value=1087}}}, -.{.t=23088844720,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1438}}}, -.{.t=23088844720,.pad=2,.ev=.{.axis=.{.idx=1,.value=953}}}, -.{.t=23088844720,.pad=2,.ev=.{.axis=.{.idx=2,.value=-498}}}, -.{.t=23088844720,.pad=2,.ev=.{.axis=.{.idx=3,.value=1148}}}, -.{.t=23088853270,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1465}}}, -.{.t=23088853270,.pad=2,.ev=.{.axis=.{.idx=2,.value=-469}}}, -.{.t=23088853270,.pad=2,.ev=.{.axis=.{.idx=3,.value=1118}}}, -.{.t=23088856830,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1438}}}, -.{.t=23088856830,.pad=2,.ev=.{.axis=.{.idx=1,.value=924}}}, -.{.t=23088856830,.pad=2,.ev=.{.axis=.{.idx=2,.value=-439}}}, -.{.t=23100184994,.pad=2,.ev=.{.axis=.{.idx=1,.value=953}}}, -.{.t=23100184994,.pad=2,.ev=.{.axis=.{.idx=2,.value=-410}}}, -.{.t=23100184994,.pad=2,.ev=.{.axis=.{.idx=3,.value=1087}}}, -.{.t=23100197834,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1465}}}, -.{.t=23100202044,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1438}}}, -.{.t=23100202044,.pad=2,.ev=.{.axis=.{.idx=1,.value=924}}}, -.{.t=23100202044,.pad=2,.ev=.{.axis=.{.idx=2,.value=-439}}}, -.{.t=23111316337,.pad=2,.ev=.{.axis=.{.idx=2,.value=-410}}}, -.{.t=23111328087,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1465}}}, -.{.t=23111328087,.pad=2,.ev=.{.axis=.{.idx=2,.value=-439}}}, -.{.t=23122579831,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1438}}}, -.{.t=23122579831,.pad=2,.ev=.{.axis=.{.idx=2,.value=-498}}}, -.{.t=23122579831,.pad=2,.ev=.{.axis=.{.idx=3,.value=1118}}}, -.{.t=23122592031,.pad=2,.ev=.{.axis=.{.idx=1,.value=953}}}, -.{.t=23122592031,.pad=2,.ev=.{.axis=.{.idx=2,.value=-469}}}, -.{.t=23122595681,.pad=2,.ev=.{.axis=.{.idx=1,.value=924}}}, -.{.t=23122595681,.pad=2,.ev=.{.axis=.{.idx=2,.value=-439}}}, -.{.t=23122595681,.pad=2,.ev=.{.axis=.{.idx=3,.value=1087}}}, -.{.t=23133201565,.pad=2,.ev=.{.axis=.{.idx=1,.value=953}}}, -.{.t=23133205635,.pad=2,.ev=.{.axis=.{.idx=4,.value=728}}}, -.{.t=23133205635,.pad=2,.ev=.{.axis=.{.idx=1,.value=924}}}, -.{.t=23133205635,.pad=2,.ev=.{.axis=.{.idx=3,.value=1118}}}, -.{.t=23144628108,.pad=2,.ev=.{.axis=.{.idx=4,.value=3169}}}, -.{.t=23144628108,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1493}}}, -.{.t=23144628108,.pad=2,.ev=.{.axis=.{.idx=1,.value=953}}}, -.{.t=23144628108,.pad=2,.ev=.{.axis=.{.idx=2,.value=-410}}}, -.{.t=23144628108,.pad=2,.ev=.{.axis=.{.idx=3,.value=1087}}}, -.{.t=23144640728,.pad=2,.ev=.{.axis=.{.idx=4,.value=6314}}}, -.{.t=23144640728,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1465}}}, -.{.t=23144640728,.pad=2,.ev=.{.axis=.{.idx=2,.value=-469}}}, -.{.t=23144640728,.pad=2,.ev=.{.axis=.{.idx=3,.value=1118}}}, -.{.t=23144644338,.pad=2,.ev=.{.axis=.{.idx=4,.value=10679}}}, -.{.t=23144644338,.pad=2,.ev=.{.axis=.{.idx=1,.value=981}}}, -.{.t=23144644338,.pad=2,.ev=.{.axis=.{.idx=2,.value=-410}}}, -.{.t=23144644338,.pad=2,.ev=.{.axis=.{.idx=3,.value=1087}}}, -.{.t=23155757852,.pad=2,.ev=.{.axis=.{.idx=4,.value=16500}}}, -.{.t=23155757852,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1493}}}, -.{.t=23155757852,.pad=2,.ev=.{.axis=.{.idx=1,.value=953}}}, -.{.t=23155767512,.pad=2,.ev=.{.axis=.{.idx=4,.value=23682}}}, -.{.t=23155767512,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1438}}}, -.{.t=23155767512,.pad=2,.ev=.{.axis=.{.idx=1,.value=924}}}, -.{.t=23155773302,.pad=2,.ev=.{.axis=.{.idx=4,.value=32084}}}, -.{.t=23155773302,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1465}}}, -.{.t=23166856095,.pad=2,.ev=.{.axis=.{.idx=4,.value=32766}}}, -.{.t=23166856095,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1438}}}, -.{.t=23166856095,.pad=2,.ev=.{.axis=.{.idx=2,.value=-439}}}, -.{.t=23166869315,.pad=2,.ev=.{.axis=.{.idx=1,.value=953}}}, -.{.t=23166869315,.pad=2,.ev=.{.axis=.{.idx=3,.value=1118}}}, -.{.t=23177937079,.pad=2,.ev=.{.axis=.{.idx=1,.value=924}}}, -.{.t=23177937079,.pad=2,.ev=.{.axis=.{.idx=3,.value=1087}}}, -.{.t=23177947099,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1465}}}, -.{.t=23177947099,.pad=2,.ev=.{.axis=.{.idx=2,.value=-410}}}, -.{.t=23177950979,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1438}}}, -.{.t=23177950979,.pad=2,.ev=.{.axis=.{.idx=2,.value=-439}}}, -.{.t=23177950979,.pad=2,.ev=.{.axis=.{.idx=3,.value=1118}}}, -.{.t=23188909763,.pad=2,.ev=.{.axis=.{.idx=2,.value=-410}}}, -.{.t=23188909763,.pad=2,.ev=.{.axis=.{.idx=3,.value=1087}}}, -.{.t=23188919373,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1493}}}, -.{.t=23188919373,.pad=2,.ev=.{.axis=.{.idx=1,.value=981}}}, -.{.t=23188923533,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1465}}}, -.{.t=23188923533,.pad=2,.ev=.{.axis=.{.idx=1,.value=953}}}, -.{.t=23188923533,.pad=2,.ev=.{.axis=.{.idx=2,.value=-439}}}, -.{.t=23188923533,.pad=2,.ev=.{.axis=.{.idx=3,.value=1057}}}, -.{.t=23200341706,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1438}}}, -.{.t=23200341706,.pad=2,.ev=.{.axis=.{.idx=1,.value=924}}}, -.{.t=23200341706,.pad=2,.ev=.{.axis=.{.idx=3,.value=1087}}}, -.{.t=23200357446,.pad=2,.ev=.{.axis=.{.idx=2,.value=-469}}}, -.{.t=23200360546,.pad=2,.ev=.{.axis=.{.idx=1,.value=866}}}, -.{.t=23200360546,.pad=2,.ev=.{.axis=.{.idx=2,.value=-439}}}, -.{.t=23211356329,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1493}}}, -.{.t=23211356329,.pad=2,.ev=.{.axis=.{.idx=1,.value=895}}}, -.{.t=23211356329,.pad=2,.ev=.{.axis=.{.idx=3,.value=1057}}}, -.{.t=23211369469,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1438}}}, -.{.t=23211369469,.pad=2,.ev=.{.axis=.{.idx=1,.value=808}}}, -.{.t=23211369469,.pad=2,.ev=.{.axis=.{.idx=2,.value=-469}}}, -.{.t=23211369469,.pad=2,.ev=.{.axis=.{.idx=3,.value=1118}}}, -.{.t=23222496653,.pad=2,.ev=.{.axis=.{.idx=1,.value=722}}}, -.{.t=23222496653,.pad=2,.ev=.{.axis=.{.idx=2,.value=-410}}}, -.{.t=23222496653,.pad=2,.ev=.{.axis=.{.idx=3,.value=1057}}}, -.{.t=23222508723,.pad=2,.ev=.{.axis=.{.idx=1,.value=664}}}, -.{.t=23222508723,.pad=2,.ev=.{.axis=.{.idx=2,.value=-439}}}, -.{.t=23222508723,.pad=2,.ev=.{.axis=.{.idx=3,.value=1087}}}, -.{.t=23222512923,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1465}}}, -.{.t=23222512923,.pad=2,.ev=.{.axis=.{.idx=1,.value=693}}}, -.{.t=23222512923,.pad=2,.ev=.{.axis=.{.idx=3,.value=1118}}}, -.{.t=23233616896,.pad=2,.ev=.{.axis=.{.idx=1,.value=404}}}, -.{.t=23233616896,.pad=2,.ev=.{.axis=.{.idx=3,.value=1087}}}, -.{.t=23233628876,.pad=2,.ev=.{.axis=.{.idx=1,.value=462}}}, -.{.t=23233628876,.pad=2,.ev=.{.axis=.{.idx=2,.value=-469}}}, -.{.t=23233628876,.pad=2,.ev=.{.axis=.{.idx=3,.value=1118}}}, -.{.t=23233634716,.pad=2,.ev=.{.axis=.{.idx=1,.value=375}}}, -.{.t=23233634716,.pad=2,.ev=.{.axis=.{.idx=2,.value=-439}}}, -.{.t=23244703810,.pad=2,.ev=.{.axis=.{.idx=1,.value=404}}}, -.{.t=23244703810,.pad=2,.ev=.{.axis=.{.idx=2,.value=-469}}}, -.{.t=23244703810,.pad=2,.ev=.{.axis=.{.idx=3,.value=1087}}}, -.{.t=23244716710,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1438}}}, -.{.t=23244716710,.pad=2,.ev=.{.axis=.{.idx=1,.value=288}}}, -.{.t=23244716710,.pad=2,.ev=.{.axis=.{.idx=2,.value=-439}}}, -.{.t=23244722470,.pad=2,.ev=.{.axis=.{.idx=1,.value=317}}}, -.{.t=23255891634,.pad=2,.ev=.{.axis=.{.idx=1,.value=260}}}, -.{.t=23255891634,.pad=2,.ev=.{.axis=.{.idx=2,.value=-469}}}, -.{.t=23255903964,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1410}}}, -.{.t=23255903964,.pad=2,.ev=.{.axis=.{.idx=1,.value=144}}}, -.{.t=23255903964,.pad=2,.ev=.{.axis=.{.idx=3,.value=1057}}}, -.{.t=23255909564,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1465}}}, -.{.t=23255909564,.pad=2,.ev=.{.axis=.{.idx=1,.value=115}}}, -.{.t=23266911057,.pad=2,.ev=.{.axis=.{.idx=4,.value=30723}}}, -.{.t=23266911057,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1438}}}, -.{.t=23266911057,.pad=2,.ev=.{.axis=.{.idx=1,.value=86}}}, -.{.t=23266924047,.pad=2,.ev=.{.axis=.{.idx=4,.value=27437}}}, -.{.t=23266924047,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1465}}}, -.{.t=23266924047,.pad=2,.ev=.{.axis=.{.idx=1,.value=115}}}, -.{.t=23266924047,.pad=2,.ev=.{.axis=.{.idx=3,.value=1087}}}, -.{.t=23278235081,.pad=2,.ev=.{.axis=.{.idx=4,.value=24292}}}, -.{.t=23278235081,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1438}}}, -.{.t=23278235081,.pad=2,.ev=.{.axis=.{.idx=1,.value=29}}}, -.{.t=23278246901,.pad=2,.ev=.{.axis=.{.idx=4,.value=21053}}}, -.{.t=23278246901,.pad=2,.ev=.{.axis=.{.idx=1,.value=57}}}, -.{.t=23278246901,.pad=2,.ev=.{.axis=.{.idx=2,.value=-439}}}, -.{.t=23278246901,.pad=2,.ev=.{.axis=.{.idx=3,.value=1057}}}, -.{.t=23278254110,.pad=2,.ev=.{.axis=.{.idx=4,.value=17814}}}, -.{.t=23278254110,.pad=2,.ev=.{.axis=.{.idx=1,.value=86}}}, -.{.t=23278254110,.pad=2,.ev=.{.axis=.{.idx=2,.value=-498}}}, -.{.t=23278254110,.pad=2,.ev=.{.axis=.{.idx=3,.value=1087}}}, -.{.t=23289217094,.pad=2,.ev=.{.axis=.{.idx=4,.value=14341}}}, -.{.t=23289217094,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1465}}}, -.{.t=23289217094,.pad=2,.ev=.{.axis=.{.idx=1,.value=144}}}, -.{.t=23289217094,.pad=2,.ev=.{.axis=.{.idx=2,.value=-469}}}, -.{.t=23289217094,.pad=2,.ev=.{.axis=.{.idx=3,.value=1057}}}, -.{.t=23289231434,.pad=2,.ev=.{.axis=.{.idx=4,.value=11384}}}, -.{.t=23289231434,.pad=2,.ev=.{.axis=.{.idx=1,.value=57}}}, -.{.t=23289236534,.pad=2,.ev=.{.axis=.{.idx=4,.value=8708}}}, -.{.t=23289236534,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1438}}}, -.{.t=23289236534,.pad=2,.ev=.{.axis=.{.idx=1,.value=0}}}, -.{.t=23300340478,.pad=2,.ev=.{.axis=.{.idx=4,.value=6126}}}, -.{.t=23300340478,.pad=2,.ev=.{.axis=.{.idx=2,.value=-439}}}, -.{.t=23300350538,.pad=2,.ev=.{.axis=.{.idx=4,.value=4014}}}, -.{.t=23300350538,.pad=2,.ev=.{.axis=.{.idx=1,.value=86}}}, -.{.t=23300354158,.pad=2,.ev=.{.axis=.{.idx=4,.value=2465}}}, -.{.t=23300354158,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1410}}}, -.{.t=23300354158,.pad=2,.ev=.{.axis=.{.idx=1,.value=288}}}, -.{.t=23311366832,.pad=2,.ev=.{.axis=.{.idx=4,.value=634}}}, -.{.t=23311366832,.pad=2,.ev=.{.axis=.{.idx=1,.value=462}}}, -.{.t=23311366832,.pad=2,.ev=.{.axis=.{.idx=3,.value=1027}}}, -.{.t=23311379542,.pad=2,.ev=.{.axis=.{.idx=4,.value=0}}}, -.{.t=23311379542,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1355}}}, -.{.t=23311379542,.pad=2,.ev=.{.axis=.{.idx=1,.value=779}}}, -.{.t=23311379542,.pad=2,.ev=.{.axis=.{.idx=2,.value=-410}}}, -.{.t=23322638775,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1272}}}, -.{.t=23322638775,.pad=2,.ev=.{.axis=.{.idx=1,.value=953}}}, -.{.t=23322638775,.pad=2,.ev=.{.axis=.{.idx=2,.value=-439}}}, -.{.t=23322649765,.pad=2,.ev=.{.axis=.{.idx=0,.value=-1051}}}, -.{.t=23322649765,.pad=2,.ev=.{.axis=.{.idx=1,.value=981}}}, -.{.t=23322649765,.pad=2,.ev=.{.axis=.{.idx=3,.value=1057}}}, -.{.t=23322654995,.pad=2,.ev=.{.axis=.{.idx=0,.value=-885}}}, -.{.t=23322654995,.pad=2,.ev=.{.axis=.{.idx=1,.value=1039}}}, -.{.t=23333351109,.pad=2,.ev=.{.axis=.{.idx=0,.value=-691}}}, -.{.t=23333351109,.pad=2,.ev=.{.axis=.{.idx=2,.value=-469}}}, -.{.t=23333359049,.pad=2,.ev=.{.axis=.{.idx=0,.value=-553}}}, -.{.t=23333359049,.pad=2,.ev=.{.axis=.{.idx=3,.value=1087}}}, -.{.t=23333362519,.pad=2,.ev=.{.axis=.{.idx=1,.value=1010}}}, -.{.t=23333362519,.pad=2,.ev=.{.axis=.{.idx=2,.value=-439}}}, -.{.t=23333362519,.pad=2,.ev=.{.axis=.{.idx=3,.value=1057}}}, -.{.t=23344695372,.pad=2,.ev=.{.axis=.{.idx=1,.value=981}}}, -.{.t=23344706662,.pad=2,.ev=.{.axis=.{.idx=0,.value=-525}}}, -.{.t=23344706662,.pad=2,.ev=.{.axis=.{.idx=1,.value=953}}}, -.{.t=23344711982,.pad=2,.ev=.{.axis=.{.idx=0,.value=-553}}}, -.{.t=23344711982,.pad=2,.ev=.{.axis=.{.idx=1,.value=981}}}, -.{.t=23355868326,.pad=2,.ev=.{.axis=.{.idx=0,.value=-498}}}, -.{.t=23355868326,.pad=2,.ev=.{.axis=.{.idx=1,.value=1010}}}, -.{.t=23355878956,.pad=2,.ev=.{.axis=.{.idx=0,.value=-525}}}, -.{.t=23355878956,.pad=2,.ev=.{.axis=.{.idx=1,.value=981}}}, -.{.t=23355878956,.pad=2,.ev=.{.axis=.{.idx=2,.value=-469}}}, -.{.t=23355878956,.pad=2,.ev=.{.axis=.{.idx=3,.value=1087}}}, -.{.t=23355884866,.pad=2,.ev=.{.axis=.{.idx=1,.value=1010}}}, -.{.t=23355884866,.pad=2,.ev=.{.axis=.{.idx=2,.value=-410}}}, -.{.t=23355884866,.pad=2,.ev=.{.axis=.{.idx=3,.value=1027}}}, -.{.t=23366942749,.pad=2,.ev=.{.axis=.{.idx=0,.value=-553}}}, -.{.t=23366952219,.pad=2,.ev=.{.axis=.{.idx=0,.value=-525}}}, -.{.t=23366952219,.pad=2,.ev=.{.axis=.{.idx=1,.value=981}}}, -.{.t=23366952219,.pad=2,.ev=.{.axis=.{.idx=2,.value=-439}}}, -.{.t=23366952219,.pad=2,.ev=.{.axis=.{.idx=3,.value=1057}}}, -.{.t=23378047613,.pad=2,.ev=.{.axis=.{.idx=0,.value=-553}}}, -.{.t=23378047613,.pad=2,.ev=.{.axis=.{.idx=1,.value=1010}}}, -.{.t=23378064723,.pad=2,.ev=.{.axis=.{.idx=0,.value=-525}}}, -.{.t=23378064723,.pad=2,.ev=.{.axis=.{.idx=1,.value=981}}}, -.{.t=23378064723,.pad=2,.ev=.{.axis=.{.idx=2,.value=-469}}}, -.{.t=23388957907,.pad=2,.ev=.{.axis=.{.idx=0,.value=-553}}}, -.{.t=23388957907,.pad=2,.ev=.{.axis=.{.idx=1,.value=1039}}}, -.{.t=23388957907,.pad=2,.ev=.{.axis=.{.idx=2,.value=-439}}}, -.{.t=23388957907,.pad=2,.ev=.{.axis=.{.idx=3,.value=1027}}}, -.{.t=23388967217,.pad=2,.ev=.{.axis=.{.idx=1,.value=1010}}}, -.{.t=23388967217,.pad=2,.ev=.{.axis=.{.idx=2,.value=-410}}}, -.{.t=23388970117,.pad=2,.ev=.{.axis=.{.idx=0,.value=-525}}}, -.{.t=23388970117,.pad=2,.ev=.{.axis=.{.idx=1,.value=981}}}, -.{.t=23388970117,.pad=2,.ev=.{.axis=.{.idx=2,.value=-439}}}, -.{.t=23388970117,.pad=2,.ev=.{.axis=.{.idx=3,.value=1057}}}, -.{.t=23400316180,.pad=2,.ev=.{.axis=.{.idx=2,.value=-469}}}, -.{.t=23400325960,.pad=2,.ev=.{.axis=.{.idx=0,.value=-580}}}, -.{.t=23400325960,.pad=2,.ev=.{.axis=.{.idx=1,.value=1039}}}, -.{.t=23400325960,.pad=2,.ev=.{.axis=.{.idx=2,.value=-410}}}, -.{.t=23400330510,.pad=2,.ev=.{.axis=.{.idx=0,.value=-525}}}, -.{.t=23400330510,.pad=2,.ev=.{.axis=.{.idx=1,.value=981}}}, -.{.t=23400330510,.pad=2,.ev=.{.axis=.{.idx=2,.value=-439}}}, -.{.t=23411327274,.pad=2,.ev=.{.axis=.{.idx=1,.value=1039}}}, -.{.t=23411337364,.pad=2,.ev=.{.axis=.{.idx=1,.value=1010}}}, -.{.t=23411337364,.pad=2,.ev=.{.axis=.{.idx=3,.value=1027}}}, -.{.t=23422593127,.pad=2,.ev=.{.axis=.{.idx=2,.value=-469}}}, -.{.t=23422593127,.pad=2,.ev=.{.axis=.{.idx=3,.value=1057}}}, -.{.t=23422603997,.pad=2,.ev=.{.axis=.{.idx=2,.value=-410}}}, -.{.t=23422603997,.pad=2,.ev=.{.axis=.{.idx=3,.value=1027}}}, -.{.t=23422607677,.pad=2,.ev=.{.axis=.{.idx=2,.value=-439}}}, -.{.t=23422607677,.pad=2,.ev=.{.axis=.{.idx=3,.value=1057}}}, -.{.t=23433465571,.pad=2,.ev=.{.axis=.{.idx=1,.value=1039}}}, -.{.t=23433465571,.pad=2,.ev=.{.axis=.{.idx=3,.value=1027}}}, -.{.t=23433473571,.pad=2,.ev=.{.axis=.{.idx=1,.value=1010}}}, -.{.t=23433473571,.pad=2,.ev=.{.axis=.{.idx=2,.value=-469}}}, -.{.t=23433473571,.pad=2,.ev=.{.axis=.{.idx=3,.value=1057}}}, -.{.t=23444613485,.pad=2,.ev=.{.axis=.{.idx=1,.value=1039}}}, -.{.t=23444623255,.pad=2,.ev=.{.axis=.{.idx=2,.value=-439}}}, -.{.t=23444626645,.pad=2,.ev=.{.axis=.{.idx=1,.value=1010}}}, -.{.t=23444626645,.pad=2,.ev=.{.axis=.{.idx=3,.value=1027}}}, + .{ .t = 3100837937, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 997 } } }, + .{ .t = 3100845387, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -829 } } }, + .{ .t = 3100845387, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = -1441 } } }, + .{ .t = 3100845387, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1027 } } }, + .{ .t = 3100849157, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -802 } } }, + .{ .t = 3100849157, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = -1411 } } }, + .{ .t = 3100849157, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1057 } } }, + .{ .t = 3111923010, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -829 } } }, + .{ .t = 3111923010, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = -1529 } } }, + .{ .t = 3111923010, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1027 } } }, + .{ .t = 3111936310, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -802 } } }, + .{ .t = 3111936310, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = -1323 } } }, + .{ .t = 3111941850, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = -1558 } } }, + .{ .t = 3111941850, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 997 } } }, + .{ .t = 3123013224, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -829 } } }, + .{ .t = 3123013224, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = -1294 } } }, + .{ .t = 3123013224, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1027 } } }, + .{ .t = 3123021794, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -802 } } }, + .{ .t = 3123021794, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = -941 } } }, + .{ .t = 3123021794, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 997 } } }, + .{ .t = 3134267607, .pad = 2, .ev = .{ .axis = .{ .idx = 5, .value = 0 } } }, + .{ .t = 3134267607, .pad = 2, .ev = .{ .axis = .{ .idx = 5, .value = 214 } } }, + .{ .t = 3134267607, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -829 } } }, + .{ .t = 3134267607, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = -647 } } }, + .{ .t = 3134277137, .pad = 2, .ev = .{ .axis = .{ .idx = 5, .value = 2674 } } }, + .{ .t = 3134277137, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -802 } } }, + .{ .t = 3134277137, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = -500 } } }, + .{ .t = 3134280727, .pad = 2, .ev = .{ .axis = .{ .idx = 5, .value = 5436 } } }, + .{ .t = 3134280727, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -829 } } }, + .{ .t = 3134280727, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = -206 } } }, + .{ .t = 3134280727, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1027 } } }, + .{ .t = 3146260210, .pad = 2, .ev = .{ .axis = .{ .idx = 5, .value = 8198 } } }, + .{ .t = 3146260210, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -774 } } }, + .{ .t = 3146260210, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = -176 } } }, + .{ .t = 3146260210, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 997 } } }, + .{ .t = 3146270520, .pad = 2, .ev = .{ .axis = .{ .idx = 5, .value = 11211 } } }, + .{ .t = 3146270520, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -802 } } }, + .{ .t = 3146270520, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = -29 } } }, + .{ .t = 3146274870, .pad = 2, .ev = .{ .axis = .{ .idx = 5, .value = 13671 } } }, + .{ .t = 3146274870, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 86 } } }, + .{ .t = 3146274870, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1027 } } }, + .{ .t = 3156416215, .pad = 2, .ev = .{ .axis = .{ .idx = 5, .value = 16432 } } }, + .{ .t = 3156416215, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -829 } } }, + .{ .t = 3156416215, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 288 } } }, + .{ .t = 3156416215, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 997 } } }, + .{ .t = 3156435465, .pad = 2, .ev = .{ .axis = .{ .idx = 5, .value = 18893 } } }, + .{ .t = 3156435465, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -802 } } }, + .{ .t = 3156435465, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 462 } } }, + .{ .t = 3156441825, .pad = 2, .ev = .{ .axis = .{ .idx = 5, .value = 21504 } } }, + .{ .t = 3156441825, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 491 } } }, + .{ .t = 3156441825, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1057 } } }, + .{ .t = 3167440508, .pad = 2, .ev = .{ .axis = .{ .idx = 5, .value = 23915 } } }, + .{ .t = 3167440508, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 664 } } }, + .{ .t = 3167440508, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1027 } } }, + .{ .t = 3167449678, .pad = 2, .ev = .{ .axis = .{ .idx = 5, .value = 26224 } } }, + .{ .t = 3167449678, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -829 } } }, + .{ .t = 3167449678, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 779 } } }, + .{ .t = 3167449678, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 997 } } }, + .{ .t = 3178634312, .pad = 2, .ev = .{ .axis = .{ .idx = 5, .value = 28384 } } }, + .{ .t = 3178634312, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -802 } } }, + .{ .t = 3178634312, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 837 } } }, + .{ .t = 3178634312, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1027 } } }, + .{ .t = 3178646332, .pad = 2, .ev = .{ .axis = .{ .idx = 5, .value = 30593 } } }, + .{ .t = 3178646332, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -829 } } }, + .{ .t = 3178646332, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 997 } } }, + .{ .t = 3178651472, .pad = 2, .ev = .{ .axis = .{ .idx = 5, .value = 32702 } } }, + .{ .t = 3178651472, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -802 } } }, + .{ .t = 3189737565, .pad = 2, .ev = .{ .axis = .{ .idx = 5, .value = 32766 } } }, + .{ .t = 3189737565, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 924 } } }, + .{ .t = 3189737565, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1027 } } }, + .{ .t = 3189748175, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1057 } } }, + .{ .t = 3189751215, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 953 } } }, + .{ .t = 3189751215, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1027 } } }, + .{ .t = 3200899959, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 997 } } }, + .{ .t = 3200909349, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -774 } } }, + .{ .t = 3200909349, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 924 } } }, + .{ .t = 3200914229, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -802 } } }, + .{ .t = 3200914229, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 953 } } }, + .{ .t = 3200914229, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1027 } } }, + .{ .t = 3212027402, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -829 } } }, + .{ .t = 3212027402, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1010 } } }, + .{ .t = 3212027402, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 997 } } }, + .{ .t = 3212033902, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1027 } } }, + .{ .t = 3222960156, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 981 } } }, + .{ .t = 3222960156, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 997 } } }, + .{ .t = 3222967916, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -802 } } }, + .{ .t = 3222967916, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 953 } } }, + .{ .t = 3222967916, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1087 } } }, + .{ .t = 3234186130, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -857 } } }, + .{ .t = 3234186130, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 981 } } }, + .{ .t = 3234186130, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1027 } } }, + .{ .t = 3234194710, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -802 } } }, + .{ .t = 3234194710, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 953 } } }, + .{ .t = 3234194710, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 997 } } }, + .{ .t = 3234198480, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -829 } } }, + .{ .t = 3234198480, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1097 } } }, + .{ .t = 3245272663, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1126 } } }, + .{ .t = 3245272663, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1057 } } }, + .{ .t = 3245280873, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -802 } } }, + .{ .t = 3245280873, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 997 } } }, + .{ .t = 3245284263, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1097 } } }, + .{ .t = 3245284263, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1027 } } }, + .{ .t = 3256351647, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -829 } } }, + .{ .t = 3256351647, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 997 } } }, + .{ .t = 3256361897, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1126 } } }, + .{ .t = 3256361897, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1027 } } }, + .{ .t = 3256366557, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -857 } } }, + .{ .t = 3267453910, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -829 } } }, + .{ .t = 3267461450, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -802 } } }, + .{ .t = 3267461450, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1097 } } }, + .{ .t = 3267461450, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1057 } } }, + .{ .t = 3278671394, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1027 } } }, + .{ .t = 3278679494, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -829 } } }, + .{ .t = 3278679494, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1126 } } }, + .{ .t = 3278679494, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 997 } } }, + .{ .t = 3278684284, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1097 } } }, + .{ .t = 3289747017, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -802 } } }, + .{ .t = 3289757957, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -774 } } }, + .{ .t = 3289757957, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1068 } } }, + .{ .t = 3289757957, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1057 } } }, + .{ .t = 3289764977, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -829 } } }, + .{ .t = 3289764977, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1027 } } }, + .{ .t = 3300894251, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -802 } } }, + .{ .t = 3300894251, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1057 } } }, + .{ .t = 3300904161, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -829 } } }, + .{ .t = 3300904161, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1027 } } }, + .{ .t = 3300908771, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1057 } } }, + .{ .t = 3312130554, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -802 } } }, + .{ .t = 3312130554, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1039 } } }, + .{ .t = 3312130554, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1027 } } }, + .{ .t = 3312142164, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1057 } } }, + .{ .t = 3312145624, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -829 } } }, + .{ .t = 3312145624, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1068 } } }, + .{ .t = 3312145624, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1027 } } }, + .{ .t = 3323185928, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -802 } } }, + .{ .t = 3323185928, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1039 } } }, + .{ .t = 3323197438, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1010 } } }, + .{ .t = 3334415941, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -829 } } }, + .{ .t = 3334415941, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1057 } } }, + .{ .t = 3334428191, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -802 } } }, + .{ .t = 3334428191, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1027 } } }, + .{ .t = 3334433441, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -829 } } }, + .{ .t = 3345319335, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -802 } } }, + .{ .t = 3345319335, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1039 } } }, + .{ .t = 3345329665, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -774 } } }, + .{ .t = 3345329665, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1010 } } }, + .{ .t = 3345329665, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 997 } } }, + .{ .t = 3345334835, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -802 } } }, + .{ .t = 3356434069, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -829 } } }, + .{ .t = 3356434069, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1039 } } }, + .{ .t = 3356434069, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1027 } } }, + .{ .t = 3356449919, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -802 } } }, + .{ .t = 3356449919, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1010 } } }, + .{ .t = 3356449919, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 997 } } }, + .{ .t = 3367716072, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -857 } } }, + .{ .t = 3367716072, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1068 } } }, + .{ .t = 3367728332, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -829 } } }, + .{ .t = 3367728332, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1039 } } }, + .{ .t = 3367728332, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1027 } } }, + .{ .t = 3367733692, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -802 } } }, + .{ .t = 3367733692, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1010 } } }, + .{ .t = 3367733692, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1057 } } }, + .{ .t = 3378615526, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 997 } } }, + .{ .t = 3389836929, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -774 } } }, + .{ .t = 3389836929, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 981 } } }, + .{ .t = 3389836929, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1027 } } }, + .{ .t = 3389847129, .pad = 2, .ev = .{ .axis = .{ .idx = 5, .value = 31648 } } }, + .{ .t = 3389847129, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -802 } } }, + .{ .t = 3389847129, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1010 } } }, + .{ .t = 3389852719, .pad = 2, .ev = .{ .axis = .{ .idx = 5, .value = 29137 } } }, + .{ .t = 3389852719, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1039 } } }, + .{ .t = 3401186593, .pad = 2, .ev = .{ .axis = .{ .idx = 5, .value = 26074 } } }, + .{ .t = 3401186593, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -829 } } }, + .{ .t = 3401194003, .pad = 2, .ev = .{ .axis = .{ .idx = 5, .value = 23262 } } }, + .{ .t = 3401194003, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -802 } } }, + .{ .t = 3401194003, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1010 } } }, + .{ .t = 3401194003, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1057 } } }, + .{ .t = 3401198713, .pad = 2, .ev = .{ .axis = .{ .idx = 5, .value = 20349 } } }, + .{ .t = 3401198713, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 997 } } }, + .{ .t = 3411932407, .pad = 2, .ev = .{ .axis = .{ .idx = 5, .value = 17587 } } }, + .{ .t = 3411932407, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -829 } } }, + .{ .t = 3411932407, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1039 } } }, + .{ .t = 3411941077, .pad = 2, .ev = .{ .axis = .{ .idx = 5, .value = 15127 } } }, + .{ .t = 3411941077, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -802 } } }, + .{ .t = 3411941077, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1027 } } }, + .{ .t = 3411944947, .pad = 2, .ev = .{ .axis = .{ .idx = 5, .value = 12617 } } }, + .{ .t = 3411944947, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -829 } } }, + .{ .t = 3411944947, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 953 } } }, + .{ .t = 3411944947, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 997 } } }, + .{ .t = 3423178470, .pad = 2, .ev = .{ .axis = .{ .idx = 5, .value = 10307 } } }, + .{ .t = 3423178470, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -802 } } }, + .{ .t = 3423178470, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 924 } } }, + .{ .t = 3423187080, .pad = 2, .ev = .{ .axis = .{ .idx = 5, .value = 8298 } } }, + .{ .t = 3423187080, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 981 } } }, + .{ .t = 3423187080, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1027 } } }, + .{ .t = 3434307174, .pad = 2, .ev = .{ .axis = .{ .idx = 5, .value = 6340 } } }, + .{ .t = 3434307174, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 924 } } }, + .{ .t = 3434315334, .pad = 2, .ev = .{ .axis = .{ .idx = 5, .value = 4532 } } }, + .{ .t = 3434315334, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 997 } } }, + .{ .t = 3434318744, .pad = 2, .ev = .{ .axis = .{ .idx = 5, .value = 2975 } } }, + .{ .t = 3434318744, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 866 } } }, + .{ .t = 3445336427, .pad = 2, .ev = .{ .axis = .{ .idx = 5, .value = 1067 } } }, + .{ .t = 3445336427, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 635 } } }, + .{ .t = 3445344507, .pad = 2, .ev = .{ .axis = .{ .idx = 4, .value = 446 } } }, + .{ .t = 3445344507, .pad = 2, .ev = .{ .axis = .{ .idx = 5, .value = 0 } } }, + .{ .t = 3445344507, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 346 } } }, + .{ .t = 3445344507, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1027 } } }, + .{ .t = 3445348567, .pad = 2, .ev = .{ .axis = .{ .idx = 4, .value = 1854 } } }, + .{ .t = 3445348567, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = -59 } } }, + .{ .t = 3456475621, .pad = 2, .ev = .{ .axis = .{ .idx = 4, .value = 3310 } } }, + .{ .t = 3456475621, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = -176 } } }, + .{ .t = 3456475621, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 997 } } }, + .{ .t = 3456483971, .pad = 2, .ev = .{ .axis = .{ .idx = 4, .value = 4436 } } }, + .{ .t = 3456483971, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = -441 } } }, + .{ .t = 3456487161, .pad = 2, .ev = .{ .axis = .{ .idx = 4, .value = 5891 } } }, + .{ .t = 3456487161, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = -558 } } }, + .{ .t = 22900269279, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1493 } } }, + .{ .t = 22900269279, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 981 } } }, + .{ .t = 22900269279, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1087 } } }, + .{ .t = 22900282319, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1465 } } }, + .{ .t = 22900282319, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 953 } } }, + .{ .t = 22900282319, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -469 } } }, + .{ .t = 22900282319, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1118 } } }, + .{ .t = 22900288339, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 981 } } }, + .{ .t = 22900288339, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -439 } } }, + .{ .t = 22900288339, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1087 } } }, + .{ .t = 22911078513, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1438 } } }, + .{ .t = 22911078513, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 953 } } }, + .{ .t = 22911078513, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -469 } } }, + .{ .t = 22911090183, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -498 } } }, + .{ .t = 22922174447, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1465 } } }, + .{ .t = 22922174447, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -527 } } }, + .{ .t = 22922174447, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1148 } } }, + .{ .t = 22922182927, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1493 } } }, + .{ .t = 22922182927, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 981 } } }, + .{ .t = 22922182927, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -498 } } }, + .{ .t = 22922182927, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1118 } } }, + .{ .t = 22922186907, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1465 } } }, + .{ .t = 22933453380, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -469 } } }, + .{ .t = 22933463530, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1438 } } }, + .{ .t = 22933463530, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 924 } } }, + .{ .t = 22933463530, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -498 } } }, + .{ .t = 22933463530, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1148 } } }, + .{ .t = 22933469520, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 953 } } }, + .{ .t = 22933469520, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -469 } } }, + .{ .t = 22933469520, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1118 } } }, + .{ .t = 22944601464, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -439 } } }, + .{ .t = 22944601464, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1087 } } }, + .{ .t = 22944613874, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1465 } } }, + .{ .t = 22944613874, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -469 } } }, + .{ .t = 22944613874, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1118 } } }, + .{ .t = 22944619754, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1438 } } }, + .{ .t = 22955633677, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1493 } } }, + .{ .t = 22955633677, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 981 } } }, + .{ .t = 22955633677, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -439 } } }, + .{ .t = 22955633677, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1087 } } }, + .{ .t = 22955647207, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1465 } } }, + .{ .t = 22955647207, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 953 } } }, + .{ .t = 22955647207, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -498 } } }, + .{ .t = 22955647207, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1148 } } }, + .{ .t = 22955652047, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1438 } } }, + .{ .t = 22955652047, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1118 } } }, + .{ .t = 22966619841, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1465 } } }, + .{ .t = 22966619841, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -469 } } }, + .{ .t = 22966628121, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 924 } } }, + .{ .t = 22966628121, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1087 } } }, + .{ .t = 22977745245, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1438 } } }, + .{ .t = 22977745245, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 953 } } }, + .{ .t = 22977745245, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -498 } } }, + .{ .t = 22977745245, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1148 } } }, + .{ .t = 22977753905, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1465 } } }, + .{ .t = 22977753905, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -469 } } }, + .{ .t = 22977753905, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1118 } } }, + .{ .t = 22977757525, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -439 } } }, + .{ .t = 22988922908, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1438 } } }, + .{ .t = 22988922908, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 981 } } }, + .{ .t = 22988936008, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1465 } } }, + .{ .t = 22988936008, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -469 } } }, + .{ .t = 22988940638, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1438 } } }, + .{ .t = 22988940638, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 953 } } }, + .{ .t = 23000140672, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1465 } } }, + .{ .t = 23000140672, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -498 } } }, + .{ .t = 23000152872, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1438 } } }, + .{ .t = 23000152872, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 924 } } }, + .{ .t = 23000152872, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -439 } } }, + .{ .t = 23000152872, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1087 } } }, + .{ .t = 23000158442, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1493 } } }, + .{ .t = 23000158442, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 953 } } }, + .{ .t = 23000158442, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -410 } } }, + .{ .t = 23011247285, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1438 } } }, + .{ .t = 23011247285, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -439 } } }, + .{ .t = 23011247285, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1057 } } }, + .{ .t = 23011260265, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1465 } } }, + .{ .t = 23011260265, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -469 } } }, + .{ .t = 23011260265, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1118 } } }, + .{ .t = 23022366569, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1438 } } }, + .{ .t = 23022366569, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 924 } } }, + .{ .t = 23022366569, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -498 } } }, + .{ .t = 23022366569, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1148 } } }, + .{ .t = 23022380099, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -439 } } }, + .{ .t = 23022380099, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1087 } } }, + .{ .t = 23022385329, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -469 } } }, + .{ .t = 23022385329, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1118 } } }, + .{ .t = 23033207513, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1465 } } }, + .{ .t = 23033207513, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 953 } } }, + .{ .t = 23033215483, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1438 } } }, + .{ .t = 23033215483, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 924 } } }, + .{ .t = 23033215483, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -439 } } }, + .{ .t = 23033215483, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1087 } } }, + .{ .t = 23033219653, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 953 } } }, + .{ .t = 23044563226, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 924 } } }, + .{ .t = 23044563226, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -469 } } }, + .{ .t = 23044563226, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1118 } } }, + .{ .t = 23044572856, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -410 } } }, + .{ .t = 23044572856, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1087 } } }, + .{ .t = 23044576806, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 953 } } }, + .{ .t = 23044576806, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -469 } } }, + .{ .t = 23044576806, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1118 } } }, + .{ .t = 23055818709, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1465 } } }, + .{ .t = 23055818709, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1087 } } }, + .{ .t = 23055828779, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1438 } } }, + .{ .t = 23055828779, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 924 } } }, + .{ .t = 23055828779, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1118 } } }, + .{ .t = 23055832789, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1410 } } }, + .{ .t = 23055832789, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1087 } } }, + .{ .t = 23066680603, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1465 } } }, + .{ .t = 23066680603, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 953 } } }, + .{ .t = 23066680603, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1118 } } }, + .{ .t = 23066690143, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1493 } } }, + .{ .t = 23066690143, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 981 } } }, + .{ .t = 23066690143, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -439 } } }, + .{ .t = 23066690143, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1087 } } }, + .{ .t = 23077703397, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1438 } } }, + .{ .t = 23077703397, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 924 } } }, + .{ .t = 23077703397, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1118 } } }, + .{ .t = 23077711687, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1465 } } }, + .{ .t = 23077711687, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 953 } } }, + .{ .t = 23077711687, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -469 } } }, + .{ .t = 23077715567, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1493 } } }, + .{ .t = 23077715567, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 981 } } }, + .{ .t = 23077715567, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -439 } } }, + .{ .t = 23077715567, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1087 } } }, + .{ .t = 23088844720, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1438 } } }, + .{ .t = 23088844720, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 953 } } }, + .{ .t = 23088844720, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -498 } } }, + .{ .t = 23088844720, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1148 } } }, + .{ .t = 23088853270, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1465 } } }, + .{ .t = 23088853270, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -469 } } }, + .{ .t = 23088853270, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1118 } } }, + .{ .t = 23088856830, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1438 } } }, + .{ .t = 23088856830, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 924 } } }, + .{ .t = 23088856830, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -439 } } }, + .{ .t = 23100184994, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 953 } } }, + .{ .t = 23100184994, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -410 } } }, + .{ .t = 23100184994, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1087 } } }, + .{ .t = 23100197834, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1465 } } }, + .{ .t = 23100202044, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1438 } } }, + .{ .t = 23100202044, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 924 } } }, + .{ .t = 23100202044, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -439 } } }, + .{ .t = 23111316337, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -410 } } }, + .{ .t = 23111328087, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1465 } } }, + .{ .t = 23111328087, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -439 } } }, + .{ .t = 23122579831, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1438 } } }, + .{ .t = 23122579831, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -498 } } }, + .{ .t = 23122579831, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1118 } } }, + .{ .t = 23122592031, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 953 } } }, + .{ .t = 23122592031, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -469 } } }, + .{ .t = 23122595681, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 924 } } }, + .{ .t = 23122595681, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -439 } } }, + .{ .t = 23122595681, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1087 } } }, + .{ .t = 23133201565, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 953 } } }, + .{ .t = 23133205635, .pad = 2, .ev = .{ .axis = .{ .idx = 4, .value = 728 } } }, + .{ .t = 23133205635, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 924 } } }, + .{ .t = 23133205635, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1118 } } }, + .{ .t = 23144628108, .pad = 2, .ev = .{ .axis = .{ .idx = 4, .value = 3169 } } }, + .{ .t = 23144628108, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1493 } } }, + .{ .t = 23144628108, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 953 } } }, + .{ .t = 23144628108, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -410 } } }, + .{ .t = 23144628108, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1087 } } }, + .{ .t = 23144640728, .pad = 2, .ev = .{ .axis = .{ .idx = 4, .value = 6314 } } }, + .{ .t = 23144640728, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1465 } } }, + .{ .t = 23144640728, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -469 } } }, + .{ .t = 23144640728, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1118 } } }, + .{ .t = 23144644338, .pad = 2, .ev = .{ .axis = .{ .idx = 4, .value = 10679 } } }, + .{ .t = 23144644338, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 981 } } }, + .{ .t = 23144644338, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -410 } } }, + .{ .t = 23144644338, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1087 } } }, + .{ .t = 23155757852, .pad = 2, .ev = .{ .axis = .{ .idx = 4, .value = 16500 } } }, + .{ .t = 23155757852, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1493 } } }, + .{ .t = 23155757852, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 953 } } }, + .{ .t = 23155767512, .pad = 2, .ev = .{ .axis = .{ .idx = 4, .value = 23682 } } }, + .{ .t = 23155767512, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1438 } } }, + .{ .t = 23155767512, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 924 } } }, + .{ .t = 23155773302, .pad = 2, .ev = .{ .axis = .{ .idx = 4, .value = 32084 } } }, + .{ .t = 23155773302, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1465 } } }, + .{ .t = 23166856095, .pad = 2, .ev = .{ .axis = .{ .idx = 4, .value = 32766 } } }, + .{ .t = 23166856095, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1438 } } }, + .{ .t = 23166856095, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -439 } } }, + .{ .t = 23166869315, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 953 } } }, + .{ .t = 23166869315, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1118 } } }, + .{ .t = 23177937079, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 924 } } }, + .{ .t = 23177937079, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1087 } } }, + .{ .t = 23177947099, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1465 } } }, + .{ .t = 23177947099, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -410 } } }, + .{ .t = 23177950979, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1438 } } }, + .{ .t = 23177950979, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -439 } } }, + .{ .t = 23177950979, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1118 } } }, + .{ .t = 23188909763, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -410 } } }, + .{ .t = 23188909763, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1087 } } }, + .{ .t = 23188919373, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1493 } } }, + .{ .t = 23188919373, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 981 } } }, + .{ .t = 23188923533, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1465 } } }, + .{ .t = 23188923533, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 953 } } }, + .{ .t = 23188923533, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -439 } } }, + .{ .t = 23188923533, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1057 } } }, + .{ .t = 23200341706, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1438 } } }, + .{ .t = 23200341706, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 924 } } }, + .{ .t = 23200341706, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1087 } } }, + .{ .t = 23200357446, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -469 } } }, + .{ .t = 23200360546, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 866 } } }, + .{ .t = 23200360546, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -439 } } }, + .{ .t = 23211356329, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1493 } } }, + .{ .t = 23211356329, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 895 } } }, + .{ .t = 23211356329, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1057 } } }, + .{ .t = 23211369469, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1438 } } }, + .{ .t = 23211369469, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 808 } } }, + .{ .t = 23211369469, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -469 } } }, + .{ .t = 23211369469, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1118 } } }, + .{ .t = 23222496653, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 722 } } }, + .{ .t = 23222496653, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -410 } } }, + .{ .t = 23222496653, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1057 } } }, + .{ .t = 23222508723, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 664 } } }, + .{ .t = 23222508723, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -439 } } }, + .{ .t = 23222508723, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1087 } } }, + .{ .t = 23222512923, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1465 } } }, + .{ .t = 23222512923, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 693 } } }, + .{ .t = 23222512923, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1118 } } }, + .{ .t = 23233616896, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 404 } } }, + .{ .t = 23233616896, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1087 } } }, + .{ .t = 23233628876, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 462 } } }, + .{ .t = 23233628876, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -469 } } }, + .{ .t = 23233628876, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1118 } } }, + .{ .t = 23233634716, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 375 } } }, + .{ .t = 23233634716, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -439 } } }, + .{ .t = 23244703810, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 404 } } }, + .{ .t = 23244703810, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -469 } } }, + .{ .t = 23244703810, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1087 } } }, + .{ .t = 23244716710, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1438 } } }, + .{ .t = 23244716710, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 288 } } }, + .{ .t = 23244716710, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -439 } } }, + .{ .t = 23244722470, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 317 } } }, + .{ .t = 23255891634, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 260 } } }, + .{ .t = 23255891634, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -469 } } }, + .{ .t = 23255903964, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1410 } } }, + .{ .t = 23255903964, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 144 } } }, + .{ .t = 23255903964, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1057 } } }, + .{ .t = 23255909564, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1465 } } }, + .{ .t = 23255909564, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 115 } } }, + .{ .t = 23266911057, .pad = 2, .ev = .{ .axis = .{ .idx = 4, .value = 30723 } } }, + .{ .t = 23266911057, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1438 } } }, + .{ .t = 23266911057, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 86 } } }, + .{ .t = 23266924047, .pad = 2, .ev = .{ .axis = .{ .idx = 4, .value = 27437 } } }, + .{ .t = 23266924047, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1465 } } }, + .{ .t = 23266924047, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 115 } } }, + .{ .t = 23266924047, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1087 } } }, + .{ .t = 23278235081, .pad = 2, .ev = .{ .axis = .{ .idx = 4, .value = 24292 } } }, + .{ .t = 23278235081, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1438 } } }, + .{ .t = 23278235081, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 29 } } }, + .{ .t = 23278246901, .pad = 2, .ev = .{ .axis = .{ .idx = 4, .value = 21053 } } }, + .{ .t = 23278246901, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 57 } } }, + .{ .t = 23278246901, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -439 } } }, + .{ .t = 23278246901, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1057 } } }, + .{ .t = 23278254110, .pad = 2, .ev = .{ .axis = .{ .idx = 4, .value = 17814 } } }, + .{ .t = 23278254110, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 86 } } }, + .{ .t = 23278254110, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -498 } } }, + .{ .t = 23278254110, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1087 } } }, + .{ .t = 23289217094, .pad = 2, .ev = .{ .axis = .{ .idx = 4, .value = 14341 } } }, + .{ .t = 23289217094, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1465 } } }, + .{ .t = 23289217094, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 144 } } }, + .{ .t = 23289217094, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -469 } } }, + .{ .t = 23289217094, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1057 } } }, + .{ .t = 23289231434, .pad = 2, .ev = .{ .axis = .{ .idx = 4, .value = 11384 } } }, + .{ .t = 23289231434, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 57 } } }, + .{ .t = 23289236534, .pad = 2, .ev = .{ .axis = .{ .idx = 4, .value = 8708 } } }, + .{ .t = 23289236534, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1438 } } }, + .{ .t = 23289236534, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 0 } } }, + .{ .t = 23300340478, .pad = 2, .ev = .{ .axis = .{ .idx = 4, .value = 6126 } } }, + .{ .t = 23300340478, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -439 } } }, + .{ .t = 23300350538, .pad = 2, .ev = .{ .axis = .{ .idx = 4, .value = 4014 } } }, + .{ .t = 23300350538, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 86 } } }, + .{ .t = 23300354158, .pad = 2, .ev = .{ .axis = .{ .idx = 4, .value = 2465 } } }, + .{ .t = 23300354158, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1410 } } }, + .{ .t = 23300354158, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 288 } } }, + .{ .t = 23311366832, .pad = 2, .ev = .{ .axis = .{ .idx = 4, .value = 634 } } }, + .{ .t = 23311366832, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 462 } } }, + .{ .t = 23311366832, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1027 } } }, + .{ .t = 23311379542, .pad = 2, .ev = .{ .axis = .{ .idx = 4, .value = 0 } } }, + .{ .t = 23311379542, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1355 } } }, + .{ .t = 23311379542, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 779 } } }, + .{ .t = 23311379542, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -410 } } }, + .{ .t = 23322638775, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1272 } } }, + .{ .t = 23322638775, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 953 } } }, + .{ .t = 23322638775, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -439 } } }, + .{ .t = 23322649765, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -1051 } } }, + .{ .t = 23322649765, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 981 } } }, + .{ .t = 23322649765, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1057 } } }, + .{ .t = 23322654995, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -885 } } }, + .{ .t = 23322654995, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1039 } } }, + .{ .t = 23333351109, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -691 } } }, + .{ .t = 23333351109, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -469 } } }, + .{ .t = 23333359049, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -553 } } }, + .{ .t = 23333359049, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1087 } } }, + .{ .t = 23333362519, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1010 } } }, + .{ .t = 23333362519, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -439 } } }, + .{ .t = 23333362519, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1057 } } }, + .{ .t = 23344695372, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 981 } } }, + .{ .t = 23344706662, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -525 } } }, + .{ .t = 23344706662, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 953 } } }, + .{ .t = 23344711982, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -553 } } }, + .{ .t = 23344711982, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 981 } } }, + .{ .t = 23355868326, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -498 } } }, + .{ .t = 23355868326, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1010 } } }, + .{ .t = 23355878956, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -525 } } }, + .{ .t = 23355878956, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 981 } } }, + .{ .t = 23355878956, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -469 } } }, + .{ .t = 23355878956, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1087 } } }, + .{ .t = 23355884866, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1010 } } }, + .{ .t = 23355884866, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -410 } } }, + .{ .t = 23355884866, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1027 } } }, + .{ .t = 23366942749, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -553 } } }, + .{ .t = 23366952219, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -525 } } }, + .{ .t = 23366952219, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 981 } } }, + .{ .t = 23366952219, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -439 } } }, + .{ .t = 23366952219, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1057 } } }, + .{ .t = 23378047613, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -553 } } }, + .{ .t = 23378047613, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1010 } } }, + .{ .t = 23378064723, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -525 } } }, + .{ .t = 23378064723, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 981 } } }, + .{ .t = 23378064723, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -469 } } }, + .{ .t = 23388957907, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -553 } } }, + .{ .t = 23388957907, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1039 } } }, + .{ .t = 23388957907, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -439 } } }, + .{ .t = 23388957907, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1027 } } }, + .{ .t = 23388967217, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1010 } } }, + .{ .t = 23388967217, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -410 } } }, + .{ .t = 23388970117, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -525 } } }, + .{ .t = 23388970117, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 981 } } }, + .{ .t = 23388970117, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -439 } } }, + .{ .t = 23388970117, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1057 } } }, + .{ .t = 23400316180, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -469 } } }, + .{ .t = 23400325960, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -580 } } }, + .{ .t = 23400325960, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1039 } } }, + .{ .t = 23400325960, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -410 } } }, + .{ .t = 23400330510, .pad = 2, .ev = .{ .axis = .{ .idx = 0, .value = -525 } } }, + .{ .t = 23400330510, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 981 } } }, + .{ .t = 23400330510, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -439 } } }, + .{ .t = 23411327274, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1039 } } }, + .{ .t = 23411337364, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1010 } } }, + .{ .t = 23411337364, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1027 } } }, + .{ .t = 23422593127, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -469 } } }, + .{ .t = 23422593127, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1057 } } }, + .{ .t = 23422603997, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -410 } } }, + .{ .t = 23422603997, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1027 } } }, + .{ .t = 23422607677, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -439 } } }, + .{ .t = 23422607677, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1057 } } }, + .{ .t = 23433465571, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1039 } } }, + .{ .t = 23433465571, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1027 } } }, + .{ .t = 23433473571, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1010 } } }, + .{ .t = 23433473571, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -469 } } }, + .{ .t = 23433473571, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1057 } } }, + .{ .t = 23444613485, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1039 } } }, + .{ .t = 23444623255, .pad = 2, .ev = .{ .axis = .{ .idx = 2, .value = -439 } } }, + .{ .t = 23444626645, .pad = 2, .ev = .{ .axis = .{ .idx = 1, .value = 1010 } } }, + .{ .t = 23444626645, .pad = 2, .ev = .{ .axis = .{ .idx = 3, .value = 1027 } } }, } } diff --git a/test/fs_bench.zig b/test/fs_bench.zig index 4764049f..a8a8fd8c 100644 --- a/test/fs_bench.zig +++ b/test/fs_bench.zig @@ -113,7 +113,7 @@ fn checkReply(s: *Session, req: ctlfs.Req, reply: ctlfs.Reply) !void { if (reply.payload != .staged or reply.payload.staged != bytes.len or bytes.len > req.size) return error.IncorrectReply; const pane = s.core.panes[s.file_id].?; - if (req.node == @intFromEnum(ctlfs.TopFile.index)) { + if (req.node == @backingInt(ctlfs.TopFile.index)) { var expected_buf: [4200]u8 = undefined; const expected = try std.fmt.bufPrint(&expected_buf, "{d} text {d} {s}\n", .{ s.file_serial, @intFromBool(pane.file.?.revision != pane.file.?.saved_revision), pane.file.?.path }); if (!std.mem.eql(u8, expected, bytes)) return error.IncorrectReply; @@ -134,7 +134,7 @@ fn checkReply(s: *Session, req: ctlfs.Req, reply: ctlfs.Reply) !void { if (reply.payload != .staged or reply.payload.staged != bytes.len or bytes.len > req.size) return error.IncorrectReply; const names = [_][]const u8{ "README", "index", "status", "focus", "ctl", "commands", "look", "exec", "log", "screen", "listeners", "pane", "os" }; - const nodes = [_]u64{ @intFromEnum(ctlfs.TopFile.README), @intFromEnum(ctlfs.TopFile.index), @intFromEnum(ctlfs.TopFile.status), @intFromEnum(ctlfs.TopFile.focus), @intFromEnum(ctlfs.TopFile.ctl), @intFromEnum(ctlfs.TopFile.commands), @intFromEnum(ctlfs.TopFile.look), @intFromEnum(ctlfs.TopFile.exec), @intFromEnum(ctlfs.TopFile.log), @intFromEnum(ctlfs.TopFile.screen), @intFromEnum(ctlfs.TopFile.listeners), @intFromEnum(ctlfs.TopFile.pane), filesystem.os_root }; + const nodes = [_]u64{ @backingInt(ctlfs.TopFile.README), @backingInt(ctlfs.TopFile.index), @backingInt(ctlfs.TopFile.status), @backingInt(ctlfs.TopFile.focus), @backingInt(ctlfs.TopFile.ctl), @backingInt(ctlfs.TopFile.commands), @backingInt(ctlfs.TopFile.look), @backingInt(ctlfs.TopFile.exec), @backingInt(ctlfs.TopFile.log), @backingInt(ctlfs.TopFile.screen), @backingInt(ctlfs.TopFile.listeners), @backingInt(ctlfs.TopFile.pane), filesystem.os_root }; var off: usize = 0; var entry: usize = 0; while (off < bytes.len) : (entry += 1) { @@ -253,7 +253,7 @@ pub fn main(init: std.process.Init) !void { try bench(&s, "read index", reps, .{ .tag = 6, .op = .read, - .node = @intFromEnum(ctlfs.TopFile.index), + .node = @backingInt(ctlfs.TopFile.index), .size = 4096, }, "one line per pane"); try bench(&s, "readdir root", reps, .{ diff --git a/test/lspfixture/broken.zig b/test/lspfixture/broken.zig index 22c86c9b..b27840cd 100644 --- a/test/lspfixture/broken.zig +++ b/test/lspfixture/broken.zig @@ -20,6 +20,6 @@ pub fn hasUnusedLocal() u32 { return 7; } -pub fn badly_spaced ( a : u32 , b : u32 ) u32 { - return a+b; +pub fn badly_spaced(a: u32, b: u32) u32 { + return a + b; } diff --git a/test/output.zig b/test/output.zig index 6ea6f6fa..8403effa 100644 --- a/test/output.zig +++ b/test/output.zig @@ -475,7 +475,7 @@ test "Mini syntax colors survive toggles themes and rendering without source acc try panes.mini.open(p, 0, "demo.zig"); const id = p.active; const mini = p.panes[id].?; - const keyword = std.mem.indexOfScalar(u8, mini.file.?.mini.?.colors, @intFromEnum(pardes.syntax.Syn.keyword)) orelse return error.MissingKeywordColor; + const keyword = std.mem.indexOfScalar(u8, mini.file.?.mini.?.colors, @backingInt(pardes.syntax.Syn.keyword)) orelse return error.MissingKeywordColor; // Direct pane construction bypasses the host update's layout sync. p.update(.{ .resize = .{ .cols = 80, .rows = 24 } }); const position = modal.positionAt(mini.file.?.content, keyword); @@ -1656,7 +1656,7 @@ test "stacked search and LSP results retain source tint navigation and dump owne } try std.testing.expectEqual(@as(usize, 6), marked); const number = std.mem.indexOf(u8, file.content, "42").?; - try std.testing.expectEqual(@intFromEnum(pardes.syntax.Syn.number), file.highlights[number]); + try std.testing.expectEqual(@backingInt(pardes.syntax.Syn.number), file.highlights[number]); p.active = id; pane.body.mode = .normal; pardes.look.armLookWalk(p, id); @@ -1815,7 +1815,7 @@ test "location cache eviction retains early colors and honors disk and unsaved r return error.MissingEarlyContext; } }; - try std.testing.expectEqual(@intFromEnum(pardes.syntax.Syn.comment), try Color.valueColor(file)); + try std.testing.expectEqual(@backingInt(pardes.syntax.Syn.comment), try Color.valueColor(file)); const single = "f00.c:4:1-6 needle();\n"; // Put the evicted file back before a same-size edit tests exact-byte keys. try panes.Output.fillResults(p, 0, dir, .search, "eviction", try p.gpa.dupe(u8, single), null); @@ -1823,14 +1823,14 @@ test "location cache eviction retains early colors and honors disk and unsaved r try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "f00.c", .data = code }); try panes.Output.fillResults(p, 0, dir, .search, "eviction", try p.gpa.dupe(u8, single), null); try std.testing.expect(p.locations_cache.analyses > analyses); - try std.testing.expectEqual(@intFromEnum(pardes.syntax.Syn.number), try Color.valueColor(file)); + try std.testing.expectEqual(@backingInt(pardes.syntax.Syn.number), try Color.valueColor(file)); // An open buffer has priority over that disk revision, even with equal size. p.gpa.free(source.file.?.path); source.file.?.path = try std.fs.path.join(p.gpa, &.{ dir, "f00.c" }); panes.File.setContent(p, &source.file.?, try p.gpa.dupe(u8, comment)); try panes.Output.fillResults(p, 0, dir, .search, "eviction", try p.gpa.dupe(u8, single), null); - try std.testing.expectEqual(@intFromEnum(pardes.syntax.Syn.comment), try Color.valueColor(file)); + try std.testing.expectEqual(@backingInt(pardes.syntax.Syn.comment), try Color.valueColor(file)); try std.testing.expectEqualStrings(comment, source.file.?.content); } diff --git a/test/panes.zig b/test/panes.zig index 54100f91..c8f4b7eb 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -3193,7 +3193,7 @@ const OutputTests = struct { p.update(.{ .mouse = .{ .button = config.select_button, .kind = .press, .col = x, .row = y } }); p.update(.{ .mouse = .{ .button = config.select_button, .kind = .drag, .col = x + 2, .row = y + 1 } }); try std.testing.expect(p.drag == .select); - try std.testing.expectEqual(.dragging, result.sel[@intFromEnum(config.select_button)].state); + try std.testing.expectEqual(.dragging, result.sel[@backingInt(config.select_button)].state); try fillResults(p, 0, "/", .{ .query = .hover }, "", try p.gpa.dupe(u8, "short\n"), null); try std.testing.expect(p.drag == .none); p.update(.{ .mouse = .{ .button = config.select_button, .kind = .release, .col = x + 2, .row = y + 1 } }); diff --git a/test/pdf.zig b/test/pdf.zig index a51fd1a9..6c9308d4 100644 --- a/test/pdf.zig +++ b/test/pdf.zig @@ -25,7 +25,7 @@ const themes = pardes.themes; const pdf_raster_policy = pardes.pdf_raster_policy; const PDF_PAGE_GAP_PX = pardes.PDF_PAGE_GAP_PX; const BOX_H = pardes.BOX_H; -const sel_slot = @intFromEnum(config.select_button); +const sel_slot = @backingInt(config.select_button); const pane_tail = " " ++ config.pdf_pane_builtins_str; fn hasPdf(pane: *const pardes.Pane) bool { @@ -483,10 +483,10 @@ test "`:N` on a PDF turns to page N, from the pane and from the root's look, and try std.testing.expectEqual(failures, p.fs.failures); // Over 9P too: the root's look at `@pN:2` answers ok and logs no err. const ctlfs = pardes.ctlfs; - const written = p.serveFs(.{ .tag = 1, .op = .write, .node = @intFromEnum(ctlfs.TopFile.look), .data = try std.fmt.bufPrint(&line, "@p{d}:2\n", .{doc.serial}) }); + const written = p.serveFs(.{ .tag = 1, .op = .write, .node = @backingInt(ctlfs.TopFile.look), .data = try std.fmt.bufPrint(&line, "@p{d}:2\n", .{doc.serial}) }); try std.testing.expectEqual(ctlfs.Status.ok, written.status); try std.testing.expectEqual(@as(usize, 1), doc.pdf.?.page); - const log = @intFromEnum(ctlfs.TopFile.log); + const log = @backingInt(ctlfs.TopFile.log); const h = p.serveFs(.{ .tag = 2, .op = .open, .node = log }).handle; const record = p.fsPayload(p.serveFs(.{ .tag = 3, .op = .read, .node = log, .handle = h, .size = 1 << 16 })); try std.testing.expect(std.mem.indexOf(u8, record, "\nerr ") == null); diff --git a/test/pdf_scroll_bench.zig b/test/pdf_scroll_bench.zig index fdc42660..0f93068d 100644 --- a/test/pdf_scroll_bench.zig +++ b/test/pdf_scroll_bench.zig @@ -475,7 +475,7 @@ const Recorder = struct { self.visual = mix(self.visual, place.w); self.visual = mix(self.visual, place.h); self.visual = mix(self.visual, place.native.page); - self.visual = mix(self.visual, @intFromEnum(place.native.fit)); + self.visual = mix(self.visual, @backingInt(place.native.fit)); self.visual = mix(self.visual, place.native.pan_x); self.visual = mix(self.visual, place.native.pan_y); self.visual = mix(self.visual, @as(u32, @bitCast(place.native.pixel_offset_y))); diff --git a/test/perf-baseline-gui-debug.json b/test/perf-baseline-gui-debug.json index 4b60520b..ffcd678f 100644 --- a/test/perf-baseline-gui-debug.json +++ b/test/perf-baseline-gui-debug.json @@ -1 +1 @@ -{"harness":"6cf9f4b8943e7e29","build":{"compiler":"0.17.0","target":"x86_64-linux.5.10...7.2-gnu.2.38","cpu":"x86_64","driver_optimize":"fast","core_optimize":"debug","c_optimize":"fast","terminal_optimize":"safe","platform":"gui","grammars":"full","mupdf":true,"jpx":true,"tracy":false,"quic":false,"theme_animation":true,"terminal_simd":true,"prebuilt_shaders":false},"cols":120,"rows":40,"reps":10,"only":"medium","fixtures":[{"name":"small","lines":1000,"cols":60,"bytes":62694},{"name":"medium","lines":50000,"cols":60,"bytes":3201944},{"name":"large","lines":300000,"cols":60,"bytes":19464444},{"name":"longline","lines":400,"cols":8000,"bytes":3200400},{"name":"esp32p4","lines":12,"cols":240,"bytes":2892}],"cells":[{"op":"open","fixture":"medium","min_us":1732,"med_us":1881,"p90_us":2035,"max_us":2072},{"op":"render","fixture":"medium","min_us":89,"med_us":92,"p90_us":101,"max_us":102},{"op":"key-down","fixture":"medium","min_us":92,"med_us":94,"p90_us":100,"max_us":100},{"op":"key-right","fixture":"medium","min_us":91,"med_us":93,"p90_us":105,"max_us":109},{"op":"page-down","fixture":"medium","min_us":91,"med_us":95,"p90_us":99,"max_us":106},{"op":"wheel","fixture":"medium","min_us":90,"med_us":95,"p90_us":101,"max_us":101},{"op":"edit-char","fixture":"medium","min_us":1226,"med_us":1678,"p90_us":2093,"max_us":2323},{"op":"edit-twin","fixture":"medium","min_us":2275,"med_us":2697,"p90_us":2868,"max_us":2920},{"op":"body-2m","fixture":"medium","min_us":5213,"med_us":11333,"p90_us":18974,"max_us":18999},{"op":"body-appends","fixture":"medium","min_us":175012,"med_us":260087,"p90_us":317184,"max_us":317469},{"op":"deep-sel","fixture":"medium","min_us":83,"med_us":85,"p90_us":86,"max_us":98}]} +{"harness":"15bee9f100e5ef64","build":{"compiler":"0.17.0","target":"x86_64-linux.5.10...7.2-gnu.2.38","cpu":"x86_64","driver_optimize":"fast","core_optimize":"debug","c_optimize":"fast","terminal_optimize":"safe","platform":"gui","grammars":"full","mupdf":true,"jpx":true,"tracy":false,"quic":false,"theme_animation":true,"terminal_simd":true,"prebuilt_shaders":false},"cols":120,"rows":40,"reps":10,"only":"medium","fixtures":[{"name":"small","lines":1000,"cols":60,"bytes":62694},{"name":"medium","lines":50000,"cols":60,"bytes":3201944},{"name":"large","lines":300000,"cols":60,"bytes":19464444},{"name":"longline","lines":400,"cols":8000,"bytes":3200400},{"name":"esp32p4","lines":12,"cols":240,"bytes":2892}],"cells":[{"op":"open","fixture":"medium","min_us":1744,"med_us":1832,"p90_us":2468,"max_us":2524},{"op":"render","fixture":"medium","min_us":88,"med_us":97,"p90_us":114,"max_us":115},{"op":"key-down","fixture":"medium","min_us":95,"med_us":98,"p90_us":104,"max_us":105},{"op":"key-right","fixture":"medium","min_us":92,"med_us":96,"p90_us":98,"max_us":105},{"op":"page-down","fixture":"medium","min_us":91,"med_us":95,"p90_us":97,"max_us":105},{"op":"wheel","fixture":"medium","min_us":87,"med_us":93,"p90_us":99,"max_us":100},{"op":"edit-char","fixture":"medium","min_us":1241,"med_us":1459,"p90_us":1691,"max_us":1724},{"op":"edit-twin","fixture":"medium","min_us":2592,"med_us":3003,"p90_us":3481,"max_us":3503},{"op":"body-2m","fixture":"medium","min_us":4576,"med_us":8262,"p90_us":15424,"max_us":17259},{"op":"body-appends","fixture":"medium","min_us":152003,"med_us":227268,"p90_us":272872,"max_us":326510},{"op":"deep-sel","fixture":"medium","min_us":82,"med_us":83,"p90_us":90,"max_us":93}]} diff --git a/test/perf-baseline-tty-debug.json b/test/perf-baseline-tty-debug.json index a01335bd..b8e534c4 100644 --- a/test/perf-baseline-tty-debug.json +++ b/test/perf-baseline-tty-debug.json @@ -1 +1 @@ -{"harness":"6cf9f4b8943e7e29","build":{"compiler":"0.17.0","target":"x86_64-linux.5.10...7.2-gnu.2.38","cpu":"x86_64","driver_optimize":"fast","core_optimize":"debug","c_optimize":"fast","terminal_optimize":"safe","platform":"tty","grammars":"full","mupdf":true,"jpx":true,"tracy":false,"quic":false,"theme_animation":true,"terminal_simd":true,"prebuilt_shaders":false},"cols":120,"rows":40,"reps":10,"only":"medium","fixtures":[{"name":"small","lines":1000,"cols":60,"bytes":62694},{"name":"medium","lines":50000,"cols":60,"bytes":3201944},{"name":"large","lines":300000,"cols":60,"bytes":19464444},{"name":"longline","lines":400,"cols":8000,"bytes":3200400},{"name":"esp32p4","lines":12,"cols":240,"bytes":2892}],"cells":[{"op":"open","fixture":"medium","min_us":2169,"med_us":2697,"p90_us":3126,"max_us":3207},{"op":"render","fixture":"medium","min_us":89,"med_us":96,"p90_us":101,"max_us":115},{"op":"key-down","fixture":"medium","min_us":93,"med_us":98,"p90_us":104,"max_us":115},{"op":"key-right","fixture":"medium","min_us":96,"med_us":97,"p90_us":102,"max_us":108},{"op":"page-down","fixture":"medium","min_us":96,"med_us":98,"p90_us":102,"max_us":103},{"op":"wheel","fixture":"medium","min_us":89,"med_us":100,"p90_us":128,"max_us":168},{"op":"edit-char","fixture":"medium","min_us":1821,"med_us":2274,"p90_us":2404,"max_us":2610},{"op":"edit-twin","fixture":"medium","min_us":2710,"med_us":3180,"p90_us":3413,"max_us":3636},{"op":"body-2m","fixture":"medium","min_us":9090,"med_us":14438,"p90_us":18158,"max_us":22063},{"op":"body-appends","fixture":"medium","min_us":241367,"med_us":375874,"p90_us":470623,"max_us":528094},{"op":"deep-sel","fixture":"medium","min_us":88,"med_us":89,"p90_us":90,"max_us":90}]} +{"harness":"15bee9f100e5ef64","build":{"compiler":"0.17.0","target":"x86_64-linux.5.10...7.2-gnu.2.38","cpu":"x86_64","driver_optimize":"fast","core_optimize":"debug","c_optimize":"fast","terminal_optimize":"safe","platform":"tty","grammars":"full","mupdf":true,"jpx":true,"tracy":false,"quic":false,"theme_animation":true,"terminal_simd":true,"prebuilt_shaders":false},"cols":120,"rows":40,"reps":10,"only":"medium","fixtures":[{"name":"small","lines":1000,"cols":60,"bytes":62694},{"name":"medium","lines":50000,"cols":60,"bytes":3201944},{"name":"large","lines":300000,"cols":60,"bytes":19464444},{"name":"longline","lines":400,"cols":8000,"bytes":3200400},{"name":"esp32p4","lines":12,"cols":240,"bytes":2892}],"cells":[{"op":"open","fixture":"medium","min_us":1747,"med_us":1912,"p90_us":2150,"max_us":2247},{"op":"render","fixture":"medium","min_us":89,"med_us":95,"p90_us":102,"max_us":104},{"op":"key-down","fixture":"medium","min_us":97,"med_us":101,"p90_us":107,"max_us":133},{"op":"key-right","fixture":"medium","min_us":93,"med_us":104,"p90_us":109,"max_us":112},{"op":"page-down","fixture":"medium","min_us":92,"med_us":96,"p90_us":106,"max_us":108},{"op":"wheel","fixture":"medium","min_us":90,"med_us":92,"p90_us":96,"max_us":96},{"op":"edit-char","fixture":"medium","min_us":1167,"med_us":1345,"p90_us":1483,"max_us":1627},{"op":"edit-twin","fixture":"medium","min_us":2319,"med_us":2921,"p90_us":3425,"max_us":3539},{"op":"body-2m","fixture":"medium","min_us":4333,"med_us":7752,"p90_us":15941,"max_us":17192},{"op":"body-appends","fixture":"medium","min_us":149149,"med_us":234177,"p90_us":285302,"max_us":295516},{"op":"deep-sel","fixture":"medium","min_us":83,"med_us":88,"p90_us":99,"max_us":119}]} diff --git a/test/perf-baseline-tty-fast.json b/test/perf-baseline-tty-fast.json index 04fc88d3..46125349 100644 --- a/test/perf-baseline-tty-fast.json +++ b/test/perf-baseline-tty-fast.json @@ -1 +1 @@ -{"harness":"6cf9f4b8943e7e29","build":{"compiler":"0.17.0","target":"x86_64-linux.5.10...7.2-gnu.2.38","cpu":"x86_64","driver_optimize":"fast","core_optimize":"fast","c_optimize":"fast","terminal_optimize":"fast","platform":"tty","grammars":"full","mupdf":true,"jpx":true,"tracy":false,"quic":false,"theme_animation":true,"terminal_simd":true,"prebuilt_shaders":false},"cols":120,"rows":40,"reps":10,"only":"medium","fixtures":[{"name":"small","lines":1000,"cols":60,"bytes":62694},{"name":"medium","lines":50000,"cols":60,"bytes":3201944},{"name":"large","lines":300000,"cols":60,"bytes":19464444},{"name":"longline","lines":400,"cols":8000,"bytes":3200400},{"name":"esp32p4","lines":12,"cols":240,"bytes":2892}],"cells":[{"op":"open","fixture":"medium","min_us":1695,"med_us":2024,"p90_us":2180,"max_us":2292},{"op":"render","fixture":"medium","min_us":79,"med_us":82,"p90_us":92,"max_us":94},{"op":"key-down","fixture":"medium","min_us":81,"med_us":82,"p90_us":83,"max_us":84},{"op":"key-right","fixture":"medium","min_us":80,"med_us":82,"p90_us":91,"max_us":91},{"op":"page-down","fixture":"medium","min_us":81,"med_us":84,"p90_us":90,"max_us":171},{"op":"wheel","fixture":"medium","min_us":79,"med_us":80,"p90_us":90,"max_us":101},{"op":"edit-char","fixture":"medium","min_us":1332,"med_us":1691,"p90_us":1967,"max_us":1987},{"op":"edit-twin","fixture":"medium","min_us":2160,"med_us":2457,"p90_us":2718,"max_us":2757},{"op":"body-2m","fixture":"medium","min_us":5047,"med_us":13525,"p90_us":16257,"max_us":20323},{"op":"body-appends","fixture":"medium","min_us":155834,"med_us":261597,"p90_us":329936,"max_us":333538},{"op":"deep-sel","fixture":"medium","min_us":75,"med_us":76,"p90_us":84,"max_us":96}]} +{"harness":"15bee9f100e5ef64","build":{"compiler":"0.17.0","target":"x86_64-linux.5.10...7.2-gnu.2.38","cpu":"x86_64","driver_optimize":"fast","core_optimize":"fast","c_optimize":"fast","terminal_optimize":"fast","platform":"tty","grammars":"full","mupdf":true,"jpx":true,"tracy":false,"quic":false,"theme_animation":true,"terminal_simd":true,"prebuilt_shaders":false},"cols":120,"rows":40,"reps":10,"only":"medium","fixtures":[{"name":"small","lines":1000,"cols":60,"bytes":62694},{"name":"medium","lines":50000,"cols":60,"bytes":3201944},{"name":"large","lines":300000,"cols":60,"bytes":19464444},{"name":"longline","lines":400,"cols":8000,"bytes":3200400},{"name":"esp32p4","lines":12,"cols":240,"bytes":2892}],"cells":[{"op":"open","fixture":"medium","min_us":1904,"med_us":2040,"p90_us":2290,"max_us":2600},{"op":"render","fixture":"medium","min_us":80,"med_us":83,"p90_us":88,"max_us":93},{"op":"key-down","fixture":"medium","min_us":81,"med_us":87,"p90_us":93,"max_us":109},{"op":"key-right","fixture":"medium","min_us":79,"med_us":82,"p90_us":86,"max_us":96},{"op":"page-down","fixture":"medium","min_us":79,"med_us":83,"p90_us":89,"max_us":93},{"op":"wheel","fixture":"medium","min_us":77,"med_us":79,"p90_us":82,"max_us":83},{"op":"edit-char","fixture":"medium","min_us":1139,"med_us":1338,"p90_us":1453,"max_us":1578},{"op":"edit-twin","fixture":"medium","min_us":2515,"med_us":2776,"p90_us":2879,"max_us":2907},{"op":"body-2m","fixture":"medium","min_us":4832,"med_us":7650,"p90_us":15076,"max_us":15371},{"op":"body-appends","fixture":"medium","min_us":165796,"med_us":240881,"p90_us":284919,"max_us":292573},{"op":"deep-sel","fixture":"medium","min_us":73,"med_us":75,"p90_us":83,"max_us":93}]} diff --git a/test/perf.zig b/test/perf.zig index d01d1bb5..7662d028 100644 --- a/test/perf.zig +++ b/test/perf.zig @@ -517,8 +517,8 @@ fn gate(cells: *const [std.enums.values(Op).len][fixtures.len]Cell, base: *const }; // Typing beside a twin costs about what typing alone does, whatever the // baseline: the twin takes the splice, never a copy of the text. - const twin_op = @intFromEnum(Op.edit_twin); - const alone_op = @intFromEnum(Op.edit_char); + const twin_op = @backingInt(Op.edit_twin); + const alone_op = @backingInt(Op.edit_char); for (fixtures, 0..) |fx, fi| { const twin = cells[twin_op][fi].min_us; const alone = cells[alone_op][fi].min_us; @@ -1220,7 +1220,7 @@ fn measureMini(io: std.Io, fallback: std.mem.Allocator, reps: usize, json: bool) break :blk try pardes.syntax.highlightFileRange(gpa, path, source, 0, source.len); }; defer gpa.free(styles); - if (styles.len != source.len or std.mem.indexOfScalar(u8, styles, @intFromEnum(pardes.syntax.Syn.comment)) == null) + if (styles.len != source.len or std.mem.indexOfScalar(u8, styles, @backingInt(pardes.syntax.Syn.comment)) == null) return error.MiniSyntaxUnavailable; const expected = try pardes.panes.mini.generate(gpa, source, styles); defer expected.deinit(gpa); diff --git a/test/unit_profile.zig b/test/unit_profile.zig index 59794df9..941efeb2 100644 --- a/test/unit_profile.zig +++ b/test/unit_profile.zig @@ -6,7 +6,7 @@ const Memory = struct { rss_after_bytes: ?usize = null, cumulative_peak_rss_byte fn send(io: std.Io, file: std.Io.File, tag: Client.Tag, body: []const u8, deadline: std.Io.Timeout) !void { var header: [8]u8 = undefined; - std.mem.writeInt(u32, header[0..4], @intFromEnum(tag), .little); + std.mem.writeInt(u32, header[0..4], @backingInt(tag), .little); std.mem.writeInt(u32, header[4..8], @intCast(body.len), .little); for ([_][]const u8{ &header, body }) |part| { var offset: usize = 0; @@ -36,7 +36,7 @@ fn readAll(io: std.Io, file: std.Io.File, bytes: []u8, deadline: std.Io.Timeout) fn receive(io: std.Io, file: std.Io.File, gpa: std.mem.Allocator, deadline: std.Io.Timeout) !struct { tag: Server.Tag, body: []u8 } { var header: [8]u8 = undefined; try readAll(io, file, &header, deadline); - const tag: Server.Tag = @enumFromInt(std.mem.readInt(u32, header[0..4], .little)); + const tag: Server.Tag = @fromBackingInt(@intCast(std.mem.readInt(u32, header[0..4], .little))); const len = std.mem.readInt(u32, header[4..8], .little); if (len > 16 * 1024 * 1024) return error.MessageTooLarge; const bytes = try gpa.alloc(u8, len); -- cgit v1.3