Blob


1 /*
2 * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
17 #ifndef UI_H
18 #define UI_H
20 #include "telescope.h"
22 extern int body_lines;
23 extern int body_cols;
24 extern int in_minibuffer;
26 extern struct kmap global_map, minibuffer_map, *current_map, *base_map;
28 struct excursion {
29 int curs_x, curs_y;
30 size_t line_off;
31 struct vline *current_line;
32 size_t cpoff;
33 };
35 enum pairs {
36 PTL_BG = 1,
37 PTL_TAB,
38 PTL_CURR,
40 PBODY,
41 PBLEFT,
42 PBRIGHT,
44 PT,
45 PT_PRFX,
46 PT_TRAIL,
47 PL,
48 PL_PRFX,
49 PL_TRAIL,
50 PT1,
51 PT1_PRFX,
52 PT1_TRAIL,
53 PT2,
54 PT2_PRFX,
55 PT2_TRAIL,
56 PT3,
57 PT3_PRFX,
58 PT3_TRAIL,
59 PI,
60 PI_PRFX,
61 PI_TRAIL,
62 PQ,
63 PQ_PRFX,
64 PQ_TRAIL,
65 PPSTART,
66 PPSTART_PRFX,
67 PPSTART_TRAIL,
68 PP,
69 PP_PRFX,
70 PP_TRAIL,
71 PPEND,
72 PPEND_PRFX,
73 PPEND_TRAIL,
75 PMODELINE,
77 PMINIBUF,
78 };
80 struct thiskey {
81 short meta;
82 int key;
83 uint32_t cp;
84 };
85 extern struct thiskey thiskey;
87 extern struct histhead eecmd_history,
88 ir_history,
89 lu_history,
90 read_history;
92 struct ministate {
93 char *curmesg;
95 char prompt[64];
96 void (*donefn)(void);
97 void (*abortfn)(void);
99 char buf[1025];
100 struct line line;
101 struct vline vline;
102 struct buffer buffer;
104 struct histhead *history;
105 struct hist *hist_cur;
106 size_t hist_off;
107 };
108 extern struct ministate ministate;
110 void save_excursion(struct excursion *, struct buffer *);
111 void restore_excursion(struct excursion *, struct buffer *);
112 void global_key_unbound(void);
113 void minibuffer_taint_hist(void);
114 void eecmd_self_insert(void);
115 void eecmd_select(void);
116 void ir_self_insert(void);
117 void ir_select(void);
118 void lu_self_insert(void);
119 void lu_select(void);
120 void bp_select(void);
121 void vmessage(const char *, va_list);
122 void message(const char *, ...) __attribute__((format(printf, 1, 2)));
123 void start_loading_anim(struct tab *);
124 void load_url_in_tab(struct tab *, const char *);
125 void switch_to_tab(struct tab *);
126 struct tab *current_tab(void);
127 struct buffer *current_buffer(void);
128 struct tab *new_tab(const char *);
129 unsigned int tab_new_id(void);
130 int ui_init(void);
131 void ui_on_tab_loaded(struct tab *);
132 void ui_on_tab_refresh(struct tab *);
133 const char *ui_keyname(int);
134 void ui_toggle_side_window(void);
135 void ui_schedule_redraw(void);
136 void ui_require_input(struct tab *, int);
137 void ui_read(const char *, void (*)(const char *, unsigned int), unsigned int);
138 void ui_yornp(const char *, void (*)(int, struct tab *), struct tab *);
139 void ui_end(void);
141 #endif