Linenoise updated again (hints support).

This commit is contained in:
antirez
2016-04-12 23:39:18 +02:00
parent 8a98b8d0c9
commit d6e2cc71c6
4 changed files with 248 additions and 8 deletions

View File

@ -11,6 +11,15 @@ void completion(const char *buf, linenoiseCompletions *lc) {
}
}
char *hints(const char *buf, int *color, int *bold) {
if (!strcasecmp(buf,"hello")) {
*color = 35;
*bold = 0;
return " World";
}
return NULL;
}
int main(int argc, char **argv) {
char *line;
char *prgname = argv[0];
@ -34,6 +43,7 @@ int main(int argc, char **argv) {
/* Set the completion callback. This will be called every time the
* user uses the <tab> key. */
linenoiseSetCompletionCallback(completion);
linenoiseSetHintsCallback(hints);
/* Load history from file. The history file is just a plain text file
* where entries are separated by newlines. */