forked from martanne/vis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.h
61 lines (53 loc) · 1.32 KB
/
ui.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#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 = 0,
UI_OPTION_LINE_NUMBERS_ABSOLUTE = 1 << 0,
UI_OPTION_LINE_NUMBERS_RELATIVE = 1 << 1,
};
typedef struct {
char str[6]; /* UTF8 character or terminal escape code */
int code; /* curses KEY_* constant */
} Key;
#include <stdbool.h>
#include <stdarg.h>
#include "text.h"
#include "view.h"
#include "editor.h"
struct Ui {
bool (*init)(Ui*, Editor*);
void (*free)(Ui*);
void (*resize)(Ui*);
UiWin* (*window_new)(Ui*, View*, File*);
void (*window_free)(UiWin*);
void (*window_focus)(UiWin*);
UiWin* (*prompt_new)(Ui*, View*, File*);
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*);
Key (*getkey)(Ui*);
bool (*haskey)(Ui*);
void (*terminal_save)(Ui*);
void (*terminal_restore)(Ui*);
};
struct UiWin {
void (*draw)(UiWin*);
void (*draw_text)(UiWin*, const Line*);
void (*draw_status)(UiWin*);
void (*reload)(UiWin*, File*);
void (*options)(UiWin*, enum UiOption);
};
#endif