Blame


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