Blame


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