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 extern int body_lines;
21 extern int body_cols;
23 extern struct kmap global_map, minibuffer_map, *current_map, *base_map;
25 struct excursion {
26 int curs_x, curs_y;
27 size_t line_off;
28 struct vline *current_line;
29 struct vline *top_line;
30 size_t cpoff;
31 };
33 enum pairs {
34 PTL_BG = 1,
35 PTL_TAB,
36 PTL_CURR,
38 PBODY,
39 PBLEFT,
40 PBRIGHT,
42 PT,
43 PT_PRFX,
44 PT_TRAIL,
45 PL,
46 PL_PRFX,
47 PL_TRAIL,
48 PT1,
49 PT1_PRFX,
50 PT1_TRAIL,
51 PT2,
52 PT2_PRFX,
53 PT2_TRAIL,
54 PT3,
55 PT3_PRFX,
56 PT3_TRAIL,
57 PI,
58 PI_PRFX,
59 PI_TRAIL,
60 PQ,
61 PQ_PRFX,
62 PQ_TRAIL,
63 PPSTART,
64 PPSTART_PRFX,
65 PPSTART_TRAIL,
66 PP,
67 PP_PRFX,
68 PP_TRAIL,
69 PPEND,
70 PPEND_PRFX,
71 PPEND_TRAIL,
73 PPATCH,
74 PPATCH_PRFX,
75 PPATCH_TRAIL,
76 PPATCH_HDR,
77 PPATCH_HDR_PRFX,
78 PPATCH_HDR_TRAIL,
79 PPATCH_HUNK_HDR,
80 PPATCH_HUNK_HDR_PRFX,
81 PPATCH_HUNK_HDR_TRAIL,
82 PPATCH_ADD,
83 PPATCH_ADD_PRFX,
84 PPATCH_ADD_TRAIL,
85 PPATCH_DEL,
86 PPATCH_DEL_PRFX,
87 PPATCH_DEL_TRAIL,
89 PCOMPL_PRFX,
90 PCOMPL,
91 PCOMPL_TRAIL,
93 PCOMPL_CURR_PRFX,
94 PCOMPL_CURR,
95 PCOMPL_CURR_TRAIL,
97 PHELP_PRFX,
98 PHELP,
99 PHELP_TRAIL,
101 PDOWNLOAD_PRFX,
102 PDOWNLOAD,
103 PDOWNLOAD_TRAIL,
105 PDOWNLOAD_DONE_PRFX,
106 PDOWNLOAD_DONE,
107 PDOWNLOAD_DONE_TRAIL,
109 PDOWNLOAD_INFO_PRFX,
110 PDOWNLOAD_INFO,
111 PDOWNLOAD_INFO_TRAIL,
113 PDOWNLOAD_WIN,
115 PMODELINE,
117 PMINIBUF,
119 PFRINGE_PRFX,
120 PFRINGE,
121 PFRINGE_TRAIL,
122 };
124 extern struct thiskey thiskey;
126 extern struct tab *current_tab;
128 extern struct buffer helpwin;
129 extern int help_lines, help_cols;
131 extern struct buffer downloadwin;
132 extern int download_lines;
133 extern int download_cols;
135 void get_scroll_position(struct tab *, size_t *, size_t *);
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_init(void);
144 void ui_main_loop(void);
145 void ui_on_tab_loaded(struct tab *);
146 void ui_on_tab_refresh(struct tab *);
147 void ui_on_download_refresh(void);
148 void ui_remotely_open_link(const char *);
149 const char *ui_keyname(int);
150 void ui_toggle_side_window(int);
151 void ui_show_downloads_pane(void);
152 void ui_schedule_redraw(void);
153 void ui_after_message_hook(void);
154 void ui_require_input(struct tab *, int, void (*)(void));
155 void ui_yornp(const char *, void (*)(int, struct tab *), struct tab *);
156 void ui_read(const char *, void (*)(const char *, struct tab *), struct tab *, const char *);
157 void ui_other_window(void);
158 void ui_suspend(void);
159 void ui_end(void);
161 #endif