blob: d2f86120b12d1d46b07e4ee24d1cf35d48ca1369 (
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
|
#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);
/**
* \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[]);
/// \}
|