From 9915b9fd0b8e59bda9e334eb9485c473b06055c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Mon, 30 Mar 2015 23:04:54 +0200 Subject: Preliminary user interface separation In theory only ui-curses.[hc] should depend on curses, however in practice keyboard input is still handled in vis.c. Furthermore the syntax definitions as well as keyboard bindings and selection code in window.c still depends on some curses constants. There is also a slight regression in that the window status bar does not show the current mode name. This and related global state should be eliminated in the future. --- ui.h | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 ui.h (limited to 'ui.h') diff --git a/ui.h b/ui.h new file mode 100644 index 0000000..92123db --- /dev/null +++ b/ui.h @@ -0,0 +1,58 @@ +#ifndef UI_H +#define UI_H + +typedef struct Ui Ui; +typedef struct UiWin UiWin; + +enum UiLayout { + UI_LAYOUT_HORIZONTAL, + UI_LAYOUT_VERTICAL, +}; + +enum UiOption { + UI_OPTION_LINE_NUMBERS_NONE, + UI_OPTION_LINE_NUMBERS_ABSOLUTE, +}; + +#include +#include +#include "text.h" +#include "window.h" +#include "editor.h" + +struct Ui { + bool (*init)(Ui*, Editor*); + void (*free)(Ui*); + short (*color_get)(short fg, short bg); + void (*resize)(Ui*); + UiWin* (*window_new)(Ui*, Text*); + void (*window_free)(UiWin*); + void (*window_focus)(UiWin*); + UiWin* (*prompt_new)(Ui*, Text*); + void (*prompt)(Ui*, const char *title, const char *value); + char* (*prompt_input)(Ui*); + void (*prompt_hide)(Ui*); + void (*info)(Ui*, const char *msg, va_list ap); + void (*info_hide)(Ui*); + void (*arrange)(Ui*, enum UiLayout); + void (*draw)(Ui*); + void (*update)(Ui*); + void (*suspend)(Ui*); + void (*resume)(Ui*); +/* TODO main loop integration, signal handling + Key getkey(void); + bool haskey(void); +*/ +}; + +struct UiWin { + void (*draw)(UiWin*); + void (*draw_text)(UiWin*, const Line*); + void (*draw_status)(UiWin*); + void (*cursor_to)(UiWin*, int x, int y); + void (*reload)(UiWin*, Text*); + void (*options)(UiWin*, enum UiOption); + Win* (*view_get)(UiWin*); +}; + +#endif -- cgit v1.2.3