199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid completion(const char *buf, linenoiseCompletions *lc) {
199767f8919635c4928607450d9e0abb932109ceToomas Soome /* Parse options, with --multiline we enable multi line editing. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome fprintf(stderr, "Usage: %s [--multiline] [--keycodes]\n", prgname);
199767f8919635c4928607450d9e0abb932109ceToomas Soome /* Set the completion callback. This will be called every time the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * user uses the <tab> key. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome /* Load history from file. The history file is just a plain text file
199767f8919635c4928607450d9e0abb932109ceToomas Soome * where entries are separated by newlines. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome linenoiseHistoryLoad("history.txt"); /* Load the history at startup */
199767f8919635c4928607450d9e0abb932109ceToomas Soome /* Now this is the main loop of the typical linenoise-based application.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The call to linenoise() will block as long as the user types something
199767f8919635c4928607450d9e0abb932109ceToomas Soome * and presses enter.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The typed string is returned as a malloc() allocated string by
199767f8919635c4928607450d9e0abb932109ceToomas Soome * linenoise, so the user needs to free() it. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome /* Do something with the string. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome linenoiseHistoryAdd(line); /* Add to the history. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome linenoiseHistorySave("history.txt"); /* Save the history on disk. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome /* The "/historylen" command will change the history len. */