diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2018-11-01 07:01:18 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2018-11-01 07:01:18 -0700 |
commit | a997f22131a7c98505cebcc88f3badd67a50518d (patch) | |
tree | b3094e7df08962db3db06af5a7222d7949f61df4 /linenoise | |
parent | b8e093dbaae99d2dc12157fcce1bb12ba26b8d3e (diff) | |
download | txr-a997f22131a7c98505cebcc88f3badd67a50518d.tar.gz txr-a997f22131a7c98505cebcc88f3badd67a50518d.tar.bz2 txr-a997f22131a7c98505cebcc88f3badd67a50518d.zip |
linenoise: move modulo operation into function.
* linenoise/linenoise.c (col_offset_in_str): Take a cols
parameter and wrap the return value into the number of
columns.
(refresh_multiline): No need to do the % cols operation on the
return value of col_offset_in_str any more; just pass cols
down into it.
Diffstat (limited to 'linenoise')
-rw-r--r-- | linenoise/linenoise.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c index f3784597..62a2c31e 100644 --- a/linenoise/linenoise.c +++ b/linenoise/linenoise.c @@ -1121,12 +1121,12 @@ static struct row_values screen_rows(const wchar_t *str, int pos, int cols) return out; } -static int col_offset_in_str(const wchar_t *str, int pos) +static int col_offset_in_str(const wchar_t *str, int pos, int cols) { int offs = 0; while (pos > 0 && str[--pos] != '\n') offs++; - return offs; + return offs % cols; } /* Multi line low level line refresh. @@ -1199,7 +1199,7 @@ static void refresh_multiline(lino_t *l) { /* Move cursor to the correct column */ { - int ccol = col_offset_in_str(l->buf, l->pos) % l->cols; + int ccol = col_offset_in_str(l->buf, l->pos, l->cols); /* Go up till we reach the expected positon. */ if (rows - nrow > 0) { |