aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authoruser <user@clank>2026-09-29 14:26:18 +0200
committeruser <user@clank>2026-09-29 14:26:18 +0200
commit43fa063445821470cbf55f85aa8116c11470396f (patch)
tree1612fa68b3aa70bf75a9ec28a76cbd8d05f9264d /include
parentpanes: $SLOSH_PANE, so a program knows which pane it is in (diff)
downloadslosh-43fa063445821470cbf55f85aa8116c11470396f.tar.gz
slosh-43fa063445821470cbf55f85aa8116c11470396f.tar.xz
slosh-43fa063445821470cbf55f85aa8116c11470396f.zip
panes: read and write a pane by id, without taking focus
`raw` wrote into the focused pane and `snapshot` composited the active tab, so driving a pane anywhere else meant focusing it or selecting its tab first. Both of those move the view of whoever is watching, and both lose to anybody doing the same thing at the same time. `raw` now takes an `id` (0 is the focused pane, as before), and `capture` answers one pane's viewport as text -- from the pane's own terminal, so it works for a pane in a background tab, changes no focus, and leaves the human's selection alone. It builds its selection as a snapshot rather than setting one on the terminal, because a read with a visible side effect is not a read. `capture` tells "no such pane" apart from "that pane is empty": a caller polling a dead id would otherwise wait forever on a pane that is quiet because it is gone.
Diffstat (limited to 'include')
-rw-r--r--include/app.h12
-rw-r--r--include/slosh.h4
2 files changed, 16 insertions, 0 deletions
diff --git a/include/app.h b/include/app.h
index 3a660b2..6de3d8d 100644
--- a/include/app.h
+++ b/include/app.h
@@ -118,6 +118,14 @@ void app_splash(app_t *a);
void app_splash_fx(app_t *a, int fx, int motion);
/* Bytes straight into the focused pane's pty (the harness's `raw`). */
void app_write_focused(app_t *a, const void *buf, size_t len);
+/* Bytes into a pane named by id (0 = focused); false when there is no such
+ * pane. What `raw` uses, so driving a pane never requires taking focus off
+ * whatever the human is doing. */
+bool app_write_pane(app_t *a, uint32_t id, const void *buf, size_t len);
+/* One pane's viewport as text, by id (0 = focused), with no side effects --
+ * works for a pane in any tab, unlike a snapshot, which can only see the tab
+ * that is composited. NULL when there is no such pane; caller frees. */
+char *app_pane_text(app_t *a, uint32_t id);
bool app_should_quit(const app_t *a);
/* C-a d asks the client to leave while the session keeps running. */
bool app_detach_requested(const app_t *a);
@@ -277,6 +285,10 @@ bool app_pane_zoomed(app_t *a, uint32_t id);
* with no tiled pane to float over. */
bool app_toggle_float(app_t *a, uint32_t id);
bool app_pane_floating(app_t *a, uint32_t id);
+/* Whether a pane with this id exists at all (any tab); 0 asks about the
+ * focused one. Lets a reply distinguish a pane that has gone from one with
+ * nothing in it. */
+bool app_pane_exists(app_t *a, uint32_t id);
/* Float a pane at a wanted rect: floats it first when it is tiled, re-places
* it when it already floats. Negative x/y and zero w/h mean "keep". */
diff --git a/include/slosh.h b/include/slosh.h
index 78972b8..5d55629 100644
--- a/include/slosh.h
+++ b/include/slosh.h
@@ -379,6 +379,10 @@ bool pane_select_word(pane_t *p, uint16_t x, uint16_t y, const char *seps);
void pane_select_done(pane_t *p);
bool pane_selecting(const pane_t *p);
char *pane_selection_text(pane_t *p);
+/* The pane's whole viewport as plain text, for a pane in any tab and with no
+ * side effects: no focus change, no tab change, and the human's selection left
+ * alone. Caller frees. NULL when there is nothing to read. */
+char *pane_viewport_text(pane_t *p);
/* Compose this pane's viewport into the screen at (x0,y0). Clears dirty. */
void pane_compose(pane_t *p, screen_t *s, uint16_t x0, uint16_t y0,
bool focused);