2 f26f1205 2022-02-09 op * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
4 f26f1205 2022-02-09 op * Permission to use, copy, modify, and distribute this software for any
5 f26f1205 2022-02-09 op * purpose with or without fee is hereby granted, provided that the above
6 f26f1205 2022-02-09 op * copyright notice and this permission notice appear in all copies.
8 f26f1205 2022-02-09 op * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 f26f1205 2022-02-09 op * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 f26f1205 2022-02-09 op * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 f26f1205 2022-02-09 op * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 f26f1205 2022-02-09 op * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 f26f1205 2022-02-09 op * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 f26f1205 2022-02-09 op * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 f26f1205 2022-02-09 op #ifndef MINIBUFFER_H
18 f26f1205 2022-02-09 op #define MINIBUFFER_H
20 f26f1205 2022-02-09 op #include "telescope.h"
22 f26f1205 2022-02-09 op /* need to be true-ish */
23 f26f1205 2022-02-09 op #define MB_READ 1
24 f26f1205 2022-02-09 op #define MB_COMPREAD 2
27 f26f1205 2022-02-09 op * Completion provider function. These functions are called
28 f26f1205 2022-02-09 op * asynchronously. The function should compute the next completion
29 f26f1205 2022-02-09 op * using the given parameter `state' and modify it eventually. To
30 f26f1205 2022-02-09 op * signal the end of the completions, complfn should return NULL: the
31 f26f1205 2022-02-09 op * value of state will then be discarded and the function never called
32 f26f1205 2022-02-09 op * again. The second parameter is some extra metadata per-line; it'll
33 f26f1205 2022-02-09 op * be available as line->data on the selected line during the
34 f26f1205 2022-02-09 op * minibuffer lifecycle. The third parameter is an extra description
35 f26f1205 2022-02-09 op * field for the current item.
37 f26f1205 2022-02-09 op typedef const char *(complfn)(void **, void **, const char **);
39 f26f1205 2022-02-09 op extern struct histhead eecmd_history,
44 f26f1205 2022-02-09 op struct ministate {
45 f26f1205 2022-02-09 op char *curmesg;
47 f26f1205 2022-02-09 op char prompt[64];
48 f26f1205 2022-02-09 op void (*donefn)(void);
49 f26f1205 2022-02-09 op void (*abortfn)(void);
51 f26f1205 2022-02-09 op char buf[1025];
52 f26f1205 2022-02-09 op struct line line;
53 f26f1205 2022-02-09 op struct vline vline;
54 f26f1205 2022-02-09 op struct buffer buffer;
56 f26f1205 2022-02-09 op struct histhead *history;
57 f26f1205 2022-02-09 op struct hist *hist_cur;
58 f26f1205 2022-02-09 op size_t hist_off;
61 f26f1205 2022-02-09 op struct buffer buffer;
64 27dbcaab 2022-04-13 op int must_select;
67 f26f1205 2022-02-09 op extern struct ministate ministate;
69 f26f1205 2022-02-09 op extern struct buffer minibufferwin;
70 f26f1205 2022-02-09 op extern int in_minibuffer;
72 f26f1205 2022-02-09 op void recompute_completions(int);
73 f26f1205 2022-02-09 op int minibuffer_insert_current_candidate(void);
74 f26f1205 2022-02-09 op void minibuffer_taint_hist(void);
75 f26f1205 2022-02-09 op void minibuffer_self_insert(void);
76 f26f1205 2022-02-09 op void sensible_self_insert(void);
77 f26f1205 2022-02-09 op void eecmd_select(void);
78 f26f1205 2022-02-09 op void ir_select_gemini(void);
79 f26f1205 2022-02-09 op void ir_select_reply(void);
80 f26f1205 2022-02-09 op void ir_select_gopher(void);
81 f26f1205 2022-02-09 op void lu_select(void);
82 f26f1205 2022-02-09 op void bp_select(void);
83 f26f1205 2022-02-09 op void ts_select(void);
84 f26f1205 2022-02-09 op void ls_select(void);
85 f26f1205 2022-02-09 op void swiper_select(void);
86 f26f1205 2022-02-09 op void toc_select(void);
88 f26f1205 2022-02-09 op void enter_minibuffer(void(*)(void), void(*)(void), void(*)(void),
89 27dbcaab 2022-04-13 op struct histhead *, complfn *, void *, int);
91 f26f1205 2022-02-09 op void exit_minibuffer(void);
92 f26f1205 2022-02-09 op void yornp(const char *, void (*)(int, struct tab *), struct tab *);
95 f26f1205 2022-02-09 op * minibuffer_read asks the user for something using the minibuffer.
96 f26f1205 2022-02-09 op * The first argument is the string prompt. The second and third are
97 f26f1205 2022-02-09 op * the callback to call when done and the data; the callback function
98 f26f1205 2022-02-09 op * can't be NULL.
100 f26f1205 2022-02-09 op void minibuffer_read(const char *,
101 f26f1205 2022-02-09 op void (*)(const char *, struct tab *), struct tab *);
103 f26f1205 2022-02-09 op void vmessage(const char *, va_list);
104 f26f1205 2022-02-09 op void message(const char *, ...) __attribute__((format(printf, 1, 2)));
105 f26f1205 2022-02-09 op void minibuffer_init(void);