about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-01-02 01:23:14 +0100
committerbptato <nincsnevem662@gmail.com>2023-01-02 01:23:14 +0100
commit278e60e1c95069f30adec94362679744b4182251 (patch)
treeaeb4e9b794e8d335d6a0a4f9841eebbd0b649b17 /src
parent9edd436512aabd6db54acf154735f6d2ed814a8b (diff)
downloadchawan-278e60e1c95069f30adec94362679744b4182251.tar.gz
term: hack to avoid a weird crash
Looks like we can't just assign canvas to pcanvas.
Diffstat (limited to 'src')
-rw-r--r--src/display/term.nim10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/display/term.nim b/src/display/term.nim
index 1a3b8b9e..dd01d2b4 100644
--- a/src/display/term.nim
+++ b/src/display/term.nim
@@ -433,12 +433,18 @@ proc outputGrid*(term: Terminal) =
   if term.config.termreload:
     term.applyConfig()
   term.outfile.write(term.resetFormat())
-  if term.config.forceclear or not term.cleared:
+  let samesize = term.canvas.width == term.pcanvas.width and term.canvas.height == term.pcanvas.height
+  if term.config.forceclear or not term.cleared or not samesize:
     term.outfile.write(term.generateFullOutput(term.canvas))
     term.cleared = true
   else:
     term.outfile.write(term.generateSwapOutput(term.canvas, term.pcanvas))
-  term.pcanvas = term.canvas
+  if not samesize:
+    term.pcanvas.width = term.canvas.width
+    term.pcanvas.height = term.canvas.height
+    term.pcanvas.cells.setLen(term.canvas.cells.len)
+  for i in 0 ..< term.canvas.cells.len:
+    term.pcanvas[i] = term.canvas[i]
 
 proc clearCanvas*(term: Terminal) =
   term.cleared = false