diff options
author | bptato <nincsnevem662@gmail.com> | 2023-01-07 16:30:43 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-01-07 20:25:54 +0100 |
commit | 230ad9476b296436c67a3e269b21e67b179b6f19 (patch) | |
tree | c9761cbc18521d2e6b82932d740e0067bc992d94 /src/display | |
parent | 2c7bc83ff4407a231130773a9359f1ef4c109482 (diff) | |
download | chawan-230ad9476b296436c67a3e269b21e67b179b6f19.tar.gz |
display/pager: correct maximum status message width
Diffstat (limited to 'src/display')
-rw-r--r-- | src/display/pager.nim | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/display/pager.nim b/src/display/pager.nim index 08cfca41..8b3ed641 100644 --- a/src/display/pager.nim +++ b/src/display/pager.nim @@ -253,9 +253,11 @@ proc writeStatusMessage(pager: Pager, str: string, if maxwidth == -1: maxwidth = pager.statusgrid.len var i = start + let e = min(start + maxwidth, pager.statusgrid.width) for r in str.runes: - if i >= maxwidth: - pager.statusgrid[^1].str = $clip + if i >= e: + if e > start: + pager.statusgrid[e - 1].str = $clip break if r.isControlChar(): pager.statusgrid[i].str = "^" & getControlLetter(char(r)) @@ -265,7 +267,7 @@ proc writeStatusMessage(pager: Pager, str: string, i += r.twidth(i) result = i var def = newFormat() - while i < maxwidth: + while i < e: pager.statusgrid[i].str = "" pager.statusgrid[i].format = def inc i @@ -296,7 +298,7 @@ proc refreshStatusMsg*(pager: Pager) = pager.writeStatusMessage(title, format, mw) else: let hover2 = " " & hover - let maxwidth = pager.statusgrid.width - mw - hover2.width() + let maxwidth = pager.statusgrid.width - hover2.width() - mw let tw = pager.writeStatusMessage(title, format, mw, maxwidth, '>') pager.writeStatusMessage(hover2, format, tw) |