aboutsummaryrefslogtreecommitdiff
path: root/client/rl.h
diff options
context:
space:
mode:
authorThomasintAnker <thomasintanker1@gmail.com>2024-06-24 14:59:56 +0200
committerThomasintAnker <thomasintanker1@gmail.com>2024-06-24 14:59:56 +0200
commita0c664908b9112306c5858ccb106d1a0e5555df7 (patch)
tree8ca77d1210d1683a97f4da131c6ffac8123d4375 /client/rl.h
parent381149dd7a1f4d5f48dd5ac07186c73371ff3c04 (diff)
parentec7f5e970ed03acb33eb5dc3b67f3d52af52e6dc (diff)
merge main into wip/mc
Diffstat (limited to 'client/rl.h')
-rw-r--r--client/rl.h43
1 files changed, 42 insertions, 1 deletions
diff --git a/client/rl.h b/client/rl.h
index ab31ddb..d2f8612 100644
--- a/client/rl.h
+++ b/client/rl.h
@@ -1,12 +1,53 @@
#pragma once
+/**
+ * \ingroup pbc
+ * \defgroup pbc_rl rl
+ * \brief GNU Readline related functions
+ * \{
+ */
+
+//! Reset color (ANSI sequence)
#define COLOR_OFF "\x1b[0m"
+//! Set font to bold (ANSI sequence)
#define COLOR_BOLD "\x1b[1m"
+//! Prompt text
#define CLI_PROMPT "(" COLOR_BOLD "pbc" COLOR_OFF ") "
+//! CLI entrypoint
int cli_main();
+
+/**
+ * \brief Print format string to stdout without disturbing the readline prompt
+ *
+ * This function saves and restores the current readline prompt before/after
+ * calling printf. This function is not required for commands that print output
+ * synchronously, as the prompt is only shown after a command handler
+ * completes.
+ */
void rl_printf(const char * fmt, ...);
+/**
+ * \brief Get the index of the word currently under the cursor
+ *
+ * \param line Command line contents
+ * \param cursor Index of cursor position
+ *
+ * This function returns the index of the word from an array made by splitting
+ * \p line on consecutive occurrences of \c IFS.
+ *
+ * \return Index of word
+ */
int rl_word(const char * line, int cursor);
-char ** rl_complete_list(const char * word, const char * suggestions[]);
+/**
+ * \brief Create a completion suggestion string array for readline
+ *
+ * \param word Word to complete
+ * \param options List of possible choices (NULL terminated array of strings)
+ *
+ * \return Suggestions matching \p word
+ */
+char ** rl_complete_list(const char * word, const char * options[]);
+
+/// \}