diff options
author | bptato <nincsnevem662@gmail.com> | 2023-01-03 20:07:08 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-01-03 20:07:08 +0100 |
commit | eda263319d5f6b4f7392398a42d67f04056c23e1 (patch) | |
tree | d4f092cfabd5039997d03f04c7182276886e2c67 /src/buffer | |
parent | e8bb0842cc7c082f873fed167427e0db4d64bb69 (diff) | |
download | chawan-eda263319d5f6b4f7392398a42d67f04056c23e1.tar.gz |
renderdocument: add StyledNodes to backgrounds
This makes it possible to e.g. click on this: <a href=x style="display: inline-block; width: 5em; height: 5em; background-color: red"></a>
Diffstat (limited to 'src/buffer')
-rw-r--r-- | src/buffer/cell.nim | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/src/buffer/cell.nim b/src/buffer/cell.nim index a5e33645..3d1d32fa 100644 --- a/src/buffer/cell.nim +++ b/src/buffer/cell.nim @@ -4,7 +4,6 @@ import strutils import sugar import css/stylednode -import layout/box import types/color import utils/twtstr @@ -28,7 +27,6 @@ type FormatCell* = object format*: Format pos*: int - computed*: ComputedFormat node*: StyledNode SimpleFormatCell* = object @@ -143,22 +141,11 @@ func findNextFormat*(line: SimpleFlexibleLine, pos: int): SimpleFormatCell = proc addLine*(grid: var FlexibleGrid) = grid.add(FlexibleLine()) -proc insertFormat*(line: var FlexibleLine, pos, i: int, format: Format, computed: ComputedFormat = nil) = - if computed == nil: - line.formats.insert(FormatCell(format: format, pos: pos), i) - else: - line.formats.insert(FormatCell(format: format, computed: computed, node: computed.node, pos: pos), i) - -proc addFormat*(line: var FlexibleLine, pos: int, format: Format) = - line.formats.add(FormatCell(format: format, pos: pos)) +proc insertFormat*(line: var FlexibleLine, pos, i: int, format: Format, node: StyledNode = nil) = + line.formats.insert(FormatCell(format: format, node: node, pos: pos), i) -proc addFormat*(line: var FlexibleLine, pos: int, format: Format, computed: ComputedFormat) = - #if computed != nil and line.formats.len > 0 and line.formats[^1].computed == computed and line.formats[^1].format.bgcolor != format.bgcolor: - # return - if computed == nil: - line.formats.add(FormatCell(format: format, pos: pos)) - else: - line.formats.add(FormatCell(format: format, computed: computed, node: computed.node, pos: pos)) +proc addFormat*(line: var FlexibleLine, pos: int, format: Format, node: StyledNode = nil) = + line.formats.add(FormatCell(format: format, node: node, pos: pos)) template inc_check(i: int) = inc i |