about summary refs log tree commit diff stats
path: root/adapter/img/sixel.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-09-05 18:55:25 +0200
committerbptato <nincsnevem662@gmail.com>2024-09-05 19:14:40 +0200
commitef5d188e05d4895125ad059f5518f9c8ff83bef5 (patch)
treee57882c92366983491e9ba299e0366cba93c5a6a /adapter/img/sixel.nim
parent3d40aced32d7c7ee1c98359ad98f43c11e72fd71 (diff)
downloadchawan-ef5d188e05d4895125ad059f5518f9c8ff83bef5.tar.gz
term: sixel sizing & output fixes
* round down to number divisible by 6 for height
* make pager's dispw match term's dispw even after width clamping
* make *BE procs actually emit/consume big-endian (lol)
* fix borked sixel set raster attributes & control string

I mixed up SRA with the device control string's parameters, so instead
of toggling transparency in the DCS, I was setting the second SRA
parameter to 0. Which, by the way, defines the aspect ratio's
denominator, and has nothing to do with transparency. Whoops.
Diffstat (limited to 'adapter/img/sixel.nim')
-rw-r--r--adapter/img/sixel.nim14
1 files changed, 7 insertions, 7 deletions
diff --git a/adapter/img/sixel.nim b/adapter/img/sixel.nim
index 7f2cdb5d..06a41a89 100644
--- a/adapter/img/sixel.nim
+++ b/adapter/img/sixel.nim
@@ -37,16 +37,16 @@ const DCSSTART = "\eP"
 const ST = "\e\\"
 
 proc setU32BE(s: var string; n: uint32; at: int) =
-  s[at] = char(n and 0xFF)
-  s[at + 1] = char((n shr 8) and 0xFF)
-  s[at + 2] = char((n shr 16) and 0xFF)
-  s[at + 3] = char((n shr 24) and 0xFF)
+  s[at] = char((n shr 24) and 0xFF)
+  s[at + 1] = char((n shr 16) and 0xFF)
+  s[at + 2] = char((n shr 8) and 0xFF)
+  s[at + 3] = char(n and 0xFF)
 
 proc putU32BE(s: var string; n: uint32) =
-  s &= char(n and 0xFF)
-  s &= char((n shr 8) and 0xFF)
-  s &= char((n shr 16) and 0xFF)
   s &= char((n shr 24) and 0xFF)
+  s &= char((n shr 16) and 0xFF)
+  s &= char((n shr 8) and 0xFF)
+  s &= char(n and 0xFF)
 
 type Node {.acyclic.} = ref object
   leaf: bool