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 struct vline *top_line;
33 size_t cpoff;
34 };
36 enum pairs {
37 PTL_BG = 1,
38 PTL_TAB,
39 PTL_CURR,
41 PBODY,
42 PBLEFT,
43 PBRIGHT,
45 PT,
46 PT_PRFX,
47 PT_TRAIL,
48 PL,
49 PL_PRFX,
50 PL_TRAIL,
51 PT1,
52 PT1_PRFX,
53 PT1_TRAIL,
54 PT2,
55 PT2_PRFX,
56 PT2_TRAIL,
57 PT3,
58 PT3_PRFX,
59 PT3_TRAIL,
60 PI,
61 PI_PRFX,
62 PI_TRAIL,
63 PQ,
64 PQ_PRFX,
65 PQ_TRAIL,
66 PPSTART,
67 PPSTART_PRFX,
68 PPSTART_TRAIL,
69 PP,
70 PP_PRFX,
71 PP_TRAIL,
72 PPEND,
73 PPEND_PRFX,
74 PPEND_TRAIL,
76 PCOMPL_PRFX,
77 PCOMPL,
78 PCOMPL_TRAIL,
80 PCOMPL_CURR_PRFX,
81 PCOMPL_CURR,
82 PCOMPL_CURR_TRAIL,
84 PMODELINE,
86 PMINIBUF,
87 };
89 struct thiskey {
90 short meta;
91 int key;
92 uint32_t cp;
93 };
94 extern struct thiskey thiskey;
96 extern struct histhead eecmd_history,
97 ir_history,
98 lu_history,
99 read_history;
101 extern struct tab *current_tab;
103 extern struct buffer helpwin;
104 extern int help_lines, help_cols;
106 void save_excursion(struct excursion *, struct buffer *);
107 void restore_excursion(struct excursion *, struct buffer *);
108 void global_key_unbound(void);
109 struct vline *adjust_line(struct vline *, struct buffer *);
110 void vmessage(const char *, va_list);
111 void message(const char *, ...) __attribute__((format(printf, 1, 2)));
112 void start_loading_anim(struct tab *);
113 void load_url_in_tab(struct tab *, const char *, const char *);
114 void switch_to_tab(struct tab *);
115 struct buffer *current_buffer(void);
116 struct tab *new_tab(const char *, const char *base);
117 unsigned int tab_new_id(void);
118 int ui_print_colors(void);
119 int ui_init(void);
120 void ui_main_loop(void);
121 void ui_on_tab_loaded(struct tab *);
122 void ui_on_tab_refresh(struct tab *);
123 const char *ui_keyname(int);
124 void ui_toggle_side_window(void);
125 void ui_schedule_redraw(void);
126 void ui_require_input(struct tab *, int);
127 void ui_read(const char *, void (*)(const char *, struct tab *), struct tab *);
128 void ui_yornp(const char *, void (*)(int, struct tab *), struct tab *);
129 void ui_suspend(void);
130 void ui_end(void);
132 #endif