2 a36bb43a 2024-01-15 op * Copyright (c) 2021, 2024 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 786e6deb 2021-07-21 op #include "compat.h"
19 61251035 2021-06-26 op #include <limits.h>
20 0548291a 2024-06-25 op #include <signal.h>
21 2b2d2872 2021-06-20 op #include <stdlib.h>
22 61251035 2021-06-26 op #include <string.h>
23 a2212172 2024-06-26 thomas.ad #include <unistd.h>
25 6d24bfb3 2024-10-19 op #include <grapheme.h>
27 4fdc9933 2024-02-05 op #include "certs.h"
28 d252d87c 2024-02-05 op #include "cmd.h"
29 b1e1e41a 2021-07-14 op #include "compl.h"
30 e5a2797f 2021-07-13 op #include "defaults.h"
31 98d3e6c1 2024-02-18 op #include "ev.h"
32 0548291a 2024-06-25 op #include "exec.h"
33 65c49665 2024-01-23 op #include "hist.h"
34 f7db6d13 2024-02-06 op #include "keymap.h"
35 eeebca22 2022-01-11 op #include "mcache.h"
36 450a89f7 2021-07-12 op #include "minibuffer.h"
37 1fce2e75 2021-08-14 op #include "session.h"
38 2b2d2872 2021-06-20 op #include "telescope.h"
39 d1a0f2a3 2021-07-12 op #include "ui.h"
40 12be77f9 2024-10-22 op #include "utf8.h"
41 c8c572e4 2022-02-08 op #include "utils.h"
43 ca231710 2021-07-15 op #define GUARD_RECURSIVE_MINIBUFFER() \
45 ca231710 2021-07-15 op if (in_minibuffer) { \
46 ca231710 2021-07-15 op message("enable-recursive-minibuffers " \
47 ca231710 2021-07-15 op "is not yet available."); \
52 5a3c3ede 2021-07-19 op #define GUARD_READ_ONLY() \
54 5a3c3ede 2021-07-19 op if (!in_minibuffer) { \
55 5a3c3ede 2021-07-19 op message("text is read-only"); \
60 c4c82003 2021-07-01 op /* return 1 if moved, 0 otherwise */
61 c4c82003 2021-07-01 op static inline int
62 c4c82003 2021-07-01 op forward_line(struct buffer *buffer, int n)
64 c4c82003 2021-07-01 op struct vline *vl;
66 12be77f9 2024-10-22 op size_t left, off;
67 12be77f9 2024-10-22 op int did, target, col = 0; /* XXX breaks with tabs! */
69 c4c82003 2021-07-01 op if (buffer->current_line == NULL)
71 963c680c 2021-07-05 op vl = buffer->current_line;
73 12be77f9 2024-10-22 op text = vl->parent->line + vl->from;
74 12be77f9 2024-10-22 op left = MIN(vl->len, buffer->point_offset);
75 12be77f9 2024-10-22 op target = utf8_snwidth(text, left, 0); /* XXX breaks with tabs! */
78 c4c82003 2021-07-01 op while (n != 0) {
80 963c680c 2021-07-05 op vl = TAILQ_NEXT(vl, vlines);
81 c4c82003 2021-07-01 op if (vl == NULL)
83 963c680c 2021-07-05 op if (vl->parent->flags & L_HIDDEN)
85 c4c82003 2021-07-01 op buffer->current_line = vl;
88 963c680c 2021-07-05 op vl = TAILQ_PREV(vl, vhead, vlines);
89 c4c82003 2021-07-01 op if (vl == NULL)
91 963c680c 2021-07-05 op if (vl->parent->flags & L_HIDDEN)
93 6e6c6afb 2021-07-14 op if (buffer->current_line == buffer->top_line) {
94 6e6c6afb 2021-07-14 op buffer->line_off--;
95 c4c82003 2021-07-01 op buffer->top_line = vl;
97 c4c82003 2021-07-01 op buffer->current_line = vl;
104 12be77f9 2024-10-22 op /* keep the cursor in the same column */
106 12be77f9 2024-10-22 op vl = buffer->current_line;
107 12be77f9 2024-10-22 op text = vl->parent->line + vl->from;
108 12be77f9 2024-10-22 op left = vl->len;
109 12be77f9 2024-10-22 op buffer->point_offset = 0;
110 12be77f9 2024-10-22 op while (left > 0 && col < target) {
111 12be77f9 2024-10-22 op off = grapheme_next_character_break_utf8(text, left);
112 12be77f9 2024-10-22 op col += utf8_snwidth(text, off, col);
115 12be77f9 2024-10-22 op buffer->point_offset += off;
123 c4c82003 2021-07-01 op cmd_previous_line(struct buffer *buffer)
125 c4c82003 2021-07-01 op forward_line(buffer, -1);
129 c4c82003 2021-07-01 op cmd_next_line(struct buffer *buffer)
131 c4c82003 2021-07-01 op forward_line(buffer, +1);
135 2b2d2872 2021-06-20 op cmd_backward_char(struct buffer *buffer)
137 6d24bfb3 2024-10-19 op struct vline *vl;
139 6d24bfb3 2024-10-19 op size_t left, off, point = 0;
141 6d24bfb3 2024-10-19 op if ((vl = buffer->current_line) == NULL)
144 6d24bfb3 2024-10-19 op text = vl->parent->line + vl->from;
145 6d24bfb3 2024-10-19 op left = vl->len;
148 6d24bfb3 2024-10-19 op off = grapheme_next_character_break_utf8(text, left);
149 6d24bfb3 2024-10-19 op if (point + off >= buffer->point_offset)
151 6d24bfb3 2024-10-19 op point += off;
156 6d24bfb3 2024-10-19 op buffer->point_offset = point;
160 2b2d2872 2021-06-20 op cmd_forward_char(struct buffer *buffer)
162 6d24bfb3 2024-10-19 op struct vline *vl;
164 6d24bfb3 2024-10-19 op size_t left, off;
166 6d24bfb3 2024-10-19 op if ((vl = buffer->current_line) == NULL)
169 6d24bfb3 2024-10-19 op text = vl->parent->line + vl->from;
170 6d24bfb3 2024-10-19 op left = vl->len;
172 6d24bfb3 2024-10-19 op text += buffer->point_offset;
173 6d24bfb3 2024-10-19 op left -= buffer->point_offset;
175 6d24bfb3 2024-10-19 op off = grapheme_next_character_break_utf8(text, left);
176 6d24bfb3 2024-10-19 op buffer->point_offset += off;
180 2b2d2872 2021-06-20 op cmd_backward_paragraph(struct buffer *buffer)
183 c4c82003 2021-07-01 op if (!forward_line(buffer, -1)) {
184 2b2d2872 2021-06-20 op message("No previous paragraph");
187 bd4a08a7 2022-11-07 op } while (buffer->current_line->len != 0 ||
188 2b2d2872 2021-06-20 op buffer->current_line->parent->type != LINE_TEXT);
192 2b2d2872 2021-06-20 op cmd_forward_paragraph(struct buffer *buffer)
195 c4c82003 2021-07-01 op if (!forward_line(buffer, +1)) {
196 2b2d2872 2021-06-20 op message("No next paragraph");
199 bd4a08a7 2022-11-07 op } while (buffer->current_line->len != 0 ||
200 2b2d2872 2021-06-20 op buffer->current_line->parent->type != LINE_TEXT);
204 2b2d2872 2021-06-20 op cmd_move_beginning_of_line(struct buffer *buffer)
206 6d24bfb3 2024-10-19 op buffer->point_offset = 0;
210 2b2d2872 2021-06-20 op cmd_move_end_of_line(struct buffer *buffer)
212 2b2d2872 2021-06-20 op struct vline *vl;
214 2b2d2872 2021-06-20 op vl = buffer->current_line;
215 bd4a08a7 2022-11-07 op if (vl == NULL)
217 6d24bfb3 2024-10-19 op buffer->point_offset = vl->len;
221 2b2d2872 2021-06-20 op cmd_redraw(struct buffer *buffer)
223 95a8c791 2021-08-26 op ui_schedule_redraw();
227 2b2d2872 2021-06-20 op cmd_scroll_line_up(struct buffer *buffer)
229 e39920a9 2021-07-07 op struct vline *vl;
232 028fff57 2021-07-30 op if (buffer->top_line == NULL)
235 028fff57 2021-07-30 op if ((vl = TAILQ_PREV(buffer->top_line, vhead, vlines))
239 028fff57 2021-07-30 op buffer->top_line = vl;
241 028fff57 2021-07-30 op if (vl->parent->flags & L_HIDDEN)
247 41b1ed04 2021-07-21 op buffer->line_off--;
249 028fff57 2021-07-30 op forward_line(buffer, -1);
253 2b2d2872 2021-06-20 op cmd_scroll_line_down(struct buffer *buffer)
255 c4c82003 2021-07-01 op if (!forward_line(buffer, +1))
259 028fff57 2021-07-30 op if (buffer->top_line == NULL)
262 028fff57 2021-07-30 op buffer->top_line = TAILQ_NEXT(buffer->top_line, vlines);
263 028fff57 2021-07-30 op if (buffer->top_line->parent->flags & L_HIDDEN)
268 2b2d2872 2021-06-20 op buffer->line_off++;
272 2b2d2872 2021-06-20 op cmd_scroll_up(struct buffer *buffer)
274 64923c4b 2021-07-15 op struct vline *vl;
277 b471d670 2021-07-24 op if (buffer->top_line == NULL)
280 64923c4b 2021-07-15 op for (i = 0; i < body_lines; ++i) {
281 64923c4b 2021-07-15 op vl = TAILQ_PREV(buffer->top_line, vhead, vlines);
282 64923c4b 2021-07-15 op if (vl == NULL)
284 eab11449 2021-07-19 op buffer->line_off--;
285 64923c4b 2021-07-15 op buffer->top_line = vl;
286 64923c4b 2021-07-15 op forward_line(buffer, -1);
291 2b2d2872 2021-06-20 op cmd_scroll_down(struct buffer *buffer)
295 b471d670 2021-07-24 op if (buffer->top_line == NULL)
298 64923c4b 2021-07-15 op for (i = 0; i < body_lines; ++i) {
299 64923c4b 2021-07-15 op if (!forward_line(buffer, +1))
302 64923c4b 2021-07-15 op buffer->top_line = TAILQ_NEXT(buffer->top_line,
304 eab11449 2021-07-19 op buffer->line_off++;
309 2b2d2872 2021-06-20 op cmd_beginning_of_buffer(struct buffer *buffer)
311 c1d27b0e 2024-06-14 op buffer->current_line = TAILQ_FIRST(&buffer->vhead);
312 6d24bfb3 2024-10-19 op buffer->point_offset = 0;
313 94ec38e8 2021-06-29 op buffer->top_line = buffer->current_line;
314 2b2d2872 2021-06-20 op buffer->line_off = 0;
318 2b2d2872 2021-06-20 op cmd_end_of_buffer(struct buffer *buffer)
320 c1d27b0e 2024-06-14 op buffer->current_line = TAILQ_LAST(&buffer->vhead, vhead);
322 52b1043c 2021-07-19 op if (buffer->current_line == NULL)
325 f04d2fc5 2021-07-18 op /* deal with invisible lines */
326 f04d2fc5 2021-07-18 op if (buffer->current_line->parent->flags & L_HIDDEN)
327 f04d2fc5 2021-07-18 op forward_line(buffer, -1);
329 f04d2fc5 2021-07-18 op cmd_move_end_of_line(buffer);
333 057e7eb6 2024-06-22 op kill_telescope_cb(int r, void *data)
336 5b3e45c1 2022-01-02 op save_session();
342 2b2d2872 2021-06-20 op cmd_kill_telescope(struct buffer *buffer)
344 5b3e45c1 2022-01-02 op yornp("really quit?", kill_telescope_cb, NULL);
348 2b2d2872 2021-06-20 op cmd_push_button(struct buffer *buffer)
350 2b2d2872 2021-06-20 op struct vline *vl;
351 963c680c 2021-07-05 op struct line *l;
353 2b2d2872 2021-06-20 op vl = buffer->current_line;
355 a87cfde9 2021-07-19 op if (vl == NULL)
358 963c680c 2021-07-05 op switch (vl->parent->type) {
359 963c680c 2021-07-05 op case LINE_LINK:
360 ed21a9a1 2022-01-11 op load_url_in_tab(current_tab, vl->parent->alt, NULL,
361 ed21a9a1 2022-01-11 op LU_MODE_NOCACHE);
363 963c680c 2021-07-05 op case LINE_PRE_START:
364 963c680c 2021-07-05 op l = TAILQ_NEXT(vl->parent, lines);
365 963c680c 2021-07-05 op for (; l != NULL; l = TAILQ_NEXT(l, lines)) {
366 963c680c 2021-07-05 op if (l->type == LINE_PRE_END)
368 963c680c 2021-07-05 op l->flags ^= L_HIDDEN;
369 6e6c6afb 2021-07-14 op if (l->flags & L_HIDDEN)
370 6e6c6afb 2021-07-14 op buffer->line_max--;
372 6e6c6afb 2021-07-14 op buffer->line_max++;
381 2b2d2872 2021-06-20 op cmd_push_button_new_tab(struct buffer *buffer)
383 2b2d2872 2021-06-20 op struct vline *vl;
385 2b2d2872 2021-06-20 op vl = buffer->current_line;
386 a87cfde9 2021-07-19 op if (vl == NULL || vl->parent->type != LINE_LINK)
389 65c49665 2024-01-23 op new_tab(vl->parent->alt, hist_cur(current_tab->hist), current_tab);
393 2b2d2872 2021-06-20 op cmd_previous_button(struct buffer *buffer)
395 5d0feb4b 2021-06-23 op struct excursion place;
397 5d0feb4b 2021-06-23 op save_excursion(&place, buffer);
400 c4c82003 2021-07-01 op if (!forward_line(buffer, -1)) {
401 5d0feb4b 2021-06-23 op restore_excursion(&place, buffer);
402 2b2d2872 2021-06-20 op message("No previous link");
405 2b2d2872 2021-06-20 op } while (buffer->current_line->parent->type != LINE_LINK);
409 2b2d2872 2021-06-20 op cmd_next_button(struct buffer *buffer)
411 5d0feb4b 2021-06-23 op struct excursion place;
413 5d0feb4b 2021-06-23 op save_excursion(&place, buffer);
416 c4c82003 2021-07-01 op if (!forward_line(buffer, +1)){
417 5d0feb4b 2021-06-23 op restore_excursion(&place, buffer);
418 2b2d2872 2021-06-20 op message("No next link");
421 2b2d2872 2021-06-20 op } while (buffer->current_line->parent->type != LINE_LINK);
424 1c412d48 2021-06-25 op static inline int
425 1c412d48 2021-06-25 op is_heading(const struct line *l)
427 1c412d48 2021-06-25 op return l->type == LINE_TITLE_1 ||
428 1c412d48 2021-06-25 op l->type == LINE_TITLE_2 ||
429 1c412d48 2021-06-25 op l->type == LINE_TITLE_3;
433 1c412d48 2021-06-25 op cmd_previous_heading(struct buffer *buffer)
435 1c412d48 2021-06-25 op struct excursion place;
437 1c412d48 2021-06-25 op save_excursion(&place, buffer);
440 c4c82003 2021-07-01 op if (!forward_line(buffer, -1)) {
441 1c412d48 2021-06-25 op restore_excursion(&place, buffer);
442 1c412d48 2021-06-25 op message("No previous heading");
445 1c412d48 2021-06-25 op } while (!is_heading(buffer->current_line->parent));
449 1c412d48 2021-06-25 op cmd_next_heading(struct buffer *buffer)
451 1c412d48 2021-06-25 op struct excursion place;
453 1c412d48 2021-06-25 op save_excursion(&place, buffer);
456 c4c82003 2021-07-01 op if (!forward_line(buffer, +1)) {
457 1c412d48 2021-06-25 op restore_excursion(&place, buffer);
458 1c412d48 2021-06-25 op message("No next heading");
461 1c412d48 2021-06-25 op } while (!is_heading(buffer->current_line->parent));
465 2b2d2872 2021-06-20 op cmd_previous_page(struct buffer *buffer)
467 83dce83d 2021-07-17 op if (!load_previous_page(current_tab))
468 2b2d2872 2021-06-20 op message("No previous page");
472 2b2d2872 2021-06-20 op cmd_next_page(struct buffer *buffer)
474 83dce83d 2021-07-17 op if (!load_next_page(current_tab))
475 2b2d2872 2021-06-20 op message("No next page");
479 2b2d2872 2021-06-20 op cmd_clear_minibuf(struct buffer *buffer)
481 95a8c791 2021-08-26 op message(NULL);
485 2b2d2872 2021-06-20 op cmd_execute_extended_command(struct buffer *buffer)
487 dfd1efcc 2024-06-23 op struct minibuffer m = {
488 dfd1efcc 2024-06-23 op .self_insert = sensible_self_insert,
489 dfd1efcc 2024-06-23 op .done = eecmd_select,
490 dfd1efcc 2024-06-23 op .history = eecmd_history,
491 dfd1efcc 2024-06-23 op .complfn = compl_eecmd,
492 dfd1efcc 2024-06-23 op .must_select = 1,
495 ca231710 2021-07-15 op GUARD_RECURSIVE_MINIBUFFER();
497 dfd1efcc 2024-06-23 op enter_minibuffer(&m, "%s%s%s", thiskey.meta ? "M-" : "",
498 dfd1efcc 2024-06-23 op ui_keyname(thiskey.key), thiskey.meta ? " " : "");
502 2b2d2872 2021-06-20 op cmd_tab_close(struct buffer *buffer)
504 2b2d2872 2021-06-20 op struct tab *tab, *t;
506 83dce83d 2021-07-17 op tab = current_tab;
508 90730426 2021-07-21 op if ((t = TAILQ_NEXT(tab, tabs)) != NULL ||
509 90730426 2021-07-21 op (t = TAILQ_PREV(tab, tabshead, tabs)) != NULL) {
510 90730426 2021-07-21 op switch_to_tab(t);
511 05de8ac3 2022-01-06 op kill_tab(tab, 0);
513 90730426 2021-07-21 op message("Can't close the only tab.");
518 2b2d2872 2021-06-20 op cmd_tab_close_other(struct buffer *buffer)
520 2b2d2872 2021-06-20 op struct tab *t, *i;
522 2b2d2872 2021-06-20 op TAILQ_FOREACH_SAFE(t, &tabshead, tabs, i) {
523 83dce83d 2021-07-17 op if (t == current_tab)
526 05de8ac3 2022-01-06 op kill_tab(t, 0);
531 6c74799d 2022-01-05 op cmd_tab_undo_close(struct buffer *buffer)
533 6c74799d 2022-01-05 op struct tab *t;
535 6c74799d 2022-01-05 op if ((t = unkill_tab()) == NULL) {
536 6c74799d 2022-01-05 op message("No recently-closed tabs");
540 6c74799d 2022-01-05 op switch_to_tab(t);
544 2b2d2872 2021-06-20 op cmd_tab_new(struct buffer *buffer)
546 2b2d2872 2021-06-20 op const char *url;
548 2b2d2872 2021-06-20 op if ((url = new_tab_url) == NULL)
549 2b2d2872 2021-06-20 op url = NEW_TAB_URL;
551 55eb4d95 2021-08-12 op new_tab(url, NULL, NULL);
555 2b2d2872 2021-06-20 op cmd_tab_next(struct buffer *buffer)
557 83dce83d 2021-07-17 op struct tab *t;
559 83dce83d 2021-07-17 op if ((t = TAILQ_NEXT(current_tab, tabs)) == NULL)
560 2b2d2872 2021-06-20 op t = TAILQ_FIRST(&tabshead);
561 2ddbda6b 2021-07-17 op switch_to_tab(t);
565 2b2d2872 2021-06-20 op cmd_tab_previous(struct buffer *buffer)
567 83dce83d 2021-07-17 op struct tab *t;
569 83dce83d 2021-07-17 op if ((t = TAILQ_PREV(current_tab, tabshead, tabs)) == NULL)
570 2b2d2872 2021-06-20 op t = TAILQ_LAST(&tabshead, tabshead);
571 2ddbda6b 2021-07-17 op switch_to_tab(t);
575 2b2d2872 2021-06-20 op cmd_tab_move(struct buffer *buffer)
577 83dce83d 2021-07-17 op struct tab *t;
579 83dce83d 2021-07-17 op t = TAILQ_NEXT(current_tab, tabs);
580 83dce83d 2021-07-17 op TAILQ_REMOVE(&tabshead, current_tab, tabs);
582 2b2d2872 2021-06-20 op if (t == NULL)
583 83dce83d 2021-07-17 op TAILQ_INSERT_HEAD(&tabshead, current_tab, tabs);
585 83dce83d 2021-07-17 op TAILQ_INSERT_AFTER(&tabshead, t, current_tab, tabs);
589 2b2d2872 2021-06-20 op cmd_tab_move_to(struct buffer *buffer)
591 83dce83d 2021-07-17 op struct tab *t;
593 83dce83d 2021-07-17 op t = TAILQ_PREV(current_tab, tabshead, tabs);
594 83dce83d 2021-07-17 op TAILQ_REMOVE(&tabshead, current_tab, tabs);
596 32ac17a4 2021-08-12 op if (t == NULL)
597 32ac17a4 2021-08-12 op TAILQ_INSERT_TAIL(&tabshead, current_tab, tabs);
599 83dce83d 2021-07-17 op TAILQ_INSERT_BEFORE(t, current_tab, tabs);
603 65601367 2021-07-14 op cmd_tab_select(struct buffer *buffer)
605 dfd1efcc 2024-06-23 op struct minibuffer m = {
606 dfd1efcc 2024-06-23 op .self_insert = sensible_self_insert,
607 dfd1efcc 2024-06-23 op .done = ts_select,
608 dfd1efcc 2024-06-23 op .complfn = compl_ts,
609 dfd1efcc 2024-06-23 op .must_select = 1,
612 ca231710 2021-07-15 op GUARD_RECURSIVE_MINIBUFFER();
614 dfd1efcc 2024-06-23 op enter_minibuffer(&m, "Select tab: ");
618 2b2d2872 2021-06-20 op cmd_load_url(struct buffer *buffer)
620 dfd1efcc 2024-06-23 op struct minibuffer m = {
621 dfd1efcc 2024-06-23 op .self_insert = sensible_self_insert,
622 dfd1efcc 2024-06-23 op .done = lu_select,
623 dfd1efcc 2024-06-23 op .history = lu_history,
624 dfd1efcc 2024-06-23 op .complfn = compl_lu,
627 ca231710 2021-07-15 op GUARD_RECURSIVE_MINIBUFFER();
629 dfd1efcc 2024-06-23 op enter_minibuffer(&m, "Load URL: ");
633 2b2d2872 2021-06-20 op cmd_load_current_url(struct buffer *buffer)
635 dfd1efcc 2024-06-23 op struct minibuffer m = {
636 dfd1efcc 2024-06-23 op .self_insert = sensible_self_insert,
637 dfd1efcc 2024-06-23 op .done = lu_select,
638 dfd1efcc 2024-06-23 op .history = lu_history,
639 dfd1efcc 2024-06-23 op .complfn = compl_lu,
640 dfd1efcc 2024-06-23 op .input = hist_cur(current_tab->hist),
643 ca231710 2021-07-15 op GUARD_RECURSIVE_MINIBUFFER();
645 dfd1efcc 2024-06-23 op enter_minibuffer(&m, "Load URL: ");
649 661233ed 2021-07-14 op cmd_reload_page(struct buffer *buffer)
651 65c49665 2024-01-23 op load_url_in_tab(current_tab, hist_cur(current_tab->hist), NULL,
652 ed21a9a1 2022-01-11 op LU_MODE_NOHIST|LU_MODE_NOCACHE);
656 2b2d2872 2021-06-20 op cmd_bookmark_page(struct buffer *buffer)
658 dfd1efcc 2024-06-23 op struct minibuffer m = {
659 dfd1efcc 2024-06-23 op .self_insert = sensible_self_insert,
660 dfd1efcc 2024-06-23 op .done = bp_select,
661 dfd1efcc 2024-06-23 op .input = hist_cur(current_tab->hist),
664 ca231710 2021-07-15 op GUARD_RECURSIVE_MINIBUFFER();
666 dfd1efcc 2024-06-23 op enter_minibuffer(&m, "Bookmark URL: ");
670 2b2d2872 2021-06-20 op cmd_list_bookmarks(struct buffer *buffer)
672 ed21a9a1 2022-01-11 op load_url_in_tab(current_tab, "about:bookmarks", NULL, LU_MODE_NONE);
676 2b2d2872 2021-06-20 op cmd_toggle_help(struct buffer *buffer)
678 3b5f459e 2021-11-05 op ui_toggle_side_window(SIDE_WINDOW_LEFT);
682 753c6ac7 2021-07-14 op cmd_link_select(struct buffer *buffer)
684 c1a72389 2021-07-15 op struct line *l;
685 dfd1efcc 2024-06-23 op struct minibuffer m = {
686 dfd1efcc 2024-06-23 op .self_insert = sensible_self_insert,
687 dfd1efcc 2024-06-23 op .done = ls_select,
688 dfd1efcc 2024-06-23 op .complfn = compl_ls,
689 dfd1efcc 2024-06-23 op .compldata = NULL,
690 dfd1efcc 2024-06-23 op .must_select = 1,
693 ca231710 2021-07-15 op GUARD_RECURSIVE_MINIBUFFER();
695 c1d27b0e 2024-06-14 op l = TAILQ_FIRST(&buffer->head);
696 c1a72389 2021-07-15 op while (l != NULL && l->type != LINE_LINK)
697 c1a72389 2021-07-15 op l = TAILQ_NEXT(l, lines);
699 c1a72389 2021-07-15 op if (l == NULL) {
700 c1a72389 2021-07-15 op message("No links found");
704 dfd1efcc 2024-06-23 op m.compldata = l;
705 dfd1efcc 2024-06-23 op enter_minibuffer(&m, "Select link: ");
709 753c6ac7 2021-07-14 op cmd_swiper(struct buffer *buffer)
711 dfd1efcc 2024-06-23 op struct minibuffer m = {
712 dfd1efcc 2024-06-23 op .self_insert = sensible_self_insert,
713 dfd1efcc 2024-06-23 op .done = swiper_select,
714 dfd1efcc 2024-06-23 op .complfn = compl_swiper,
715 dfd1efcc 2024-06-23 op .compldata = TAILQ_FIRST(&buffer->head),
716 dfd1efcc 2024-06-23 op .must_select = 1,
719 ca231710 2021-07-15 op GUARD_RECURSIVE_MINIBUFFER();
721 dfd1efcc 2024-06-23 op enter_minibuffer(&m, "Select line: ");
725 edd9a650 2021-07-15 op cmd_toc(struct buffer *buffer)
727 c1a72389 2021-07-15 op struct line *l;
728 dfd1efcc 2024-06-23 op struct minibuffer m = {
729 dfd1efcc 2024-06-23 op .self_insert = sensible_self_insert,
730 dfd1efcc 2024-06-23 op .done = toc_select,
731 dfd1efcc 2024-06-23 op .complfn = compl_toc,
732 dfd1efcc 2024-06-23 op .compldata = NULL,
733 dfd1efcc 2024-06-23 op .must_select = 1,
736 ca231710 2021-07-15 op GUARD_RECURSIVE_MINIBUFFER();
738 c1d27b0e 2024-06-14 op l = TAILQ_FIRST(&buffer->head);
739 c1a72389 2021-07-15 op while (l != NULL &&
740 c1a72389 2021-07-15 op l->type != LINE_TITLE_1 &&
741 c1a72389 2021-07-15 op l->type != LINE_TITLE_2 &&
742 c1a72389 2021-07-15 op l->type != LINE_TITLE_3)
743 c1a72389 2021-07-15 op l = TAILQ_NEXT(l, lines);
745 c1a72389 2021-07-15 op if (l == NULL) {
746 c1a72389 2021-07-15 op message("No headings found");
750 dfd1efcc 2024-06-23 op m.compldata = l;
751 dfd1efcc 2024-06-23 op enter_minibuffer(&m, "Select heading: ");
755 61251035 2021-06-26 op cmd_inc_fill_column(struct buffer *buffer)
757 61251035 2021-06-26 op if (fill_column == INT_MAX)
760 61251035 2021-06-26 op fill_column += 2;
761 61251035 2021-06-26 op message("fill-column: %d", fill_column);
763 61251035 2021-06-26 op ui_schedule_redraw();
767 61251035 2021-06-26 op cmd_dec_fill_column(struct buffer *buffer)
769 61251035 2021-06-26 op if (fill_column == INT_MAX || fill_column < 8)
772 61251035 2021-06-26 op fill_column -= 2;
773 61251035 2021-06-26 op message("fill-column: %d", fill_column);
775 61251035 2021-06-26 op ui_schedule_redraw();
779 2b2d2872 2021-06-20 op cmd_olivetti_mode(struct buffer *buffer)
781 2b2d2872 2021-06-20 op olivetti_mode = !olivetti_mode;
782 2b2d2872 2021-06-20 op if (olivetti_mode)
783 2b2d2872 2021-06-20 op message("olivetti-mode enabled");
785 2b2d2872 2021-06-20 op message("olivetti-mode disabled");
787 2b2d2872 2021-06-20 op ui_schedule_redraw();
791 2b2d2872 2021-06-20 op cmd_mini_delete_char(struct buffer *buffer)
793 6d24bfb3 2024-10-19 op struct vline *vl;
795 6d24bfb3 2024-10-19 op size_t old_point, gap, rest;
797 5a3c3ede 2021-07-19 op GUARD_READ_ONLY();
799 6d24bfb3 2024-10-19 op vl = buffer->current_line;
800 6d24bfb3 2024-10-19 op old_point = buffer->point_offset;
801 6d24bfb3 2024-10-19 op cmd_forward_char(buffer);
802 6d24bfb3 2024-10-19 op gap = buffer->point_offset - old_point;
803 6d24bfb3 2024-10-19 op if (gap == 0)
806 6d24bfb3 2024-10-19 op minibuffer_taint_hist();
808 6d24bfb3 2024-10-19 op text = vl->parent->line + vl->from + old_point;
809 6d24bfb3 2024-10-19 op rest = vl->len - buffer->point_offset;
810 9863381c 2024-10-20 op memmove(text, text + gap, rest + 1);
811 6d24bfb3 2024-10-19 op buffer->point_offset = old_point;
812 9863381c 2024-10-20 op vl->len -= gap;
814 b1e1e41a 2021-07-14 op recompute_completions(0);
818 2b2d2872 2021-06-20 op cmd_mini_delete_backward_char(struct buffer *buffer)
820 6d24bfb3 2024-10-19 op struct vline *vl;
822 6d24bfb3 2024-10-19 op size_t old_point, gap, rest;
824 5a3c3ede 2021-07-19 op GUARD_READ_ONLY();
826 6d24bfb3 2024-10-19 op vl = buffer->current_line;
827 6d24bfb3 2024-10-19 op old_point = buffer->point_offset;
828 6d24bfb3 2024-10-19 op cmd_backward_char(buffer);
829 6d24bfb3 2024-10-19 op gap = old_point - buffer->point_offset;
830 6d24bfb3 2024-10-19 op if (gap == 0)
833 6d24bfb3 2024-10-19 op minibuffer_taint_hist();
835 6d24bfb3 2024-10-19 op text = vl->parent->line + vl->from + buffer->point_offset;
836 6d24bfb3 2024-10-19 op rest = vl->len - old_point;
837 9863381c 2024-10-20 op memmove(text, text + gap, rest + 1);
838 9863381c 2024-10-20 op vl->len -= gap;
840 b1e1e41a 2021-07-14 op recompute_completions(0);
844 2b2d2872 2021-06-20 op cmd_mini_kill_line(struct buffer *buffer)
846 bd4a08a7 2022-11-07 op char *line, *c;
848 5a3c3ede 2021-07-19 op GUARD_READ_ONLY();
850 2b2d2872 2021-06-20 op minibuffer_taint_hist();
852 bd4a08a7 2022-11-07 op line = buffer->current_line->parent->line + buffer->current_line->from;
853 6d24bfb3 2024-10-19 op c = line + buffer->point_offset;
856 b1e1e41a 2021-07-14 op recompute_completions(0);
860 067b7ffd 2022-04-15 op cmd_mini_kill_whole_line(struct buffer *buffer)
862 067b7ffd 2022-04-15 op GUARD_READ_ONLY();
864 067b7ffd 2022-04-15 op minibuffer_taint_hist();
865 bd4a08a7 2022-11-07 op *buffer->current_line->parent->line = '\0';
866 6d24bfb3 2024-10-19 op buffer->point_offset = 0;
867 307e9acc 2024-10-20 op buffer->current_line->len = 0;
869 232164c7 2024-05-31 thomas.ad recompute_completions(0);
873 2b2d2872 2021-06-20 op cmd_mini_abort(struct buffer *buffer)
875 2b2d2872 2021-06-20 op if (!in_minibuffer)
878 2b2d2872 2021-06-20 op ministate.abortfn();
882 2b2d2872 2021-06-20 op cmd_mini_complete_and_exit(struct buffer *buffer)
884 27dbcaab 2022-04-13 op struct vline *vl;
886 2b2d2872 2021-06-20 op if (!in_minibuffer)
889 65c49665 2024-01-23 op if (ministate.compl.must_select && ministate.hist == NULL) {
890 27dbcaab 2022-04-13 op vl = ministate.compl.buffer.current_line;
891 27dbcaab 2022-04-13 op if (vl == NULL || vl->parent->flags & L_HIDDEN ||
892 27dbcaab 2022-04-13 op vl->parent->type == LINE_COMPL) {
893 27dbcaab 2022-04-13 op message("no match");
898 0fceedb5 2024-06-07 op minibuffer_confirm();
902 2b2d2872 2021-06-20 op cmd_mini_previous_history_element(struct buffer *buffer)
906 65c49665 2024-01-23 op if (ministate.hist == NULL) {
907 2b2d2872 2021-06-20 op message("No history");
911 65c49665 2024-01-23 op if (hist_prev(ministate.hist) == NULL) {
912 65c49665 2024-01-23 op message("No prev history item");
916 65c49665 2024-01-23 op ministate.editing = 0;
918 65c49665 2024-01-23 op /* XXX the minibuffer line is never modified so this is fine */
919 65c49665 2024-01-23 op text = (char *)hist_cur(ministate.hist);
920 65c49665 2024-01-23 op buffer->current_line->parent->line = text;
921 65c49665 2024-01-23 op recompute_completions(0);
925 2b2d2872 2021-06-20 op cmd_mini_next_history_element(struct buffer *buffer)
929 65c49665 2024-01-23 op if (ministate.hist == NULL) {
930 2b2d2872 2021-06-20 op message("No history");
934 65c49665 2024-01-23 op if (hist_next(ministate.hist) == NULL) {
935 65c49665 2024-01-23 op message("No next history item");
939 65c49665 2024-01-23 op ministate.editing = 0;
941 65c49665 2024-01-23 op /* XXX the minibuffer line is never modified so this is fine */
942 65c49665 2024-01-23 op text = (char *)hist_cur(ministate.hist);
943 65c49665 2024-01-23 op buffer->current_line->parent->line = text;
944 65c49665 2024-01-23 op recompute_completions(0);
948 e7b982f4 2021-07-14 op cmd_previous_completion(struct buffer *buffer)
950 e7b982f4 2021-07-14 op if (in_minibuffer != MB_COMPREAD)
953 e7b982f4 2021-07-14 op buffer = &ministate.compl.buffer;
954 fea02b0b 2022-04-13 op if (buffer->current_line == NULL)
957 fea02b0b 2022-04-13 op buffer->current_line->parent->type = LINE_COMPL;
958 fea02b0b 2022-04-13 op if (!forward_line(buffer, -1))
959 e7b982f4 2021-07-14 op buffer->current_line->parent->type = LINE_COMPL;
961 e7b982f4 2021-07-14 op buffer->current_line->parent->type = LINE_COMPL_CURRENT;
965 e7b982f4 2021-07-14 op cmd_next_completion(struct buffer *buffer)
967 e7b982f4 2021-07-14 op if (in_minibuffer != MB_COMPREAD)
970 e7b982f4 2021-07-14 op buffer = &ministate.compl.buffer;
971 fea02b0b 2022-04-13 op if (buffer->current_line == NULL)
974 fea02b0b 2022-04-13 op if (buffer->current_line->parent->type == LINE_COMPL_CURRENT) {
975 e7b982f4 2021-07-14 op buffer->current_line->parent->type = LINE_COMPL;
976 fea02b0b 2022-04-13 op forward_line(buffer, +1);
979 e7b982f4 2021-07-14 op if (buffer->current_line != NULL)
980 e7b982f4 2021-07-14 op buffer->current_line->parent->type = LINE_COMPL_CURRENT;
984 e7b982f4 2021-07-14 op cmd_insert_current_candidate(struct buffer *buffer)
986 e7b982f4 2021-07-14 op if (in_minibuffer != MB_COMPREAD)
989 16578ca5 2022-01-02 op minibuffer_insert_current_candidate();
993 8a3b5609 2021-07-15 op cmd_suspend_telescope(struct buffer *buffer)
995 8a3b5609 2021-07-15 op message("Zzz...");
996 8a3b5609 2021-07-15 op ui_suspend();
997 0548291a 2024-06-25 op kill(getpid(), SIGSTOP);
1002 987d9c88 2021-07-15 op cmd_toggle_pre_wrap(struct buffer *buffer)
1004 987d9c88 2021-07-15 op dont_wrap_pre = !dont_wrap_pre;
1006 987d9c88 2021-07-15 op if (dont_wrap_pre)
1007 987d9c88 2021-07-15 op message("Don't wrap preformatted blocks");
1009 987d9c88 2021-07-15 op message("Wrap preformatted blocks");
1011 987d9c88 2021-07-15 op ui_schedule_redraw();
1015 f350bc73 2024-05-27 thomas.ad cmd_toggle_styling(struct buffer *buffer)
1017 f350bc73 2024-05-27 thomas.ad dont_apply_styling = !dont_apply_styling;
1019 f350bc73 2024-05-27 thomas.ad config_apply_style();
1021 f350bc73 2024-05-27 thomas.ad /* Force a reload here, rather than calling ui_schedule_redraw() so
1022 f350bc73 2024-05-27 thomas.ad * that any lines which are set as L_HIDDEN are redrawn appropriately.
1024 f350bc73 2024-05-27 thomas.ad load_url_in_tab(current_tab, hist_cur(current_tab->hist), NULL,
1025 f350bc73 2024-05-27 thomas.ad LU_MODE_NOHIST);
1029 de190a2b 2021-07-17 op cmd_mini_goto_beginning(struct buffer *buffer)
1031 de190a2b 2021-07-17 op struct vline *vl;
1033 de190a2b 2021-07-17 op if (!in_minibuffer)
1036 de190a2b 2021-07-17 op buffer = &ministate.compl.buffer;
1038 de190a2b 2021-07-17 op if ((vl = buffer->current_line) != NULL)
1039 de190a2b 2021-07-17 op vl->parent->type = LINE_COMPL;
1041 c1d27b0e 2024-06-14 op vl = TAILQ_FIRST(&buffer->vhead);
1042 de190a2b 2021-07-17 op while (vl != NULL && vl->parent->flags & L_HIDDEN)
1043 de190a2b 2021-07-17 op vl = TAILQ_NEXT(vl, vlines);
1045 de190a2b 2021-07-17 op if (vl == NULL)
1048 de190a2b 2021-07-17 op vl->parent->type = LINE_COMPL_CURRENT;
1049 de190a2b 2021-07-17 op buffer->top_line = vl;
1050 de190a2b 2021-07-17 op buffer->current_line = vl;
1054 de190a2b 2021-07-17 op cmd_mini_goto_end(struct buffer *buffer)
1056 de190a2b 2021-07-17 op struct vline *vl;
1058 de190a2b 2021-07-17 op if (!in_minibuffer)
1061 de190a2b 2021-07-17 op buffer = &ministate.compl.buffer;
1063 de190a2b 2021-07-17 op if ((vl = buffer->current_line) != NULL)
1064 de190a2b 2021-07-17 op vl->parent->type = LINE_COMPL;
1066 c1d27b0e 2024-06-14 op vl = TAILQ_LAST(&buffer->vhead, vhead);
1067 de190a2b 2021-07-17 op while (vl != NULL && vl->parent->flags & L_HIDDEN)
1068 de190a2b 2021-07-17 op vl = TAILQ_PREV(vl, vhead, vlines);
1070 de190a2b 2021-07-17 op if (vl == NULL)
1073 de190a2b 2021-07-17 op vl->parent->type = LINE_COMPL_CURRENT;
1074 de190a2b 2021-07-17 op buffer->current_line = vl;
1078 65340174 2021-07-21 op cmd_other_window(struct buffer *buffer)
1080 65340174 2021-07-21 op ui_other_window();
1084 167131d5 2021-07-24 op cmd_mini_scroll_up(struct buffer *buffer)
1086 167131d5 2021-07-24 op if (!in_minibuffer)
1089 0e2ac864 2021-08-26 op buffer = &ministate.compl.buffer;
1090 167131d5 2021-07-24 op if (buffer->current_line == NULL)
1093 167131d5 2021-07-24 op buffer->current_line->parent->type = LINE_COMPL;
1094 167131d5 2021-07-24 op cmd_scroll_up(buffer);
1095 167131d5 2021-07-24 op buffer->current_line->parent->type = LINE_COMPL_CURRENT;
1099 167131d5 2021-07-24 op cmd_mini_scroll_down(struct buffer *buffer)
1101 167131d5 2021-07-24 op if (!in_minibuffer)
1104 0e2ac864 2021-08-26 op buffer = &ministate.compl.buffer;
1105 167131d5 2021-07-24 op if (buffer->current_line == NULL)
1108 167131d5 2021-07-24 op buffer->current_line->parent->type = LINE_COMPL;
1109 167131d5 2021-07-24 op cmd_scroll_down(buffer);
1110 167131d5 2021-07-24 op buffer->current_line->parent->type = LINE_COMPL_CURRENT;
1114 3b5f459e 2021-11-05 op cmd_toggle_downloads(struct buffer *buffer)
1116 3b5f459e 2021-11-05 op ui_toggle_side_window(SIDE_WINDOW_BOTTOM);
1120 eeebca22 2022-01-11 op cmd_cache_info(struct buffer *buffer)
1122 eeebca22 2022-01-11 op size_t npages, tot;
1123 eeebca22 2022-01-11 op char fmt[FMT_SCALED_STRSIZE];
1125 eeebca22 2022-01-11 op mcache_info(&npages, &tot);
1127 eeebca22 2022-01-11 op if (fmt_scaled(tot, fmt) == 0)
1128 bb5abe9f 2022-01-13 op message("pages: %zu, total: %s", npages, fmt);
1130 bb5abe9f 2022-01-13 op message("pages: %zu, total: %zu", npages, tot);
1134 ed504b9e 2022-02-07 op cmd_reply_last_input(struct buffer *buffer)
1136 ed504b9e 2022-02-07 op GUARD_RECURSIVE_MINIBUFFER();
1138 ed504b9e 2022-02-07 op if (current_tab->last_input_url == NULL) {
1139 ed504b9e 2022-02-07 op message("there was no previous input request in this tab");
1143 d89eb764 2022-04-24 op if (!strncmp(current_tab->last_input_url, "gopher", 6)) {
1144 acf9defe 2022-02-08 op load_url_in_tab(current_tab, current_tab->last_input_url,
1145 acf9defe 2022-02-08 op NULL, LU_MODE_NOCACHE);
1149 ed504b9e 2022-02-07 op message("%s", current_tab->last_input_url);
1150 ed504b9e 2022-02-07 op ui_require_input(current_tab, 0, ir_select_reply);
1154 868b3a8f 2022-04-13 op cmd_write_buffer(struct buffer *buffer)
1156 868b3a8f 2022-04-13 op const char *f, *url;
1157 868b3a8f 2022-04-13 op char path[PATH_MAX];
1159 868b3a8f 2022-04-13 op GUARD_RECURSIVE_MINIBUFFER();
1161 868b3a8f 2022-04-13 op if (safe_mode) {
1162 868b3a8f 2022-04-13 op message("Can't write buffer in safe-mode.");
1166 65c49665 2024-01-23 op url = hist_cur(current_tab->hist);
1168 868b3a8f 2022-04-13 op if ((f = strrchr(url, '/')) != NULL)
1170 868b3a8f 2022-04-13 op if (f == NULL || *f == '\0') {
1171 868b3a8f 2022-04-13 op /* guess a decent file name based on the protocol used */
1172 868b3a8f 2022-04-13 op if (!strncmp(url, "gemini://", 9))
1173 868b3a8f 2022-04-13 op f = "index.gmi";
1175 868b3a8f 2022-04-13 op f = "index.txt";
1178 868b3a8f 2022-04-13 op strlcpy(path, download_path, sizeof(path));
1179 868b3a8f 2022-04-13 op strlcat(path, f, sizeof(path));
1181 868b3a8f 2022-04-13 op ui_read("Write file", write_buffer, current_tab, path);
1185 a36bb43a 2024-01-15 op cmd_home(struct buffer *buffer)
1187 86294a09 2024-01-16 op char path[GEMINI_URL_LEN];
1188 86294a09 2024-01-16 op char *tilde, *t;
1190 86294a09 2024-01-16 op strlcpy(path, current_tab->iri.iri_path, sizeof(path));
1192 a526f3eb 2024-02-02 op if ((tilde = strstr(path, "/~")) != NULL &&
1193 a526f3eb 2024-02-02 op tilde[2] != '\0' && tilde[2] != '/') {
1194 a526f3eb 2024-02-02 op if ((t = strchr(tilde + 2, '/')) != NULL)
1195 86294a09 2024-01-16 op *++t = '\0';
1196 65c49665 2024-01-23 op load_url_in_tab(current_tab, path, NULL, LU_MODE_NOCACHE);
1198 86294a09 2024-01-16 op cmd_root(buffer);
1202 a36bb43a 2024-01-15 op cmd_root(struct buffer *buffer)
1204 65c49665 2024-01-23 op load_url_in_tab(current_tab, "/", NULL, LU_MODE_NOCACHE);
1208 a36bb43a 2024-01-15 op cmd_up(struct buffer *buffer)
1210 65c49665 2024-01-23 op load_url_in_tab(current_tab, "..", NULL, LU_MODE_NOCACHE);
1214 5a39f593 2024-02-05 op cmd_use_certificate(struct buffer *buffer)
1216 dfd1efcc 2024-06-23 op struct minibuffer m = {
1217 dfd1efcc 2024-06-23 op .self_insert = sensible_self_insert,
1218 dfd1efcc 2024-06-23 op .done = uc_select,
1219 dfd1efcc 2024-06-23 op .complfn = compl_uc,
1220 dfd1efcc 2024-06-23 op .must_select = 1,
1223 5a39f593 2024-02-05 op GUARD_RECURSIVE_MINIBUFFER();
1225 dfd1efcc 2024-06-23 op enter_minibuffer(&m, "Select certificate: ");
1229 4655add6 2024-02-05 op cmd_client_certificate_info(struct buffer *buffer)
1231 4655add6 2024-02-05 op if (current_tab->client_cert)
1232 4655add6 2024-02-05 op message("Using certificate %s", current_tab->client_cert);
1234 4655add6 2024-02-05 op message("Not using any client certificate.");
1238 057e7eb6 2024-06-22 op unload_certificate_cb(int r, void *data)
1240 057e7eb6 2024-06-22 op struct tab *tab = data;
1242 71bc1636 2024-02-06 op message("Won't use %s for this site.", tab->client_cert);
1243 4fdc9933 2024-02-05 op cert_delete_for(tab->client_cert, &tab->iri, r);
1247 4fdc9933 2024-02-05 op cmd_unload_certificate(struct buffer *buffer)
1249 71bc1636 2024-02-06 op struct tab *tab = current_tab;
1251 4fdc9933 2024-02-05 op GUARD_RECURSIVE_MINIBUFFER();
1253 71bc1636 2024-02-06 op if (tab->client_cert == NULL) {
1254 4fdc9933 2024-02-05 op message("No client certificate in use!");
1258 71bc1636 2024-02-06 op if (tab->client_cert_temp) {
1259 71bc1636 2024-02-06 op message("Won't use %s for this site.", tab->client_cert);
1260 71bc1636 2024-02-06 op cert_delete_for(tab->client_cert, &tab->iri, 0);
1264 4fdc9933 2024-02-05 op yornp("Unload only for the current session?", unload_certificate_cb,
1265 4fdc9933 2024-02-05 op current_tab);
1269 fd6c540b 2024-02-12 op cmd_search(struct buffer *buffer)
1271 dfd1efcc 2024-06-23 op struct minibuffer m = {
1272 dfd1efcc 2024-06-23 op .self_insert = sensible_self_insert,
1273 dfd1efcc 2024-06-23 op .done = search_select,
1276 fd6c540b 2024-02-12 op GUARD_RECURSIVE_MINIBUFFER();
1278 50fd8b26 2024-02-12 op if (!strncmp(default_search_engine, "gopher://", 9)) {
1279 50fd8b26 2024-02-12 op load_url_in_tab(current_tab, default_search_engine, NULL,
1280 50fd8b26 2024-02-12 op LU_MODE_NOCACHE);
1284 dfd1efcc 2024-06-23 op enter_minibuffer(&m, "Search: ");
1288 e1bf3d6e 2024-06-07 op cmd_mini_edit_external(struct buffer *buffer)
1291 0548291a 2024-06-25 op char buf[1024 + 1];
1292 0548291a 2024-06-25 op size_t r, len = 0;
1294 e1bf3d6e 2024-06-07 op GUARD_READ_ONLY();
1296 0548291a 2024-06-25 op if (ministate.compl.must_select || ministate.donefn == NULL) {
1297 0548291a 2024-06-25 op message("Can't use an external editor to complete");
1301 0548291a 2024-06-25 op if ((fp = exec_editor(ministate.buf, strlen(ministate.buf))) == NULL)
1304 0548291a 2024-06-25 op while (len < sizeof(buf) - 1) {
1305 0548291a 2024-06-25 op r = fread(buf + len, 1, sizeof(buf) - 1 - len, fp);
1310 0548291a 2024-06-25 op buf[len] = '\0';
1311 0548291a 2024-06-25 op while (len > 0 && buf[len-1] == '\n')
1312 0548291a 2024-06-25 op buf[--len] = '\0';
1315 0548291a 2024-06-25 op * XXX: do not use minibuffer_confirm() since the text could
1316 0548291a 2024-06-25 op * have multiple lines and we are not prepared to render them
1317 0548291a 2024-06-25 op * in the history navigation.
1319 0548291a 2024-06-25 op ministate.donefn(buf);
1320 0548291a 2024-06-25 op exit_minibuffer();