puzzlebox
Loading...
Searching...
No Matches
rl

GNU Readline related functions. More...

Detailed Description

Macros

#define COLOR_OFF   "\x1b[0m"
 Reset color (ANSI sequence)
 
#define COLOR_BOLD   "\x1b[1m"
 Set font to bold (ANSI sequence)
 
#define CLI_PROMPT   "(" COLOR_BOLD "pbc" COLOR_OFF ") "
 Prompt text.
 

Functions

int cli_main ()
 CLI entrypoint.
 
void rl_printf (const char *fmt,...)
 Print format string to stdout without disturbing the readline prompt.
 
int rl_word (const char *line, int cursor)
 Get the index of the word currently under the cursor.
 
char ** rl_complete_list (const char *word, const char *options[])
 Create a completion suggestion string array for readline.
 

Function Documentation

◆ rl_complete_list()

char ** rl_complete_list ( const char * word,
const char * options[] )
Parameters
wordWord to complete
optionsList of possible choices (NULL terminated array of strings)
Returns
Suggestions matching word

◆ rl_printf()

void rl_printf ( const char * fmt,
... )

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.

◆ rl_word()

int rl_word ( const char * line,
int cursor )
Parameters
lineCommand line contents
cursorIndex of cursor position

This function returns the index of the word from an array made by splitting line on consecutive occurrences of IFS.

Returns
Index of word