diff options
author | bptato <nincsnevem662@gmail.com> | 2022-02-15 12:16:10 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2022-02-15 12:16:10 +0100 |
commit | 8efeab3d8770d0e5beaaa872a161d18b90d67658 (patch) | |
tree | c0f3841e0dc2086a2d2c93855351a36f57f1e9df /src/render | |
parent | c2236634bcbde5576949bcad7bd7ca6e9ccf3eb7 (diff) | |
download | chawan-8efeab3d8770d0e5beaaa872a161d18b90d67658.tar.gz |
Background color improvements
Diffstat (limited to 'src/render')
-rw-r--r-- | src/render/renderdocument.nim | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/render/renderdocument.nim b/src/render/renderdocument.nim index f2b8d9f8..983999a9 100644 --- a/src/render/renderdocument.nim +++ b/src/render/renderdocument.nim @@ -27,6 +27,8 @@ func formatFromWord(computed: ComputedFormat): Format = if computed.textdecoration == TEXT_DECORATION_BLINK: result.blink = true +#TODO format.pos signifying byte instead of actual position was a huge +# mistake... proc setFormats(lines: var FlexibleGrid, y, ox, i: int, nx, cx: var int, newformat: Format, oformats: seq[FormatCell], str, ostr: string, computed: ComputedFormat = nil) {.inline.} = @@ -46,8 +48,13 @@ proc setFormats(lines: var FlexibleGrid, y, ox, i: int, nx, cx: var int, if cx > newstrwidth + ox: # last oformat starts after newformat ends nx = ox + newstrwidth + eprint "ret" return + if osi >= ostr.len: + # I don't even know anymore + break + # move nx to cx while nsi < str.len and nx < cx: var r: Rune @@ -56,12 +63,14 @@ proc setFormats(lines: var FlexibleGrid, y, ox, i: int, nx, cx: var int, if format.format.bgcolor != newformat.bgcolor: newformat.bgcolor = format.format.bgcolor + eprint "odd", i + nsi, newformat.bgcolor, ox, nx if computed == nil: lines.addFormat(y, i + nsi, newformat) else: # have to pass nil to force new format... TODO? lines.addFormat(y, i + nsi, newformat, nil, computed.node) + eprint "end", ostr, "->", str, obg, nsi # last oformat starts before newformat ends # move cx to last old char @@ -78,6 +87,7 @@ proc setFormats(lines: var FlexibleGrid, y, ox, i: int, nx, cx: var int, if nsi < str.len: newformat.bgcolor = obg + eprint "add", str, ":", i + nsi if computed == nil: lines.addFormat(y, i + nsi, newformat) else: @@ -265,9 +275,9 @@ proc renderInlineContext(grid: var FlexibleGrid, ctx: InlineContext, x, y: int, grid.addLine() for atom in row.atoms: - if atom of BlockContext: - let ctx = BlockContext(atom) - grid.renderBlockContext(ctx, x, y, term) + if atom of InlineBlock: + let iblock = InlineBlock(atom) + grid.renderBlockContext(iblock.bctx, x + iblock.relx, y + iblock.rely, term) elif atom of InlineWord: let word = InlineWord(atom) grid.setRowWord(word, x, y, term) |