vis: implement :set cursorline
[vis.git] / ui.h
blob4efd79f08600a5fa0cdf44fa969f9efa8cb889cb
1 #ifndef UI_H
2 #define UI_H
4 #include <stdbool.h>
5 #include <stdarg.h>
6 #include <termkey.h>
8 typedef struct Ui Ui;
9 typedef struct UiWin UiWin;
11 enum UiLayout {
12 UI_LAYOUT_HORIZONTAL,
13 UI_LAYOUT_VERTICAL,
16 enum UiOption {
17 UI_OPTION_LINE_NUMBERS_ABSOLUTE = 1 << 0,
18 UI_OPTION_LINE_NUMBERS_RELATIVE = 1 << 1,
19 UI_OPTION_SYMBOL_SPACE = 1 << 2,
20 UI_OPTION_SYMBOL_TAB = 1 << 3,
21 UI_OPTION_SYMBOL_TAB_FILL = 1 << 4,
22 UI_OPTION_SYMBOL_EOL = 1 << 5,
23 UI_OPTION_SYMBOL_EOF = 1 << 6,
24 UI_OPTION_CURSOR_LINE = 1 << 7,
27 enum UiStyles {
28 UI_STYLE_LEXER_MAX = 64,
29 UI_STYLE_DEFAULT,
30 UI_STYLE_CURSOR,
31 UI_STYLE_CURSOR_LINE,
32 UI_STYLE_SELECTION,
33 UI_STYLE_LINENUMBER,
34 UI_STYLE_MAX,
37 #include "text.h"
38 #include "view.h"
39 #include "vis.h"
41 struct Ui {
42 bool (*init)(Ui*, Vis*);
43 void (*free)(Ui*);
44 void (*resize)(Ui*);
45 UiWin* (*window_new)(Ui*, View*, File*);
46 void (*window_free)(UiWin*);
47 void (*window_focus)(UiWin*);
48 UiWin* (*prompt_new)(Ui*, View*, File*);
49 void (*prompt)(Ui*, const char *title, const char *value);
50 char* (*prompt_input)(Ui*);
51 void (*prompt_hide)(Ui*);
52 void (*die)(Ui*, const char *msg, va_list ap);
53 void (*info)(Ui*, const char *msg, va_list ap);
54 void (*info_hide)(Ui*);
55 void (*arrange)(Ui*, enum UiLayout);
56 void (*draw)(Ui*);
57 void (*update)(Ui*);
58 void (*suspend)(Ui*);
59 const char* (*getkey)(Ui*);
60 bool (*haskey)(Ui*);
61 void (*terminal_save)(Ui*);
62 void (*terminal_restore)(Ui*);
63 TermKey* (*termkey_get)(Ui*);
66 struct UiWin {
67 void (*draw)(UiWin*);
68 void (*draw_status)(UiWin*);
69 void (*reload)(UiWin*, File*);
70 void (*options_set)(UiWin*, enum UiOption);
71 enum UiOption (*options_get)(UiWin*);
72 bool (*syntax_style)(UiWin*, int id, const char *style);
75 #endif