From 497acdd8860d629ba24ed9976fd47eeb743b74ab Mon Sep 17 00:00:00 2001 From: rodri Date: Thu, 21 Sep 2023 16:49:11 +0000 Subject: add parsecmd to the server. modified it to allow for commands with the same name but different nargs. now each match list entry is preceded by an 'm', to simplify its processing. note that this breaks the client. the next commit will fix that. --- dat.h | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'dat.h') diff --git a/dat.h b/dat.h index 7828287..dad541d 100644 --- a/dat.h +++ b/dat.h @@ -129,9 +129,30 @@ struct Menulist char *title; Rectangle r, sr; /* content and scroll rects */ int high; /* [-1,nitems) where -1 is none */ + int off; /* entry offset ∈ [0, nitems-Maxvisitems] */ void (*add)(Menulist*, int, char*); void (*clear)(Menulist*); - void (*update)(Menulist*, Mousectl*); + int (*update)(Menulist*, Mousectl*, Channel*); void (*draw)(Menulist*, Image*); }; + +/* + * Kernel-style command parser + */ +typedef struct Cmdbuf Cmdbuf; +typedef struct Cmdtab Cmdtab; + +struct Cmdbuf +{ + char *buf; + char **f; + int nf; +}; + +struct Cmdtab +{ + int index; /* used by client to switch on result */ + char *cmd; /* command name */ + int narg; /* expected #args; 0 ==> variadic */ +}; -- cgit v1.2.3