free(history[j]);
free(history);
history = NULL;
+ history_len = 0;
}
}
linenoiseHistoryFree();
}
-/* gcc/glibc insists that we care about the return code of write! */
+/* gcc/glibc insists that we care about the return code of write!
+ * Clarification: This means that a void-cast like "(void) (EXPR)"
+ * does not work.
+ */
#define IGNORE_RC(EXPR) if (EXPR) {}
/* This is fdprintf() on some systems, but use a different
{
COORD pos = { (SHORT)current->x, (SHORT)current->y };
DWORD n;
-
+
WriteConsoleOutputCharacter(current->outh, buf, len, pos, &n);
current->x += len;
return 0;
/* Only autocomplete when the callback is set. It returns < 0 when
* there was an error reading from fd. Otherwise it will return the
* character that should be handled next. */
- if (c == 9 && completionCallback != NULL) {
+ if (c == '\t' && current->pos == current->chars && completionCallback != NULL) {
c = completeLine(current);
/* Return on errors */
if (c < 0) return current->len;
char buf[LINENOISE_MAX_LINE];
if (enableRawMode(¤t) == -1) {
- printf("%s", prompt);
+ printf("%s", prompt);
fflush(stdout);
if (fgets(buf, sizeof(buf), stdin) == NULL) {
- return NULL;
+ return NULL;
}
count = strlen(buf);
if (count && buf[count-1] == '\n') {
return 1;
}
+int linenoiseHistoryGetMaxLen(void) {
+ return history_max_len;
+}
+
int linenoiseHistorySetMaxLen(int len) {
char **newHistory;