From 70fa1e8594be04c203179e8249a27ae648a81e71 Mon Sep 17 00:00:00 2001 From: Randy Palamar Date: Thu, 23 May 2024 22:21:40 -0600 Subject: combine Win and UiWin These are not seperate things and keeping them this way makes gives this convoluted mess where both Wins and UiWins must have linked lists to the other Wins and UiWins in the program despite the fact that neither of them can exist in isolation. This, like my previous cleanup commits, is part of a larger goal of properly isolating the various subsystems in vis. Doing so is required if we ever want to be able to have a vis-server and a vis-client. --- ui.h | 39 +++++++++++++-------------------------- 1 file changed, 13 insertions(+), 26 deletions(-) (limited to 'ui.h') diff --git a/ui.h b/ui.h index c03a709..5680400 100644 --- a/ui.h +++ b/ui.h @@ -79,24 +79,12 @@ typedef struct { CellStyle style; /* colors and attributes used to display this cell */ } Cell; -struct Ui; struct Win; -typedef struct UiWin { - struct Ui *ui; /* ui which manages this window */ - struct Win *win; /* editor window being displayed */ - int id; /* unique identifier for this window */ - int width, height; /* window dimension including status bar */ - int x, y; /* window position */ - int sidebar_width; /* width of the sidebar showing line numbers etc. */ - struct UiWin *next, *prev; /* pointers to neighbouring windows */ - enum UiOption options; /* display settings for this window */ -} UiWin; - struct Vis; -typedef struct Ui { +typedef struct { struct Vis *vis; /* editor instance to which this ui belongs */ - UiWin *windows; /* all windows managed by this ui */ - UiWin *selwin; /* the currently selected layout */ + struct Win *windows; /* all windows managed by this ui */ + struct Win *selwin; /* the currently selected layout */ char info[UI_MAX_WIDTH]; /* info message displayed at the bottom of the screen */ int width, height; /* terminal dimensions available for all windows */ enum UiLayout layout; /* whether windows are displayed horizontally or vertically */ @@ -114,8 +102,6 @@ typedef struct Ui { #include "vis.h" #include "text.h" -#define UI_OPTIONS_GET(ui) ((ui) ? (ui)->options : 0) - bool ui_terminal_init(Ui*); int ui_terminal_colors(void); void ui_terminal_free(Ui*); @@ -133,18 +119,19 @@ void ui_info_show(Ui *, const char *, va_list); void ui_redraw(Ui*); void ui_resize(Ui*); -UiWin *ui_window_new(Ui *, Win *, enum UiOption); -void ui_window_focus(UiWin *); -void ui_window_free(UiWin *); -void ui_window_swap(UiWin *, UiWin *); +bool ui_window_init(Ui *, Win *, enum UiOption); +void ui_window_focus(Win *); +/* removes a window from the list of open windows */ +void ui_window_release(Ui *, Win *); +void ui_window_swap(Win *, Win *); bool ui_getkey(Ui *, TermKeyKey *); -bool ui_style_define(UiWin *win, int id, const char *style); -bool ui_window_style_set_pos(UiWin *win, int x, int y, enum UiStyle id); -void ui_window_style_set(UiWin *win, Cell *cell, enum UiStyle id); +bool ui_style_define(Win *win, int id, const char *style); +bool ui_window_style_set_pos(Win *win, int x, int y, enum UiStyle id); +void ui_window_style_set(Win *win, Cell *cell, enum UiStyle id); -void ui_window_options_set(UiWin *win, enum UiOption options); -void ui_window_status(UiWin *win, const char *status); +void ui_window_options_set(Win *win, enum UiOption options); +void ui_window_status(Win *win, const char *status); #endif -- cgit v1.2.3