From 9bcf2667e7e239873597b7ec2172206a9af18071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Tue, 14 Mar 2017 16:53:53 +0100 Subject: Restructure display code Use pull instead of push based model for display code. Previously view.c was calling into the ui frontend code, with the new scheme this switches around: the necessary data is fetched by the ui as necessary. The UI independent display code is moved out of view.c/ui-curses.c into vis.c. The cell styles are now directly embedded into the Cell struct. New UI styles are introduced for: - status bar (focused / non-focused) - info message - window separator - EOF symbol You will have to update your color themes. The terminal output code is further abstracted into a generic ui-terminal.c part which keeps track of the whole in-memory cell matrix and #includes ui-terminal-curses.c for the actual terminal output. This architecture currently assumes that there are no overlapping windows. It will also allow non-curses based terminal user interfaces. --- ui.h | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'ui.h') diff --git a/ui.h b/ui.h index dd663b8..41ef975 100644 --- a/ui.h +++ b/ui.h @@ -42,9 +42,26 @@ enum UiStyle { UI_STYLE_SELECTION, UI_STYLE_LINENUMBER, UI_STYLE_COLOR_COLUMN, + UI_STYLE_STATUS, + UI_STYLE_STATUS_FOCUSED, + UI_STYLE_SEPARATOR, + UI_STYLE_INFO, + UI_STYLE_EOF, UI_STYLE_MAX, }; +typedef uint64_t CellAttr; +typedef short CellColor; + +static inline bool cell_color_equal(CellColor c1, CellColor c2) { + return c1 == c2; +} + +typedef struct { + CellAttr attr; + CellColor fg, bg; +} CellStyle; + #include "vis.h" #include "text.h" #include "view.h" @@ -53,7 +70,7 @@ struct Ui { bool (*init)(Ui*, Vis*); void (*free)(Ui*); void (*resize)(Ui*); - UiWin* (*window_new)(Ui*, View*, File*, enum UiOption); + UiWin* (*window_new)(Ui*, Win*, enum UiOption); void (*window_free)(UiWin*); void (*window_focus)(UiWin*); void (*window_swap)(UiWin*, UiWin*); @@ -65,6 +82,7 @@ struct Ui { void (*redraw)(Ui*); void (*update)(Ui*); void (*suspend)(Ui*); + void (*resume)(Ui*); bool (*getkey)(Ui*, TermKeyKey*); void (*terminal_save)(Ui*); void (*terminal_restore)(Ui*); @@ -73,12 +91,11 @@ struct Ui { }; struct UiWin { - void (*draw)(UiWin*); + CellStyle (*style_get)(UiWin*, enum UiStyle); void (*status)(UiWin*, const char *txt); - void (*reload)(UiWin*, File*); void (*options_set)(UiWin*, enum UiOption); enum UiOption (*options_get)(UiWin*); - bool (*syntax_style)(UiWin*, int id, const char *style); + bool (*style_define)(UiWin*, int id, const char *style); int (*window_width)(UiWin*); int (*window_height)(UiWin*); }; -- cgit v1.2.3