2 2b2d2872 2021-06-20 op * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
4 2b2d2872 2021-06-20 op * Permission to use, copy, modify, and distribute this software for any
5 2b2d2872 2021-06-20 op * purpose with or without fee is hereby granted, provided that the above
6 2b2d2872 2021-06-20 op * copyright notice and this permission notice appear in all copies.
8 2b2d2872 2021-06-20 op * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 2b2d2872 2021-06-20 op * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 2b2d2872 2021-06-20 op * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 2b2d2872 2021-06-20 op * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 2b2d2872 2021-06-20 op * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 2b2d2872 2021-06-20 op * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 2b2d2872 2021-06-20 op * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 61251035 2021-06-26 op #include <limits.h>
18 2b2d2872 2021-06-20 op #include <stdlib.h>
19 61251035 2021-06-26 op #include <string.h>
21 b1e1e41a 2021-07-14 op #include "compl.h"
22 e5a2797f 2021-07-13 op #include "defaults.h"
23 450a89f7 2021-07-12 op #include "minibuffer.h"
24 2b2d2872 2021-06-20 op #include "telescope.h"
25 d1a0f2a3 2021-07-12 op #include "ui.h"
26 5caf7d67 2021-07-12 op #include "utf8.h"
28 c4c82003 2021-07-01 op /* return 1 if moved, 0 otherwise */
29 c4c82003 2021-07-01 op static inline int
30 c4c82003 2021-07-01 op forward_line(struct buffer *buffer, int n)
32 c4c82003 2021-07-01 op struct vline *vl;
35 c4c82003 2021-07-01 op if (buffer->current_line == NULL)
37 963c680c 2021-07-05 op vl = buffer->current_line;
40 c4c82003 2021-07-01 op while (n != 0) {
42 963c680c 2021-07-05 op vl = TAILQ_NEXT(vl, vlines);
43 c4c82003 2021-07-01 op if (vl == NULL)
45 963c680c 2021-07-05 op if (vl->parent->flags & L_HIDDEN)
47 c4c82003 2021-07-01 op buffer->current_line = vl;
50 963c680c 2021-07-05 op vl = TAILQ_PREV(vl, vhead, vlines);
51 c4c82003 2021-07-01 op if (vl == NULL)
53 963c680c 2021-07-05 op if (vl->parent->flags & L_HIDDEN)
55 c4c82003 2021-07-01 op if (buffer->current_line == buffer->top_line)
56 c4c82003 2021-07-01 op buffer->top_line = vl;
57 c4c82003 2021-07-01 op buffer->current_line = vl;
68 c4c82003 2021-07-01 op cmd_previous_line(struct buffer *buffer)
70 c4c82003 2021-07-01 op forward_line(buffer, -1);
74 c4c82003 2021-07-01 op cmd_next_line(struct buffer *buffer)
76 c4c82003 2021-07-01 op forward_line(buffer, +1);
80 2b2d2872 2021-06-20 op cmd_backward_char(struct buffer *buffer)
82 2b2d2872 2021-06-20 op if (buffer->cpoff != 0)
83 2b2d2872 2021-06-20 op buffer->cpoff--;
87 2b2d2872 2021-06-20 op cmd_forward_char(struct buffer *buffer)
89 2b2d2872 2021-06-20 op size_t len = 0;
91 2b2d2872 2021-06-20 op if (buffer->current_line->line != NULL)
92 2b2d2872 2021-06-20 op len = utf8_cplen(buffer->current_line->line);
93 2b2d2872 2021-06-20 op if (++buffer->cpoff > len)
94 2b2d2872 2021-06-20 op buffer->cpoff = len;
98 2b2d2872 2021-06-20 op cmd_backward_paragraph(struct buffer *buffer)
101 c4c82003 2021-07-01 op if (!forward_line(buffer, -1)) {
102 2b2d2872 2021-06-20 op message("No previous paragraph");
105 2b2d2872 2021-06-20 op } while (buffer->current_line->line != NULL ||
106 2b2d2872 2021-06-20 op buffer->current_line->parent->type != LINE_TEXT);
110 2b2d2872 2021-06-20 op cmd_forward_paragraph(struct buffer *buffer)
113 c4c82003 2021-07-01 op if (!forward_line(buffer, +1)) {
114 2b2d2872 2021-06-20 op message("No next paragraph");
117 2b2d2872 2021-06-20 op } while (buffer->current_line->line != NULL ||
118 2b2d2872 2021-06-20 op buffer->current_line->parent->type != LINE_TEXT);
122 2b2d2872 2021-06-20 op cmd_move_beginning_of_line(struct buffer *buffer)
124 2b2d2872 2021-06-20 op buffer->cpoff = 0;
128 2b2d2872 2021-06-20 op cmd_move_end_of_line(struct buffer *buffer)
130 2b2d2872 2021-06-20 op struct vline *vl;
132 2b2d2872 2021-06-20 op vl = buffer->current_line;
133 2b2d2872 2021-06-20 op if (vl->line == NULL)
135 2b2d2872 2021-06-20 op buffer->cpoff = utf8_cplen(vl->line);
139 2b2d2872 2021-06-20 op cmd_redraw(struct buffer *buffer)
141 2b2d2872 2021-06-20 op ui_schedule_redraw();
145 2b2d2872 2021-06-20 op cmd_scroll_line_up(struct buffer *buffer)
147 e39920a9 2021-07-07 op struct vline *vl;
149 e39920a9 2021-07-07 op if ((vl = TAILQ_PREV(buffer->top_line, vhead, vlines))
153 e39920a9 2021-07-07 op forward_line(buffer, -1);
155 2b2d2872 2021-06-20 op buffer->line_off--;
156 e39920a9 2021-07-07 op buffer->top_line = vl;
160 2b2d2872 2021-06-20 op cmd_scroll_line_down(struct buffer *buffer)
162 c4c82003 2021-07-01 op if (!forward_line(buffer, +1))
165 94ec38e8 2021-06-29 op buffer->top_line = TAILQ_NEXT(buffer->top_line, vlines);
166 2b2d2872 2021-06-20 op buffer->line_off++;
170 2b2d2872 2021-06-20 op cmd_scroll_up(struct buffer *buffer)
172 d38e7214 2021-07-05 op forward_line(buffer, -1*body_lines);
176 2b2d2872 2021-06-20 op cmd_scroll_down(struct buffer *buffer)
178 d38e7214 2021-07-05 op forward_line(buffer, body_lines);
182 2b2d2872 2021-06-20 op cmd_beginning_of_buffer(struct buffer *buffer)
184 2b2d2872 2021-06-20 op buffer->current_line = TAILQ_FIRST(&buffer->head);
185 c4c82003 2021-07-01 op buffer->cpoff = 0;
186 94ec38e8 2021-06-29 op buffer->top_line = buffer->current_line;
187 2b2d2872 2021-06-20 op buffer->line_off = 0;
191 2b2d2872 2021-06-20 op cmd_end_of_buffer(struct buffer *buffer)
193 2b2d2872 2021-06-20 op buffer->current_line = TAILQ_LAST(&buffer->head, vhead);
194 2b2d2872 2021-06-20 op buffer->cpoff = body_cols;
198 2b2d2872 2021-06-20 op cmd_kill_telescope(struct buffer *buffer)
200 2b2d2872 2021-06-20 op save_session();
201 2b2d2872 2021-06-20 op event_loopbreak();
205 2b2d2872 2021-06-20 op cmd_push_button(struct buffer *buffer)
207 2b2d2872 2021-06-20 op struct vline *vl;
208 963c680c 2021-07-05 op struct line *l;
210 2b2d2872 2021-06-20 op vl = buffer->current_line;
211 963c680c 2021-07-05 op switch (vl->parent->type) {
212 963c680c 2021-07-05 op case LINE_LINK:
213 963c680c 2021-07-05 op load_url_in_tab(current_tab(), vl->parent->alt);
215 963c680c 2021-07-05 op case LINE_PRE_START:
216 963c680c 2021-07-05 op l = TAILQ_NEXT(vl->parent, lines);
217 963c680c 2021-07-05 op for (; l != NULL; l = TAILQ_NEXT(l, lines)) {
218 963c680c 2021-07-05 op if (l->type == LINE_PRE_END)
220 963c680c 2021-07-05 op l->flags ^= L_HIDDEN;
229 2b2d2872 2021-06-20 op cmd_push_button_new_tab(struct buffer *buffer)
231 2b2d2872 2021-06-20 op struct vline *vl;
233 2b2d2872 2021-06-20 op vl = buffer->current_line;
234 2b2d2872 2021-06-20 op if (vl->parent->type != LINE_LINK)
237 2b2d2872 2021-06-20 op new_tab(vl->parent->alt);
241 2b2d2872 2021-06-20 op cmd_previous_button(struct buffer *buffer)
243 5d0feb4b 2021-06-23 op struct excursion place;
245 5d0feb4b 2021-06-23 op save_excursion(&place, buffer);
248 c4c82003 2021-07-01 op if (!forward_line(buffer, -1)) {
249 5d0feb4b 2021-06-23 op restore_excursion(&place, buffer);
250 2b2d2872 2021-06-20 op message("No previous link");
253 2b2d2872 2021-06-20 op } while (buffer->current_line->parent->type != LINE_LINK);
257 2b2d2872 2021-06-20 op cmd_next_button(struct buffer *buffer)
259 5d0feb4b 2021-06-23 op struct excursion place;
261 5d0feb4b 2021-06-23 op save_excursion(&place, buffer);
264 c4c82003 2021-07-01 op if (!forward_line(buffer, +1)){
265 5d0feb4b 2021-06-23 op restore_excursion(&place, buffer);
266 2b2d2872 2021-06-20 op message("No next link");
269 2b2d2872 2021-06-20 op } while (buffer->current_line->parent->type != LINE_LINK);
272 1c412d48 2021-06-25 op static inline int
273 1c412d48 2021-06-25 op is_heading(const struct line *l)
275 1c412d48 2021-06-25 op return l->type == LINE_TITLE_1 ||
276 1c412d48 2021-06-25 op l->type == LINE_TITLE_2 ||
277 1c412d48 2021-06-25 op l->type == LINE_TITLE_3;
281 1c412d48 2021-06-25 op cmd_previous_heading(struct buffer *buffer)
283 1c412d48 2021-06-25 op struct excursion place;
285 1c412d48 2021-06-25 op save_excursion(&place, buffer);
288 c4c82003 2021-07-01 op if (!forward_line(buffer, -1)) {
289 1c412d48 2021-06-25 op restore_excursion(&place, buffer);
290 1c412d48 2021-06-25 op message("No previous heading");
293 1c412d48 2021-06-25 op } while (!is_heading(buffer->current_line->parent));
297 1c412d48 2021-06-25 op cmd_next_heading(struct buffer *buffer)
299 1c412d48 2021-06-25 op struct excursion place;
301 1c412d48 2021-06-25 op save_excursion(&place, buffer);
304 c4c82003 2021-07-01 op if (!forward_line(buffer, +1)) {
305 1c412d48 2021-06-25 op restore_excursion(&place, buffer);
306 1c412d48 2021-06-25 op message("No next heading");
309 1c412d48 2021-06-25 op } while (!is_heading(buffer->current_line->parent));
313 2b2d2872 2021-06-20 op cmd_previous_page(struct buffer *buffer)
315 2b2d2872 2021-06-20 op struct tab *tab = current_tab();
317 2b2d2872 2021-06-20 op if (!load_previous_page(tab))
318 2b2d2872 2021-06-20 op message("No previous page");
320 2b2d2872 2021-06-20 op start_loading_anim(tab);
324 2b2d2872 2021-06-20 op cmd_next_page(struct buffer *buffer)
326 2b2d2872 2021-06-20 op struct tab *tab = current_tab();
328 2b2d2872 2021-06-20 op if (!load_next_page(tab))
329 2b2d2872 2021-06-20 op message("No next page");
331 2b2d2872 2021-06-20 op start_loading_anim(tab);
335 2b2d2872 2021-06-20 op cmd_clear_minibuf(struct buffer *buffer)
337 2b2d2872 2021-06-20 op message(NULL);
341 2b2d2872 2021-06-20 op cmd_execute_extended_command(struct buffer *buffer)
345 2b2d2872 2021-06-20 op if (in_minibuffer) {
346 2b2d2872 2021-06-20 op message("We don't have enable-recursive-minibuffers");
350 2b2d2872 2021-06-20 op enter_minibuffer(eecmd_self_insert, eecmd_select, exit_minibuffer,
351 b1e1e41a 2021-07-14 op &eecmd_history, compl_eecmd, NULL);
353 2b2d2872 2021-06-20 op len = sizeof(ministate.prompt);
354 2b2d2872 2021-06-20 op strlcpy(ministate.prompt, "", len);
356 2b2d2872 2021-06-20 op if (thiskey.meta)
357 2b2d2872 2021-06-20 op strlcat(ministate.prompt, "M-", len);
359 2b2d2872 2021-06-20 op strlcat(ministate.prompt, ui_keyname(thiskey.key), len);
361 2b2d2872 2021-06-20 op if (thiskey.meta)
362 2b2d2872 2021-06-20 op strlcat(ministate.prompt, " ", len);
366 2b2d2872 2021-06-20 op cmd_tab_close(struct buffer *buffer)
368 2b2d2872 2021-06-20 op struct tab *tab, *t;
370 2b2d2872 2021-06-20 op tab = current_tab();
371 2b2d2872 2021-06-20 op if (TAILQ_PREV(tab, tabshead, tabs) == NULL &&
372 2b2d2872 2021-06-20 op TAILQ_NEXT(tab, tabs) == NULL) {
373 2b2d2872 2021-06-20 op message("Can't close the only tab.");
377 2b2d2872 2021-06-20 op if (evtimer_pending(&tab->loadingev, NULL))
378 2b2d2872 2021-06-20 op evtimer_del(&tab->loadingev);
380 2b2d2872 2021-06-20 op stop_tab(tab);
382 2b2d2872 2021-06-20 op if ((t = TAILQ_PREV(tab, tabshead, tabs)) == NULL)
383 2b2d2872 2021-06-20 op t = TAILQ_NEXT(tab, tabs);
384 2b2d2872 2021-06-20 op TAILQ_REMOVE(&tabshead, tab, tabs);
387 2b2d2872 2021-06-20 op switch_to_tab(t);
391 2b2d2872 2021-06-20 op cmd_tab_close_other(struct buffer *buffer)
393 2b2d2872 2021-06-20 op struct tab *t, *i;
395 2b2d2872 2021-06-20 op TAILQ_FOREACH_SAFE(t, &tabshead, tabs, i) {
396 2b2d2872 2021-06-20 op if (t->flags & TAB_CURRENT)
400 2b2d2872 2021-06-20 op TAILQ_REMOVE(&tabshead, t, tabs);
406 2b2d2872 2021-06-20 op cmd_tab_new(struct buffer *buffer)
408 2b2d2872 2021-06-20 op const char *url;
410 2b2d2872 2021-06-20 op if ((url = new_tab_url) == NULL)
411 2b2d2872 2021-06-20 op url = NEW_TAB_URL;
413 2b2d2872 2021-06-20 op new_tab(url);
417 2b2d2872 2021-06-20 op cmd_tab_next(struct buffer *buffer)
419 2b2d2872 2021-06-20 op struct tab *tab, *t;
421 2b2d2872 2021-06-20 op tab = current_tab();
422 2b2d2872 2021-06-20 op tab->flags &= ~TAB_CURRENT;
424 2b2d2872 2021-06-20 op if ((t = TAILQ_NEXT(tab, tabs)) == NULL)
425 2b2d2872 2021-06-20 op t = TAILQ_FIRST(&tabshead);
426 2b2d2872 2021-06-20 op t->flags |= TAB_CURRENT;
427 2b2d2872 2021-06-20 op t->flags &= ~TAB_URGENT;
431 2b2d2872 2021-06-20 op cmd_tab_previous(struct buffer *buffer)
433 2b2d2872 2021-06-20 op struct tab *tab, *t;
435 2b2d2872 2021-06-20 op tab = current_tab();
436 2b2d2872 2021-06-20 op tab->flags &= ~TAB_CURRENT;
438 2b2d2872 2021-06-20 op if ((t = TAILQ_PREV(tab, tabshead, tabs)) == NULL)
439 2b2d2872 2021-06-20 op t = TAILQ_LAST(&tabshead, tabshead);
440 2b2d2872 2021-06-20 op t->flags |= TAB_CURRENT;
441 2b2d2872 2021-06-20 op t->flags &= ~TAB_URGENT;
445 2b2d2872 2021-06-20 op cmd_tab_move(struct buffer *buffer)
447 2b2d2872 2021-06-20 op struct tab *tab, *t;
449 2b2d2872 2021-06-20 op tab = current_tab();
450 2b2d2872 2021-06-20 op t = TAILQ_NEXT(tab, tabs);
451 2b2d2872 2021-06-20 op TAILQ_REMOVE(&tabshead, tab, tabs);
453 2b2d2872 2021-06-20 op if (t == NULL)
454 2b2d2872 2021-06-20 op TAILQ_INSERT_HEAD(&tabshead, tab, tabs);
456 2b2d2872 2021-06-20 op TAILQ_INSERT_AFTER(&tabshead, t, tab, tabs);
460 2b2d2872 2021-06-20 op cmd_tab_move_to(struct buffer *buffer)
462 2b2d2872 2021-06-20 op struct tab *tab, *t;
464 2b2d2872 2021-06-20 op tab = current_tab();
465 2b2d2872 2021-06-20 op t = TAILQ_PREV(tab, tabshead, tabs);
466 2b2d2872 2021-06-20 op TAILQ_REMOVE(&tabshead, tab, tabs);
468 2b2d2872 2021-06-20 op if (t == NULL) {
469 2b2d2872 2021-06-20 op if (TAILQ_EMPTY(&tabshead))
470 2b2d2872 2021-06-20 op TAILQ_INSERT_HEAD(&tabshead, tab, tabs);
472 2b2d2872 2021-06-20 op TAILQ_INSERT_TAIL(&tabshead, tab, tabs);
474 2b2d2872 2021-06-20 op TAILQ_INSERT_BEFORE(t, tab, tabs);
478 2b2d2872 2021-06-20 op cmd_load_url(struct buffer *buffer)
480 2b2d2872 2021-06-20 op if (in_minibuffer) {
481 2b2d2872 2021-06-20 op message("We don't have enable-recursive-minibuffers");
485 2b2d2872 2021-06-20 op enter_minibuffer(lu_self_insert, lu_select, exit_minibuffer,
486 e5a2797f 2021-07-13 op &lu_history, NULL, NULL);
487 2b2d2872 2021-06-20 op strlcpy(ministate.prompt, "Load URL: ", sizeof(ministate.prompt));
488 2b2d2872 2021-06-20 op strlcpy(ministate.buf, "gemini://", sizeof(ministate.buf));
489 2b2d2872 2021-06-20 op cmd_move_end_of_line(&ministate.buffer);
493 2b2d2872 2021-06-20 op cmd_load_current_url(struct buffer *buffer)
495 2b2d2872 2021-06-20 op struct tab *tab = current_tab();
497 2b2d2872 2021-06-20 op if (in_minibuffer) {
498 2b2d2872 2021-06-20 op message("We don't have enable-recursive-minibuffers");
502 2b2d2872 2021-06-20 op enter_minibuffer(lu_self_insert, lu_select, exit_minibuffer,
503 e5a2797f 2021-07-13 op &lu_history, NULL, NULL);
504 2b2d2872 2021-06-20 op strlcpy(ministate.prompt, "Load URL: ", sizeof(ministate.prompt));
505 2b2d2872 2021-06-20 op strlcpy(ministate.buf, tab->hist_cur->h, sizeof(ministate.buf));
506 2b2d2872 2021-06-20 op ministate.buffer.cpoff = utf8_cplen(ministate.buf);
510 2b2d2872 2021-06-20 op cmd_bookmark_page(struct buffer *buffer)
512 2b2d2872 2021-06-20 op struct tab *tab = current_tab();
514 e5a2797f 2021-07-13 op enter_minibuffer(lu_self_insert, bp_select, exit_minibuffer, NULL,
516 2b2d2872 2021-06-20 op strlcpy(ministate.prompt, "Bookmark URL: ", sizeof(ministate.prompt));
517 2b2d2872 2021-06-20 op strlcpy(ministate.buf, tab->hist_cur->h, sizeof(ministate.buf));
518 2b2d2872 2021-06-20 op ministate.buffer.cpoff = utf8_cplen(ministate.buf);
522 2b2d2872 2021-06-20 op cmd_list_bookmarks(struct buffer *buffer)
524 2b2d2872 2021-06-20 op load_url_in_tab(current_tab(), "about:bookmarks");
528 2b2d2872 2021-06-20 op cmd_toggle_help(struct buffer *buffer)
530 2b2d2872 2021-06-20 op ui_toggle_side_window();
534 61251035 2021-06-26 op cmd_inc_fill_column(struct buffer *buffer)
536 61251035 2021-06-26 op if (fill_column == INT_MAX)
539 61251035 2021-06-26 op fill_column += 2;
540 61251035 2021-06-26 op message("fill-column: %d", fill_column);
542 61251035 2021-06-26 op ui_schedule_redraw();
546 61251035 2021-06-26 op cmd_dec_fill_column(struct buffer *buffer)
548 61251035 2021-06-26 op if (fill_column == INT_MAX || fill_column < 8)
551 61251035 2021-06-26 op fill_column -= 2;
552 61251035 2021-06-26 op message("fill-column: %d", fill_column);
554 61251035 2021-06-26 op ui_schedule_redraw();
558 2b2d2872 2021-06-20 op cmd_olivetti_mode(struct buffer *buffer)
560 2b2d2872 2021-06-20 op olivetti_mode = !olivetti_mode;
561 2b2d2872 2021-06-20 op if (olivetti_mode)
562 2b2d2872 2021-06-20 op message("olivetti-mode enabled");
564 2b2d2872 2021-06-20 op message("olivetti-mode disabled");
566 2b2d2872 2021-06-20 op ui_schedule_redraw();
570 2b2d2872 2021-06-20 op cmd_mini_delete_char(struct buffer *buffer)
574 2b2d2872 2021-06-20 op if (!in_minibuffer) {
575 2b2d2872 2021-06-20 op message("text is read-only");
579 2b2d2872 2021-06-20 op minibuffer_taint_hist();
581 2b2d2872 2021-06-20 op c = utf8_nth(buffer->current_line->line, buffer->cpoff);
582 2b2d2872 2021-06-20 op if (*c == '\0')
584 2b2d2872 2021-06-20 op n = utf8_next_cp(c);
586 2b2d2872 2021-06-20 op memmove(c, n, strlen(n)+1);
588 b1e1e41a 2021-07-14 op recompute_completions(0);
592 2b2d2872 2021-06-20 op cmd_mini_delete_backward_char(struct buffer *buffer)
594 2b2d2872 2021-06-20 op char *c, *p, *start;
596 2b2d2872 2021-06-20 op if (!in_minibuffer) {
597 2b2d2872 2021-06-20 op message("text is read-only");
601 2b2d2872 2021-06-20 op minibuffer_taint_hist();
603 2b2d2872 2021-06-20 op c = utf8_nth(buffer->current_line->line, buffer->cpoff);
604 2b2d2872 2021-06-20 op start = buffer->current_line->line;
605 2b2d2872 2021-06-20 op if (c == start)
607 2b2d2872 2021-06-20 op p = utf8_prev_cp(c-1, start);
609 2b2d2872 2021-06-20 op memmove(p, c, strlen(c)+1);
610 2b2d2872 2021-06-20 op buffer->cpoff--;
612 b1e1e41a 2021-07-14 op recompute_completions(0);
616 2b2d2872 2021-06-20 op cmd_mini_kill_line(struct buffer *buffer)
620 2b2d2872 2021-06-20 op if (!in_minibuffer) {
621 2b2d2872 2021-06-20 op message("text is read-only");
625 2b2d2872 2021-06-20 op minibuffer_taint_hist();
626 2b2d2872 2021-06-20 op c = utf8_nth(buffer->current_line->line, buffer->cpoff);
629 b1e1e41a 2021-07-14 op recompute_completions(0);
633 2b2d2872 2021-06-20 op cmd_mini_abort(struct buffer *buffer)
635 2b2d2872 2021-06-20 op if (!in_minibuffer)
638 2b2d2872 2021-06-20 op ministate.abortfn();
642 2b2d2872 2021-06-20 op cmd_mini_complete_and_exit(struct buffer *buffer)
644 2b2d2872 2021-06-20 op if (!in_minibuffer)
647 2b2d2872 2021-06-20 op minibuffer_taint_hist();
648 2b2d2872 2021-06-20 op ministate.donefn();
652 2b2d2872 2021-06-20 op cmd_mini_previous_history_element(struct buffer *buffer)
654 2b2d2872 2021-06-20 op if (ministate.history == NULL) {
655 2b2d2872 2021-06-20 op message("No history");
659 2b2d2872 2021-06-20 op if (ministate.hist_cur == NULL ||
660 2b2d2872 2021-06-20 op (ministate.hist_cur = TAILQ_PREV(ministate.hist_cur, mhisthead, entries)) == NULL) {
661 2b2d2872 2021-06-20 op ministate.hist_cur = TAILQ_LAST(&ministate.history->head, mhisthead);
662 2b2d2872 2021-06-20 op ministate.hist_off = ministate.history->len - 1;
663 2b2d2872 2021-06-20 op if (ministate.hist_cur == NULL)
664 2b2d2872 2021-06-20 op message("No prev item");
666 2b2d2872 2021-06-20 op ministate.hist_off--;
669 2b2d2872 2021-06-20 op if (ministate.hist_cur != NULL)
670 2b2d2872 2021-06-20 op buffer->current_line->line = ministate.hist_cur->h;
674 2b2d2872 2021-06-20 op cmd_mini_next_history_element(struct buffer *buffer)
676 2b2d2872 2021-06-20 op if (ministate.history == NULL) {
677 2b2d2872 2021-06-20 op message("No history");
681 2b2d2872 2021-06-20 op if (ministate.hist_cur == NULL ||
682 2b2d2872 2021-06-20 op (ministate.hist_cur = TAILQ_NEXT(ministate.hist_cur, entries)) == NULL) {
683 2b2d2872 2021-06-20 op ministate.hist_cur = TAILQ_FIRST(&ministate.history->head);
684 2b2d2872 2021-06-20 op ministate.hist_off = 0;
685 2b2d2872 2021-06-20 op if (ministate.hist_cur == NULL)
686 2b2d2872 2021-06-20 op message("No next item");
688 2b2d2872 2021-06-20 op ministate.hist_off++;
691 2b2d2872 2021-06-20 op if (ministate.hist_cur != NULL)
692 2b2d2872 2021-06-20 op buffer->current_line->line = ministate.hist_cur->h;