From e41eb5691417ecacade402759231f64778e3147f Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Wed, 10 Jun 2020 14:49:45 -0700 Subject: checkin: massive restructuring of dvtm --- sys/cmd/dvtm/dvtm.h | 117 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 67 insertions(+), 50 deletions(-) (limited to 'sys/cmd/dvtm/dvtm.h') diff --git a/sys/cmd/dvtm/dvtm.h b/sys/cmd/dvtm/dvtm.h index c36cb87..f89f517 100644 --- a/sys/cmd/dvtm/dvtm.h +++ b/sys/cmd/dvtm/dvtm.h @@ -13,37 +13,49 @@ #include #include +// #include #include #include "vt.h" -#ifdef PDCURSES -int ESCDELAY; -#endif - -#ifndef NCURSES_REENTRANT -#define set_escdelay(d) (ESCDELAY = (d)) -#endif +/* types */ +typedef struct Term Term; +typedef struct Screen Screen; +typedef struct Layout Layout; +typedef struct Window Window; +typedef struct Client Client; -typedef struct { - float mfact; - uint nmaster; - int history; - int w; - int h; +typedef struct Cmd Cmd; +typedef struct CmdFifo CmdFifo; +typedef struct Register Register; +typedef struct Editor Editor; + +typedef struct Button Button; +typedef struct KeyBinding KeyBinding; +typedef struct StatusBar StatusBar; + +struct Screen +{ + Term *backend; + float mfact; + uint nmaster; + int history; + int w, h; volatile sig_atomic_t need_resize; -} Screen; +}; -typedef struct { +struct Layout +{ const char *symbol; void (*arrange)(void); -} Layout; - -typedef struct Client Client; -struct Client { - WINDOW *window; - Vt *term; - Vt *editor, *app; +} ; + +struct Client +{ + Window *window; + Vt *term; + Vt *editor, *app; + /* meta data */ int editor_fds[2]; volatile sig_atomic_t editor_died; const char *cmd; @@ -51,26 +63,22 @@ struct Client { int order; pid_t pid; ushort id; - ushort x; - ushort y; - ushort w; - ushort h; + ushort x, y, w, h; bool has_title_line; bool minimized; bool urgent; volatile sig_atomic_t died; - Client *next; - Client *prev; - Client *snext; + Client *next, *prev, *snext; uint tags; }; +#if 0 typedef struct { - short fg; - short bg; - short fg256; - short bg256; - short pair; + int fg; + int bg; + int fg256; + int bg256; + int pair; } Color; typedef struct { @@ -78,6 +86,7 @@ typedef struct { attr_t attrs; Color *color; } ColorRule; +#endif #define ALT(k) ((k) + (161 - 'a')) @@ -92,7 +101,8 @@ typedef struct { #define MAX_ARGS 8 -typedef struct { +typedef struct +{ void (*cmd)(const char *args[]); const char *args[3]; } Action; @@ -101,24 +111,28 @@ typedef struct { typedef uint KeyCombo[MAX_KEYS]; -typedef struct { +struct KeyBinding +{ KeyCombo keys; Action action; -} KeyBinding; +}; -typedef struct { +struct Button +{ mmask_t mask; Action action; -} Button; +}; -typedef struct { +struct Cmd +{ const char *name; Action action; -} Cmd; +} ; enum { BAR_TOP, BAR_BOTTOM, BAR_OFF }; -typedef struct { +struct StatusBar +{ int fd; int pos, lastpos; bool autohide; @@ -126,26 +140,29 @@ typedef struct { ushort y; char text[512]; const char *file; -} StatusBar; +}; -typedef struct { +struct CmdFifo +{ int fd; const char *file; ushort id; -} CmdFifo; +}; -typedef struct { +struct Register +{ char *data; size_t len; size_t size; -} Register; +}; -typedef struct { +struct Editor +{ char *name; const char *argv[4]; bool filter; bool color; -} Editor; +}; #define TAGMASK ((1 << arrlen(tags)) - 1) @@ -206,7 +223,7 @@ void resize(Client *c, int x, int y, int w, int h); extern Screen screen; extern uint waw, wah, wax, way; extern Client *clients; -extern char *title; +extern char *title; void fibonacci(int s); void spiral(void); -- cgit v1.2.1