From f05da6c6ca60ad249e8ab4f5a1d3e8bde643d593 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D0=BB=D0=B0=20=D0=93=D0=BE=D1=80?= =?UTF-8?q?=D0=BD=D1=83=D1=88=D0=BA=D0=BE?= Date: Thu, 23 Nov 2023 01:39:29 +0300 Subject: [PATCH] Multiline: just remember last num of rows, not max. orig commit 8087db3 --- components/console/linenoise/linenoise.c | 9 ++++----- components/console/linenoise/linenoise.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/components/console/linenoise/linenoise.c b/components/console/linenoise/linenoise.c index e011b1a..997c4c7 100644 --- a/components/console/linenoise/linenoise.c +++ b/components/console/linenoise/linenoise.c @@ -509,12 +509,11 @@ static void refreshMultiLine(struct linenoiseState *l, int flags) { int rpos = (plen+l->oldpos+l->cols)/l->cols; /* cursor relative row. */ int rpos2; /* rpos after refresh. */ int col; /* colum position, zero-based. */ - int old_rows = l->maxrows; + int old_rows = l->oldrows; int j; struct abuf ab; - /* Update maxrows if needed. */ - if (rows > (int)l->maxrows) l->maxrows = rows; + l->oldrows = rows; /* First step: clear all the lines used before. To do so start by * going to the last row. */ @@ -562,7 +561,7 @@ static void refreshMultiLine(struct linenoiseState *l, int flags) { snprintf(seq,64,"\r"); abAppend(&ab,seq,strlen(seq)); rows++; - if (rows > (int)l->maxrows) l->maxrows = rows; + if (rows > (int)l->oldrows) l->oldrows = rows; } /* Move cursor to right position. */ @@ -781,7 +780,7 @@ int linenoiseEditStart(struct linenoiseState *l, char *buf, size_t buflen, const l->oldpos = l->pos = 0; l->len = 0; l->cols = getColumns(); - l->maxrows = 0; + l->oldrows = 0; l->history_index = 0; /* Buffer starts empty. */ diff --git a/components/console/linenoise/linenoise.h b/components/console/linenoise/linenoise.h index 1715776..f42843a 100644 --- a/components/console/linenoise/linenoise.h +++ b/components/console/linenoise/linenoise.h @@ -63,7 +63,7 @@ struct linenoiseState { size_t oldpos; /* Previous refresh cursor position. */ size_t len; /* Current edited line length. */ size_t cols; /* Number of columns in terminal. */ - size_t maxrows; /* Maximum num of rows used so far (multiline mode) */ + size_t oldrows; /* Rows used by last refrehsed line (multiline mode) */ int history_index; /* The history index we are currently editing. */ };