about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-07-20 15:36:39 +0200
committerbptato <nincsnevem662@gmail.com>2024-07-20 15:36:39 +0200
commitf60f8010604c227d13e1d953f1565d4d54174416 (patch)
tree2cfbf8112fa55f4357bdbed5243e17a71e2c7ba8
parent7cafa1f5e0f1e83ec5064764284433d64e94cc9f (diff)
downloadchawan-f60f8010604c227d13e1d953f1565d4d54174416.tar.gz
term: fix kitty image positioning
only use sixelMaxWidth/sixelMaxHeight for sixel
-rw-r--r--src/local/term.nim7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/local/term.nim b/src/local/term.nim
index 37ec90e1..109c6710 100644
--- a/src/local/term.nim
+++ b/src/local/term.nim
@@ -647,8 +647,11 @@ proc positionImage(term: Terminal; image: CanvasImage; x, y, maxw, maxh: int):
   image.offy = -min(ypx, 0)
   # calculate maximum image size that fits on the screen relative to the image
   # origin (*not* offx/offy)
-  let maxwpx = min(maxw * term.attrs.ppc, term.sixelMaxWidth)
-  let maxhpx = min(maxh * term.attrs.ppl, term.sixelMaxHeight)
+  var maxwpx = maxw * term.attrs.ppc
+  var maxhpx = maxh * term.attrs.ppl
+  if term.imageMode == imSixel:
+    maxwpx = min(maxwpx, term.sixelMaxWidth)
+    maxhpx = min(maxhpx, term.sixelMaxHeight)
   image.dispw = min(int(image.bmp.width) + xpx, maxwpx) - xpx
   image.disph = min(int(image.bmp.height) + ypx, maxhpx) - ypx
   image.damaged = true