From 98fdd778d2c222b9b6b61d181680a74a09ecf44f Mon Sep 17 00:00:00 2001 From: bptato Date: Tue, 30 Jul 2024 19:45:46 +0200 Subject: term: constify queries + also send register & image dimension queries in forced sixel mode, and image dimension query on window resize --- src/local/term.nim | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/local') diff --git a/src/local/term.nim b/src/local/term.nim index 71ff9e25..1c3629e0 100644 --- a/src/local/term.nim +++ b/src/local/term.nim @@ -131,6 +131,12 @@ const XTSHIFTESCAPE = CSI(">0s") template XTSMGRAPHICS(pi, pa, pv: untyped): string = CSI("?" & $pi, $pa, $pv & "S") +# number of color registers +const XTNUMREGS = XTSMGRAPHICS(1, 1, 0) + +# image dimensions +const XTIMGDIMS = XTSMGRAPHICS(2, 1, 0) + # device control string const DCSSTART = "\eP" @@ -140,6 +146,8 @@ template DCS(a, b: char; s: varargs[string]): string = template XTGETTCAP(s: varargs[string, `$`]): string = DCS('+', 'q', s) +const XTGETRGB = XTGETTCAP("524742") + # OS command template OSC(s: varargs[string, `$`]): string = "\e]" & s.join(';') & '\a' @@ -969,10 +977,13 @@ proc queryAttrs(term: Terminal; windowOnly: bool): QueryResult = outs &= XTGETFG if term.config.display.image_mode.isNone: outs &= KITTYQUERY - outs &= XTSMGRAPHICS(1, 1, 0) # color registers - outs &= XTSMGRAPHICS(2, 1, 0) # dimensions + outs &= XTNUMREGS + outs &= XTIMGDIMS + elif term.config.display.image_mode.get == imSixel: + outs &= XTNUMREGS + outs &= XTIMGDIMS if term.config.display.color_mode.isNone: - outs &= XTGETTCAP("524742") + outs &= XTGETRGB outs &= XTGETANSI & GEOMPIXEL & @@ -985,6 +996,7 @@ proc queryAttrs(term: Terminal; windowOnly: bool): QueryResult = GEOMPIXEL & CELLSIZE & GEOMCELL & + XTIMGDIMS & DA1 term.outfile.write(outs) term.flush() -- cgit 1.4.1-2-gfad0