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"
23 2b2d2872 2021-06-20 op #define message ui_notify
26 2b2d2872 2021-06-20 op cmd_previous_line(struct buffer *buffer)
28 2b2d2872 2021-06-20 op struct vline *vl;
30 2b2d2872 2021-06-20 op if (buffer->current_line == NULL
31 2b2d2872 2021-06-20 op || (vl = TAILQ_PREV(buffer->current_line, vhead, vlines)) == NULL)
34 2b2d2872 2021-06-20 op if (--buffer->curs_y < 0) {
35 2b2d2872 2021-06-20 op buffer->curs_y = 0;
36 2b2d2872 2021-06-20 op cmd_scroll_line_up(buffer);
40 2b2d2872 2021-06-20 op buffer->current_line = vl;
41 2b2d2872 2021-06-20 op restore_cursor(buffer);
45 2b2d2872 2021-06-20 op cmd_next_line(struct buffer *buffer)
47 2b2d2872 2021-06-20 op struct vline *vl;
49 2b2d2872 2021-06-20 op if (buffer->current_line == NULL
50 2b2d2872 2021-06-20 op || (vl = TAILQ_NEXT(buffer->current_line, vlines)) == NULL)
53 2b2d2872 2021-06-20 op if (++buffer->curs_y > body_lines-1) {
54 2b2d2872 2021-06-20 op buffer->curs_y = body_lines-1;
55 2b2d2872 2021-06-20 op cmd_scroll_line_down(buffer);
59 2b2d2872 2021-06-20 op buffer->current_line = vl;
60 2b2d2872 2021-06-20 op restore_cursor(buffer);
64 2b2d2872 2021-06-20 op cmd_backward_char(struct buffer *buffer)
66 2b2d2872 2021-06-20 op if (buffer->cpoff != 0)
67 2b2d2872 2021-06-20 op buffer->cpoff--;
68 2b2d2872 2021-06-20 op restore_cursor(buffer);
72 2b2d2872 2021-06-20 op cmd_forward_char(struct buffer *buffer)
74 2b2d2872 2021-06-20 op size_t len = 0;
76 2b2d2872 2021-06-20 op if (buffer->current_line->line != NULL)
77 2b2d2872 2021-06-20 op len = utf8_cplen(buffer->current_line->line);
78 2b2d2872 2021-06-20 op if (++buffer->cpoff > len)
79 2b2d2872 2021-06-20 op buffer->cpoff = len;
80 2b2d2872 2021-06-20 op restore_cursor(buffer);
84 2b2d2872 2021-06-20 op cmd_backward_paragraph(struct buffer *buffer)
87 2b2d2872 2021-06-20 op if (buffer->current_line == NULL ||
88 2b2d2872 2021-06-20 op buffer->current_line == TAILQ_FIRST(&buffer->head)) {
89 2b2d2872 2021-06-20 op message("No previous paragraph");
92 2b2d2872 2021-06-20 op cmd_previous_line(buffer);
93 2b2d2872 2021-06-20 op } while (buffer->current_line->line != NULL ||
94 2b2d2872 2021-06-20 op buffer->current_line->parent->type != LINE_TEXT);
98 2b2d2872 2021-06-20 op cmd_forward_paragraph(struct buffer *buffer)
101 2b2d2872 2021-06-20 op if (buffer->current_line == NULL ||
102 2b2d2872 2021-06-20 op buffer->current_line == TAILQ_LAST(&buffer->head, vhead)) {
103 2b2d2872 2021-06-20 op message("No next paragraph");
106 2b2d2872 2021-06-20 op cmd_next_line(buffer);
107 2b2d2872 2021-06-20 op } while (buffer->current_line->line != NULL ||
108 2b2d2872 2021-06-20 op buffer->current_line->parent->type != LINE_TEXT);
112 2b2d2872 2021-06-20 op cmd_move_beginning_of_line(struct buffer *buffer)
114 2b2d2872 2021-06-20 op buffer->cpoff = 0;
115 2b2d2872 2021-06-20 op restore_cursor(buffer);
119 2b2d2872 2021-06-20 op cmd_move_end_of_line(struct buffer *buffer)
121 2b2d2872 2021-06-20 op struct vline *vl;
123 2b2d2872 2021-06-20 op vl = buffer->current_line;
124 2b2d2872 2021-06-20 op if (vl->line == NULL)
126 2b2d2872 2021-06-20 op buffer->cpoff = utf8_cplen(vl->line);
127 2b2d2872 2021-06-20 op restore_cursor(buffer);
131 2b2d2872 2021-06-20 op cmd_redraw(struct buffer *buffer)
133 2b2d2872 2021-06-20 op ui_schedule_redraw();
137 2b2d2872 2021-06-20 op cmd_scroll_line_up(struct buffer *buffer)
139 2b2d2872 2021-06-20 op struct vline *vl;
141 2b2d2872 2021-06-20 op if (buffer->current_line == NULL)
144 2b2d2872 2021-06-20 op if ((vl = TAILQ_PREV(buffer->current_line, vhead, vlines)) == NULL)
147 2b2d2872 2021-06-20 op buffer->current_line = vl;
148 2b2d2872 2021-06-20 op buffer->line_off--;
149 2b2d2872 2021-06-20 op restore_cursor(buffer);
153 2b2d2872 2021-06-20 op cmd_scroll_line_down(struct buffer *buffer)
155 2b2d2872 2021-06-20 op struct vline *vl;
157 2b2d2872 2021-06-20 op if (buffer->current_line == NULL)
160 2b2d2872 2021-06-20 op if ((vl = TAILQ_NEXT(buffer->current_line, vlines)) == NULL)
163 2b2d2872 2021-06-20 op buffer->current_line = vl;
164 2b2d2872 2021-06-20 op buffer->line_off++;
165 2b2d2872 2021-06-20 op restore_cursor(buffer);
169 2b2d2872 2021-06-20 op cmd_scroll_up(struct buffer *buffer)
173 2b2d2872 2021-06-20 op off = body_lines-1;
175 2b2d2872 2021-06-20 op for (; off > 0; --off)
176 2b2d2872 2021-06-20 op cmd_scroll_line_up(buffer);
180 2b2d2872 2021-06-20 op cmd_scroll_down(struct buffer *buffer)
184 2b2d2872 2021-06-20 op off = body_lines-1;
186 2b2d2872 2021-06-20 op for (; off > 0; --off)
187 2b2d2872 2021-06-20 op cmd_scroll_line_down(buffer);
191 2b2d2872 2021-06-20 op cmd_beginning_of_buffer(struct buffer *buffer)
193 2b2d2872 2021-06-20 op buffer->current_line = TAILQ_FIRST(&buffer->head);
194 2b2d2872 2021-06-20 op buffer->line_off = 0;
195 2b2d2872 2021-06-20 op buffer->curs_y = 0;
196 2b2d2872 2021-06-20 op buffer->cpoff = 0;
197 2b2d2872 2021-06-20 op restore_cursor(buffer);
201 2b2d2872 2021-06-20 op cmd_end_of_buffer(struct buffer *buffer)
205 2b2d2872 2021-06-20 op off = buffer->line_max - body_lines;
206 2b2d2872 2021-06-20 op off = MAX(0, off);
208 2b2d2872 2021-06-20 op buffer->line_off = off;
209 2b2d2872 2021-06-20 op buffer->curs_y = MIN((size_t)body_lines, buffer->line_max-1);
211 2b2d2872 2021-06-20 op buffer->current_line = TAILQ_LAST(&buffer->head, vhead);
212 2b2d2872 2021-06-20 op buffer->cpoff = body_cols;
213 2b2d2872 2021-06-20 op restore_cursor(buffer);
217 2b2d2872 2021-06-20 op cmd_kill_telescope(struct buffer *buffer)
219 2b2d2872 2021-06-20 op save_session();
220 2b2d2872 2021-06-20 op event_loopbreak();
224 2b2d2872 2021-06-20 op cmd_push_button(struct buffer *buffer)
226 2b2d2872 2021-06-20 op struct vline *vl;
228 2b2d2872 2021-06-20 op vl = buffer->current_line;
229 2b2d2872 2021-06-20 op if (vl->parent->type != LINE_LINK)
232 2b2d2872 2021-06-20 op load_url_in_tab(current_tab(), vl->parent->alt);
236 2b2d2872 2021-06-20 op cmd_push_button_new_tab(struct buffer *buffer)
238 2b2d2872 2021-06-20 op struct vline *vl;
240 2b2d2872 2021-06-20 op vl = buffer->current_line;
241 2b2d2872 2021-06-20 op if (vl->parent->type != LINE_LINK)
244 2b2d2872 2021-06-20 op new_tab(vl->parent->alt);
248 2b2d2872 2021-06-20 op cmd_previous_button(struct buffer *buffer)
251 2b2d2872 2021-06-20 op if (buffer->current_line == NULL ||
252 2b2d2872 2021-06-20 op buffer->current_line == TAILQ_FIRST(&buffer->head)) {
253 2b2d2872 2021-06-20 op message("No previous link");
256 2b2d2872 2021-06-20 op cmd_previous_line(buffer);
257 2b2d2872 2021-06-20 op } while (buffer->current_line->parent->type != LINE_LINK);
261 2b2d2872 2021-06-20 op cmd_next_button(struct buffer *buffer)
264 2b2d2872 2021-06-20 op if (buffer->current_line == NULL ||
265 2b2d2872 2021-06-20 op buffer->current_line == TAILQ_LAST(&buffer->head, vhead)) {
266 2b2d2872 2021-06-20 op message("No next link");
269 2b2d2872 2021-06-20 op cmd_next_line(buffer);
270 2b2d2872 2021-06-20 op } while (buffer->current_line->parent->type != LINE_LINK);
274 2b2d2872 2021-06-20 op cmd_previous_page(struct buffer *buffer)
276 2b2d2872 2021-06-20 op struct tab *tab = current_tab();
278 2b2d2872 2021-06-20 op if (!load_previous_page(tab))
279 2b2d2872 2021-06-20 op message("No previous page");
281 2b2d2872 2021-06-20 op start_loading_anim(tab);
285 2b2d2872 2021-06-20 op cmd_next_page(struct buffer *buffer)
287 2b2d2872 2021-06-20 op struct tab *tab = current_tab();
289 2b2d2872 2021-06-20 op if (!load_next_page(tab))
290 2b2d2872 2021-06-20 op message("No next page");
292 2b2d2872 2021-06-20 op start_loading_anim(tab);
296 2b2d2872 2021-06-20 op cmd_clear_minibuf(struct buffer *buffer)
298 2b2d2872 2021-06-20 op message(NULL);
302 2b2d2872 2021-06-20 op cmd_execute_extended_command(struct buffer *buffer)
306 2b2d2872 2021-06-20 op if (in_minibuffer) {
307 2b2d2872 2021-06-20 op message("We don't have enable-recursive-minibuffers");
311 2b2d2872 2021-06-20 op enter_minibuffer(eecmd_self_insert, eecmd_select, exit_minibuffer,
312 2b2d2872 2021-06-20 op &eecmd_history);
314 2b2d2872 2021-06-20 op len = sizeof(ministate.prompt);
315 2b2d2872 2021-06-20 op strlcpy(ministate.prompt, "", len);
317 2b2d2872 2021-06-20 op if (thiskey.meta)
318 2b2d2872 2021-06-20 op strlcat(ministate.prompt, "M-", len);
320 2b2d2872 2021-06-20 op strlcat(ministate.prompt, ui_keyname(thiskey.key), len);
322 2b2d2872 2021-06-20 op if (thiskey.meta)
323 2b2d2872 2021-06-20 op strlcat(ministate.prompt, " ", len);
327 2b2d2872 2021-06-20 op cmd_tab_close(struct buffer *buffer)
329 2b2d2872 2021-06-20 op struct tab *tab, *t;
331 2b2d2872 2021-06-20 op tab = current_tab();
332 2b2d2872 2021-06-20 op if (TAILQ_PREV(tab, tabshead, tabs) == NULL &&
333 2b2d2872 2021-06-20 op TAILQ_NEXT(tab, tabs) == NULL) {
334 2b2d2872 2021-06-20 op message("Can't close the only tab.");
338 2b2d2872 2021-06-20 op if (evtimer_pending(&tab->loadingev, NULL))
339 2b2d2872 2021-06-20 op evtimer_del(&tab->loadingev);
341 2b2d2872 2021-06-20 op stop_tab(tab);
343 2b2d2872 2021-06-20 op if ((t = TAILQ_PREV(tab, tabshead, tabs)) == NULL)
344 2b2d2872 2021-06-20 op t = TAILQ_NEXT(tab, tabs);
345 2b2d2872 2021-06-20 op TAILQ_REMOVE(&tabshead, tab, tabs);
348 2b2d2872 2021-06-20 op switch_to_tab(t);
352 2b2d2872 2021-06-20 op cmd_tab_close_other(struct buffer *buffer)
354 2b2d2872 2021-06-20 op struct tab *t, *i;
356 2b2d2872 2021-06-20 op TAILQ_FOREACH_SAFE(t, &tabshead, tabs, i) {
357 2b2d2872 2021-06-20 op if (t->flags & TAB_CURRENT)
361 2b2d2872 2021-06-20 op TAILQ_REMOVE(&tabshead, t, tabs);
367 2b2d2872 2021-06-20 op cmd_tab_new(struct buffer *buffer)
369 2b2d2872 2021-06-20 op const char *url;
371 2b2d2872 2021-06-20 op if ((url = new_tab_url) == NULL)
372 2b2d2872 2021-06-20 op url = NEW_TAB_URL;
374 2b2d2872 2021-06-20 op new_tab(url);
378 2b2d2872 2021-06-20 op cmd_tab_next(struct buffer *buffer)
380 2b2d2872 2021-06-20 op struct tab *tab, *t;
382 2b2d2872 2021-06-20 op tab = current_tab();
383 2b2d2872 2021-06-20 op tab->flags &= ~TAB_CURRENT;
385 2b2d2872 2021-06-20 op if ((t = TAILQ_NEXT(tab, tabs)) == NULL)
386 2b2d2872 2021-06-20 op t = TAILQ_FIRST(&tabshead);
387 2b2d2872 2021-06-20 op t->flags |= TAB_CURRENT;
388 2b2d2872 2021-06-20 op t->flags &= ~TAB_URGENT;
392 2b2d2872 2021-06-20 op cmd_tab_previous(struct buffer *buffer)
394 2b2d2872 2021-06-20 op struct tab *tab, *t;
396 2b2d2872 2021-06-20 op tab = current_tab();
397 2b2d2872 2021-06-20 op tab->flags &= ~TAB_CURRENT;
399 2b2d2872 2021-06-20 op if ((t = TAILQ_PREV(tab, tabshead, tabs)) == NULL)
400 2b2d2872 2021-06-20 op t = TAILQ_LAST(&tabshead, tabshead);
401 2b2d2872 2021-06-20 op t->flags |= TAB_CURRENT;
402 2b2d2872 2021-06-20 op t->flags &= ~TAB_URGENT;
406 2b2d2872 2021-06-20 op cmd_tab_move(struct buffer *buffer)
408 2b2d2872 2021-06-20 op struct tab *tab, *t;
410 2b2d2872 2021-06-20 op tab = current_tab();
411 2b2d2872 2021-06-20 op t = TAILQ_NEXT(tab, tabs);
412 2b2d2872 2021-06-20 op TAILQ_REMOVE(&tabshead, tab, tabs);
414 2b2d2872 2021-06-20 op if (t == NULL)
415 2b2d2872 2021-06-20 op TAILQ_INSERT_HEAD(&tabshead, tab, tabs);
417 2b2d2872 2021-06-20 op TAILQ_INSERT_AFTER(&tabshead, t, tab, tabs);
421 2b2d2872 2021-06-20 op cmd_tab_move_to(struct buffer *buffer)
423 2b2d2872 2021-06-20 op struct tab *tab, *t;
425 2b2d2872 2021-06-20 op tab = current_tab();
426 2b2d2872 2021-06-20 op t = TAILQ_PREV(tab, tabshead, tabs);
427 2b2d2872 2021-06-20 op TAILQ_REMOVE(&tabshead, tab, tabs);
429 2b2d2872 2021-06-20 op if (t == NULL) {
430 2b2d2872 2021-06-20 op if (TAILQ_EMPTY(&tabshead))
431 2b2d2872 2021-06-20 op TAILQ_INSERT_HEAD(&tabshead, tab, tabs);
433 2b2d2872 2021-06-20 op TAILQ_INSERT_TAIL(&tabshead, tab, tabs);
435 2b2d2872 2021-06-20 op TAILQ_INSERT_BEFORE(t, tab, tabs);
439 2b2d2872 2021-06-20 op cmd_load_url(struct buffer *buffer)
441 2b2d2872 2021-06-20 op if (in_minibuffer) {
442 2b2d2872 2021-06-20 op message("We don't have enable-recursive-minibuffers");
446 2b2d2872 2021-06-20 op enter_minibuffer(lu_self_insert, lu_select, exit_minibuffer,
447 2b2d2872 2021-06-20 op &lu_history);
448 2b2d2872 2021-06-20 op strlcpy(ministate.prompt, "Load URL: ", sizeof(ministate.prompt));
449 2b2d2872 2021-06-20 op strlcpy(ministate.buf, "gemini://", sizeof(ministate.buf));
450 2b2d2872 2021-06-20 op cmd_move_end_of_line(&ministate.buffer);
454 2b2d2872 2021-06-20 op cmd_load_current_url(struct buffer *buffer)
456 2b2d2872 2021-06-20 op struct tab *tab = current_tab();
458 2b2d2872 2021-06-20 op if (in_minibuffer) {
459 2b2d2872 2021-06-20 op message("We don't have enable-recursive-minibuffers");
463 2b2d2872 2021-06-20 op enter_minibuffer(lu_self_insert, lu_select, exit_minibuffer,
464 2b2d2872 2021-06-20 op &lu_history);
465 2b2d2872 2021-06-20 op strlcpy(ministate.prompt, "Load URL: ", sizeof(ministate.prompt));
466 2b2d2872 2021-06-20 op strlcpy(ministate.buf, tab->hist_cur->h, sizeof(ministate.buf));
467 2b2d2872 2021-06-20 op ministate.buffer.cpoff = utf8_cplen(ministate.buf);
471 2b2d2872 2021-06-20 op cmd_bookmark_page(struct buffer *buffer)
473 2b2d2872 2021-06-20 op struct tab *tab = current_tab();
475 2b2d2872 2021-06-20 op enter_minibuffer(lu_self_insert, bp_select, exit_minibuffer, NULL);
476 2b2d2872 2021-06-20 op strlcpy(ministate.prompt, "Bookmark URL: ", sizeof(ministate.prompt));
477 2b2d2872 2021-06-20 op strlcpy(ministate.buf, tab->hist_cur->h, sizeof(ministate.buf));
478 2b2d2872 2021-06-20 op ministate.buffer.cpoff = utf8_cplen(ministate.buf);
482 2b2d2872 2021-06-20 op cmd_list_bookmarks(struct buffer *buffer)
484 2b2d2872 2021-06-20 op load_url_in_tab(current_tab(), "about:bookmarks");
488 2b2d2872 2021-06-20 op cmd_toggle_help(struct buffer *buffer)
490 2b2d2872 2021-06-20 op ui_toggle_side_window();
491 2b2d2872 2021-06-20 op ui_schedule_redraw();
495 2b2d2872 2021-06-20 op cmd_olivetti_mode(struct buffer *buffer)
497 2b2d2872 2021-06-20 op olivetti_mode = !olivetti_mode;
498 2b2d2872 2021-06-20 op if (olivetti_mode)
499 2b2d2872 2021-06-20 op message("olivetti-mode enabled");
501 2b2d2872 2021-06-20 op message("olivetti-mode disabled");
503 2b2d2872 2021-06-20 op ui_schedule_redraw();
507 2b2d2872 2021-06-20 op cmd_mini_delete_char(struct buffer *buffer)
511 2b2d2872 2021-06-20 op if (!in_minibuffer) {
512 2b2d2872 2021-06-20 op message("text is read-only");
516 2b2d2872 2021-06-20 op minibuffer_taint_hist();
518 2b2d2872 2021-06-20 op c = utf8_nth(buffer->current_line->line, buffer->cpoff);
519 2b2d2872 2021-06-20 op if (*c == '\0')
521 2b2d2872 2021-06-20 op n = utf8_next_cp(c);
523 2b2d2872 2021-06-20 op memmove(c, n, strlen(n)+1);
527 2b2d2872 2021-06-20 op cmd_mini_delete_backward_char(struct buffer *buffer)
529 2b2d2872 2021-06-20 op char *c, *p, *start;
531 2b2d2872 2021-06-20 op if (!in_minibuffer) {
532 2b2d2872 2021-06-20 op message("text is read-only");
536 2b2d2872 2021-06-20 op minibuffer_taint_hist();
538 2b2d2872 2021-06-20 op c = utf8_nth(buffer->current_line->line, buffer->cpoff);
539 2b2d2872 2021-06-20 op start = buffer->current_line->line;
540 2b2d2872 2021-06-20 op if (c == start)
542 2b2d2872 2021-06-20 op p = utf8_prev_cp(c-1, start);
544 2b2d2872 2021-06-20 op memmove(p, c, strlen(c)+1);
545 2b2d2872 2021-06-20 op buffer->cpoff--;
549 2b2d2872 2021-06-20 op cmd_mini_kill_line(struct buffer *buffer)
553 2b2d2872 2021-06-20 op if (!in_minibuffer) {
554 2b2d2872 2021-06-20 op message("text is read-only");
558 2b2d2872 2021-06-20 op minibuffer_taint_hist();
559 2b2d2872 2021-06-20 op c = utf8_nth(buffer->current_line->line, buffer->cpoff);
564 2b2d2872 2021-06-20 op cmd_mini_abort(struct buffer *buffer)
566 2b2d2872 2021-06-20 op if (!in_minibuffer)
569 2b2d2872 2021-06-20 op ministate.abortfn();
573 2b2d2872 2021-06-20 op cmd_mini_complete_and_exit(struct buffer *buffer)
575 2b2d2872 2021-06-20 op if (!in_minibuffer)
578 2b2d2872 2021-06-20 op minibuffer_taint_hist();
579 2b2d2872 2021-06-20 op ministate.donefn();
583 2b2d2872 2021-06-20 op cmd_mini_previous_history_element(struct buffer *buffer)
585 2b2d2872 2021-06-20 op if (ministate.history == NULL) {
586 2b2d2872 2021-06-20 op message("No history");
590 2b2d2872 2021-06-20 op if (ministate.hist_cur == NULL ||
591 2b2d2872 2021-06-20 op (ministate.hist_cur = TAILQ_PREV(ministate.hist_cur, mhisthead, entries)) == NULL) {
592 2b2d2872 2021-06-20 op ministate.hist_cur = TAILQ_LAST(&ministate.history->head, mhisthead);
593 2b2d2872 2021-06-20 op ministate.hist_off = ministate.history->len - 1;
594 2b2d2872 2021-06-20 op if (ministate.hist_cur == NULL)
595 2b2d2872 2021-06-20 op message("No prev item");
597 2b2d2872 2021-06-20 op ministate.hist_off--;
600 2b2d2872 2021-06-20 op if (ministate.hist_cur != NULL)
601 2b2d2872 2021-06-20 op buffer->current_line->line = ministate.hist_cur->h;
605 2b2d2872 2021-06-20 op cmd_mini_next_history_element(struct buffer *buffer)
607 2b2d2872 2021-06-20 op if (ministate.history == NULL) {
608 2b2d2872 2021-06-20 op message("No history");
612 2b2d2872 2021-06-20 op if (ministate.hist_cur == NULL ||
613 2b2d2872 2021-06-20 op (ministate.hist_cur = TAILQ_NEXT(ministate.hist_cur, entries)) == NULL) {
614 2b2d2872 2021-06-20 op ministate.hist_cur = TAILQ_FIRST(&ministate.history->head);
615 2b2d2872 2021-06-20 op ministate.hist_off = 0;
616 2b2d2872 2021-06-20 op if (ministate.hist_cur == NULL)
617 2b2d2872 2021-06-20 op message("No next item");
619 2b2d2872 2021-06-20 op ministate.hist_off++;
622 2b2d2872 2021-06-20 op if (ministate.hist_cur != NULL)
623 2b2d2872 2021-06-20 op buffer->current_line->line = ministate.hist_cur->h;