2 * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
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.
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.
18 * Ncurses UI for telescope.
24 * There's a simple text wrapping algorithm.
26 * 1. if it's a line in a pre-formatted block:
29 * 2. there is enough room for the next word?
31 * b. no: break the current line.
32 * i. while there isn't enough space to draw the current
34 * ii. draw the remainder of the current word (can be the
36 * 3. render the spaces after the word
37 * a. but if there is not enough room break the line and
45 * ncurses allows you to scroll a window, but when a line goes out of
46 * the visible area it's forgotten. We keep a list of formatted lines
47 * (``visual lines'') that we know fits in the window, and draw them.
48 * This way is easy to scroll: just call wscrl and then render the
51 * This means that on every resize we have to clear our list of lines
52 * and re-render everything. A clever approach would be to do this
55 * TODO: make the text formatting on-demand.
59 #include <telescope.h>
71 #define TAB_CURRENT 0x1
73 #define MIN(a, b) ((a) < (b) ? (a) : (b))
74 #define MAX(a, b) ((a) > (b) ? (a) : (b))
78 static struct event stdioev, winchev;
80 static int kbd(const char*);
81 static void kmap_define_key(struct kmap*, const char*, void(*)(struct tab*));
82 static void load_default_keys(void);
83 static int push_line(struct tab*, const struct line*, const char*, size_t);
84 static void empty_vlist(struct tab*);
85 static void restore_cursor(struct tab *);
87 static void cmd_previous_line(struct tab*);
88 static void cmd_next_line(struct tab*);
89 static void cmd_forward_char(struct tab*);
90 static void cmd_backward_char(struct tab*);
91 static void cmd_redraw(struct tab*);
92 static void cmd_scroll_line_down(struct tab*);
93 static void cmd_scroll_line_up(struct tab*);
94 static void cmd_scroll_up(struct tab*);
95 static void cmd_scroll_down(struct tab*);
96 static void cmd_kill_telescope(struct tab*);
97 static void cmd_push_button(struct tab*);
98 static void cmd_execute_extended_command(struct tab*);
100 static void global_key_unbound(void);
102 static void cmd_mini_del(struct tab*);
103 static void cmd_mini_forward_char(struct tab*);
104 static void cmd_mini_backward_char(struct tab*);
105 static void cmd_mini_move_end_of_line(struct tab*);
106 static void cmd_mini_move_beginning_of_line(struct tab*);
107 static void cmd_mini_kill_line(struct tab*);
108 static void cmd_mini_abort();
109 static void cmd_mini_complete_and_exit();
111 static void eecmd_self_insert(void);
112 static void eecmd_select(void);
114 static struct line *nth_line(struct tab*, size_t);
115 static struct tab *current_tab(void);
116 static void dispatch_stdio(int, short, void*);
117 static void handle_clear_minibuf(int, short, void*);
118 static void handle_resize(int, short, void*);
119 static int word_bourdaries(const char*, const char*, const char**, const char**);
120 static void wrap_text(struct tab*, const char*, struct line*);
121 static int hardwrap_text(struct tab*, struct line*);
122 static int wrap_page(struct tab*);
123 static void print_line(struct line*);
124 static void redraw_tabline(void);
125 static void redraw_modeline(struct tab*);
126 static void redraw_minibuffer(void);
127 static void redraw_tab(struct tab*);
128 static void message(const char*, ...) __attribute__((format(printf, 1, 2)));
129 static void start_loading_anim(struct tab*);
130 static void update_loading_anim(int, short, void*);
131 static void stop_loading_anim(struct tab*);
132 static void load_url_in_tab(struct tab*, const char*);
133 static void enter_minibuffer(void(*)(void), void(*)(void), void(*)(void));
134 static void exit_minibuffer(void);
135 static void new_tab(void);
137 static struct { int meta, key; } thiskey;
139 static WINDOW *tabline, *body, *modeline, *minibuf;
140 static int body_lines, body_cols;
142 static struct event clminibufev;
143 static int clminibufev_set;
144 static struct timeval clminibufev_timer = { 5, 0 };
145 static struct timeval loadingev_timer = { 0, 250000 };
147 static uint32_t tab_counter;
156 short loading_anim_step;
157 struct event loadingev;
159 TAILQ_HEAD(, line) head;
162 #define CTRL(n) ((n)&0x1F)
169 { "<down>", KEY_DOWN },
170 { "<left>", KEY_LEFT },
171 { "<right>", KEY_RIGHT },
172 { "<prior>", KEY_PPAGE },
173 { "<next>", KEY_NPAGE },
174 { "<home>", KEY_HOME },
175 { "<end>", KEY_END },
177 { "del", KEY_BACKSPACE },
181 { "enter", CTRL('m') },
182 { "ret", CTRL('m' )},
183 { "tab", CTRL('i') },
189 TAILQ_HEAD(map, keymap) m;
190 void (*unhandled_input)(void);
193 struct kmap global_map,
202 void (*fn)(struct tab*);
204 TAILQ_ENTRY(keymap) keymaps;
207 static int in_minibuffer;
215 void (*donefn)(void);
216 void (*abortfn)(void);
224 for (t = keytable; t->p != NULL; ++t) {
225 if (has_prefix(key, t->p))
237 for (t = keytable; t->p != NULL; ++t) {
246 kmap_define_key(struct kmap *map, const char *key, void (*fn)(struct tab*))
249 struct keymap *entry;
252 if ((ctrl = has_prefix(key, "C-")))
254 if ((meta = has_prefix(key, "M-")))
263 /* skip key & spaces */
264 while (*key != '\0' && !isspace(*key))
266 while (*key != '\0' && isspace(*key))
269 TAILQ_FOREACH(entry, &map->m, keymaps) {
270 if (entry->meta == meta && entry->key == k) {
280 if ((entry = calloc(1, sizeof(*entry))) == NULL)
285 TAILQ_INIT(&entry->map.m);
287 if (TAILQ_EMPTY(&map->m))
288 TAILQ_INSERT_HEAD(&map->m, entry, keymaps);
290 TAILQ_INSERT_TAIL(&map->m, entry, keymaps);
301 global_set_key(const char *key, void (*fn)(struct tab*))
303 kmap_define_key(&global_map, key, fn);
307 minibuffer_set_key(const char *key, void (*fn)(struct tab*))
309 kmap_define_key(&minibuffer_map, key, fn);
313 load_default_keys(void)
315 /* === global map === */
318 global_set_key("C-p", cmd_previous_line);
319 global_set_key("C-n", cmd_next_line);
320 global_set_key("C-f", cmd_forward_char);
321 global_set_key("C-b", cmd_backward_char);
323 global_set_key("M-v", cmd_scroll_up);
324 global_set_key("C-v", cmd_scroll_down);
326 global_set_key("C-x C-c", cmd_kill_telescope);
328 global_set_key("M-x", cmd_execute_extended_command);
331 global_set_key("k", cmd_previous_line);
332 global_set_key("j", cmd_next_line);
333 global_set_key("l", cmd_forward_char);
334 global_set_key("h", cmd_backward_char);
336 global_set_key("K", cmd_scroll_line_up);
337 global_set_key("J", cmd_scroll_line_down);
340 global_set_key("q", cmd_kill_telescope);
342 global_set_key(":", cmd_execute_extended_command);
345 global_set_key("<up>", cmd_previous_line);
346 global_set_key("<down>", cmd_next_line);
347 global_set_key("<right>", cmd_forward_char);
348 global_set_key("<left>", cmd_backward_char);
349 global_set_key("<prior>", cmd_scroll_up);
350 global_set_key("<next>", cmd_scroll_down);
352 /* "ncurses standard" */
353 global_set_key("C-l", cmd_redraw);
356 global_set_key("C-m", cmd_push_button);
358 /* === minibuffer map === */
359 minibuffer_set_key("ret", cmd_mini_complete_and_exit);
360 minibuffer_set_key("C-g", cmd_mini_abort);
361 minibuffer_set_key("esc", cmd_mini_abort);
362 minibuffer_set_key("del", cmd_mini_del);
364 minibuffer_set_key("C-f", cmd_mini_forward_char);
365 minibuffer_set_key("C-b", cmd_mini_backward_char);
366 minibuffer_set_key("C-e", cmd_mini_move_end_of_line);
367 minibuffer_set_key("C-a", cmd_mini_move_beginning_of_line);
368 minibuffer_set_key("<end>", cmd_mini_move_end_of_line);
369 minibuffer_set_key("<home>", cmd_mini_move_beginning_of_line);
370 minibuffer_set_key("C-k", cmd_mini_kill_line);
374 push_line(struct tab *tab, const struct line *l, const char *buf, size_t len)
380 if ((vl = calloc(1, sizeof(*vl))) == NULL)
383 if (len != 0 && (vl->line = calloc(1, len+1)) == NULL) {
390 memcpy(vl->line, buf, len);
393 if (TAILQ_EMPTY(&tab->s->head))
394 TAILQ_INSERT_HEAD(&tab->s->head, vl, lines);
396 TAILQ_INSERT_TAIL(&tab->s->head, vl, lines);
401 empty_vlist(struct tab *tab)
405 tab->s->line_max = 0;
407 TAILQ_FOREACH_SAFE(l, &tab->s->head, lines, t) {
408 TAILQ_REMOVE(&tab->s->head, l, lines);
410 /* l->alt references the original line! */
416 restore_cursor(struct tab *tab)
418 wmove(body, tab->s->curs_y, tab->s->curs_x);
422 cmd_previous_line(struct tab *tab)
424 if (--tab->s->curs_y < 0) {
426 cmd_scroll_line_up(tab);
433 cmd_next_line(struct tab *tab)
435 if (++tab->s->curs_y > body_lines-1) {
436 tab->s->curs_y = body_lines-1;
437 cmd_scroll_line_down(tab);
444 cmd_forward_char(struct tab *tab)
446 tab->s->curs_x = MIN(body_cols-1, tab->s->curs_x+1);
451 cmd_backward_char(struct tab *tab)
453 tab->s->curs_x = MAX(0, tab->s->curs_x-1);
458 cmd_redraw(struct tab *tab)
460 handle_resize(0, 0, NULL);
464 cmd_scroll_line_up(struct tab *tab)
468 if (tab->s->line_off == 0)
471 l = nth_line(tab, --tab->s->line_off);
478 cmd_scroll_line_down(struct tab *tab)
483 if (tab->s->line_max == 0 || tab->s->line_off == tab->s->line_max-1)
489 if (tab->s->line_max - tab->s->line_off < body_lines)
492 l = nth_line(tab, tab->s->line_off + body_lines-1);
493 wmove(body, body_lines-1, 0);
498 cmd_scroll_up(struct tab *tab)
504 for (; off > 0; --off)
505 cmd_scroll_line_up(tab);
509 cmd_scroll_down(struct tab *tab)
513 off = tab->s->line_off + body_lines;
514 off = MIN(tab->s->line_max, off);
516 for (; off >= 0; --off)
517 cmd_scroll_line_down(tab);
521 cmd_kill_telescope(struct tab *tab)
527 cmd_push_button(struct tab *tab)
532 nth = tab->s->line_off + tab->s->curs_y;
533 if (nth > tab->s->line_max)
535 l = nth_line(tab, nth);
536 if (l->type != LINE_LINK)
539 load_url_in_tab(tab, l->alt);
543 cmd_execute_extended_command(struct tab *tab)
547 enter_minibuffer(eecmd_self_insert, eecmd_select, exit_minibuffer);
549 len = sizeof(ministate.prompt);
550 strlcpy(ministate.prompt, "", len);
553 strlcat(ministate.prompt, "M-", len);
555 strlcat(ministate.prompt, keyname(thiskey.key), len);
556 strlcat(ministate.prompt, " ", len);
560 global_key_unbound(void)
563 char tmp[2] = {0, 0};
565 if ((keyname = unkbd(thiskey.key)) == NULL) {
566 message("%s%c is undefined",
567 thiskey.meta ? "M-" : "",
572 message("%s%s is undefined",
573 thiskey.meta ? "M-" : "",
578 cmd_mini_del(struct tab *tab)
580 if (ministate.len == 0 || ministate.off == 0)
583 memmove(&ministate.buf[ministate.off-1],
584 &ministate.buf[ministate.off],
585 ministate.len - ministate.off + 1);
591 cmd_mini_forward_char(struct tab *tab)
593 if (ministate.off == ministate.len)
599 cmd_mini_backward_char(struct tab *tab)
601 if (ministate.off == 0)
607 cmd_mini_move_end_of_line(struct tab *tab)
609 ministate.off = ministate.len;
613 cmd_mini_move_beginning_of_line(struct tab *tab)
619 cmd_mini_kill_line(struct tab *tab)
621 if (ministate.off == ministate.len)
623 ministate.buf[ministate.off] = '\0';
624 ministate.len -= ministate.off;
628 cmd_mini_abort(struct tab *tab)
634 cmd_mini_complete_and_exit(struct tab *tab)
640 eecmd_self_insert(void)
642 if (thiskey.meta || isspace(thiskey.key) ||
643 !isgraph(thiskey.key)) {
644 global_key_unbound();
648 if (ministate.len == sizeof(ministate.buf) -1)
651 /* TODO: utf8 handling! */
653 memmove(&ministate.buf[ministate.off+1],
654 &ministate.buf[ministate.off],
655 ministate.len - ministate.off + 1);
656 ministate.buf[ministate.off] = thiskey.key;
665 message("TODO: try to execute %s", ministate.buf);
669 nth_line(struct tab *tab, size_t n)
675 TAILQ_FOREACH(l, &tab->s->head, lines) {
690 TAILQ_FOREACH(t, &tabshead, tabs) {
691 if (t->flags & TAB_CURRENT)
700 dispatch_stdio(int fd, short ev, void *d)
704 thiskey.key = wgetch(body);
705 if (thiskey.key == ERR)
707 if (thiskey.key == 27) {
708 /* TODO: make escape-time customizable */
711 thiskey.key = wgetch(body);
712 if (thiskey.key == ERR)
717 TAILQ_FOREACH(k, ¤t_map->m, keymaps) {
718 if (k->meta == thiskey.meta &&
719 k->key == thiskey.key) {
721 current_map = &k->map;
723 current_map = base_map;
724 k->fn(current_tab());
730 current_map->unhandled_input();
731 current_map = base_map;
735 restore_cursor(current_tab());
749 handle_clear_minibuf(int fd, short ev, void *d)
753 free(ministate.curmesg);
754 ministate.curmesg = NULL;
767 handle_resize(int sig, short ev, void *d)
775 /* move and resize the windows, in reverse order! */
777 mvwin(minibuf, LINES-1, 0);
778 wresize(minibuf, 1, COLS);
780 mvwin(modeline, LINES-2, 0);
781 wresize(modeline, 1, COLS);
783 wresize(body, LINES-3, COLS);
784 body_lines = LINES-3;
787 wresize(tabline, 1, COLS);
796 * Helper function for wrap_text. Find the end of the current word
797 * and the end of the separator after the word.
800 word_boundaries(const char *s, const char *sep, const char **endword, const char **endspc)
808 /* find the end of the current world */
809 for (; *s != '\0'; ++s) {
810 if (strchr(sep, *s) != NULL)
816 /* find the end of the separator */
817 for (; *s != '\0'; ++s) {
818 if (strchr(sep, *s) == NULL)
828 emitline(struct tab *tab, size_t zero, size_t *off, const struct line *l,
831 if (!push_line(tab, l, *line, *off - zero))
833 *line += *off - zero;
839 emitstr(const char **s, size_t len, size_t *off)
843 /* printw("%*s", ...) doesn't seem to respect the precision, so... */
844 for (i = 0; i < len; ++i)
851 * Build a list of visual line by wrapping the given line, assuming
852 * that when printed will have a leading prefix prfx.
854 * TODO: it considers each byte one cell on the screen!
857 wrap_text(struct tab *tab, const char *prfx, struct line *l)
859 size_t zero, off, len, split;
860 const char *endword, *endspc, *line, *linestart;
867 while (word_boundaries(line, " \t-", &endword, &endspc)) {
868 len = endword - line;
869 if (off + len >= body_cols) {
870 emitline(tab, zero, &off, l, &linestart);
871 while (len >= body_cols) {
873 emitline(tab, zero, &off, l, &linestart);
883 /* print the spaces iff not at bol */
884 len = endspc - endword;
887 if (off + len >= body_cols) {
888 emitline(tab, zero, &off, l, &linestart);
897 emitline(tab, zero, &off, l, &linestart);
901 hardwrap_text(struct tab *tab, struct line *l)
904 const char *linestart;
906 len = strlen(l->line);
910 while (len >= COLS) {
913 if (!emitline(tab, 0, &off, l, &linestart))
918 return emitline(tab, 0, &len, l, &linestart);
924 wrap_page(struct tab *tab)
930 TAILQ_FOREACH(l, &tab->page.head, lines) {
933 wrap_text(tab, "", l);
936 wrap_text(tab, "=> ", l);
939 wrap_text(tab, "# ", l);
942 wrap_text(tab, "## ", l);
945 wrap_text(tab, "### ", l);
948 wrap_text(tab, "* ", l);
951 wrap_text(tab, "> ", l);
955 push_line(tab, l, NULL, 0);
957 case LINE_PRE_CONTENT:
958 hardwrap_text(tab, l);
966 print_line(struct line *l)
968 const char *text = l->line;
975 wprintw(body, "%s", text);
978 wattron(body, A_UNDERLINE);
979 wprintw(body, "=> %s", text);
980 wattroff(body, A_UNDERLINE);
983 wattron(body, A_BOLD);
984 wprintw(body, "# %s", text);
985 wattroff(body, A_BOLD);
988 wattron(body, A_BOLD);
989 wprintw(body, "## %s", text);
990 wattroff(body, A_BOLD);
993 wattron(body, A_BOLD);
994 wprintw(body, "### %s", text);
995 wattroff(body, A_BOLD);
998 wprintw(body, "* %s", text);
1001 wattron(body, A_DIM);
1002 wprintw(body, "> %s", text);
1003 wattroff(body, A_DIM);
1005 case LINE_PRE_START:
1007 wprintw(body, "```");
1009 case LINE_PRE_CONTENT:
1010 wprintw(body, "%s", text);
1016 redraw_tabline(void)
1019 wbkgd(tabline, A_REVERSE);
1020 mvwprintw(tabline, 0, 0, "TODO: tabs here");
1024 redraw_modeline(struct tab *tab)
1026 int x, y, max_x, max_y;
1027 const char *mode = "text/gemini-mode";
1028 const char *spin = "-\\|/";
1031 wattron(modeline, A_REVERSE);
1032 wmove(modeline, 0, 0);
1034 wprintw(modeline, "-%c %s %s ",
1035 spin[tab->s->loading_anim_step], mode, tab->urlstr);
1036 getyx(modeline, y, x);
1037 getmaxyx(modeline, max_y, max_x);
1042 for (; x < max_x; ++x)
1043 waddstr(modeline, "-");
1047 redraw_minibuffer(void)
1049 size_t skip = 0, off = 0;
1055 off = strlen(ministate.prompt);
1057 while (ministate.off - skip > COLS / 2) {
1058 skip += MIN(ministate.off/4, 1);
1061 mvwprintw(minibuf, 0, 0, "%s%s", ministate.prompt,
1062 ministate.buf + skip);
1065 if (ministate.curmesg != NULL) {
1067 wprintw(minibuf, " [%s]", ministate.curmesg);
1069 wprintw(minibuf, "%s", ministate.curmesg);
1072 wmove(minibuf, 0, off + ministate.off - skip);
1076 redraw_tab(struct tab *tab)
1083 tab->s->line_off = MIN(tab->s->line_max, tab->s->line_off);
1084 if (TAILQ_EMPTY(&tab->s->head))
1088 l = nth_line(tab, tab->s->line_off);
1089 for (; l != NULL; l = TAILQ_NEXT(l, lines)) {
1090 wmove(body, line, 0);
1093 if (line == body_lines)
1098 redraw_modeline(tab);
1099 redraw_minibuffer();
1101 restore_cursor(tab);
1105 if (in_minibuffer) {
1115 message(const char *fmt, ...)
1119 if (clminibufev_set)
1120 evtimer_del(&clminibufev);
1121 evtimer_set(&clminibufev, handle_clear_minibuf, NULL);
1122 evtimer_add(&clminibufev, &clminibufev_timer);
1123 clminibufev_set = 1;
1126 /* TODO: what to do if the allocation fails here? */
1127 if (vasprintf(&ministate.curmesg, fmt, ap) == -1)
1128 ministate.curmesg = NULL;
1131 redraw_minibuffer();
1133 if (in_minibuffer) {
1143 start_loading_anim(struct tab *tab)
1145 if (tab->s->loading_anim)
1147 tab->s->loading_anim = 1;
1148 evtimer_set(&tab->s->loadingev, update_loading_anim, tab);
1149 evtimer_add(&tab->s->loadingev, &loadingev_timer);
1153 update_loading_anim(int fd, short ev, void *d)
1155 struct tab *tab = d;
1157 tab->s->loading_anim_step = (tab->s->loading_anim_step+1)%4;
1159 redraw_modeline(tab);
1166 evtimer_add(&tab->s->loadingev, &loadingev_timer);
1170 stop_loading_anim(struct tab *tab)
1172 if (!tab->s->loading_anim)
1174 evtimer_del(&tab->s->loadingev);
1175 tab->s->loading_anim = 0;
1176 tab->s->loading_anim_step = 0;
1178 redraw_modeline(tab);
1187 load_url_in_tab(struct tab *tab, const char *url)
1190 message("Loading %s...", url);
1191 start_loading_anim(tab);
1200 enter_minibuffer(void (*self_insert_fn)(void), void (*donefn)(void),
1201 void (*abortfn)(void))
1204 base_map = &minibuffer_map;
1205 current_map = &minibuffer_map;
1207 base_map->unhandled_input = self_insert_fn;
1209 ministate.donefn = donefn;
1210 ministate.abortfn = abortfn;
1211 memset(ministate.buf, 0, sizeof(ministate.buf));
1213 strlcpy(ministate.buf, "", sizeof(ministate.prompt));
1217 exit_minibuffer(void)
1222 base_map = &global_map;
1223 current_map = &global_map;
1229 struct tab *tab, *t;
1230 const char *url = "about:new";
1232 if ((tab = calloc(1, sizeof(*tab))) == NULL)
1235 if ((tab->s = calloc(1, sizeof(*t->s))) == NULL)
1238 TAILQ_INIT(&tab->s->head);
1239 TAILQ_FOREACH(t, &tabshead, tabs) {
1240 t->flags &= ~TAB_CURRENT;
1243 tab->id = tab_counter++;
1244 tab->flags = TAB_CURRENT;
1246 if (TAILQ_EMPTY(&tabshead))
1247 TAILQ_INSERT_HEAD(&tabshead, tab, tabs);
1249 TAILQ_INSERT_TAIL(&tabshead, tab, tabs);
1251 load_url_in_tab(tab, url);
1261 setlocale(LC_ALL, "");
1263 TAILQ_INIT(&global_map.m);
1264 global_map.unhandled_input = global_key_unbound;
1266 TAILQ_INIT(&minibuffer_map.m);
1268 base_map = &global_map;
1269 current_map = &global_map;
1270 load_default_keys();
1277 intrflush(stdscr, FALSE);
1279 if ((tabline = newwin(1, COLS, 0, 0)) == NULL)
1281 if ((body = newwin(LINES - 3, COLS, 1, 0)) == NULL)
1283 if ((modeline = newwin(1, COLS, LINES-2, 0)) == NULL)
1285 if ((minibuf = newwin(1, COLS, LINES-1, 0)) == NULL)
1288 body_lines = LINES-3;
1292 scrollok(body, TRUE);
1294 /* non-blocking input */
1297 mvwprintw(body, 0, 0, "");
1299 event_set(&stdioev, 0, EV_READ | EV_PERSIST, dispatch_stdio, NULL);
1300 event_add(&stdioev, NULL);
1302 signal_set(&winchev, SIGWINCH, handle_resize, NULL);
1303 signal_add(&winchev, NULL);
1311 ui_on_tab_loaded(struct tab *tab)
1313 stop_loading_anim(tab);
1314 message("Loaded %s", tab->urlstr);
1318 ui_on_tab_refresh(struct tab *tab)
1320 if (!(tab->flags & TAB_CURRENT))