diff options
author | Harry Jeffery <harry@exec64.co.uk> | 2019-06-15 14:28:29 +0100 |
---|---|---|
committer | Harry Jeffery <harry@exec64.co.uk> | 2019-07-03 20:50:19 +0100 |
commit | 7c7dc660e587eac1aa3c8b3405eba95ba558e682 (patch) | |
tree | 81d12d560b60d397be23c7d132e32a5de30e409a /src/console.h | |
parent | 20e9d23b82f55a751c3cf1166cb59ef26775ee00 (diff) | |
download | imv-7c7dc660e587eac1aa3c8b3405eba95ba558e682.tar.gz |
Big glfw refactor
I did a lot of this in a very ad-hoc fashion with no proper commit
history. As such, the kindest thing to do seemed to be to just squash it
into this one commit.
Diffstat (limited to 'src/console.h')
-rw-r--r-- | src/console.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/console.h b/src/console.h new file mode 100644 index 0000000..22cf9b6 --- /dev/null +++ b/src/console.h @@ -0,0 +1,47 @@ +#ifndef IMV_CONSOLE +#define IMV_CONSOLE + +#include <stdbool.h> + +struct imv_console; + +/* Create a console instance */ +struct imv_console *imv_console_create(void); + +/* Clean up a console */ +void imv_console_free(struct imv_console *console); + +/* Set the callback to be invoked when a command to run by the console */ +typedef void (*imv_console_callback)(const char *command, void *data); +void imv_console_set_command_callback(struct imv_console *console, + imv_console_callback callback, void *data); + +/* Returns true if console is still active (i.e. user hasn't hit enter/escape yet */ +bool imv_console_is_active(struct imv_console *console); + +/* Mark console as activated until user exits or submits a command */ +void imv_console_activate(struct imv_console *console); + +/* Pass text input to the console */ +void imv_console_input(struct imv_console *console, const char *text); + +/* Pass a key input to the console. Returns true if consumed. If so, + * do not also send input text to the console. + */ +bool imv_console_key(struct imv_console *console, const char *key); + +/* What is the console prompt's current text? */ +const char *imv_console_prompt(struct imv_console *console); + +/* What is the output history of the console? */ +const char *imv_console_backlog(struct imv_console *console); + +/* Write some text to the console's backlog */ +void imv_console_write(struct imv_console *console, const char *text); + +/* Add a tab-completion template. If the users hits tab, the rest of the + * command will be suggested. If multiple matches, tab will cycle through them. + */ +void imv_console_add_completion(struct imv_console *console, const char *template); + +#endif |