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.
44 #include "minibuffer.h"
45 #include "telescope.h"
49 static struct event stdioev, winchev;
51 static void restore_curs_x(struct buffer *);
53 static struct vline *nth_line(struct buffer*, size_t);
54 static int readkey(void);
55 static void dispatch_stdio(int, short, void*);
56 static void handle_clear_echoarea(int, short, void*);
57 static void handle_resize(int, short, void*);
58 static void handle_resize_nodelay(int, short, void*);
59 static int wrap_page(struct buffer*, int);
60 static void print_vline(int, int, WINDOW*, struct vline*);
61 static void redraw_tabline(void);
62 static void redraw_window(WINDOW*, 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 place_cursor(int);
70 static void redraw_tab(struct tab*);
71 static void emit_help_item(char*, void*);
72 static void rec_compute_help(struct kmap*, char*, size_t);
73 static void recompute_help(void);
74 static void update_loading_anim(int, short, void*);
75 static void stop_loading_anim(struct tab*);
80 struct thiskey thiskey;
82 static struct event resizeev;
83 static struct timeval resize_timer = { 0, 250000 };
85 static WINDOW *tabline, *body, *modeline, *echoarea, *minibuffer;
87 int body_lines, body_cols;
90 static struct buffer helpwin;
91 static int help_lines, help_cols;
93 static int side_window;
95 static struct event clechoev;
96 static struct timeval clechoev_timer = { 5, 0 };
97 static struct timeval loadingev_timer = { 0, 250000 };
99 static uint32_t tab_counter;
101 static char keybuf[64];
103 struct kmap global_map,
111 update_x_offset(void)
113 if (olivetti_mode && fill_column < body_cols)
114 x_offset = (body_cols - fill_column)/2;
120 save_excursion(struct excursion *place, struct buffer *buffer)
122 place->curs_x = buffer->curs_x;
123 place->curs_y = buffer->curs_y;
124 place->line_off = buffer->line_off;
125 place->current_line = buffer->current_line;
126 place->cpoff = buffer->cpoff;
130 restore_excursion(struct excursion *place, struct buffer *buffer)
132 buffer->curs_x = place->curs_x;
133 buffer->curs_y = place->curs_y;
134 buffer->line_off = place->line_off;
135 buffer->current_line = place->current_line;
136 buffer->cpoff = place->cpoff;
140 restore_curs_x(struct buffer *buffer)
145 vl = buffer->current_line;
146 if (vl == NULL || vl->line == NULL)
147 buffer->curs_x = buffer->cpoff = 0;
149 buffer->curs_x = utf8_snwidth(vl->line, buffer->cpoff);
151 buffer->curs_x += x_offset;
154 prfx = line_prefixes[vl->parent->type].prfx1;
155 buffer->curs_x += utf8_swidth(prfx);
160 global_key_unbound(void)
162 message("%s is undefined", keybuf);
165 static struct vline *
166 nth_line(struct buffer *buffer, size_t n)
172 TAILQ_FOREACH(vl, &buffer->head, vlines) {
187 TAILQ_FOREACH(t, &tabshead, tabs) {
188 if (t->flags & TAB_CURRENT)
200 return &ministate.buffer;
201 return ¤t_tab()->buffer;
209 if ((thiskey.key = wgetch(body)) == ERR)
212 thiskey.meta = thiskey.key == 27;
214 thiskey.key = wgetch(body);
215 if (thiskey.key == ERR || thiskey.key == 27) {
222 if ((unsigned int)thiskey.key < UINT8_MAX) {
224 if (!utf8_decode(&state, &thiskey.cp, (uint8_t)thiskey.key))
226 if ((thiskey.key = wgetch(body)) == ERR) {
227 message("Error decoding user input");
237 dispatch_stdio(int fd, short ev, void *d)
243 /* TODO: schedule a redraw? */
250 if (keybuf[0] != '\0')
251 strlcat(keybuf, " ", sizeof(keybuf));
253 strlcat(keybuf, "M-", sizeof(keybuf));
254 if (thiskey.cp != 0) {
255 utf8_encode(thiskey.cp, tmp);
256 strlcat(keybuf, tmp, sizeof(keybuf));
258 if ((keyname = unkbd(thiskey.key)) != NULL)
259 strlcat(keybuf, keyname, sizeof(keybuf));
261 tmp[0] = thiskey.key;
262 strlcat(keybuf, tmp, sizeof(keybuf));
266 TAILQ_FOREACH(k, ¤t_map->m, keymaps) {
267 if (k->meta == thiskey.meta &&
268 k->key == thiskey.key) {
270 current_map = &k->map;
272 current_map = base_map;
273 strlcpy(keybuf, "", sizeof(keybuf));
274 k->fn(current_buffer());
280 if (current_map->unhandled_input != NULL)
281 current_map->unhandled_input();
283 global_key_unbound();
285 strlcpy(keybuf, "", sizeof(keybuf));
286 current_map = base_map;
292 redraw_tab(current_tab());
296 handle_clear_echoarea(int fd, short ev, void *d)
298 free(ministate.curmesg);
299 ministate.curmesg = NULL;
306 handle_resize(int sig, short ev, void *d)
308 if (event_pending(&resizeev, EV_TIMEOUT, NULL)) {
309 event_del(&resizeev);
311 evtimer_set(&resizeev, handle_resize_nodelay, NULL);
312 evtimer_add(&resizeev, &resize_timer);
316 handle_resize_nodelay(int s, short ev, void *d)
327 if ((too_small = lines < 15)) {
329 printw("Window too small.");
334 /* move and resize the windows, in reverse order! */
336 mvwin(echoarea, --lines, 0);
337 wresize(echoarea, 1, COLS);
339 mvwin(modeline, --lines, 0);
340 wresize(modeline, 1, COLS);
342 body_lines = --lines;
346 help_cols = 0.3 * COLS;
349 wresize(help, help_lines, help_cols);
351 wrap_page(&helpwin, help_cols);
353 body_cols = COLS - help_cols - 1;
354 mvwin(body, 1, help_cols);
359 wresize(body, body_lines, body_cols);
361 wresize(tabline, 1, COLS);
365 wrap_page(&tab->buffer, body_cols);
370 wrap_page(struct buffer *buffer, int width)
373 const struct line *top_orig, *orig;
378 top_orig = buffer->top_line == NULL ? NULL : buffer->top_line->parent;
379 orig = buffer->current_line == NULL ? NULL : buffer->current_line->parent;
381 buffer->top_line = NULL;
382 buffer->current_line = NULL;
384 buffer->force_redraw = 1;
386 buffer->line_off = 0;
390 TAILQ_FOREACH(l, &buffer->page.head, lines) {
391 prfx = line_prefixes[l->type].prfx1;
402 wrap_text(buffer, prfx, l, MIN(fill_column, width));
404 case LINE_PRE_CONTENT:
406 pre_width = MIN(fill_column, width);
409 hardwrap_text(buffer, l, pre_width);
413 if (top_orig == l && buffer->top_line == NULL) {
414 buffer->line_off = buffer->line_max-1;
415 buffer->top_line = TAILQ_LAST(&buffer->head, vhead);
418 vl = TAILQ_PREV(buffer->top_line, vhead, vlines);
419 if (vl == NULL || vl->parent != orig)
421 buffer->top_line = vl;
426 if (orig == l && buffer->current_line == NULL) {
427 buffer->current_line = TAILQ_LAST(&buffer->head, vhead);
430 vl = TAILQ_PREV(buffer->current_line, vhead, vlines);
431 if (vl == NULL || vl->parent != orig)
433 buffer->current_line = vl;
438 if (buffer->current_line == NULL)
439 buffer->current_line = TAILQ_FIRST(&buffer->head);
441 if (buffer->top_line == NULL)
442 buffer->top_line = buffer->current_line;
448 print_vline(int off, int width, WINDOW *window, struct vline *vl)
455 f = &line_faces[vl->parent->type];
457 /* unused, set by getyx */
461 prfx = line_prefixes[vl->parent->type].prfx1;
463 prfx = line_prefixes[vl->parent->type].prfx2;
469 wattr_on(window, body_face.left, NULL);
470 for (i = 0; i < off; i++)
472 wattr_off(window, body_face.left, NULL);
474 wattr_on(window, f->prefix, NULL);
475 wprintw(window, "%s", prfx);
476 wattr_off(window, f->prefix, NULL);
478 wattr_on(window, f->text, NULL);
479 wprintw(window, "%s", text);
480 wattr_off(window, f->text, NULL);
486 wattr_on(window, f->trail, NULL);
487 for (i = 0; i < left - off; ++i)
489 wattr_off(window, f->trail, NULL);
491 wattr_on(window, body_face.right, NULL);
492 for (i = 0; i < off; i++)
494 wattr_off(window, body_face.right, NULL);
502 size_t toskip, ots, tabwidth, space, x;
503 int current, y, truncated;
509 /* unused, but setted by a getyx */
512 tabwidth = sizeof(buf)+1;
516 TAILQ_FOREACH(tab, &tabshead, tabs) {
518 if (tab->flags & TAB_CURRENT)
522 if (toskip * tabwidth < space)
527 while (toskip != 0 &&
528 (ots - toskip+1) * tabwidth < space)
533 wattr_on(tabline, tab_face.background, NULL);
534 wprintw(tabline, toskip == 0 ? " " : "<");
535 wattr_off(tabline, tab_face.background, NULL);
538 TAILQ_FOREACH(tab, &tabshead, tabs) {
546 getyx(tabline, y, x);
547 if (x + sizeof(buf)+2 >= (size_t)COLS)
550 current = tab->flags & TAB_CURRENT;
552 if (*(title = tab->buffer.page.title) == '\0')
553 title = tab->hist_cur->h;
555 if (tab->flags & TAB_URGENT)
556 strlcpy(buf, "!", sizeof(buf));
558 strlcpy(buf, " ", sizeof(buf));
560 if (strlcat(buf, title, sizeof(buf)) >= sizeof(buf)) {
561 /* truncation happens */
562 strlcpy(&buf[sizeof(buf)-4], "...", 4);
564 /* pad with spaces */
565 while (strlcat(buf, " ", sizeof(buf)) < sizeof(buf))
570 wattr_on(tabline, tab_face.current, NULL);
572 wattr_on(tabline, tab_face.tab, NULL);
574 wprintw(tabline, "%s", buf);
575 if (TAILQ_NEXT(tab, tabs) != NULL)
576 wprintw(tabline, " ");
579 wattr_off(tabline, tab_face.current, NULL);
581 wattr_off(tabline, tab_face.tab, NULL);
584 wattr_on(tabline, tab_face.background, NULL);
585 for (; x < (size_t)COLS; ++x)
586 waddch(tabline, ' ');
588 mvwprintw(tabline, 0, COLS-1, ">");
589 wattr_off(tabline, tab_face.background, NULL);
593 * Compute the first visible line around vl. Try to search forward
594 * until the end of the buffer; if a visible line is not found, search
595 * backward. Return NULL if no viable line was found.
597 static inline struct vline *
598 adjust_line(struct vline *vl, struct buffer *buffer)
602 if (!(vl->parent->flags & L_HIDDEN))
607 t != NULL && t->parent->flags & L_HIDDEN;
608 t = TAILQ_NEXT(t, vlines))
614 /* search backward */
616 t != NULL && t->parent->flags & L_HIDDEN;
617 t = TAILQ_PREV(t, vhead, vlines))
624 redraw_window(WINDOW *win, int height, int width, struct buffer *buffer)
629 restore_curs_x(buffer);
632 * TODO: ignoring buffer->force_update and always
633 * re-rendering. In theory we can recompute the y position
634 * without a re-render, and optimize here. It's not the only
635 * optimisation possible here, wscrl wolud also be an
643 if (TAILQ_EMPTY(&buffer->head))
646 buffer->top_line = adjust_line(buffer->top_line, buffer);
647 if (buffer->top_line == NULL)
650 buffer->current_line = adjust_line(buffer->current_line, buffer);
654 for (vl = buffer->top_line; vl != NULL; vl = TAILQ_NEXT(vl, vlines)) {
655 if (vl->parent->flags & L_HIDDEN)
659 print_vline(x_offset, width, win, vl);
661 if (vl == buffer->current_line)
673 for (; vl != NULL; vl = TAILQ_NEXT(vl, vlines)) {
674 if (vl == buffer->current_line)
676 if (vl->parent->flags & L_HIDDEN)
679 buffer->top_line = TAILQ_NEXT(buffer->top_line, vlines);
685 buffer->last_line_off = buffer->line_off;
686 buffer->force_redraw = 0;
688 wmove(win, buffer->curs_y, buffer->curs_x);
694 redraw_window(help, help_lines, help_cols, &helpwin);
698 redraw_body(struct tab *tab)
700 static struct tab *last_tab;
703 tab->buffer.force_redraw =1;
706 redraw_window(body, body_lines, body_cols, &tab->buffer);
710 trust_status_char(enum trust_state ts)
713 case TS_UNKNOWN: return 'u';
714 case TS_UNTRUSTED: return '!';
715 case TS_TEMP_TRUSTED: return '!';
716 case TS_TRUSTED: return 'v';
717 case TS_VERIFIED: return 'V';
723 redraw_modeline(struct tab *tab)
726 int x, y, max_x, max_y;
727 const char *mode = tab->buffer.page.name;
728 const char *spin = "-\\|/";
731 wattr_on(modeline, modeline_face.background, NULL);
732 wmove(modeline, 0, 0);
734 wprintw(modeline, "-%c%c %s ",
735 spin[tab->loading_anim_step],
736 trust_status_char(tab->trust),
737 mode == NULL ? "(none)" : mode);
739 pct = (tab->buffer.line_off + tab->buffer.curs_y) * 100.0 / tab->buffer.line_max;
741 if (tab->buffer.line_max <= (size_t)body_lines)
742 wprintw(modeline, "All ");
743 else if (tab->buffer.line_off == 0)
744 wprintw(modeline, "Top ");
745 else if (tab->buffer.line_off + body_lines >= tab->buffer.line_max)
746 wprintw(modeline, "Bottom ");
748 wprintw(modeline, "%.0f%% ", pct);
750 wprintw(modeline, "%d/%d %s ",
751 tab->buffer.line_off + tab->buffer.curs_y,
752 tab->buffer.line_max,
755 getyx(modeline, y, x);
756 getmaxyx(modeline, max_y, max_x);
761 for (; x < max_x; ++x)
762 waddstr(modeline, "-");
764 wattr_off(modeline, modeline_face.background, NULL);
768 redraw_minibuffer(void)
770 wattr_on(echoarea, minibuffer_face.background, NULL);
774 do_redraw_minibuffer();
776 do_redraw_echoarea();
778 wattr_off(echoarea, minibuffer_face.background, NULL);
782 do_redraw_echoarea(void)
786 if (ministate.curmesg != NULL)
787 wprintw(echoarea, "%s", ministate.curmesg);
788 else if (*keybuf != '\0')
789 waddstr(echoarea, keybuf);
791 /* If nothing else, show the URL at point */
793 if (tab->buffer.current_line != NULL &&
794 tab->buffer.current_line->parent->type == LINE_LINK)
795 waddstr(echoarea, tab->buffer.current_line->parent->alt);
800 do_redraw_minibuffer(void)
802 size_t off_y, off_x = 0;
803 const char *start, *c;
805 /* unused, set by getyx */
808 mvwprintw(echoarea, 0, 0, "%s", ministate.prompt);
809 if (ministate.hist_cur != NULL)
810 wprintw(echoarea, "(%zu/%zu) ",
811 ministate.hist_off + 1,
812 ministate.history->len);
814 getyx(echoarea, off_y, off_x);
816 start = ministate.hist_cur != NULL
817 ? ministate.hist_cur->h
819 c = utf8_nth(ministate.buffer.current_line->line,
820 ministate.buffer.cpoff);
821 while (utf8_swidth_between(start, c) > (size_t)COLS/2) {
822 start = utf8_next_cp(start);
825 waddstr(echoarea, start);
827 if (ministate.curmesg != NULL)
828 wprintw(echoarea, " [%s]", ministate.curmesg);
830 wmove(echoarea, 0, off_x + utf8_swidth_between(start, c));
834 * Place the cursor in the right ncurses window. If soft is 1, use
835 * wnoutrefresh (which shouldn't cause any I/O); otherwise use
839 place_cursor(int soft)
841 int (*touch)(WINDOW *);
844 touch = wnoutrefresh;
858 redraw_tab(struct tab *tab)
870 redraw_modeline(tab);
873 wnoutrefresh(tabline);
874 wnoutrefresh(modeline);
882 emit_help_item(char *prfx, void *fn)
887 for (cmd = cmds; cmd->cmd != NULL; ++cmd) {
893 if ((l = calloc(1, sizeof(*l))) == NULL)
899 asprintf(&l->line, "%s %s", prfx, cmd->cmd);
901 if (TAILQ_EMPTY(&helpwin.page.head))
902 TAILQ_INSERT_HEAD(&helpwin.page.head, l, lines);
904 TAILQ_INSERT_TAIL(&helpwin.page.head, l, lines);
908 rec_compute_help(struct kmap *keymap, char *prfx, size_t len)
914 TAILQ_FOREACH(k, &keymap->m, keymaps) {
915 strlcpy(p, prfx, sizeof(p));
917 strlcat(p, " ", sizeof(p));
919 strlcat(p, "M-", sizeof(p));
920 if ((kn = unkbd(k->key)) != NULL)
921 strlcat(p, kn, sizeof(p));
923 strlcat(p, keyname(k->key), sizeof(p));
926 rec_compute_help(&k->map, p, sizeof(p));
928 emit_help_item(p, k->fn);
937 empty_vlist(&helpwin);
938 empty_linelist(&helpwin);
939 rec_compute_help(current_map, p, sizeof(p));
940 wrap_page(&helpwin, help_cols);
944 vmessage(const char *fmt, va_list ap)
946 if (evtimer_pending(&clechoev, NULL))
947 evtimer_del(&clechoev);
949 free(ministate.curmesg);
950 ministate.curmesg = NULL;
953 evtimer_set(&clechoev, handle_clear_echoarea, NULL);
954 evtimer_add(&clechoev, &clechoev_timer);
956 /* TODO: what to do if the allocation fails here? */
957 if (vasprintf(&ministate.curmesg, fmt, ap) == -1)
958 ministate.curmesg = NULL;
966 message(const char *fmt, ...)
976 start_loading_anim(struct tab *tab)
978 if (tab->loading_anim)
980 tab->loading_anim = 1;
981 evtimer_set(&tab->loadingev, update_loading_anim, tab);
982 evtimer_add(&tab->loadingev, &loadingev_timer);
986 update_loading_anim(int fd, short ev, void *d)
990 tab->loading_anim_step = (tab->loading_anim_step+1)%4;
992 if (tab->flags & TAB_CURRENT) {
993 redraw_modeline(tab);
1000 evtimer_add(&tab->loadingev, &loadingev_timer);
1004 stop_loading_anim(struct tab *tab)
1006 if (!tab->loading_anim)
1008 evtimer_del(&tab->loadingev);
1009 tab->loading_anim = 0;
1010 tab->loading_anim_step = 0;
1012 if (!(tab->flags & TAB_CURRENT))
1015 redraw_modeline(tab);
1024 load_url_in_tab(struct tab *tab, const char *url)
1026 message("Loading %s...", url);
1027 start_loading_anim(tab);
1030 tab->buffer.curs_x = 0;
1031 tab->buffer.curs_y = 0;
1036 switch_to_tab(struct tab *tab)
1040 TAILQ_FOREACH(t, &tabshead, tabs) {
1041 t->flags &= ~TAB_CURRENT;
1044 tab->flags |= TAB_CURRENT;
1045 tab->flags &= ~TAB_URGENT;
1051 return tab_counter++;
1055 new_tab(const char *url)
1059 if ((tab = calloc(1, sizeof(*tab))) == NULL) {
1065 TAILQ_INIT(&tab->hist.head);
1067 TAILQ_INIT(&tab->buffer.head);
1069 tab->id = tab_new_id();
1072 if (TAILQ_EMPTY(&tabshead))
1073 TAILQ_INSERT_HEAD(&tabshead, tab, tabs);
1075 TAILQ_INSERT_TAIL(&tabshead, tab, tabs);
1077 load_url_in_tab(tab, url);
1084 setlocale(LC_ALL, "");
1086 TAILQ_INIT(&eecmd_history.head);
1087 TAILQ_INIT(&ir_history.head);
1088 TAILQ_INIT(&lu_history.head);
1090 ministate.line.type = LINE_TEXT;
1091 ministate.vline.parent = &ministate.line;
1092 ministate.buffer.current_line = &ministate.vline;
1094 /* initialize help window */
1095 TAILQ_INIT(&helpwin.head);
1097 base_map = &global_map;
1098 current_map = &global_map;
1102 if (enable_colors) {
1105 use_default_colors();
1110 config_apply_style();
1115 intrflush(stdscr, FALSE);
1117 if ((tabline = newwin(1, COLS, 0, 0)) == NULL)
1119 if ((body = newwin(LINES - 3, COLS, 1, 0)) == NULL)
1121 if ((modeline = newwin(1, COLS, LINES-2, 0)) == NULL)
1123 if ((echoarea = newwin(1, COLS, LINES-1, 0)) == NULL)
1125 if ((minibuffer = newwin(1, COLS, LINES-1, 0)) == NULL)
1127 if ((help = newwin(1, 1, 1, 0)) == NULL)
1130 body_lines = LINES-3;
1133 wbkgd(body, body_face.body);
1134 wbkgd(echoarea, minibuffer_face.background);
1139 scrollok(body, FALSE);
1141 /* non-blocking input */
1144 mvwprintw(body, 0, 0, "");
1146 event_set(&stdioev, 0, EV_READ | EV_PERSIST, dispatch_stdio, NULL);
1147 event_add(&stdioev, NULL);
1149 signal_set(&winchev, SIGWINCH, handle_resize, NULL);
1150 signal_add(&winchev, NULL);
1156 ui_on_tab_loaded(struct tab *tab)
1158 stop_loading_anim(tab);
1159 message("Loaded %s", tab->hist_cur->h);
1167 ui_on_tab_refresh(struct tab *tab)
1169 wrap_page(&tab->buffer, body_cols);
1170 if (tab->flags & TAB_CURRENT)
1173 tab->flags |= TAB_URGENT;
1183 ui_toggle_side_window(void)
1185 side_window = !side_window;
1190 * ugly hack, but otherwise the window doesn't get updated
1191 * until I call handle_resize a second time (i.e. C-l). I
1192 * will be happy to know why something like this is needed.
1194 handle_resize_nodelay(0, 0, NULL);
1195 handle_resize_nodelay(0, 0, NULL);
1199 ui_schedule_redraw(void)
1201 handle_resize_nodelay(0, 0, NULL);
1205 ui_require_input(struct tab *tab, int hide)
1207 /* TODO: hard-switching to another tab is ugly */
1210 enter_minibuffer(ir_self_insert, ir_select, exit_minibuffer,
1211 &ir_history, NULL, NULL);
1212 strlcpy(ministate.prompt, "Input required: ",
1213 sizeof(ministate.prompt));
1218 ui_yornp(const char *prompt, void (*fn)(int, struct tab *),
1221 yornp(prompt, fn, data);
1222 redraw_tab(current_tab());
1226 ui_read(const char *prompt, void (*fn)(const char*, struct tab *),
1229 completing_read(prompt, fn, data, NULL, NULL);
1230 redraw_tab(current_tab());