aboutsummaryrefslogtreecommitdiff
path: root/xC-proto
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2022-08-08 04:39:20 +0200
committerPřemysl Eric Janouch <p@janouch.name>2022-09-05 14:26:00 +0200
commit1639235a48dbed75c2563c9a497b41c31a2a1bae (patch)
tree18193b72fa47e6bcac1358289ac9c36ed00c70ac /xC-proto
parent2160d037943ef0a3adbf4c6e30a91ee0f205c3f3 (diff)
downloadxK-1639235a48dbed75c2563c9a497b41c31a2a1bae.tar.gz
xK-1639235a48dbed75c2563c9a497b41c31a2a1bae.tar.xz
xK-1639235a48dbed75c2563c9a497b41c31a2a1bae.zip
Start X11 and web frontends for xC
For this, we needed a wire protocol. After surveying available options, it was decided to implement an XDR-like protocol code generator in portable AWK. It now has two backends, per each of: - xF, the X11 frontend, is in C, and is meant to be the primary user interface in the future. - xP, the web frontend, relies on a protocol proxy written in Go, and is meant for use on-the-go (no pun intended). They are very much work-in-progress proofs of concept right now, and the relay protocol is certain to change.
Diffstat (limited to 'xC-proto')
-rw-r--r--xC-proto120
1 files changed, 120 insertions, 0 deletions
diff --git a/xC-proto b/xC-proto
new file mode 100644
index 0000000..31534d4
--- /dev/null
+++ b/xC-proto
@@ -0,0 +1,120 @@
+// Backwards-compatible protocol version.
+const VERSION = 1;
+
+// From the frontend to the relay.
+struct CommandMessage {
+ u32 command_seq;
+ union CommandData switch (enum Command {
+ HELLO,
+ PING,
+ ACTIVE,
+ BUFFER_COMPLETE,
+ BUFFER_INPUT,
+ BUFFER_ACTIVATE,
+ BUFFER_LOG,
+ } command) {
+ case HELLO:
+ u32 version;
+ case PING:
+ void;
+ case ACTIVE:
+ void;
+ case BUFFER_COMPLETE:
+ string buffer_name;
+ string text;
+ u32 position;
+ case BUFFER_INPUT:
+ string buffer_name;
+ string text;
+ case BUFFER_ACTIVATE:
+ string buffer_name;
+ case BUFFER_LOG:
+ string buffer_name;
+ } data;
+};
+
+// From the relay to the frontend.
+struct EventMessage {
+ u32 event_seq;
+ union EventData switch (enum Event {
+ PING,
+ BUFFER_UPDATE,
+ BUFFER_RENAME,
+ BUFFER_REMOVE,
+ BUFFER_ACTIVATE,
+ BUFFER_LINE,
+ BUFFER_CLEAR,
+ ERROR,
+ RESPONSE,
+ } event) {
+ case PING:
+ void;
+ case BUFFER_UPDATE:
+ string buffer_name;
+ case BUFFER_RENAME:
+ string buffer_name;
+ string new;
+ case BUFFER_REMOVE:
+ string buffer_name;
+ case BUFFER_ACTIVATE:
+ string buffer_name;
+ case BUFFER_LINE:
+ string buffer_name;
+ bool is_unimportant;
+ bool is_highlight;
+ enum Rendition {
+ BARE,
+ INDENT,
+ STATUS,
+ ERROR,
+ JOIN,
+ PART,
+ } rendition;
+ // Unix timestamp in seconds.
+ u64 when;
+ // Broken-up text, with in-band formatting.
+ union ItemData switch (enum Item {
+ TEXT,
+ RESET,
+ FG_COLOR,
+ BG_COLOR,
+ FLIP_BOLD,
+ FLIP_ITALIC,
+ FLIP_UNDERLINE,
+ FLIP_INVERSE,
+ FLIP_CROSSED_OUT,
+ FLIP_MONOSPACE,
+ } kind) {
+ case TEXT:
+ string text;
+ case RESET:
+ void;
+ case FG_COLOR:
+ i16 color;
+ case BG_COLOR:
+ i16 color;
+ case FLIP_BOLD:
+ case FLIP_ITALIC:
+ case FLIP_UNDERLINE:
+ case FLIP_INVERSE:
+ case FLIP_CROSSED_OUT:
+ case FLIP_MONOSPACE:
+ void;
+ } items<>;
+ case BUFFER_CLEAR:
+ string buffer_name;
+ case ERROR:
+ u32 command_seq;
+ string error;
+ case RESPONSE:
+ u32 command_seq;
+ union ResponseData switch (Command command) {
+ case BUFFER_COMPLETE:
+ u32 start;
+ string completions<>;
+ case BUFFER_LOG:
+ // UTF-8, but not guaranteed.
+ u8 log<>;
+ } data;
+ } data;
+};