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 2b2d2872 2021-06-20 op #include <string.h>
18 2b2d2872 2021-06-20 op #include <stdlib.h>
20 2b2d2872 2021-06-20 op #include "telescope.h"
21 2b2d2872 2021-06-20 op #include "cmd.gen.h"
24 2b2d2872 2021-06-20 op cmd_previous_line(struct buffer *buffer)
26 2b2d2872 2021-06-20 op struct vline *vl;
28 2b2d2872 2021-06-20 op if (buffer->current_line == NULL
29 2b2d2872 2021-06-20 op || (vl = TAILQ_PREV(buffer->current_line, vhead, vlines)) == NULL)
32 2b2d2872 2021-06-20 op if (--buffer->curs_y < 0) {
33 2b2d2872 2021-06-20 op buffer->curs_y = 0;
34 2b2d2872 2021-06-20 op cmd_scroll_line_up(buffer);
38 2b2d2872 2021-06-20 op buffer->current_line = vl;
39 2b2d2872 2021-06-20 op restore_cursor(buffer);
43 2b2d2872 2021-06-20 op cmd_next_line(struct buffer *buffer)
45 2b2d2872 2021-06-20 op struct vline *vl;
47 2b2d2872 2021-06-20 op if (buffer->current_line == NULL
48 2b2d2872 2021-06-20 op || (vl = TAILQ_NEXT(buffer->current_line, vlines)) == NULL)
51 2b2d2872 2021-06-20 op if (++buffer->curs_y > body_lines-1) {
52 2b2d2872 2021-06-20 op buffer->curs_y = body_lines-1;
53 2b2d2872 2021-06-20 op cmd_scroll_line_down(buffer);
57 2b2d2872 2021-06-20 op buffer->current_line = vl;
58 2b2d2872 2021-06-20 op restore_cursor(buffer);
62 2b2d2872 2021-06-20 op cmd_backward_char(struct buffer *buffer)
64 2b2d2872 2021-06-20 op if (buffer->cpoff != 0)
65 2b2d2872 2021-06-20 op buffer->cpoff--;
66 2b2d2872 2021-06-20 op restore_cursor(buffer);
70 2b2d2872 2021-06-20 op cmd_forward_char(struct buffer *buffer)
72 2b2d2872 2021-06-20 op size_t len = 0;
74 2b2d2872 2021-06-20 op if (buffer->current_line->line != NULL)
75 2b2d2872 2021-06-20 op len = utf8_cplen(buffer->current_line->line);
76 2b2d2872 2021-06-20 op if (++buffer->cpoff > len)
77 2b2d2872 2021-06-20 op buffer->cpoff = len;
78 2b2d2872 2021-06-20 op restore_cursor(buffer);
82 2b2d2872 2021-06-20 op cmd_backward_paragraph(struct buffer *buffer)
85 2b2d2872 2021-06-20 op if (buffer->current_line == NULL ||
86 2b2d2872 2021-06-20 op buffer->current_line == TAILQ_FIRST(&buffer->head)) {
87 2b2d2872 2021-06-20 op message("No previous paragraph");
90 2b2d2872 2021-06-20 op cmd_previous_line(buffer);
91 2b2d2872 2021-06-20 op } while (buffer->current_line->line != NULL ||
92 2b2d2872 2021-06-20 op buffer->current_line->parent->type != LINE_TEXT);
96 2b2d2872 2021-06-20 op cmd_forward_paragraph(struct buffer *buffer)
99 2b2d2872 2021-06-20 op if (buffer->current_line == NULL ||
100 2b2d2872 2021-06-20 op buffer->current_line == TAILQ_LAST(&buffer->head, vhead)) {
101 2b2d2872 2021-06-20 op message("No next paragraph");
104 2b2d2872 2021-06-20 op cmd_next_line(buffer);
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_move_beginning_of_line(struct buffer *buffer)
112 2b2d2872 2021-06-20 op buffer->cpoff = 0;
113 2b2d2872 2021-06-20 op restore_cursor(buffer);
117 2b2d2872 2021-06-20 op cmd_move_end_of_line(struct buffer *buffer)
119 2b2d2872 2021-06-20 op struct vline *vl;
121 2b2d2872 2021-06-20 op vl = buffer->current_line;
122 2b2d2872 2021-06-20 op if (vl->line == NULL)
124 2b2d2872 2021-06-20 op buffer->cpoff = utf8_cplen(vl->line);
125 2b2d2872 2021-06-20 op restore_cursor(buffer);
129 2b2d2872 2021-06-20 op cmd_redraw(struct buffer *buffer)
131 2b2d2872 2021-06-20 op ui_schedule_redraw();
135 2b2d2872 2021-06-20 op cmd_scroll_line_up(struct buffer *buffer)
137 2b2d2872 2021-06-20 op if (buffer->current_line == NULL)
140 28eca2fc 2021-06-20 op if (buffer->line_off == 0)
143 2b2d2872 2021-06-20 op buffer->line_off--;
144 28eca2fc 2021-06-20 op buffer->current_line = TAILQ_PREV(buffer->current_line, vhead, vlines);
145 2b2d2872 2021-06-20 op restore_cursor(buffer);
149 2b2d2872 2021-06-20 op cmd_scroll_line_down(struct buffer *buffer)
151 2b2d2872 2021-06-20 op struct vline *vl;
153 2b2d2872 2021-06-20 op if (buffer->current_line == NULL)
156 2b2d2872 2021-06-20 op if ((vl = TAILQ_NEXT(buffer->current_line, vlines)) == NULL)
159 2b2d2872 2021-06-20 op buffer->current_line = vl;
160 2b2d2872 2021-06-20 op buffer->line_off++;
161 2b2d2872 2021-06-20 op restore_cursor(buffer);
165 2b2d2872 2021-06-20 op cmd_scroll_up(struct buffer *buffer)
169 2b2d2872 2021-06-20 op off = body_lines-1;
171 2b2d2872 2021-06-20 op for (; off > 0; --off)
172 2b2d2872 2021-06-20 op cmd_scroll_line_up(buffer);
176 2b2d2872 2021-06-20 op cmd_scroll_down(struct buffer *buffer)
180 2b2d2872 2021-06-20 op off = body_lines-1;
182 2b2d2872 2021-06-20 op for (; off > 0; --off)
183 2b2d2872 2021-06-20 op cmd_scroll_line_down(buffer);
187 2b2d2872 2021-06-20 op cmd_beginning_of_buffer(struct buffer *buffer)
189 2b2d2872 2021-06-20 op buffer->current_line = TAILQ_FIRST(&buffer->head);
190 2b2d2872 2021-06-20 op buffer->line_off = 0;
191 2b2d2872 2021-06-20 op buffer->curs_y = 0;
192 2b2d2872 2021-06-20 op buffer->cpoff = 0;
193 2b2d2872 2021-06-20 op restore_cursor(buffer);
197 2b2d2872 2021-06-20 op cmd_end_of_buffer(struct buffer *buffer)
201 2b2d2872 2021-06-20 op off = buffer->line_max - body_lines;
202 2b2d2872 2021-06-20 op off = MAX(0, off);
204 2b2d2872 2021-06-20 op buffer->line_off = off;
205 4f0158a7 2021-06-20 op buffer->curs_y = MIN((size_t)body_lines-1, buffer->line_max-1);
207 2b2d2872 2021-06-20 op buffer->current_line = TAILQ_LAST(&buffer->head, vhead);
208 2b2d2872 2021-06-20 op buffer->cpoff = body_cols;
209 2b2d2872 2021-06-20 op restore_cursor(buffer);
213 2b2d2872 2021-06-20 op cmd_kill_telescope(struct buffer *buffer)
215 2b2d2872 2021-06-20 op save_session();
216 2b2d2872 2021-06-20 op event_loopbreak();
220 2b2d2872 2021-06-20 op cmd_push_button(struct buffer *buffer)
222 2b2d2872 2021-06-20 op struct vline *vl;
224 2b2d2872 2021-06-20 op vl = buffer->current_line;
225 2b2d2872 2021-06-20 op if (vl->parent->type != LINE_LINK)
228 2b2d2872 2021-06-20 op load_url_in_tab(current_tab(), vl->parent->alt);
232 2b2d2872 2021-06-20 op cmd_push_button_new_tab(struct buffer *buffer)
234 2b2d2872 2021-06-20 op struct vline *vl;
236 2b2d2872 2021-06-20 op vl = buffer->current_line;
237 2b2d2872 2021-06-20 op if (vl->parent->type != LINE_LINK)
240 2b2d2872 2021-06-20 op new_tab(vl->parent->alt);
244 2b2d2872 2021-06-20 op cmd_previous_button(struct buffer *buffer)
247 2b2d2872 2021-06-20 op if (buffer->current_line == NULL ||
248 2b2d2872 2021-06-20 op buffer->current_line == TAILQ_FIRST(&buffer->head)) {
249 2b2d2872 2021-06-20 op message("No previous link");
252 2b2d2872 2021-06-20 op cmd_previous_line(buffer);
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)
260 2b2d2872 2021-06-20 op if (buffer->current_line == NULL ||
261 2b2d2872 2021-06-20 op buffer->current_line == TAILQ_LAST(&buffer->head, vhead)) {
262 2b2d2872 2021-06-20 op message("No next link");
265 2b2d2872 2021-06-20 op cmd_next_line(buffer);
266 2b2d2872 2021-06-20 op } while (buffer->current_line->parent->type != LINE_LINK);
270 2b2d2872 2021-06-20 op cmd_previous_page(struct buffer *buffer)
272 2b2d2872 2021-06-20 op struct tab *tab = current_tab();
274 2b2d2872 2021-06-20 op if (!load_previous_page(tab))
275 2b2d2872 2021-06-20 op message("No previous page");
277 2b2d2872 2021-06-20 op start_loading_anim(tab);
281 2b2d2872 2021-06-20 op cmd_next_page(struct buffer *buffer)
283 2b2d2872 2021-06-20 op struct tab *tab = current_tab();
285 2b2d2872 2021-06-20 op if (!load_next_page(tab))
286 2b2d2872 2021-06-20 op message("No next page");
288 2b2d2872 2021-06-20 op start_loading_anim(tab);
292 2b2d2872 2021-06-20 op cmd_clear_minibuf(struct buffer *buffer)
294 2b2d2872 2021-06-20 op message(NULL);
298 2b2d2872 2021-06-20 op cmd_execute_extended_command(struct buffer *buffer)
302 2b2d2872 2021-06-20 op if (in_minibuffer) {
303 2b2d2872 2021-06-20 op message("We don't have enable-recursive-minibuffers");
307 2b2d2872 2021-06-20 op enter_minibuffer(eecmd_self_insert, eecmd_select, exit_minibuffer,
308 2b2d2872 2021-06-20 op &eecmd_history);
310 2b2d2872 2021-06-20 op len = sizeof(ministate.prompt);
311 2b2d2872 2021-06-20 op strlcpy(ministate.prompt, "", len);
313 2b2d2872 2021-06-20 op if (thiskey.meta)
314 2b2d2872 2021-06-20 op strlcat(ministate.prompt, "M-", len);
316 2b2d2872 2021-06-20 op strlcat(ministate.prompt, ui_keyname(thiskey.key), len);
318 2b2d2872 2021-06-20 op if (thiskey.meta)
319 2b2d2872 2021-06-20 op strlcat(ministate.prompt, " ", len);
323 2b2d2872 2021-06-20 op cmd_tab_close(struct buffer *buffer)
325 2b2d2872 2021-06-20 op struct tab *tab, *t;
327 2b2d2872 2021-06-20 op tab = current_tab();
328 2b2d2872 2021-06-20 op if (TAILQ_PREV(tab, tabshead, tabs) == NULL &&
329 2b2d2872 2021-06-20 op TAILQ_NEXT(tab, tabs) == NULL) {
330 2b2d2872 2021-06-20 op message("Can't close the only tab.");
334 2b2d2872 2021-06-20 op if (evtimer_pending(&tab->loadingev, NULL))
335 2b2d2872 2021-06-20 op evtimer_del(&tab->loadingev);
337 2b2d2872 2021-06-20 op stop_tab(tab);
339 2b2d2872 2021-06-20 op if ((t = TAILQ_PREV(tab, tabshead, tabs)) == NULL)
340 2b2d2872 2021-06-20 op t = TAILQ_NEXT(tab, tabs);
341 2b2d2872 2021-06-20 op TAILQ_REMOVE(&tabshead, tab, tabs);
344 2b2d2872 2021-06-20 op switch_to_tab(t);
348 2b2d2872 2021-06-20 op cmd_tab_close_other(struct buffer *buffer)
350 2b2d2872 2021-06-20 op struct tab *t, *i;
352 2b2d2872 2021-06-20 op TAILQ_FOREACH_SAFE(t, &tabshead, tabs, i) {
353 2b2d2872 2021-06-20 op if (t->flags & TAB_CURRENT)
357 2b2d2872 2021-06-20 op TAILQ_REMOVE(&tabshead, t, tabs);
363 2b2d2872 2021-06-20 op cmd_tab_new(struct buffer *buffer)
365 2b2d2872 2021-06-20 op const char *url;
367 2b2d2872 2021-06-20 op if ((url = new_tab_url) == NULL)
368 2b2d2872 2021-06-20 op url = NEW_TAB_URL;
370 2b2d2872 2021-06-20 op new_tab(url);
374 2b2d2872 2021-06-20 op cmd_tab_next(struct buffer *buffer)
376 2b2d2872 2021-06-20 op struct tab *tab, *t;
378 2b2d2872 2021-06-20 op tab = current_tab();
379 2b2d2872 2021-06-20 op tab->flags &= ~TAB_CURRENT;
381 2b2d2872 2021-06-20 op if ((t = TAILQ_NEXT(tab, tabs)) == NULL)
382 2b2d2872 2021-06-20 op t = TAILQ_FIRST(&tabshead);
383 2b2d2872 2021-06-20 op t->flags |= TAB_CURRENT;
384 2b2d2872 2021-06-20 op t->flags &= ~TAB_URGENT;
388 2b2d2872 2021-06-20 op cmd_tab_previous(struct buffer *buffer)
390 2b2d2872 2021-06-20 op struct tab *tab, *t;
392 2b2d2872 2021-06-20 op tab = current_tab();
393 2b2d2872 2021-06-20 op tab->flags &= ~TAB_CURRENT;
395 2b2d2872 2021-06-20 op if ((t = TAILQ_PREV(tab, tabshead, tabs)) == NULL)
396 2b2d2872 2021-06-20 op t = TAILQ_LAST(&tabshead, tabshead);
397 2b2d2872 2021-06-20 op t->flags |= TAB_CURRENT;
398 2b2d2872 2021-06-20 op t->flags &= ~TAB_URGENT;
402 2b2d2872 2021-06-20 op cmd_tab_move(struct buffer *buffer)
404 2b2d2872 2021-06-20 op struct tab *tab, *t;
406 2b2d2872 2021-06-20 op tab = current_tab();
407 2b2d2872 2021-06-20 op t = TAILQ_NEXT(tab, tabs);
408 2b2d2872 2021-06-20 op TAILQ_REMOVE(&tabshead, tab, tabs);
410 2b2d2872 2021-06-20 op if (t == NULL)
411 2b2d2872 2021-06-20 op TAILQ_INSERT_HEAD(&tabshead, tab, tabs);
413 2b2d2872 2021-06-20 op TAILQ_INSERT_AFTER(&tabshead, t, tab, tabs);
417 2b2d2872 2021-06-20 op cmd_tab_move_to(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 t = TAILQ_PREV(tab, tabshead, tabs);
423 2b2d2872 2021-06-20 op TAILQ_REMOVE(&tabshead, tab, tabs);
425 2b2d2872 2021-06-20 op if (t == NULL) {
426 2b2d2872 2021-06-20 op if (TAILQ_EMPTY(&tabshead))
427 2b2d2872 2021-06-20 op TAILQ_INSERT_HEAD(&tabshead, tab, tabs);
429 2b2d2872 2021-06-20 op TAILQ_INSERT_TAIL(&tabshead, tab, tabs);
431 2b2d2872 2021-06-20 op TAILQ_INSERT_BEFORE(t, tab, tabs);
435 2b2d2872 2021-06-20 op cmd_load_url(struct buffer *buffer)
437 2b2d2872 2021-06-20 op if (in_minibuffer) {
438 2b2d2872 2021-06-20 op message("We don't have enable-recursive-minibuffers");
442 2b2d2872 2021-06-20 op enter_minibuffer(lu_self_insert, lu_select, exit_minibuffer,
443 2b2d2872 2021-06-20 op &lu_history);
444 2b2d2872 2021-06-20 op strlcpy(ministate.prompt, "Load URL: ", sizeof(ministate.prompt));
445 2b2d2872 2021-06-20 op strlcpy(ministate.buf, "gemini://", sizeof(ministate.buf));
446 2b2d2872 2021-06-20 op cmd_move_end_of_line(&ministate.buffer);
450 2b2d2872 2021-06-20 op cmd_load_current_url(struct buffer *buffer)
452 2b2d2872 2021-06-20 op struct tab *tab = current_tab();
454 2b2d2872 2021-06-20 op if (in_minibuffer) {
455 2b2d2872 2021-06-20 op message("We don't have enable-recursive-minibuffers");
459 2b2d2872 2021-06-20 op enter_minibuffer(lu_self_insert, lu_select, exit_minibuffer,
460 2b2d2872 2021-06-20 op &lu_history);
461 2b2d2872 2021-06-20 op strlcpy(ministate.prompt, "Load URL: ", sizeof(ministate.prompt));
462 2b2d2872 2021-06-20 op strlcpy(ministate.buf, tab->hist_cur->h, sizeof(ministate.buf));
463 2b2d2872 2021-06-20 op ministate.buffer.cpoff = utf8_cplen(ministate.buf);
467 2b2d2872 2021-06-20 op cmd_bookmark_page(struct buffer *buffer)
469 2b2d2872 2021-06-20 op struct tab *tab = current_tab();
471 2b2d2872 2021-06-20 op enter_minibuffer(lu_self_insert, bp_select, exit_minibuffer, NULL);
472 2b2d2872 2021-06-20 op strlcpy(ministate.prompt, "Bookmark URL: ", sizeof(ministate.prompt));
473 2b2d2872 2021-06-20 op strlcpy(ministate.buf, tab->hist_cur->h, sizeof(ministate.buf));
474 2b2d2872 2021-06-20 op ministate.buffer.cpoff = utf8_cplen(ministate.buf);
478 2b2d2872 2021-06-20 op cmd_list_bookmarks(struct buffer *buffer)
480 2b2d2872 2021-06-20 op load_url_in_tab(current_tab(), "about:bookmarks");
484 2b2d2872 2021-06-20 op cmd_toggle_help(struct buffer *buffer)
486 2b2d2872 2021-06-20 op ui_toggle_side_window();
490 2b2d2872 2021-06-20 op cmd_olivetti_mode(struct buffer *buffer)
492 2b2d2872 2021-06-20 op olivetti_mode = !olivetti_mode;
493 2b2d2872 2021-06-20 op if (olivetti_mode)
494 2b2d2872 2021-06-20 op message("olivetti-mode enabled");
496 2b2d2872 2021-06-20 op message("olivetti-mode disabled");
498 2b2d2872 2021-06-20 op ui_schedule_redraw();
502 2b2d2872 2021-06-20 op cmd_mini_delete_char(struct buffer *buffer)
506 2b2d2872 2021-06-20 op if (!in_minibuffer) {
507 2b2d2872 2021-06-20 op message("text is read-only");
511 2b2d2872 2021-06-20 op minibuffer_taint_hist();
513 2b2d2872 2021-06-20 op c = utf8_nth(buffer->current_line->line, buffer->cpoff);
514 2b2d2872 2021-06-20 op if (*c == '\0')
516 2b2d2872 2021-06-20 op n = utf8_next_cp(c);
518 2b2d2872 2021-06-20 op memmove(c, n, strlen(n)+1);
522 2b2d2872 2021-06-20 op cmd_mini_delete_backward_char(struct buffer *buffer)
524 2b2d2872 2021-06-20 op char *c, *p, *start;
526 2b2d2872 2021-06-20 op if (!in_minibuffer) {
527 2b2d2872 2021-06-20 op message("text is read-only");
531 2b2d2872 2021-06-20 op minibuffer_taint_hist();
533 2b2d2872 2021-06-20 op c = utf8_nth(buffer->current_line->line, buffer->cpoff);
534 2b2d2872 2021-06-20 op start = buffer->current_line->line;
535 2b2d2872 2021-06-20 op if (c == start)
537 2b2d2872 2021-06-20 op p = utf8_prev_cp(c-1, start);
539 2b2d2872 2021-06-20 op memmove(p, c, strlen(c)+1);
540 2b2d2872 2021-06-20 op buffer->cpoff--;
544 2b2d2872 2021-06-20 op cmd_mini_kill_line(struct buffer *buffer)
548 2b2d2872 2021-06-20 op if (!in_minibuffer) {
549 2b2d2872 2021-06-20 op message("text is read-only");
553 2b2d2872 2021-06-20 op minibuffer_taint_hist();
554 2b2d2872 2021-06-20 op c = utf8_nth(buffer->current_line->line, buffer->cpoff);
559 2b2d2872 2021-06-20 op cmd_mini_abort(struct buffer *buffer)
561 2b2d2872 2021-06-20 op if (!in_minibuffer)
564 2b2d2872 2021-06-20 op ministate.abortfn();
568 2b2d2872 2021-06-20 op cmd_mini_complete_and_exit(struct buffer *buffer)
570 2b2d2872 2021-06-20 op if (!in_minibuffer)
573 2b2d2872 2021-06-20 op minibuffer_taint_hist();
574 2b2d2872 2021-06-20 op ministate.donefn();
578 2b2d2872 2021-06-20 op cmd_mini_previous_history_element(struct buffer *buffer)
580 2b2d2872 2021-06-20 op if (ministate.history == NULL) {
581 2b2d2872 2021-06-20 op message("No history");
585 2b2d2872 2021-06-20 op if (ministate.hist_cur == NULL ||
586 2b2d2872 2021-06-20 op (ministate.hist_cur = TAILQ_PREV(ministate.hist_cur, mhisthead, entries)) == NULL) {
587 2b2d2872 2021-06-20 op ministate.hist_cur = TAILQ_LAST(&ministate.history->head, mhisthead);
588 2b2d2872 2021-06-20 op ministate.hist_off = ministate.history->len - 1;
589 2b2d2872 2021-06-20 op if (ministate.hist_cur == NULL)
590 2b2d2872 2021-06-20 op message("No prev item");
592 2b2d2872 2021-06-20 op ministate.hist_off--;
595 2b2d2872 2021-06-20 op if (ministate.hist_cur != NULL)
596 2b2d2872 2021-06-20 op buffer->current_line->line = ministate.hist_cur->h;
600 2b2d2872 2021-06-20 op cmd_mini_next_history_element(struct buffer *buffer)
602 2b2d2872 2021-06-20 op if (ministate.history == NULL) {
603 2b2d2872 2021-06-20 op message("No history");
607 2b2d2872 2021-06-20 op if (ministate.hist_cur == NULL ||
608 2b2d2872 2021-06-20 op (ministate.hist_cur = TAILQ_NEXT(ministate.hist_cur, entries)) == NULL) {
609 2b2d2872 2021-06-20 op ministate.hist_cur = TAILQ_FIRST(&ministate.history->head);
610 2b2d2872 2021-06-20 op ministate.hist_off = 0;
611 2b2d2872 2021-06-20 op if (ministate.hist_cur == NULL)
612 2b2d2872 2021-06-20 op message("No next item");
614 2b2d2872 2021-06-20 op ministate.hist_off++;
617 2b2d2872 2021-06-20 op if (ministate.hist_cur != NULL)
618 2b2d2872 2021-06-20 op buffer->current_line->line = ministate.hist_cur->h;