diff options
| author | user <user@clank> | 2026-08-19 13:46:57 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-08-19 13:46:57 +0200 |
| commit | 42b3c10995eb67778d9dd3aa2fd80624896acd5f (patch) | |
| tree | 751bcb8604967dc8687cf23fbeb1033aa26ca427 /include/proto.h | |
| parent | slosh: a website that is a page, not a mock session (diff) | |
| download | slosh-42b3c10995eb67778d9dd3aa2fd80624896acd5f.tar.gz slosh-42b3c10995eb67778d9dd3aa2fd80624896acd5f.tar.xz slosh-42b3c10995eb67778d9dd3aa2fd80624896acd5f.zip | |
slosh: defaults most people can live in, said by shaders
The out-of-the-box look, rethought as one piece:
- the compiled-in palette calms down: muted blue #7aa2f7 on the same
neutral darks, with the colours that mean something kept semantic --
amber bell, red-orange dead. sl0p stays one include away as the house
style, and contrib/themes/default.kdl is the starting point written
down (theme-tour shows it).
- derived state defaults now actually follow the theme: the scrolled
wash is rebuilt from scroll_bg after the theme block (it used to bake
the compiled accent), and declaring a state -- in any file of an
include chain -- still wins. The dump writes derived states as
comments so C-a e cannot pin what is meant to keep following.
- a bell you can see: the frame blinks three times in theme's bell
colour then breathes until answered, and a soft diagonal shimmer --
the bell colour halved towards default_fg, width breathing on a sine
-- crosses the body for the same 900ms. bell_indicator false silences
all of it; states { bell { } } replaces it like any state. since
carries the clock dependency, so an idle session pays nothing.
- scrollback says where it continues: while scrolled, the viewport's
top and bottom rows melt towards an edge with content past it and
turn solid at the buffer's end. New expression variables above/below
(lines hidden past each edge, own dependency bit, cached per scroll
position), carried in shade_ctx_t -- SLOSH_SHADER_ABI 3 -> 4.
- expressions survive the dump: a program keeps its source and cb_chain
writes it back, so amount="(y % 2) * 40" no longer dumps as a number.
- headers move to include/, -Iinclude everywhere; the plugin Makefile's
SLOSH var becomes SLOSH_DIR because slosh exports SLOSH=1 into every
pane it runs, and building from inside a session read that as a path.
- comment drift culled where features outran the prose, and the
derivation boilerplate folded into derived_pass()/ctx_scroll().
Diffstat (limited to 'include/proto.h')
| -rw-r--r-- | include/proto.h | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/include/proto.h b/include/proto.h new file mode 100644 index 0000000..e6cd42c --- /dev/null +++ b/include/proto.h @@ -0,0 +1,68 @@ +/* The client/server wire, and where sessions live. + * + * Frames are `u8 type, u32 length (big endian), payload`. Deliberately dull: + * the interesting protocol is the JSON control channel (M3) that rides on + * MSG_CMD, and it speaks the same vocabulary as the headless driver. + */ +#ifndef SLOSH_PROTO_H +#define SLOSH_PROTO_H + +#include <stdbool.h> +#include <stddef.h> +#include <stdint.h> + +/* MSG_HELLO and MSG_RESIZE carry u16 cols, u16 rows, and since the graphics + * fix two more: u16 cell_w, u16 cell_h, the client's cell size in pixels. + * A four-byte payload is still accepted and means "I did not say", which is + * what an older client sends and what a terminal that reports no pixel size + * leads to. */ +enum { + MSG_HELLO = 1, /* client -> server: u16 cols, rows[, cell_w, cell_h] */ + MSG_INPUT = 2, /* client -> server: raw bytes from the terminal */ + MSG_RESIZE = 3, /* client -> server: u16 cols, rows[, cell_w, cell_h] */ + MSG_DETACH = 4, /* client -> server: leave, but keep running */ + MSG_OUTPUT = 5, /* server -> client: bytes for the terminal */ + MSG_EXIT = 6, /* server -> client: u8 reason */ + MSG_CMD = 7, /* client -> server: one JSON line */ + MSG_REPLY = 8, /* server -> client: one JSON line */ +}; + +enum { + EXIT_SESSION_ENDED = 0, /* the last pane closed */ + EXIT_DETACHED = 1, /* the user detached */ + EXIT_REPLACED = 2, /* another client attached */ +}; + +typedef struct { + uint8_t type; + uint8_t *data; + uint32_t len; +} msg_t; + +/* Incremental framing: feed bytes, take whole messages out. */ +typedef struct { + uint8_t *buf; + size_t len, cap; + uint8_t *msg; /* the payload handed to the caller, lifted out of buf */ + size_t msg_cap; +} msg_reader_t; + +void msg_reader_init(msg_reader_t *r); +void msg_reader_free(msg_reader_t *r); +void msg_reader_feed(msg_reader_t *r, const uint8_t *data, size_t len); +/* Returns true and fills `out` (data points into the reader's buffer, valid + * until the next call) when a whole message is available. */ +bool msg_reader_next(msg_reader_t *r, msg_t *out); + +/* Blocking send of one frame. Returns 0 on success, -1 if the peer is gone. */ +int msg_send(int fd, uint8_t type, const void *data, size_t len); + +/* $XDG_RUNTIME_DIR/slosh/<name>.sock, or /tmp/slosh-<uid>/<name>.sock. + * Creates the directory (0700). Returns 0 on success. */ +int session_socket_path(const char *name, char *out, size_t cap); +int session_log_path(const char *name, char *out, size_t cap); +/* Names of live sessions (sockets that answer). Caller frees each and the + * array. Returns the count. */ +size_t session_list(char ***out_names); + +#endif /* SLOSH_PROTO_H */ |
