summaryrefslogtreecommitdiff
path: root/src/dged/minibuffer.h
diff options
context:
space:
mode:
authorAlbert Cervin <albert@acervin.com>2023-04-06 23:23:46 +0200
committerAlbert Cervin <albert@acervin.com>2023-05-01 22:19:14 +0200
commita123725a12e948d78badb2cb686d38548f1c633b (patch)
treec92c46134ef5536fbbf3bf08983c4f0dea1aaf58 /src/dged/minibuffer.h
parentb5ed4cf757afc50afb6ac499eee7b87a2648fa4c (diff)
downloaddged-a123725a12e948d78badb2cb686d38548f1c633b.tar.gz
dged-a123725a12e948d78badb2cb686d38548f1c633b.tar.xz
dged-a123725a12e948d78badb2cb686d38548f1c633b.zip
Implement window handling
Also implement searching. fix undo boundaries when it checked for other save point, it used && instead of == which caused it to overwrite other types. Fix bytes vs chars bug in text_get_region
Diffstat (limited to 'src/dged/minibuffer.h')
-rw-r--r--src/dged/minibuffer.h108
1 files changed, 108 insertions, 0 deletions
diff --git a/src/dged/minibuffer.h b/src/dged/minibuffer.h
new file mode 100644
index 0000000..24f54cf
--- /dev/null
+++ b/src/dged/minibuffer.h
@@ -0,0 +1,108 @@
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <time.h>
+
+struct buffer;
+struct command_ctx;
+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.
+ */
+void minibuffer_init(struct buffer *buffer);
+
+/**
+ * Destroy the minibuffer
+ *
+ * Note that this does not release the buffer used.
+ */
+void minibuffer_destroy();
+
+struct text_chunk minibuffer_content();
+
+struct buffer *minibuffer_buffer();
+
+/**
+ * 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 @ref 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_interactive(struct command_ctx command_ctx,
+ void (*update_callback)(),
+ const char *fmt, ...);
+
+void minibuffer_set_prompt(const char *fmt, ...);
+
+/**
+ * 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();