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.
23 * ncurses allows you to scroll a window, but when a line goes out of
24 * the visible area it's forgotten. We keep a list of formatted lines
25 * (``visual lines'') that we know fits in the window, and draw them.
27 * This means that on every resize we have to clear our list of lines
28 * and re-render everything. A clever approach would be to do this
29 * ``on-demand'', but it's still missing.
45 #include "minibuffer.h"
46 #include "telescope.h"
50 static struct event stdioev, winchev;
52 static void restore_curs_x(struct buffer *);
54 static int readkey(void);
55 static void dispatch_stdio(int, short, void*);
56 static void handle_resize(int, short, void*);
57 static void handle_resize_nodelay(int, short, void*);
58 static void rearrange_windows(void);
59 static void line_prefix_and_text(struct vline *, char *, size_t, const char **, const char **);
60 static void print_vline(int, int, WINDOW*, struct vline*);
61 static void redraw_tabline(void);
62 static void redraw_window(WINDOW*, int, int, int, struct buffer*);
63 static void redraw_help(void);
64 static void redraw_body(struct tab*);
65 static void redraw_modeline(struct tab*);
66 static void redraw_minibuffer(void);
67 static void do_redraw_echoarea(void);
68 static void do_redraw_minibuffer(void);
69 static void do_redraw_minibuffer_compl(void);
70 static void place_cursor(int);
71 static void redraw_tab(struct tab*);
72 static void update_loading_anim(int, short, void*);
73 static void stop_loading_anim(struct tab*);
76 * Used to know when we're finished loading.
80 static int should_rearrange_windows;
84 struct thiskey thiskey;
85 struct tab *current_tab;
87 static struct event resizeev;
88 static struct timeval resize_timer = { 0, 250000 };
90 static WINDOW *tabline, *body, *modeline, *echoarea, *minibuffer;
92 int body_lines, body_cols;
95 /* not static so we can see them from help.c */
96 struct buffer helpwin;
97 int help_lines, help_cols;
99 static int side_window;
100 static int in_side_window;
102 static struct timeval loadingev_timer = { 0, 250000 };
104 static uint32_t tab_counter;
106 static char keybuf[64];
108 /* XXX: don't forget to init these in main() */
109 struct kmap global_map,
115 update_x_offset(void)
117 if (olivetti_mode && fill_column < body_cols)
118 x_offset = (body_cols - fill_column)/2;
124 save_excursion(struct excursion *place, struct buffer *buffer)
126 place->curs_x = buffer->curs_x;
127 place->curs_y = buffer->curs_y;
128 place->line_off = buffer->line_off;
129 place->top_line = buffer->top_line;
130 place->current_line = buffer->current_line;
131 place->cpoff = buffer->cpoff;
135 restore_excursion(struct excursion *place, struct buffer *buffer)
137 buffer->curs_x = place->curs_x;
138 buffer->curs_y = place->curs_y;
139 buffer->line_off = place->line_off;
140 buffer->top_line = place->top_line;
141 buffer->current_line = place->current_line;
142 buffer->cpoff = place->cpoff;
146 restore_curs_x(struct buffer *buffer)
149 const char *prfx, *text;
151 vl = buffer->current_line;
152 if (vl == NULL || vl->line == NULL)
153 buffer->curs_x = buffer->cpoff = 0;
154 else if (vl->parent->data != NULL) {
155 text = vl->parent->data;
156 buffer->curs_x = utf8_snwidth(text + 1, buffer->cpoff) + 1;
158 buffer->curs_x = utf8_snwidth(vl->line, buffer->cpoff);
160 buffer->curs_x += x_offset;
165 if (vl->parent->data != NULL)
166 buffer->curs_x += utf8_swidth_between(vl->parent->line,
169 prfx = line_prefixes[vl->parent->type].prfx1;
170 buffer->curs_x += utf8_swidth(prfx);
175 global_key_unbound(void)
177 message("%s is undefined", keybuf);
184 return &ministate.buffer;
187 return ¤t_tab->buffer;
195 if ((thiskey.key = wgetch(body)) == ERR)
198 thiskey.meta = thiskey.key == 27;
200 thiskey.key = wgetch(body);
201 if (thiskey.key == ERR || thiskey.key == 27) {
209 if ((unsigned int)thiskey.key >= UINT8_MAX)
213 if (!utf8_decode(&state, &thiskey.cp, (uint8_t)thiskey.key))
215 if ((thiskey.key = wgetch(body)) == ERR) {
216 message("Error decoding user input");
225 dispatch_stdio(int fd, short ev, void *d)
231 /* TODO: schedule a redraw? */
238 if (keybuf[0] != '\0')
239 strlcat(keybuf, " ", sizeof(keybuf));
241 strlcat(keybuf, "M-", sizeof(keybuf));
242 if (thiskey.cp != 0) {
243 utf8_encode(thiskey.cp, tmp);
244 strlcat(keybuf, tmp, sizeof(keybuf));
245 } else if ((keyname = unkbd(thiskey.key)) != NULL) {
246 strlcat(keybuf, keyname, sizeof(keybuf));
248 tmp[0] = thiskey.key;
249 strlcat(keybuf, tmp, sizeof(keybuf));
252 TAILQ_FOREACH(k, ¤t_map->m, keymaps) {
253 if (k->meta == thiskey.meta &&
254 k->key == thiskey.key) {
256 current_map = &k->map;
258 current_map = base_map;
259 strlcpy(keybuf, "", sizeof(keybuf));
260 k->fn(current_buffer());
266 if (current_map->unhandled_input != NULL)
267 current_map->unhandled_input();
269 global_key_unbound();
271 strlcpy(keybuf, "", sizeof(keybuf));
272 current_map = base_map;
278 if (should_rearrange_windows)
280 redraw_tab(current_tab);
284 handle_resize(int sig, short ev, void *d)
286 if (event_pending(&resizeev, EV_TIMEOUT, NULL)) {
287 event_del(&resizeev);
289 evtimer_set(&resizeev, handle_resize_nodelay, NULL);
290 evtimer_add(&resizeev, &resize_timer);
294 handle_resize_nodelay(int s, short ev, void *d)
304 rearrange_windows(void)
308 should_rearrange_windows = 0;
312 if ((too_small = lines < 15)) {
314 printw("Window too small.");
319 /* move and resize the windows, in reverse order! */
321 if (in_minibuffer == MB_COMPREAD) {
322 mvwin(minibuffer, lines-10, 0);
323 wresize(minibuffer, 10, COLS);
326 wrap_page(&ministate.compl.buffer, COLS);
329 mvwin(echoarea, --lines, 0);
330 wresize(echoarea, 1, COLS);
332 mvwin(modeline, --lines, 0);
333 wresize(modeline, 1, COLS);
335 body_lines = --lines;
339 help_cols = 0.3 * COLS;
342 wresize(help, help_lines, help_cols);
344 wrap_page(&helpwin, help_cols);
346 body_cols = COLS - help_cols - 1;
347 mvwin(body, 1, help_cols);
352 wresize(body, body_lines, body_cols);
354 wresize(tabline, 1, COLS);
356 wrap_page(¤t_tab->buffer, body_cols);
357 redraw_tab(current_tab);
361 line_prefix_and_text(struct vline *vl, char *buf, size_t len,
362 const char **prfx_ret, const char **text_ret)
364 int type, i, cont, width;
367 if ((*text_ret = vl->line) == NULL)
370 cont = vl->flags & L_CONTINUATION;
371 type = vl->parent->type;
373 *prfx_ret = line_prefixes[type].prfx1;
375 *prfx_ret = line_prefixes[type].prfx2;
377 space = vl->parent->data;
378 if (!emojify_link || type != LINE_LINK || space == NULL)
383 width = utf8_swidth_between(vl->parent->line, space);
384 for (i = 0; i < width + 1; ++i)
385 strlcat(buf, " ", len);
387 strlcpy(buf, *text_ret, len);
388 if ((t = strchr(buf, ' ')) != NULL)
390 strlcat(buf, " ", len);
393 *text_ret += (space - vl->parent->line) + 1;
400 print_vline_descr(int width, WINDOW *window, struct vline *vl)
404 if (vl->parent->type != LINE_COMPL &&
405 vl->parent->type != LINE_COMPL_CURRENT &&
406 vl->parent->type != LINE_HELP)
409 if (vl->parent->alt == NULL)
415 if (vl->parent->type == LINE_HELP)
421 wprintw(window, " ");
422 for (; goal > x; ++x)
423 wprintw(window, " ");
425 wprintw(window, "%s", vl->parent->alt);
429 * Core part of the rendering. It prints a vline starting from the
430 * current cursor position. Printing a vline consists of skipping
431 * `off' columns (for olivetti-mode), print the correct prefix (which
432 * may be the emoji in case of emojified links-lines), printing the
433 * text itself, filling until width - off and filling off columns
437 print_vline(int off, int width, WINDOW *window, struct vline *vl)
440 * Believe me or not, I've seen emoji ten code points long!
441 * That means, to stay large, 4*10 bytes + NUL.
443 char emojibuf[41] = {0};
444 const char *text, *prfx;
448 f = &line_faces[vl->parent->type];
450 /* unused, set by getyx */
453 line_prefix_and_text(vl, emojibuf, sizeof(emojibuf), &prfx, &text);
455 wattr_on(window, body_face.left, NULL);
456 for (i = 0; i < off; i++)
458 wattr_off(window, body_face.left, NULL);
460 wattr_on(window, f->prefix, NULL);
461 wprintw(window, "%s", prfx);
462 wattr_off(window, f->prefix, NULL);
464 wattr_on(window, f->text, NULL);
465 wprintw(window, "%s", text);
466 print_vline_descr(width, window, vl);
467 wattr_off(window, f->text, NULL);
473 wattr_on(window, f->trail, NULL);
474 for (i = 0; i < left - off; ++i)
476 wattr_off(window, f->trail, NULL);
478 wattr_on(window, body_face.right, NULL);
479 for (i = 0; i < off; i++)
481 wattr_off(window, body_face.right, NULL);
489 size_t toskip, ots, tabwidth, space, x;
490 int current, y, truncated, pair;
496 /* unused, but setted by a getyx */
499 tabwidth = sizeof(buf)+1;
503 TAILQ_FOREACH(tab, &tabshead, tabs) {
505 if (tab == current_tab)
509 if (toskip * tabwidth < space)
514 while (toskip != 0 &&
515 (ots - toskip+1) * tabwidth < space)
520 wattr_on(tabline, tab_face.background, NULL);
521 wprintw(tabline, toskip == 0 ? " " : "<");
522 wattr_off(tabline, tab_face.background, NULL);
525 TAILQ_FOREACH(tab, &tabshead, tabs) {
533 getyx(tabline, y, x);
534 if (x + sizeof(buf)+2 >= (size_t)COLS)
537 current = tab == current_tab;
539 if (*(title = tab->buffer.page.title) == '\0')
540 title = tab->hist_cur->h;
542 if (tab->flags & TAB_URGENT)
543 strlcpy(buf, "!", sizeof(buf));
545 strlcpy(buf, " ", sizeof(buf));
547 if (strlcat(buf, title, sizeof(buf)) >= sizeof(buf)) {
548 /* truncation happens */
549 strlcpy(&buf[sizeof(buf)-4], "...", 4);
551 /* pad with spaces */
552 while (strlcat(buf, " ", sizeof(buf)) < sizeof(buf))
556 pair = current ? tab_face.current : tab_face.tab;
557 wattr_on(tabline, pair, NULL);
558 wprintw(tabline, "%s", buf);
559 wattr_off(tabline, pair, NULL);
561 wattr_on(tabline, tab_face.background, NULL);
562 if (TAILQ_NEXT(tab, tabs) != NULL)
563 wprintw(tabline, "┃");
564 wattr_off(tabline, tab_face.background, NULL);
567 wattr_on(tabline, tab_face.background, NULL);
568 for (; x < (size_t)COLS; ++x)
569 waddch(tabline, ' ');
571 mvwprintw(tabline, 0, COLS-1, ">");
572 wattr_off(tabline, tab_face.background, NULL);
576 * Compute the first visible line around vl. Try to search forward
577 * until the end of the buffer; if a visible line is not found, search
578 * backward. Return NULL if no viable line was found.
581 adjust_line(struct vline *vl, struct buffer *buffer)
588 if (!(vl->parent->flags & L_HIDDEN))
593 t != NULL && t->parent->flags & L_HIDDEN;
594 t = TAILQ_NEXT(t, vlines))
600 /* search backward */
602 t != NULL && t->parent->flags & L_HIDDEN;
603 t = TAILQ_PREV(t, vhead, vlines))
610 redraw_window(WINDOW *win, int off, int height, int width,
611 struct buffer *buffer)
616 restore_curs_x(buffer);
619 * TODO: ignoring buffer->force_update and always
620 * re-rendering. In theory we can recompute the y position
621 * without a re-render, and optimize here. It's not the only
622 * optimisation possible here, wscrl wolud also be an
630 if (TAILQ_EMPTY(&buffer->head))
633 if (buffer->top_line == NULL)
634 buffer->top_line = TAILQ_FIRST(&buffer->head);
636 buffer->top_line = adjust_line(buffer->top_line, buffer);
637 if (buffer->top_line == NULL)
640 buffer->current_line = adjust_line(buffer->current_line, buffer);
644 for (vl = buffer->top_line; vl != NULL; vl = TAILQ_NEXT(vl, vlines)) {
645 if (vl->parent->flags & L_HIDDEN)
649 print_vline(off, width, win, vl);
651 if (vl == buffer->current_line)
663 for (; vl != NULL; vl = TAILQ_NEXT(vl, vlines)) {
664 if (vl == buffer->current_line)
666 if (vl->parent->flags & L_HIDDEN)
669 buffer->top_line = TAILQ_NEXT(buffer->top_line, vlines);
676 buffer->last_line_off = buffer->line_off;
677 buffer->force_redraw = 0;
679 wmove(win, buffer->curs_y, buffer->curs_x);
685 redraw_window(help, 0, help_lines, help_cols, &helpwin);
689 redraw_body(struct tab *tab)
691 static struct tab *last_tab;
694 tab->buffer.force_redraw =1;
697 redraw_window(body, x_offset, body_lines, body_cols, &tab->buffer);
701 trust_status_char(enum trust_state ts)
704 case TS_UNKNOWN: return '-';
705 case TS_UNTRUSTED: return '!';
706 case TS_TEMP_TRUSTED: return '!';
707 case TS_TRUSTED: return 'v';
708 case TS_VERIFIED: return 'V';
714 redraw_modeline(struct tab *tab)
716 struct buffer *buffer;
718 int x, y, max_x, max_y;
720 const char *spin = "-\\|/";
722 buffer = current_buffer();
723 mode = buffer->page.name;
726 wattr_on(modeline, modeline_face.background, NULL);
727 wmove(modeline, 0, 0);
729 wprintw(modeline, "-%c%c %s ",
730 spin[tab->loading_anim_step],
731 trust_status_char(tab->trust),
732 mode == NULL ? "(none)" : mode);
734 pct = (buffer->line_off + buffer->curs_y) * 100.0
737 if (buffer->line_max <= (size_t)body_lines)
738 wprintw(modeline, "All ");
739 else if (buffer->line_off == 0)
740 wprintw(modeline, "Top ");
741 else if (buffer->line_off + body_lines >= buffer->line_max)
742 wprintw(modeline, "Bottom ");
744 wprintw(modeline, "%.0f%% ", pct);
746 wprintw(modeline, "%d/%d %s ",
747 buffer->line_off + buffer->curs_y,
751 getyx(modeline, y, x);
752 getmaxyx(modeline, max_y, max_x);
757 for (; x < max_x; ++x)
758 waddstr(modeline, "-");
760 wattr_off(modeline, modeline_face.background, NULL);
764 redraw_minibuffer(void)
766 wattr_on(echoarea, minibuffer_face.background, NULL);
770 do_redraw_minibuffer();
772 do_redraw_echoarea();
774 if (in_minibuffer == MB_COMPREAD)
775 do_redraw_minibuffer_compl();
777 wattr_off(echoarea, minibuffer_face.background, NULL);
781 do_redraw_echoarea(void)
785 if (ministate.curmesg != NULL)
786 wprintw(echoarea, "%s", ministate.curmesg);
787 else if (*keybuf != '\0')
788 waddstr(echoarea, keybuf);
790 /* If nothing else, show the URL at point */
791 vl = current_tab->buffer.current_line;
792 if (vl != NULL && vl->parent->type == LINE_LINK)
793 waddstr(echoarea, vl->parent->alt);
798 do_redraw_minibuffer(void)
800 struct buffer *cmplbuf, *buffer;
801 size_t off_y, off_x = 0;
802 const char *start, *c;
804 cmplbuf = &ministate.compl.buffer;
805 buffer = &ministate.buffer;
806 (void)off_y; /* unused, set by getyx */
808 wmove(echoarea, 0, 0);
810 if (in_minibuffer == MB_COMPREAD)
811 wprintw(echoarea, "(%2d) ",
814 wprintw(echoarea, "%s", ministate.prompt);
815 if (ministate.hist_cur != NULL)
816 wprintw(echoarea, "(%zu/%zu) ",
817 ministate.hist_off + 1,
818 ministate.history->len);
820 getyx(echoarea, off_y, off_x);
822 start = ministate.hist_cur != NULL
823 ? ministate.hist_cur->h
825 c = utf8_nth(buffer->current_line->line, buffer->cpoff);
826 while (utf8_swidth_between(start, c) > (size_t)COLS/2) {
827 start = utf8_next_cp(start);
830 waddstr(echoarea, start);
832 if (ministate.curmesg != NULL)
833 wprintw(echoarea, " [%s]", ministate.curmesg);
835 wmove(echoarea, 0, off_x + utf8_swidth_between(start, c));
839 do_redraw_minibuffer_compl(void)
841 redraw_window(minibuffer, 0, 10, COLS,
842 &ministate.compl.buffer);
846 * Place the cursor in the right ncurses window. If soft is 1, use
847 * wnoutrefresh (which shouldn't cause any I/O); otherwise use
851 place_cursor(int soft)
853 int (*touch)(WINDOW *);
856 touch = wnoutrefresh;
865 } else if (in_side_window) {
878 redraw_tab(struct tab *tab)
890 redraw_modeline(tab);
893 wnoutrefresh(tabline);
894 wnoutrefresh(modeline);
896 if (in_minibuffer == MB_COMPREAD)
897 wnoutrefresh(minibuffer);
904 dprintf(1, "\033]0;%s - Telescope\a",
905 current_tab->buffer.page.title);
909 start_loading_anim(struct tab *tab)
911 if (tab->loading_anim)
913 tab->loading_anim = 1;
914 evtimer_set(&tab->loadingev, update_loading_anim, tab);
915 evtimer_add(&tab->loadingev, &loadingev_timer);
919 update_loading_anim(int fd, short ev, void *d)
923 tab->loading_anim_step = (tab->loading_anim_step+1)%4;
925 if (tab == current_tab) {
926 redraw_modeline(tab);
933 evtimer_add(&tab->loadingev, &loadingev_timer);
937 stop_loading_anim(struct tab *tab)
939 if (!tab->loading_anim)
941 evtimer_del(&tab->loadingev);
942 tab->loading_anim = 0;
943 tab->loading_anim_step = 0;
945 if (tab != current_tab)
948 redraw_modeline(tab);
957 load_url_in_tab(struct tab *tab, const char *url, const char *base, int nohist)
960 load_url(tab, url, base, nohist);
966 message("Loading %s...", url);
967 start_loading_anim(tab);
968 load_url(tab, url, base, nohist);
974 switch_to_tab(struct tab *tab)
977 tab->flags &= ~TAB_URGENT;
979 if (operating && tab->flags & TAB_LAZY)
980 load_url_in_tab(tab, tab->hist_cur->h, NULL, 0);
986 return tab_counter++;
990 new_tab(const char *url, const char *base, struct tab *after)
996 if ((tab = calloc(1, sizeof(*tab))) == NULL) {
1002 TAILQ_INIT(&tab->hist.head);
1004 TAILQ_INIT(&tab->buffer.head);
1005 TAILQ_INIT(&tab->buffer.page.head);
1007 tab->id = tab_new_id();
1009 tab->flags |= TAB_LAZY;
1013 TAILQ_INSERT_AFTER(&tabshead, after, tab, tabs);
1015 TAILQ_INSERT_TAIL(&tabshead, tab, tabs);
1017 load_url_in_tab(tab, url, base, 0);
1022 ui_print_colors(void)
1024 int colors = 0, pairs = 0, can_change = 0;
1025 int columns = 16, lines, color, i, j;
1030 use_default_colors();
1033 pairs = COLOR_PAIRS;
1034 can_change = can_change_color();
1038 printf("Term info:\n");
1039 printf("TERM=%s COLORS=%d COLOR_PAIRS=%d can_change_colors=%d\n",
1040 getenv("TERM"), colors, pairs, can_change);
1044 printf("No color support\n");
1048 printf("Available colors:\n\n");
1049 lines = (colors - 1) / columns + 1;
1051 for (i = 0; i < lines; ++i) {
1052 for (j = 0; j < columns; ++j, ++color) {
1053 printf("\033[0;38;5;%dm %03d", color, color);
1066 setlocale(LC_ALL, "");
1068 if (TAILQ_EMPTY(&global_map.m)) {
1069 fprintf(stderr, "no keys defined!\n");
1075 /* initialize help window */
1076 TAILQ_INIT(&helpwin.head);
1077 TAILQ_INIT(&helpwin.page.head);
1079 base_map = &global_map;
1080 current_map = &global_map;
1084 if (enable_colors) {
1087 use_default_colors();
1092 config_apply_style();
1097 intrflush(stdscr, FALSE);
1099 if ((tabline = newwin(1, COLS, 0, 0)) == NULL)
1101 if ((body = newwin(LINES - 3, COLS, 1, 0)) == NULL)
1103 if ((modeline = newwin(1, COLS, LINES-2, 0)) == NULL)
1105 if ((echoarea = newwin(1, COLS, LINES-1, 0)) == NULL)
1107 if ((minibuffer = newwin(1, COLS, LINES-1, 0)) == NULL)
1109 if ((help = newwin(1, 1, 1, 0)) == NULL)
1112 body_lines = LINES-3;
1115 wbkgd(body, body_face.body);
1116 wbkgd(echoarea, minibuffer_face.background);
1121 scrollok(body, FALSE);
1123 /* non-blocking input */
1127 mvwprintw(body, 0, 0, "");
1129 evtimer_set(&resizeev, handle_resize, NULL);
1131 event_set(&stdioev, 0, EV_READ | EV_PERSIST, dispatch_stdio, NULL);
1132 event_add(&stdioev, NULL);
1134 signal_set(&winchev, SIGWINCH, handle_resize, NULL);
1135 signal_add(&winchev, NULL);
1144 switch_to_tab(current_tab);
1145 redraw_tab(current_tab);
1151 ui_on_tab_loaded(struct tab *tab)
1153 stop_loading_anim(tab);
1154 message("Loaded %s", tab->hist_cur->h);
1162 ui_on_tab_refresh(struct tab *tab)
1164 wrap_page(&tab->buffer, body_cols);
1165 if (tab == current_tab)
1168 tab->flags |= TAB_URGENT;
1178 ui_toggle_side_window(void)
1180 side_window = !side_window;
1187 * ugly hack, but otherwise the window doesn't get updated
1188 * until I call rearrange_windows a second time (e.g. via
1189 * C-l). I will be happy to know why something like this is
1192 rearrange_windows();
1193 rearrange_windows();
1197 ui_schedule_redraw(void)
1199 should_rearrange_windows = 1;
1203 ui_require_input(struct tab *tab, int hide, int proto)
1207 if (proto == PROTO_GEMINI)
1208 fn = ir_select_gemini;
1209 else if (proto == PROTO_GOPHER)
1210 fn = ir_select_gopher;
1214 /* TODO: hard-switching to another tab is ugly */
1217 enter_minibuffer(sensible_self_insert, fn, exit_minibuffer,
1218 &ir_history, NULL, NULL);
1219 strlcpy(ministate.prompt, "Input required: ",
1220 sizeof(ministate.prompt));
1225 ui_after_message_hook(void)
1227 redraw_minibuffer();
1232 ui_yornp(const char *prompt, void (*fn)(int, struct tab *),
1235 yornp(prompt, fn, data);
1236 redraw_tab(current_tab);
1240 ui_read(const char *prompt, void (*fn)(const char*, struct tab *),
1243 minibuffer_read(prompt, fn, data);
1244 redraw_tab(current_tab);
1248 ui_other_window(void)
1251 in_side_window = !in_side_window;
1253 message("No other window to select");
1261 kill(getpid(), SIGSTOP);
1265 rearrange_windows();