diff options
author | bptato <nincsnevem662@gmail.com> | 2024-04-27 18:48:46 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-04-27 18:49:03 +0200 |
commit | a87aae2ee477089fb45d9bf085f31966b2afe833 (patch) | |
tree | 56c4c8b63172838596ffff8c7ae54b0b4e95bd5a | |
parent | 59144327fbd13ed3a5387696f1011c9ec9ec7ce9 (diff) | |
download | chawan-a87aae2ee477089fb45d9bf085f31966b2afe833.tar.gz |
ua.css: style xmp like pre
-rw-r--r-- | res/ua.css | 2 | ||||
-rw-r--r-- | src/local/term.nim | 10 |
2 files changed, 10 insertions, 2 deletions
diff --git a/res/ua.css b/res/ua.css index 7c43cc0e..82ba0aee 100644 --- a/res/ua.css +++ b/res/ua.css @@ -183,7 +183,7 @@ h1, h2, h3, h4, h5, h6 { font-weight: bold; } -pre { +pre, xmp { margin-top: 1em; margin-bottom: 1em; white-space: pre; diff --git a/src/local/term.nim b/src/local/term.nim index 85347f49..129411c3 100644 --- a/src/local/term.nim +++ b/src/local/term.nim @@ -684,14 +684,22 @@ proc outputSixelImage(term: Terminal; x, y, offx, offy, dispw, disph: int; let W = int(dispw) - offx var n = offy * int(bmp.width) let L = disph * int(bmp.width) + let cx0 = offx div term.attrs.ppc while n < L: var bands = newSeq[SixelBand]() + let cy = n div int(bmp.width) div term.attrs.ppl for i in 0 ..< 6: if n >= bmp.px.len: break let mask = 1u8 shl i for x in 0 ..< W: - let c = RGBColor(bmp.px[n + x + offx]).toEightBit() + let cx = cx0 + x div term.attrs.ppc + let bgcolor0 = term.canvas[cy * term.canvas.width + cx].format.bgcolor + let bgcolor = if bgcolor0.t == ctRGB: + bgcolor0.rgbcolor + else: + term.defaultBackground + let c = RGBColor(bgcolor.blend(bmp.px[n + x + offx])).toEightBit() if (let j = bands.find(c); j != -1): bands[j].data[x] = bands[j].data[x] or mask else: |