diff options
author | bptato <nincsnevem662@gmail.com> | 2023-01-02 01:23:14 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-01-02 01:23:14 +0100 |
commit | 278e60e1c95069f30adec94362679744b4182251 (patch) | |
tree | aeb4e9b794e8d335d6a0a4f9841eebbd0b649b17 /src | |
parent | 9edd436512aabd6db54acf154735f6d2ed814a8b (diff) | |
download | chawan-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.nim | 10 |
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 |