pane.h (1429B)
1 #ifndef PANE_H 2 #define PANE_H 3 4 #include <termbox.h> 5 6 enum INPUT_SIGNALS { INPUT_IGNORED, INPUT_HANDLED, INPUT_REFORM }; 7 8 #define T Pane_T 9 typedef struct T *T; 10 11 int pane_start(int active); 12 int pane_stop(void); 13 void pane_event_loop(void); 14 int pane_handle_resize(void); 15 int pane_resize(T self); 16 17 T pane_child(T self, int index); 18 19 int pane_x(T self); 20 int pane_y(T self); 21 int pane_width(T self); 22 int pane_height(T self); 23 24 T *pane_split(T self, size_t count, ...); 25 T *pane_vsplit(T self, size_t count, ...); 26 void pane_unsplit(T self); 27 void pane_clear(T self, int clear_border); 28 void setActive(int direction); 29 30 void pane_setTitle(T self, char *title); 31 32 int centerVertical(Pane_T pane, int len); 33 int centerHorisontal(Pane_T pane, int len); 34 void draw_border(int x, int y, int x_max, int y_max, uintattr_t color); 35 36 /* WIDGET */ 37 38 typedef struct data_T *data_T; 39 typedef struct widget_T *widget_T; 40 41 typedef int (*data_handler)(data_T, struct tb_event); 42 43 struct data_T { 44 data_handler handle_input; 45 void *payload; 46 47 int widget_num; 48 widget_T *widgets; 49 }; 50 51 struct widget_T { 52 int resized; 53 int inited; 54 55 char *title; 56 Pane_T pane; 57 data_T data; 58 void *style; 59 void *info; 60 void (*callback)(widget_T); 61 }; 62 63 data_T data_new(void *payload, data_handler handler); 64 65 int widget_activate(widget_T self, Pane_T pane); 66 int widget_deactivate(widget_T self); 67 void widget_setData(widget_T self, data_T data); 68 widget_T pane_widget(T self); 69 70 #undef T 71 #endif