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;
25 extern struct kmap global_map, minibuffer_map, *current_map, *base_map;
27 struct excursion {
28 int curs_x, curs_y;
29 size_t line_off;
30 struct vline *current_line;
31 struct vline *top_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 PPATCH,
76 PPATCH_PRFX,
77 PPATCH_TRAIL,
78 PPATCH_HDR,
79 PPATCH_HDR_PRFX,
80 PPATCH_HDR_TRAIL,
81 PPATCH_HUNK_HDR,
82 PPATCH_HUNK_HDR_PRFX,
83 PPATCH_HUNK_HDR_TRAIL,
84 PPATCH_ADD,
85 PPATCH_ADD_PRFX,
86 PPATCH_ADD_TRAIL,
87 PPATCH_DEL,
88 PPATCH_DEL_PRFX,
89 PPATCH_DEL_TRAIL,
91 PCOMPL_PRFX,
92 PCOMPL,
93 PCOMPL_TRAIL,
95 PCOMPL_CURR_PRFX,
96 PCOMPL_CURR,
97 PCOMPL_CURR_TRAIL,
99 PHELP_PRFX,
100 PHELP,
101 PHELP_TRAIL,
103 PDOWNLOAD_PRFX,
104 PDOWNLOAD,
105 PDOWNLOAD_TRAIL,
107 PDOWNLOAD_DONE_PRFX,
108 PDOWNLOAD_DONE,
109 PDOWNLOAD_DONE_TRAIL,
111 PDOWNLOAD_INFO_PRFX,
112 PDOWNLOAD_INFO,
113 PDOWNLOAD_INFO_TRAIL,
115 PDOWNLOAD_WIN,
117 PMODELINE,
119 PMINIBUF,
120 };
122 struct thiskey {
123 short meta;
124 int key;
125 uint32_t cp;
126 };
127 extern struct thiskey thiskey;
129 extern struct tab *current_tab;
131 extern struct buffer helpwin;
132 extern int help_lines, help_cols;
134 extern struct buffer downloadwin;
136 void save_excursion(struct excursion *, struct buffer *);
137 void restore_excursion(struct excursion *, struct buffer *);
138 void global_key_unbound(void);
139 struct buffer *current_buffer(void);
140 struct vline *adjust_line(struct vline *, struct buffer *);
141 void start_loading_anim(struct tab *);
143 int ui_print_colors(void);
144 int ui_init(void);
145 void ui_main_loop(void);
146 void ui_on_tab_loaded(struct tab *);
147 void ui_on_tab_refresh(struct tab *);
148 const char *ui_keyname(int);
149 void ui_toggle_side_window(int);
150 void ui_schedule_redraw(void);
151 void ui_after_message_hook(void);
152 void ui_require_input(struct tab *, int, int);
153 void ui_yornp(const char *, void (*)(int, struct tab *), struct tab *);
154 void ui_read(const char *, void (*)(const char *, struct tab *), struct tab *, const char *);
155 void ui_other_window(void);
156 void ui_suspend(void);
157 void ui_end(void);
159 #endif