aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authoruser <user@clank>2026-09-29 14:26:06 +0200
committeruser <user@clank>2026-09-29 14:26:06 +0200
commite779c1fafa556330752b2c5f43c56415f655ff24 (patch)
treeb87d335587fbfb68696569c5a41d912435d67140 /include
parentmouse: encode pixel reports against the cell size we advertise (diff)
downloadslosh-e779c1fafa556330752b2c5f43c56415f655ff24.tar.gz
slosh-e779c1fafa556330752b2c5f43c56415f655ff24.tar.xz
slosh-e779c1fafa556330752b2c5f43c56415f655ff24.zip
panes: $SLOSH_PANE, so a program knows which pane it is in
A program in a pane could name every pane but its own. `panes` says which one is *focused*, and focus belongs to the human, so anything that inferred "where do I live" from it did its work in whichever tab somebody else happened to be looking at -- and lost a race with anybody else asking the same question. So export the id into the child, the way tmux has $TMUX_PANE and zellij $ZELLIJ_PANE_ID. The id is taken before the pane is made, because pane_new spawns the program and assigning it afterwards is one instruction too late; it lives on the pane rather than the layout, so a rerun keeps it -- an identity that changed under a rerun would be no identity at all. Unset, not zero, when there is none: a stale value inherited from an outer session would read as this one's. `panes` also reports each pane's pid now, which is the same question answered for anything that cannot read its own environment: walk your parents up until one of them is on that list.
Diffstat (limited to 'include')
-rw-r--r--include/slosh.h18
1 files changed, 15 insertions, 3 deletions
diff --git a/include/slosh.h b/include/slosh.h
index b8c8849..78972b8 100644
--- a/include/slosh.h
+++ b/include/slosh.h
@@ -169,8 +169,16 @@ typedef struct {
* success). Panes do this on their own when the entry is missing
* everywhere; `slosh --install-terminfo` is the by-hand spelling. */
int pty_terminfo_install(void);
+/* `pane_id` is the id the session knows this pane by, exported into the child
+ * as $SLOSH_PANE. A program in a pane has to be able to name the pane it is
+ * *in* -- `panes` says which pane is focused, and focus is the human's, not the
+ * caller's, so anything that inferred "where do I live" from it spawned its
+ * work in whichever tab somebody else happened to be looking at. tmux answers
+ * this with $TMUX_PANE and zellij with $ZELLIJ_PANE_ID; this is ours. 0 means
+ * "no id", and then the variable is left unset rather than set to a lie. */
int pty_spawn(pty_t *p, const char *const argv[], uint16_t cols, uint16_t rows,
- const char *cwd, uint16_t cell_w, uint16_t cell_h);
+ const char *cwd, uint16_t cell_w, uint16_t cell_h,
+ uint32_t pane_id);
int pty_resize(pty_t *p, uint16_t cols, uint16_t rows, uint16_t cell_w,
uint16_t cell_h);
void pty_close(pty_t *p);
@@ -194,12 +202,16 @@ typedef void (*pane_clip_fn)(pane_t *p, char *text, void *ud);
typedef void (*pane_notify_fn)(pane_t *p, const char *title, const char *body,
void *ud);
+/* `id` is what the session will know this pane by: it reaches the program as
+ * $SLOSH_PANE, and every respawn of this pane (start/rerun) carries the same
+ * one, so a pane's identity outlives the process that had it. */
pane_t *pane_new(const char *const argv[], uint16_t cols, uint16_t rows,
- const char *cwd);
+ const char *cwd, uint32_t id);
/* `suspended`: create the pane but run nothing until pane_start(). `label` is
* what to show in the meantime (usually the command line). */
pane_t *pane_new_ex(const char *const argv[], uint16_t cols, uint16_t rows,
- const char *cwd, bool suspended, const char *label);
+ const char *cwd, bool suspended, const char *label,
+ uint32_t id);
bool pane_suspended(const pane_t *p);
/* A pane opened to do one thing, rather than one the session is made of: an
* editor you popped open, not the dev server a layout declared. It runs a