diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2015-03-30 23:04:54 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2015-04-03 23:52:06 +0200 |
| commit | 9915b9fd0b8e59bda9e334eb9485c473b06055c9 (patch) | |
| tree | 768f0a04df7e6cfc6d1379de8f19d1d4acdbf3a2 /ui.h | |
| parent | b3b1abc76a832e53159b1191120bef56fe3a7041 (diff) | |
| download | vis-9915b9fd0b8e59bda9e334eb9485c473b06055c9.tar.gz vis-9915b9fd0b8e59bda9e334eb9485c473b06055c9.tar.xz | |
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.
Diffstat (limited to 'ui.h')
| -rw-r--r-- | ui.h | 58 |
1 files changed, 58 insertions, 0 deletions
@@ -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 <stdbool.h> +#include <stdarg.h> +#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 |
