2 84b88039 2021-07-12 op * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
4 84b88039 2021-07-12 op * Permission to use, copy, modify, and distribute this software for any
5 84b88039 2021-07-12 op * purpose with or without fee is hereby granted, provided that the above
6 84b88039 2021-07-12 op * copyright notice and this permission notice appear in all copies.
8 84b88039 2021-07-12 op * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 84b88039 2021-07-12 op * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 84b88039 2021-07-12 op * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 84b88039 2021-07-12 op * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 84b88039 2021-07-12 op * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 84b88039 2021-07-12 op * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 84b88039 2021-07-12 op * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 4bc446b9 2021-07-21 op #include "compat.h"
19 4bc446b9 2021-07-21 op #include <stdio.h>
20 84b88039 2021-07-12 op #include <stdlib.h>
21 84b88039 2021-07-12 op #include <string.h>
23 450a89f7 2021-07-12 op #include "minibuffer.h"
24 1fce2e75 2021-08-14 op #include "session.h"
25 d1a0f2a3 2021-07-12 op #include "ui.h"
26 5caf7d67 2021-07-12 op #include "utf8.h"
27 9d65b1d9 2022-01-11 op #include "utils.h"
29 eefb3de5 2022-02-26 op #define nitems(x) (sizeof(x)/sizeof(x[0]))
31 d7ee7b5e 2021-07-15 op static void *minibuffer_metadata(void);
32 7bd3a14b 2022-04-13 op static const char *minibuffer_compl_text(void);
33 84b88039 2021-07-12 op static void minibuffer_hist_save_entry(void);
34 84b88039 2021-07-12 op static void yornp_self_insert(void);
35 84b88039 2021-07-12 op static void yornp_abort(void);
36 84b88039 2021-07-12 op static void read_self_insert(void);
37 84b88039 2021-07-12 op static void read_abort(void);
38 84b88039 2021-07-12 op static void read_select(void);
39 4bc446b9 2021-07-21 op static void handle_clear_echoarea(int, short, void *);
41 4bc446b9 2021-07-21 op static struct event clechoev;
42 4bc446b9 2021-07-21 op static struct timeval clechoev_timer = { 5, 0 };
44 84b88039 2021-07-12 op static void (*yornp_cb)(int, struct tab *);
45 84b88039 2021-07-12 op static struct tab *yornp_data;
47 d1353324 2021-07-13 op static void (*read_cb)(const char*, struct tab *);
48 d1353324 2021-07-13 op static struct tab *read_data;
50 78894e73 2021-08-12 op /* XXX: don't forget to init these in minibuffer_init */
51 84b88039 2021-07-12 op struct histhead eecmd_history,
56 84b88039 2021-07-12 op struct ministate ministate;
58 b1e1e41a 2021-07-14 op struct buffer minibufferwin;
60 54ee0a94 2021-07-21 op int in_minibuffer;
62 eefb3de5 2022-02-26 op static inline int
63 eefb3de5 2022-02-26 op matches(char **words, size_t len, struct line *l)
68 eefb3de5 2022-02-26 op for (i = 0; i < len; ++i) {
71 eefb3de5 2022-02-26 op if (strcasestr(l->line, words[i]) != NULL)
73 eefb3de5 2022-02-26 op if (l->alt != NULL &&
74 eefb3de5 2022-02-26 op strcasestr(l->alt, words[i]) != NULL)
77 eefb3de5 2022-02-26 op if (!lm && !am)
85 b1e1e41a 2021-07-14 op * Recompute the visible completions. If add is 1, don't consider the
86 b1e1e41a 2021-07-14 op * ones already hidden.
89 b1e1e41a 2021-07-14 op recompute_completions(int add)
91 eefb3de5 2022-02-26 op static char buf[GEMINI_URL_LEN];
92 eefb3de5 2022-02-26 op char *input, **ap, *words[10];
93 eefb3de5 2022-02-26 op size_t len = 0;
94 b1e1e41a 2021-07-14 op struct line *l;
95 e7b982f4 2021-07-14 op struct buffer *b;
97 b1e1e41a 2021-07-14 op if (in_minibuffer != MB_COMPREAD)
100 eefb3de5 2022-02-26 op strlcpy(buf, ministate.buf, sizeof(buf));
103 eefb3de5 2022-02-26 op /* tokenize the input */
104 eefb3de5 2022-02-26 op for (ap = words; ap < words + nitems(words) &&
105 eefb3de5 2022-02-26 op (*ap = strsep(&input, " ")) != NULL;) {
106 eefb3de5 2022-02-26 op if (**ap != '\0')
110 e7b982f4 2021-07-14 op b = &ministate.compl.buffer;
111 e7b982f4 2021-07-14 op TAILQ_FOREACH(l, &b->page.head, lines) {
112 e7b982f4 2021-07-14 op l->type = LINE_COMPL;
113 b1e1e41a 2021-07-14 op if (add && l->flags & L_HIDDEN)
115 eefb3de5 2022-02-26 op if (matches(words, len, l)) {
116 5977965a 2021-07-15 op if (l->flags & L_HIDDEN)
117 5977965a 2021-07-15 op b->line_max++;
118 b1e1e41a 2021-07-14 op l->flags &= ~L_HIDDEN;
120 5977965a 2021-07-15 op if (!(l->flags & L_HIDDEN))
121 5977965a 2021-07-15 op b->line_max--;
122 b1e1e41a 2021-07-14 op l->flags |= L_HIDDEN;
126 e7b982f4 2021-07-14 op if (b->current_line == NULL)
127 e7b982f4 2021-07-14 op b->current_line = TAILQ_FIRST(&b->head);
128 e7b982f4 2021-07-14 op b->current_line = adjust_line(b->current_line, b);
132 16578ca5 2021-01-02 op minibuffer_insert_current_candidate(void)
134 16578ca5 2021-01-02 op struct vline *vl;
136 16578ca5 2021-01-02 op vl = ministate.compl.buffer.current_line;
137 16578ca5 2021-01-02 op if (vl == NULL || vl->parent->flags & L_HIDDEN)
140 16578ca5 2021-01-02 op minibuffer_taint_hist();
141 16578ca5 2021-01-02 op strlcpy(ministate.buf, vl->parent->line, sizeof(ministate.buf));
142 16578ca5 2021-01-02 op ministate.buffer.cpoff = utf8_cplen(ministate.buf);
147 d7ee7b5e 2021-07-15 op static void *
148 d7ee7b5e 2021-07-15 op minibuffer_metadata(void)
150 d7ee7b5e 2021-07-15 op struct vline *vl;
152 d7ee7b5e 2021-07-15 op vl = ministate.compl.buffer.current_line;
154 d7ee7b5e 2021-07-15 op if (vl == NULL || vl->parent->flags & L_HIDDEN)
157 fbadd395 2021-07-16 op return vl->parent->data;
160 7bd3a14b 2022-04-13 op static const char *
161 7bd3a14b 2022-04-13 op minibuffer_compl_text(void)
163 7bd3a14b 2022-04-13 op struct vline *vl;
165 7bd3a14b 2022-04-13 op vl = ministate.compl.buffer.current_line;
166 7bd3a14b 2022-04-13 op if (vl == NULL || vl->parent->flags & L_HIDDEN ||
167 7bd3a14b 2022-04-13 op vl->parent->type == LINE_COMPL || vl->parent->line == NULL)
168 7bd3a14b 2022-04-13 op return ministate.buf;
169 7bd3a14b 2022-04-13 op return vl->parent->line;
173 84b88039 2021-07-12 op minibuffer_hist_save_entry(void)
175 84b88039 2021-07-12 op struct hist *hist;
176 7bd3a14b 2022-04-13 op const char *t;
178 84b88039 2021-07-12 op if (ministate.history == NULL)
181 84b88039 2021-07-12 op if ((hist = calloc(1, sizeof(*hist))) == NULL)
184 7bd3a14b 2022-04-13 op t = minibuffer_compl_text();
185 7bd3a14b 2022-04-13 op strlcpy(hist->h, t, sizeof(hist->h));
187 32ac17a4 2021-08-12 op TAILQ_INSERT_TAIL(&ministate.history->head, hist, entries);
188 84b88039 2021-07-12 op ministate.history->len++;
192 84b88039 2021-07-12 op * taint the minibuffer cache: if we're currently showing a history
193 84b88039 2021-07-12 op * element, copy that to the current buf and reset the "history
194 84b88039 2021-07-12 op * navigation" thing.
197 84b88039 2021-07-12 op minibuffer_taint_hist(void)
199 84b88039 2021-07-12 op if (ministate.hist_cur == NULL)
202 84b88039 2021-07-12 op strlcpy(ministate.buf, ministate.hist_cur->h, sizeof(ministate.buf));
203 84b88039 2021-07-12 op ministate.hist_cur = NULL;
204 19f7f20c 2021-07-12 op ministate.buffer.current_line->line = ministate.buf;
208 84b88039 2021-07-12 op minibuffer_self_insert(void)
210 84b88039 2021-07-12 op char *c, tmp[5] = {0};
213 84b88039 2021-07-12 op minibuffer_taint_hist();
215 84b88039 2021-07-12 op if (thiskey.cp == 0)
218 84b88039 2021-07-12 op len = utf8_encode(thiskey.cp, tmp);
219 84b88039 2021-07-12 op c = utf8_nth(ministate.buffer.current_line->line, ministate.buffer.cpoff);
220 84b88039 2021-07-12 op if (c + len > ministate.buf + sizeof(ministate.buf) - 1)
223 84b88039 2021-07-12 op memmove(c + len, c, strlen(c)+1);
224 84b88039 2021-07-12 op memcpy(c, tmp, len);
225 84b88039 2021-07-12 op ministate.buffer.cpoff++;
227 b1e1e41a 2021-07-14 op recompute_completions(1);
231 40fbc354 2021-07-14 op sensible_self_insert(void)
233 e8c9de1e 2021-07-20 op if (thiskey.meta ||
234 85c820b8 2021-07-24 op (!unicode_isgraph(thiskey.key) && thiskey.key != ' ')) {
235 84b88039 2021-07-12 op global_key_unbound();
239 84b88039 2021-07-12 op minibuffer_self_insert();
243 84b88039 2021-07-12 op eecmd_select(void)
245 16578ca5 2021-01-02 op struct cmd *cmd;
246 16578ca5 2021-01-02 op const char *t;
248 7bd3a14b 2022-04-13 op t = minibuffer_compl_text();
249 84b88039 2021-07-12 op for (cmd = cmds; cmd->cmd != NULL; ++cmd) {
250 16578ca5 2021-01-02 op if (!strcmp(cmd->cmd, t)) {
251 16578ca5 2021-01-02 op minibuffer_insert_current_candidate();
252 84b88039 2021-07-12 op minibuffer_hist_save_entry();
253 7bd3a14b 2022-04-13 op exit_minibuffer();
254 84b88039 2021-07-12 op cmd->fn(current_buffer());
259 84b88039 2021-07-12 op message("No match");
263 9a28e7e5 2021-08-03 op ir_select_gemini(void)
265 84b88039 2021-07-12 op char buf[1025] = {0};
266 84b88039 2021-07-12 op struct phos_uri uri;
267 83dce83d 2021-07-17 op struct tab *tab = current_tab;
269 84b88039 2021-07-12 op minibuffer_hist_save_entry();
271 84b88039 2021-07-12 op /* a bit ugly but... */
272 84b88039 2021-07-12 op memcpy(&uri, &tab->uri, sizeof(tab->uri));
273 7bd3a14b 2022-04-13 op phos_uri_set_query(&uri, minibuffer_compl_text());
274 ed504b9e 2022-02-07 op phos_serialize_uri(&uri, buf, sizeof(buf));
276 7bd3a14b 2022-04-13 op exit_minibuffer();
277 ed504b9e 2022-02-07 op load_url_in_tab(tab, buf, NULL, LU_MODE_NOCACHE);
281 ed504b9e 2022-02-07 op ir_select_reply(void)
283 ed504b9e 2022-02-07 op char buf[1025] = {0};
284 ed504b9e 2022-02-07 op struct phos_uri uri;
285 ed504b9e 2022-02-07 op struct tab *tab = current_tab;
287 ed504b9e 2022-02-07 op minibuffer_hist_save_entry();
289 ed504b9e 2022-02-07 op /* a bit ugly but... */
290 ed504b9e 2022-02-07 op strlcpy(buf, tab->last_input_url, sizeof(buf));
291 ed504b9e 2022-02-07 op phos_parse_absolute_uri(buf, &uri);
292 7bd3a14b 2022-04-13 op phos_uri_set_query(&uri, minibuffer_compl_text());
293 84b88039 2021-07-12 op phos_serialize_uri(&uri, buf, sizeof(buf));
295 7bd3a14b 2022-04-13 op exit_minibuffer();
296 ed21a9a1 2022-01-11 op load_url_in_tab(tab, buf, NULL, LU_MODE_NOCACHE);
300 9a28e7e5 2021-08-03 op ir_select_gopher(void)
302 9a28e7e5 2021-08-03 op minibuffer_hist_save_entry();
303 7bd3a14b 2022-04-13 op gopher_send_search_req(current_tab, minibuffer_compl_text());
304 7bd3a14b 2022-04-13 op exit_minibuffer();
308 84b88039 2021-07-12 op lu_select(void)
310 c6efff96 2021-08-16 op char url[GEMINI_URL_LEN+1];
312 84b88039 2021-07-12 op minibuffer_hist_save_entry();
313 7bd3a14b 2022-04-13 op humanify_url(minibuffer_compl_text(), url, sizeof(url));
314 7bd3a14b 2022-04-13 op exit_minibuffer();
315 ed21a9a1 2022-01-11 op load_url_in_tab(current_tab, url, NULL, LU_MODE_NOCACHE);
319 84b88039 2021-07-12 op bp_select(void)
321 84b88039 2021-07-12 op exit_minibuffer();
322 84b88039 2021-07-12 op if (*ministate.buf != '\0')
323 84b88039 2021-07-12 op add_to_bookmarks(ministate.buf);
325 84b88039 2021-07-12 op message("Abort.");
329 65601367 2021-07-14 op ts_select(void)
331 65601367 2021-07-14 op struct tab *tab;
333 d7ee7b5e 2021-07-15 op if ((tab = minibuffer_metadata()) == NULL) {
334 65601367 2021-07-14 op message("No tab selected");
338 65601367 2021-07-14 op exit_minibuffer();
339 65601367 2021-07-14 op switch_to_tab(tab);
343 753c6ac7 2021-07-14 op ls_select(void)
345 753c6ac7 2021-07-14 op struct line *l;
347 d7ee7b5e 2021-07-15 op if ((l = minibuffer_metadata()) == NULL) {
348 753c6ac7 2021-07-14 op message("No link selected");
352 753c6ac7 2021-07-14 op exit_minibuffer();
353 ed21a9a1 2022-01-11 op load_url_in_tab(current_tab, l->alt, NULL, LU_MODE_NOCACHE);
356 d7ee7b5e 2021-07-15 op static inline void
357 d7ee7b5e 2021-07-15 op jump_to_line(struct line *l)
359 753c6ac7 2021-07-14 op struct vline *vl;
360 5924d8d2 2021-07-21 op struct buffer *buffer;
362 5924d8d2 2021-07-21 op buffer = current_buffer();
364 5924d8d2 2021-07-21 op TAILQ_FOREACH(vl, &buffer->head, vlines) {
365 753c6ac7 2021-07-14 op if (vl->parent == l)
369 753c6ac7 2021-07-14 op if (vl == NULL)
370 d7ee7b5e 2021-07-15 op message("Ops, %s error! Please report to %s",
371 d7ee7b5e 2021-07-15 op __func__, PACKAGE_BUGREPORT);
373 5924d8d2 2021-07-21 op buffer->top_line = vl;
374 5924d8d2 2021-07-21 op buffer->current_line = vl;
379 d7ee7b5e 2021-07-15 op swiper_select(void)
381 edd9a650 2021-07-15 op struct line *l;
383 edd9a650 2021-07-15 op if ((l = minibuffer_metadata()) == NULL) {
384 edd9a650 2021-07-15 op message("No line selected");
388 edd9a650 2021-07-15 op exit_minibuffer();
389 edd9a650 2021-07-15 op jump_to_line(l);
393 edd9a650 2021-07-15 op toc_select(void)
395 d7ee7b5e 2021-07-15 op struct line *l;
397 d7ee7b5e 2021-07-15 op if ((l = minibuffer_metadata()) == NULL) {
398 d7ee7b5e 2021-07-15 op message("No line selected");
402 d7ee7b5e 2021-07-15 op exit_minibuffer();
403 d7ee7b5e 2021-07-15 op jump_to_line(l);
407 84b88039 2021-07-12 op yornp_self_insert(void)
409 84b88039 2021-07-12 op if (thiskey.key != 'y' && thiskey.key != 'n') {
410 84b88039 2021-07-12 op message("Please answer y or n");
414 84b88039 2021-07-12 op exit_minibuffer();
415 84b88039 2021-07-12 op yornp_cb(thiskey.key == 'y', yornp_data);
419 84b88039 2021-07-12 op yornp_abort(void)
421 84b88039 2021-07-12 op exit_minibuffer();
422 84b88039 2021-07-12 op yornp_cb(0, yornp_data);
426 84b88039 2021-07-12 op read_self_insert(void)
428 84b88039 2021-07-12 op if (thiskey.meta || !unicode_isgraph(thiskey.cp)) {
429 84b88039 2021-07-12 op global_key_unbound();
433 84b88039 2021-07-12 op minibuffer_self_insert();
437 84b88039 2021-07-12 op read_abort(void)
439 84b88039 2021-07-12 op exit_minibuffer();
440 84b88039 2021-07-12 op read_cb(NULL, read_data);
444 84b88039 2021-07-12 op read_select(void)
446 95a8c791 2021-08-26 op exit_minibuffer();
447 84b88039 2021-07-12 op minibuffer_hist_save_entry();
448 84b88039 2021-07-12 op read_cb(ministate.buf, read_data);
452 b1e1e41a 2021-07-14 op * TODO: we should collect this asynchronously...
454 b1e1e41a 2021-07-14 op static inline void
455 b1e1e41a 2021-07-14 op populate_compl_buffer(complfn *fn, void *data)
457 b3be07ea 2021-07-18 op const char *s, *descr;
458 b1e1e41a 2021-07-14 op struct line *l;
459 b1e1e41a 2021-07-14 op struct buffer *b;
460 b1e1e41a 2021-07-14 op struct parser *p;
461 0ce8aa3e 2021-07-18 op void *linedata;
463 b1e1e41a 2021-07-14 op b = &ministate.compl.buffer;
464 b1e1e41a 2021-07-14 op p = &b->page;
466 0ce8aa3e 2021-07-18 op linedata = NULL;
467 0ce8aa3e 2021-07-18 op descr = NULL;
468 b3be07ea 2021-07-18 op while ((s = fn(&data, &linedata, &descr)) != NULL) {
469 b1e1e41a 2021-07-14 op if ((l = calloc(1, sizeof(*l))) == NULL)
472 e7b982f4 2021-07-14 op l->type = LINE_COMPL;
473 fbadd395 2021-07-16 op l->data = linedata;
474 b3be07ea 2021-07-18 op l->alt = (char*)descr;
475 e7b982f4 2021-07-14 op if ((l->line = strdup(s)) == NULL)
478 32ac17a4 2021-08-12 op TAILQ_INSERT_TAIL(&p->head, l, lines);
480 65601367 2021-07-14 op linedata = NULL;
481 b3be07ea 2021-07-18 op descr = NULL;
486 84b88039 2021-07-12 op enter_minibuffer(void (*self_insert_fn)(void), void (*donefn)(void),
487 e5a2797f 2021-07-13 op void (*abortfn)(void), struct histhead *hist,
488 e5a2797f 2021-07-13 op complfn *complfn, void *compldata)
490 b1e1e41a 2021-07-14 op in_minibuffer = complfn == NULL ? MB_READ : MB_COMPREAD;
491 b1e1e41a 2021-07-14 op if (in_minibuffer == MB_COMPREAD) {
492 b1e1e41a 2021-07-14 op ui_schedule_redraw();
494 b1e1e41a 2021-07-14 op ministate.compl.fn = complfn;
495 b1e1e41a 2021-07-14 op ministate.compl.data = compldata;
496 b1e1e41a 2021-07-14 op populate_compl_buffer(complfn, compldata);
499 84b88039 2021-07-12 op base_map = &minibuffer_map;
500 84b88039 2021-07-12 op current_map = &minibuffer_map;
502 84b88039 2021-07-12 op base_map->unhandled_input = self_insert_fn;
504 84b88039 2021-07-12 op ministate.donefn = donefn;
505 84b88039 2021-07-12 op ministate.abortfn = abortfn;
506 84b88039 2021-07-12 op memset(ministate.buf, 0, sizeof(ministate.buf));
507 84b88039 2021-07-12 op ministate.buffer.current_line = &ministate.vline;
508 84b88039 2021-07-12 op ministate.buffer.current_line->line = ministate.buf;
509 84b88039 2021-07-12 op ministate.buffer.cpoff = 0;
510 84b88039 2021-07-12 op strlcpy(ministate.buf, "", sizeof(ministate.prompt));
512 84b88039 2021-07-12 op ministate.history = hist;
513 84b88039 2021-07-12 op ministate.hist_cur = NULL;
514 84b88039 2021-07-12 op ministate.hist_off = 0;
518 84b88039 2021-07-12 op exit_minibuffer(void)
520 e7b982f4 2021-07-14 op if (in_minibuffer == MB_COMPREAD) {
521 e7b982f4 2021-07-14 op erase_buffer(&ministate.compl.buffer);
522 b1e1e41a 2021-07-14 op ui_schedule_redraw();
525 84b88039 2021-07-12 op in_minibuffer = 0;
526 84b88039 2021-07-12 op base_map = &global_map;
527 84b88039 2021-07-12 op current_map = &global_map;
531 84b88039 2021-07-12 op yornp(const char *prompt, void (*fn)(int, struct tab*),
532 84b88039 2021-07-12 op struct tab *data)
536 84b88039 2021-07-12 op if (in_minibuffer) {
541 84b88039 2021-07-12 op yornp_cb = fn;
542 84b88039 2021-07-12 op yornp_data = data;
543 84b88039 2021-07-12 op enter_minibuffer(yornp_self_insert, yornp_self_insert,
544 e5a2797f 2021-07-13 op yornp_abort, NULL, NULL, NULL);
546 84b88039 2021-07-12 op len = sizeof(ministate.prompt);
547 84b88039 2021-07-12 op strlcpy(ministate.prompt, prompt, len);
548 84b88039 2021-07-12 op strlcat(ministate.prompt, " (y or n) ", len);
552 4bc446b9 2021-07-21 op minibuffer_read(const char *prompt, void (*fn)(const char *, struct tab *),
553 b1e1e41a 2021-07-14 op struct tab *data)
557 84b88039 2021-07-12 op if (in_minibuffer)
560 84b88039 2021-07-12 op read_cb = fn;
561 84b88039 2021-07-12 op read_data = data;
562 84b88039 2021-07-12 op enter_minibuffer(read_self_insert, read_select, read_abort,
563 b1e1e41a 2021-07-14 op &read_history, NULL, NULL);
565 84b88039 2021-07-12 op len = sizeof(ministate.prompt);
566 84b88039 2021-07-12 op strlcpy(ministate.prompt, prompt, len);
567 84b88039 2021-07-12 op strlcat(ministate.prompt, ": ", len);
571 4bc446b9 2021-07-21 op handle_clear_echoarea(int fd, short ev, void *d)
573 4bc446b9 2021-07-21 op free(ministate.curmesg);
574 4bc446b9 2021-07-21 op ministate.curmesg = NULL;
576 4bc446b9 2021-07-21 op ui_after_message_hook();
580 4bc446b9 2021-07-21 op vmessage(const char *fmt, va_list ap)
582 4bc446b9 2021-07-21 op if (evtimer_pending(&clechoev, NULL))
583 4bc446b9 2021-07-21 op evtimer_del(&clechoev);
585 4bc446b9 2021-07-21 op free(ministate.curmesg);
586 4bc446b9 2021-07-21 op ministate.curmesg = NULL;
588 4bc446b9 2021-07-21 op if (fmt != NULL) {
589 4bc446b9 2021-07-21 op evtimer_set(&clechoev, handle_clear_echoarea, NULL);
590 4bc446b9 2021-07-21 op evtimer_add(&clechoev, &clechoev_timer);
592 4bc446b9 2021-07-21 op /* TODO: what to do if the allocation fails here? */
593 4bc446b9 2021-07-21 op if (vasprintf(&ministate.curmesg, fmt, ap) == -1)
594 4bc446b9 2021-07-21 op ministate.curmesg = NULL;
597 4bc446b9 2021-07-21 op ui_after_message_hook();
601 4bc446b9 2021-07-21 op message(const char *fmt, ...)
605 4bc446b9 2021-07-21 op va_start(ap, fmt);
606 4bc446b9 2021-07-21 op vmessage(fmt, ap);
611 4bc446b9 2021-07-21 op minibuffer_init(void)
613 bccb5b0b 2021-07-21 op TAILQ_INIT(&eecmd_history.head);
614 bccb5b0b 2021-07-21 op TAILQ_INIT(&ir_history.head);
615 bccb5b0b 2021-07-21 op TAILQ_INIT(&lu_history.head);
616 78894e73 2021-08-12 op TAILQ_INIT(&read_history.head);
618 78894e73 2021-08-12 op TAILQ_INIT(&ministate.compl.buffer.head);
619 78894e73 2021-08-12 op TAILQ_INIT(&ministate.compl.buffer.page.head);
621 bccb5b0b 2021-07-21 op ministate.line.type = LINE_TEXT;
622 bccb5b0b 2021-07-21 op ministate.vline.parent = &ministate.line;
623 ab0a4274 2021-07-25 op ministate.buffer.page.name = "*minibuffer*";
624 bccb5b0b 2021-07-21 op ministate.buffer.current_line = &ministate.vline;
626 4bc446b9 2021-07-21 op evtimer_set(&clechoev, handle_clear_echoarea, NULL);