From 0428a82aee8a4f27634e341c62d53d5e2180a6fb Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Tue, 22 Mar 2022 12:26:20 -0400 Subject: [PATCH] reorganized and consolidated tide specific headers --- inc/draw.h | 12 ----- inc/win.h | 41 ---------------- inc/xpty.h | 6 --- src/lib/utf8/utf8.c | 2 +- src/tide/buf.c | 3 +- src/tide/draw.c | 5 +- src/tide/editlog.c | 3 +- src/tide/exec.c | 10 +--- src/tide/gapbuf.c | 3 +- src/tide/job.c | 4 +- src/tide/main.c | 15 +----- src/tide/mouse.c | 5 +- src/tide/range.c | 3 +- src/tide/shortcuts.c | 5 +- inc/edit.h => src/tide/tide.h | 90 +++++++++++++++++++++++++++++++++-- src/tide/view.c | 3 +- src/tide/xpty.c | 2 +- tests/lib/buf.c | 3 +- tests/lib/utf8.c | 1 - tests/libedit.c | 1 - 20 files changed, 112 insertions(+), 105 deletions(-) delete mode 100644 inc/draw.h delete mode 100644 inc/win.h delete mode 100644 inc/xpty.h rename inc/edit.h => src/tide/tide.h (79%) diff --git a/inc/draw.h b/inc/draw.h deleted file mode 100644 index d7354bf..0000000 --- a/inc/draw.h +++ /dev/null @@ -1,12 +0,0 @@ -/** @file */ -typedef struct { - int x, y; - int h, w; -} drawcsr; - -void draw_rect(XConf* x, int color, int posx, int posy, int width, int height); -void draw_statbox(XConf* x, int status); -int draw_hrule(XConf* x, drawcsr* csr); -void draw_view(XConf* x, View* view, XftFont* font, size_t nrows, drawcsr* csr, int bg, int fg, int sel, bool csrsync); -bool draw_csr(XConf* x, View* view, int fg, size_t fheight, int posx, int posy, bool csrdrawn); -void draw_scroll(XConf* x, drawcsr* csr, View* view, int divider); diff --git a/inc/win.h b/inc/win.h deleted file mode 100644 index 1ddb23c..0000000 --- a/inc/win.h +++ /dev/null @@ -1,41 +0,0 @@ -/** @file */ -typedef struct XFont XFont; - -typedef struct { - uint32_t attr; /* attributes applied to this cell */ - uint32_t rune; /* rune value for the cell */ -} XGlyph; - -typedef struct { - void* font; - uint32_t glyph; - short x; - short y; -} XGlyphSpec; - -enum { - MouseLeft = 1, - MouseMiddle = 2, - MouseRight = 3, - MouseWheelUp = 4, - MouseWheelDn = 5 -}; - -typedef enum { - TAGS = 0, - EDIT = 1, - NREGIONS = 2, - FOCUSED = 2 -} WinRegion; - -void win_init(void); -void win_title(char* path); -void win_font(char* font); -void win_prop_set(char* xname, char* ename, char* value); -void win_loop(void); -void win_quit(void); -void win_togglefocus(void); -View* win_view(WinRegion id); -Buf* win_buf(WinRegion id); -bool win_keymodsset(int mask); -void win_setln(int line_num); diff --git a/inc/xpty.h b/inc/xpty.h deleted file mode 100644 index ab20594..0000000 --- a/inc/xpty.h +++ /dev/null @@ -1,6 +0,0 @@ -/** @file */ -bool xpty_active(void); -void xpty_togglescroll(void); -int xpty_run(View* view, char** cmd); -void xpty_send(char* cmd); -void xpty_rawsend(char* cmd); diff --git a/src/lib/utf8/utf8.c b/src/lib/utf8/utf8.c index 622dc67..cb2ea5d 100644 --- a/src/lib/utf8/utf8.c +++ b/src/lib/utf8/utf8.c @@ -1,8 +1,8 @@ #include #include -#include #include #include + #include "config.h" static const uint8_t UTF8_SeqBits[] = { 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE }; diff --git a/src/tide/buf.c b/src/tide/buf.c index 3bae4fb..cfe040d 100644 --- a/src/tide/buf.c +++ b/src/tide/buf.c @@ -1,11 +1,12 @@ #include #include #include -#include #include #include #include #include + +#include "tide.h" #include "config.h" #ifndef NDEBUG diff --git a/src/tide/draw.c b/src/tide/draw.c index abe9c24..fdcbea6 100644 --- a/src/tide/draw.c +++ b/src/tide/draw.c @@ -1,8 +1,7 @@ #include #include -#include -#include -#include + +#include "tide.h" #include "config.h" void draw_rect(XConf* x, int color, int posx, int posy, int width, int height) diff --git a/src/tide/editlog.c b/src/tide/editlog.c index 023edce..747f87c 100644 --- a/src/tide/editlog.c +++ b/src/tide/editlog.c @@ -1,7 +1,8 @@ #include #include #include -#include + +#include "tide.h" #include "config.h" static Log* mklog(Buf* buf, size_t beg, size_t end, char* data, Log* next) diff --git a/src/tide/exec.c b/src/tide/exec.c index a12876e..f6ac771 100644 --- a/src/tide/exec.c +++ b/src/tide/exec.c @@ -1,15 +1,9 @@ #include #include -#include -#include -#include #include -#include "config.h" -typedef struct { - char* tag; - void (*action)(char*); -} Tag; +#include "tide.h" +#include "config.h" static Tag* Builtins = NULL; diff --git a/src/tide/gapbuf.c b/src/tide/gapbuf.c index e66b0ff..68ca32a 100644 --- a/src/tide/gapbuf.c +++ b/src/tide/gapbuf.c @@ -1,7 +1,6 @@ #include #include #include -#include #include #include #include @@ -9,6 +8,8 @@ #include #include #include + +#include "tide.h" #include "config.h" size_t gapbuf_end(GapBuf* buf) diff --git a/src/tide/job.c b/src/tide/job.c index 08f1c8c..27a6efe 100644 --- a/src/tide/job.c +++ b/src/tide/job.c @@ -1,7 +1,5 @@ #include #include -#include -#include #include #include #include @@ -10,6 +8,8 @@ #include #include +#include "tide.h" + struct PipeData { char* data; ssize_t ndata; diff --git a/src/tide/main.c b/src/tide/main.c index f385ccc..f4f630c 100644 --- a/src/tide/main.c +++ b/src/tide/main.c @@ -1,24 +1,11 @@ #include #include #include -#include -#include -#include #include -#include -#include #include #include -typedef struct { - char* tag; - void (*action)(char*); -} Tag; - -void exec_init(Tag* p_tags); -void exec_cmd(char* cmd); -void exec_cmdwarg(char* cmd, char* arg); -void exec_rawwarg(char* cmd, char* arg); +#include "tide.h" #define INCLUDE_DEFS #include "config.h" diff --git a/src/tide/mouse.c b/src/tide/mouse.c index db022b1..9e252ee 100644 --- a/src/tide/mouse.c +++ b/src/tide/mouse.c @@ -1,9 +1,8 @@ #include #include -#include -#include -#include #include + +#include "tide.h" #include "config.h" static inline int PRESSED(int mods, int btn) diff --git a/src/tide/range.c b/src/tide/range.c index 7eecc44..6b6a517 100644 --- a/src/tide/range.c +++ b/src/tide/range.c @@ -1,6 +1,7 @@ #include #include -#include + +#include "tide.h" void range_add(Sel* p_range, size_t off) { diff --git a/src/tide/shortcuts.c b/src/tide/shortcuts.c index aee1832..55c37b4 100644 --- a/src/tide/shortcuts.c +++ b/src/tide/shortcuts.c @@ -1,8 +1,7 @@ #include #include -#include -#include -#include + +#include "tide.h" #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" diff --git a/inc/edit.h b/src/tide/tide.h similarity index 79% rename from inc/edit.h rename to src/tide/tide.h index b28eaed..1b9d4e9 100644 --- a/inc/edit.h +++ b/src/tide/tide.h @@ -1,6 +1,5 @@ -/** @file */ -/* Buffer management functions - *****************************************************************************/ +#include + /* undo/redo list item */ typedef struct Log { struct Log* next; /* pointer to next operation in the stack */ @@ -198,6 +197,8 @@ void view_selectobj(View* view, bool (*istype)(Rune)); /* Command Executions *****************************************************************************/ +/* src/tide/job.c */ + typedef struct Job Job; typedef void (*jobfn_t)(Job* job); @@ -220,6 +221,8 @@ void job_readfd(int fd, View* view); /* Common Shortcuts *****************************************************************************/ +/* src/tide/shortcuts.c */ + void select_line(char* arg); void join_lines(char* arg); void delete(char* arg); @@ -263,3 +266,84 @@ enum { }; int process_mouse(int btn, bool pressed); + +/* Command and Tag Exectuion + *****************************************************************************/ +/* src/tide/exec.c */ + +typedef struct { + char* tag; + void (*action)(char*); +} Tag; + +void exec_init(Tag* p_tags); +void exec_cmd(char* cmd); +void exec_cmdwarg(char* cmd, char* arg); +void exec_rawwarg(char* cmd, char* arg); + +/* UI Window Control + *****************************************************************************/ +/* src/tide/main.c */ + +typedef struct XFont XFont; + +typedef struct { + uint32_t attr; /* attributes applied to this cell */ + uint32_t rune; /* rune value for the cell */ +} XGlyph; + +typedef struct { + void* font; + uint32_t glyph; + short x; + short y; +} XGlyphSpec; + +enum { + MouseLeft = 1, + MouseMiddle = 2, + MouseRight = 3, + MouseWheelUp = 4, + MouseWheelDn = 5 +}; + +typedef enum { + TAGS = 0, + EDIT = 1, + NREGIONS = 2, + FOCUSED = 2 +} WinRegion; + +void win_init(void); +void win_title(char* path); +void win_font(char* font); +void win_prop_set(char* xname, char* ename, char* value); +void win_loop(void); +void win_quit(void); +void win_togglefocus(void); +View* win_view(WinRegion id); +Buf* win_buf(WinRegion id); +bool win_keymodsset(int mask); +void win_setln(int line_num); + +typedef struct { + int x, y; + int h, w; +} drawcsr; + +/* UI Drawing Routines + *****************************************************************************/ +void draw_rect(XConf* x, int color, int posx, int posy, int width, int height); +void draw_statbox(XConf* x, int status); +int draw_hrule(XConf* x, drawcsr* csr); +void draw_view(XConf* x, View* view, XftFont* font, size_t nrows, drawcsr* csr, int bg, int fg, int sel, bool csrsync); +bool draw_csr(XConf* x, View* view, int fg, size_t fheight, int posx, int posy, bool csrdrawn); +void draw_scroll(XConf* x, drawcsr* csr, View* view, int divider); + +/* Pseudo Terminal Routines + *****************************************************************************/ +bool xpty_active(void); +void xpty_togglescroll(void); +int xpty_run(View* view, char** cmd); +void xpty_send(char* cmd); +void xpty_rawsend(char* cmd); diff --git a/src/tide/view.c b/src/tide/view.c index 87e24e1..90fd6ce 100644 --- a/src/tide/view.c +++ b/src/tide/view.c @@ -1,8 +1,9 @@ #include #include #include -#include #include + +#include "tide.h" #include "config.h" #ifndef NDEBUG diff --git a/src/tide/xpty.c b/src/tide/xpty.c index 2907e3e..1ac4e04 100644 --- a/src/tide/xpty.c +++ b/src/tide/xpty.c @@ -1,6 +1,5 @@ #include #include -#include #include #include #ifdef __linux__ @@ -8,6 +7,7 @@ #else #include #endif +#include "tide.h" #define BUFFERSZ 16384 diff --git a/tests/lib/buf.c b/tests/lib/buf.c index b372a87..3639fa9 100644 --- a/tests/lib/buf.c +++ b/tests/lib/buf.c @@ -2,7 +2,8 @@ #include #include #include -#include + +#include "src/tide/tide.h" #include "config.h" #pragma GCC diagnostic ignored "-Wunused-function" diff --git a/tests/lib/utf8.c b/tests/lib/utf8.c index 493223d..a1624a4 100644 --- a/tests/lib/utf8.c +++ b/tests/lib/utf8.c @@ -1,7 +1,6 @@ #include #include #include -#include TEST_SUITE(Utf8Tests) { diff --git a/tests/libedit.c b/tests/libedit.c index fe324a2..ef91963 100644 --- a/tests/libedit.c +++ b/tests/libedit.c @@ -1,6 +1,5 @@ #include #include -#include #define INCLUDE_DEFS #include -- 2.52.0