diff options
author | bptato <nincsnevem662@gmail.com> | 2023-10-18 12:30:09 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-10-18 12:30:09 +0200 |
commit | b66ab79dd2139167ab1e5661892a5705e471a5e4 (patch) | |
tree | 4fa4de40171ac2c5a0b4b265d2320aac5eced5e8 | |
parent | ab6dad2bcc77450e3ded9f5b303662aae978c4e4 (diff) | |
download | chawan-b66ab79dd2139167ab1e5661892a5705e471a5e4.tar.gz |
pager/lineedit: notify lineedit of windowChange
this was causing crashes
-rw-r--r-- | src/display/lineedit.nim | 4 | ||||
-rw-r--r-- | src/local/pager.nim | 2 |
2 files changed, 6 insertions, 0 deletions
diff --git a/src/display/lineedit.nim b/src/display/lineedit.nim index 12d64715..374cb3d7 100644 --- a/src/display/lineedit.nim +++ b/src/display/lineedit.nim @@ -3,6 +3,7 @@ import strutils import unicode import bindings/quickjs +import display/window import js/javascript import types/cell import types/opt @@ -304,6 +305,9 @@ proc nextHist(edit: LineEdit) {.jsfunc.} = edit.end() edit.histtmp = "" +proc windowChange*(edit: LineEdit, attrs: WindowAttributes) = + edit.maxwidth = attrs.width - edit.promptw - 1 + proc readLine*(prompt: string, termwidth: int, current = "", disallowed: set[char] = {}, hide = false, hist: LineHistory): LineEdit = result = LineEdit( diff --git a/src/local/pager.nim b/src/local/pager.nim index 3630f08f..2559e029 100644 --- a/src/local/pager.nim +++ b/src/local/pager.nim @@ -588,6 +588,8 @@ proc toggleSource(pager: Pager) {.jsfunc.} = pager.addContainer(container) proc windowChange*(pager: Pager, attrs: WindowAttributes) = + if pager.lineedit.isSome: + pager.lineedit.get.windowChange(attrs) pager.term.windowChange(attrs) pager.display = newFixedGrid(attrs.width, attrs.height - 1) pager.statusgrid = newFixedGrid(attrs.width) |