about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-10-18 12:30:09 +0200
committerbptato <nincsnevem662@gmail.com>2023-10-18 12:30:09 +0200
commitb66ab79dd2139167ab1e5661892a5705e471a5e4 (patch)
tree4fa4de40171ac2c5a0b4b265d2320aac5eced5e8
parentab6dad2bcc77450e3ded9f5b303662aae978c4e4 (diff)
downloadchawan-b66ab79dd2139167ab1e5661892a5705e471a5e4.tar.gz
pager/lineedit: notify lineedit of windowChange
this was causing crashes
-rw-r--r--src/display/lineedit.nim4
-rw-r--r--src/local/pager.nim2
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)