diff options
author | bptato <nincsnevem662@gmail.com> | 2022-06-17 12:23:26 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2022-06-17 12:23:26 +0200 |
commit | be10c6a289273ca8f06400aa6ae88dd7108f4ac6 (patch) | |
tree | 23bcd9524dfea8553dd283f7612b4b845bba00d9 /src/render | |
parent | b6b4e896e07f143484e22cf45fb7658b10af084d (diff) | |
download | chawan-be10c6a289273ca8f06400aa6ae88dd7108f4ac6.tar.gz |
Re-implement inline-block
Still far from standard-compliant, or even non-broken... but it's something
Diffstat (limited to 'src/render')
-rw-r--r-- | src/render/renderdocument.nim | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/render/renderdocument.nim b/src/render/renderdocument.nim index 3dc72c38..6227b4c7 100644 --- a/src/render/renderdocument.nim +++ b/src/render/renderdocument.nim @@ -101,10 +101,10 @@ proc setText(lines: var FlexibleGrid, linestr: string, format: ComputedFormat, x proc setRowWord(lines: var FlexibleGrid, word: InlineWord, x, y: int, term: TermAttributes) = var r: Rune - var y = (y + word.rely) div term.ppl + var y = (y + word.offset.y) div term.ppl if y < 0: y = 0 - var x = (x + word.relx) div term.ppc + var x = (x + word.offset.x) div term.ppc var i = 0 while x < 0 and i < word.str.len: fastRuneAt(word.str, i, r) @@ -114,12 +114,10 @@ proc setRowWord(lines: var FlexibleGrid, word: InlineWord, x, y: int, term: Term lines.setText(linestr, word.format, x, y) proc setSpacing(lines: var FlexibleGrid, spacing: InlineSpacing, x, y: int, term: TermAttributes) = - var r: Rune - - var y = (y + spacing.rely) div term.ppl + var y = (y + spacing.offset.y) div term.ppl if y < 0: y = 0 - var x = (x + spacing.relx) div term.ppc + var x = (x + spacing.offset.x) div term.ppc let width = spacing.width div term.ppc var i = 0 @@ -208,8 +206,8 @@ proc renderInlineContext(grid: var FlexibleGrid, ctx: InlineContext, x, y: int, let x = x + ctx.offset.x let y = y + ctx.offset.y for row in ctx.rows: - let x = x + row.relx - let y = y + row.rely + let x = x + row.offset.x + let y = y + row.offset.y let r = y div term.ppl while grid.len <= r: @@ -218,7 +216,7 @@ proc renderInlineContext(grid: var FlexibleGrid, ctx: InlineContext, x, y: int, for atom in row.atoms: if atom of InlineBlock: let iblock = InlineBlock(atom) - grid.renderBlockContext(iblock.bctx, x + iblock.relx, y + iblock.rely, term) + grid.renderBlockContext(iblock.bctx, x + iblock.offset.x, y + iblock.offset.y, term) elif atom of InlineWord: let word = InlineWord(atom) grid.setRowWord(word, x, y, term) |