From 1ddb53f3c22693c34eb84ca1c6945396b98996c1 Mon Sep 17 00:00:00 2001 From: bptato Date: Mon, 9 Sep 2024 21:45:53 +0200 Subject: pager, term: fix kitty display, add a sixel bounds check --- src/local/pager.nim | 4 ++-- src/local/term.nim | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/local/pager.nim b/src/local/pager.nim index 3822eb77..b0521706 100644 --- a/src/local/pager.nim +++ b/src/local/pager.nim @@ -575,8 +575,8 @@ proc initImages(pager: Pager; container: Container) = dispw = min(width + xpx, maxwpx) - xpx let ypx = (image.y - container.fromy) * pager.attrs.ppl erry = -min(ypx, 0) mod 6 - if dispw <= offx: - continue + if dispw <= offx: + continue let cached = container.findCachedImage(image, offx, erry, dispw) let imageId = image.bmp.imageId if cached == nil: diff --git a/src/local/term.nim b/src/local/term.nim index 2f31104a..e9b404a1 100644 --- a/src/local/term.nim +++ b/src/local/term.nim @@ -821,8 +821,9 @@ proc outputSixelImage(term: Terminal; x, y: int; image: CanvasImage; proc outputSixelImage(term: Terminal; x, y: int; image: CanvasImage) = var p = cast[ptr UncheckedArray[char]](image.data.buffer) - let H = int(image.data.size - 1) - term.outputSixelImage(x, y, image, p.toOpenArray(0, H)) + if image.data.size > 0: + let H = int(image.data.size - 1) + term.outputSixelImage(x, y, image, p.toOpenArray(0, H)) proc outputKittyImage(term: Terminal; x, y: int; image: CanvasImage) = var outs = term.cursorGoto(x, y) & -- cgit 1.4.1-2-gfad0