summaryrefslogtreecommitdiff
path: root/src/dged/minibuffer.h
blob: 6ac69c171898d8132a565f6093648416d6a6fafc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <time.h>

struct buffer;
struct buffers;
struct command_ctx;
struct command_list;
struct keymap;

/**
 * Initialize the minibuffer.
 *
 * Note that the minibuffer is a global instance and this function will do
 * nothing if called more than once.
 * @param buffer Underlying buffer to use for text IO in the minibuffer.
 * @param buffers Buffer list used to create and store messages buffer.
 */
void minibuffer_init(struct buffer *buffer, struct buffers *buffers);

/**
 * Destroy the minibuffer
 *
 * Note that this does not release the buffer used.
 */
void minibuffer_destroy();

struct text_chunk minibuffer_content();

struct buffer *minibuffer_buffer();

void message(const char *fmt, ...);

/**
 * Echo a message to the minibuffer.
 *
 * @param fmt Format string for the message.
 * @param ... Format arguments.
 */
void minibuffer_echo(const char *fmt, ...);

/**
 * Echo a message to the minibuffer that disappears after @p timeout.
 *
 * @param timeout The timeout in seconds after which the message should
 * disappear.
 * @param fmt Format string for the message.
 * @param ... Format arguments.
 */
void minibuffer_echo_timeout(uint32_t timeout, const char *fmt, ...);

/**
 * Prompt for user input in the minibuffer.
 *
 * This will move focus to the minibuffer and wait for user input, with the
 * given prompt.
 * @param command_ctx The command context to use to re-execute the calling
 * command (or other command) when the user confirms the input.
 * @param fmt Format string for the prompt.
 * @param ... Format arguments.
 * @returns 0 on success.
 */
int32_t minibuffer_prompt(struct command_ctx command_ctx, const char *fmt, ...);

int32_t minibuffer_prompt_initial(struct command_ctx command_ctx,
                                  const char *initial, const char *fmt, ...);

void minibuffer_set_prompt(const char *fmt, ...);
uint32_t minibuffer_draw_prompt(struct command_list *commands);

/**
 * Evaluate the current contents of the minibuffer
 *
 * @returns zero on success, non-zero to indicate failure
 */
int32_t minibuffer_execute();

/**
 * Abort the current minibuffer prompt.
 *
 * This returns focus to the previously focused window.
 */
void minibuffer_abort_prompt();

/**
 * Minibuffer prompt args
 */
struct minibuffer_prompt_args {
  int argc;
  const char **argv;
};

/**
 * Clear the current text in the minibuffer.
 */
void minibuffer_clear();

bool minibuffer_empty();

/**
 * Is the minibuffer currently displaying something?
 *
 * @returns True if the minibuffer is displaying anything, false otherwise.
 */
bool minibuffer_displaying();

/**
 * Is the minibuffer currently focused?
 *
 * @returns True if the minibuffer is currently focused, receiving user input.
 */
bool minibuffer_focused();

struct window *minibuffer_target_window();