diff options
| author | Gabriel Schneider <[email protected]> | 2026-08-10 09:58:31 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-08-11 09:58:59 -0300 |
| commit | eb11ab331b4e13e2b9e5a673a4c012d22fdd1d9c (patch) | |
| tree | cc993ad239451adb6f23645ee5ca001802832ed0 /src/macos/pardes.h | |
| parent | 38e9919a9ea9055538409b388d580c4e4c838434 (diff) | |
| download | pardes-eb11ab331b4e13e2b9e5a673a4c012d22fdd1d9c.tar.gz pardes-eb11ab331b4e13e2b9e5a673a4c012d22fdd1d9c.zip | |
macos: the AppKit shell, its icon, and the offscreen e2e harness
Diffstat (limited to 'src/macos/pardes.h')
| -rw-r--r-- | src/macos/pardes.h | 74 |
1 files changed, 64 insertions, 10 deletions
diff --git a/src/macos/pardes.h b/src/macos/pardes.h index e0d6fa32..62ddbae5 100644 --- a/src/macos/pardes.h +++ b/src/macos/pardes.h @@ -118,6 +118,15 @@ typedef enum { PARDES_MOUSE_DRAG = 3, } pardes_mouse_kind_e; +// What the core just did, for a shell that can answer with something the hand +// feels. Taken with pardes_take_haptic once per pump; the two acme verbs are +// distinguished because they deserve distinct taps. +typedef enum { + PARDES_HAPTIC_NONE = 0, + PARDES_HAPTIC_EXEC = 1, + PARDES_HAPTIC_LOOK = 2, +} pardes_haptic_e; + // ---------------------------------------------------------------- runtime // What the host lends the core. Two callbacks, because everything else the @@ -149,8 +158,14 @@ int pardes_init(const pardes_runtime_s *runtime, uint16_t cols, uint16_t rows); void pardes_deinit(void); // Drain pty output into the core and perform the effects it queued. Call after -// every input function and on every wakeup. Returns true if anything changed -// and the host should mark its view dirty. +// every input function and on every wakeup. +// +// The return value is whether this tick did any IO — bytes arrived from a pty, +// or an effect was performed. It is NOT a repaint signal, and a host that uses +// it as one shows a stale screen: moving the cursor, extending a selection, +// changing mode and scrolling all mutate the grid while queueing nothing and +// performing nothing, so they tick false. Mark the view dirty after any call +// into the core and use this only to decide whether there was work. bool pardes_tick(void); // The core asked to exit (the Exit builtin, or the last pane closing). @@ -169,14 +184,30 @@ void pardes_paste(const char *text, size_t len); void pardes_mouse(pardes_mouse_button_e button, pardes_mouse_kind_e kind, uint16_t col, uint16_t row, uint32_t mods); -// Trackpad/precision wheel distance in rows, sign following the grid (positive -// scrolls down). The core has no fractional scroll — it moves a row at a time — -// so libpardes accumulates here and emits whole-row wheel presses, keeping the -// remainder. Both other shells do this same accumulation host-side (stepScroll -// in gui.zig, the drain loop in web/app.mjs); it lives in Zig here so the Swift -// side stays a translator. A discrete wheel notch should go through -// pardes_mouse instead. -void pardes_scroll(float delta_rows, uint16_t col, uint16_t row); +// Trackpad/precision wheel distance in CELLS, sign following the grid +// (positive scrolls down and right). The core has no fractional scroll — it +// moves a row or a column at a time — so libpardes accumulates here and emits +// whole wheel presses, keeping the remainder. Both other shells do this same +// accumulation host-side (stepScroll in gui.zig, the drain loop in +// web/app.mjs); it lives in Zig here so the Swift side stays a translator, and +// so the quantizer is unit-tested on a machine with no trackpad. A discrete +// wheel notch should go through pardes_mouse instead. +void pardes_scroll(float delta_rows, float delta_cols, uint16_t col, + uint16_t row); + +// A two-finger trackpad rotation, in degrees since the last call, positive +// counterclockwise (AppKit's sign, unchanged). The core has no rotation: this +// is spent as the search-step keys, clockwise `n` and counterclockwise `N`, a +// notch at a time with the remainder kept — the same accumulate-and-spend +// shape as pardes_scroll, and in Zig for the same reason. Feed it the raw +// per-event delta; pass 0 at gesture start to drop a stale remainder. +void pardes_rotate(float degrees); + +// Run one builtin command line, exactly as executing the same text in a tag +// would. This is the core's own `command` event, which is how a nested pardes +// talks to its host; here it is what a menu item is made of, and what opens +// the file named on argv or dropped on the Dock icon (`Look <path>`). +void pardes_command(const char *text, size_t len); // `cell_w`/`cell_h` are one cell in physical pixels, which only the native PDF // placement path reads. Pass the backing-store size, not points. @@ -197,6 +228,29 @@ int32_t pardes_cursor_x(void); int32_t pardes_cursor_y(void); bool pardes_cursor_bar(void); +// The Look or Exec the core performed since this was last asked, and clears +// it. Call it once per pump, after pardes_tick — the input functions run the +// dispatch synchronously, so a gesture's pulse is already waiting by the time +// its tick returns. PARDES_HAPTIC_NONE means nothing to feel. +pardes_haptic_e pardes_take_haptic(void); + +// The font file the `Font` builtin asked for since this was last called, and +// clears it; NULL when nothing was asked. Ask once per pump, beside the haptic +// above. The string is a NUL-terminated absolute path owned by libpardes and +// valid until the next call. +// +// A path rather than a family name: the core found the file by walking the +// font directories itself, so both shells agree on which faces exist and +// neither has to ask its platform to resolve a name it might resolve +// differently. A `.ttc` collection names its first face, which is the cut the +// file is named after. +// +// The host loads it, re-measures its cell, and reports the new grid through +// pardes_resize. A file the host cannot load is one to ignore: keep wearing +// the face that works, because a terminal that cannot draw has no way back +// out of it. +const char *pardes_font_take(void); + #ifdef __cplusplus } #endif |
