From 6747131cd3dab85a711f4f96dde92e15e5979c8f Mon Sep 17 00:00:00 2001 From: bptato Date: Sun, 19 Dec 2021 13:53:11 +0100 Subject: Fix pager mode formatting --- src/io/cell.nim | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/io/cell.nim') diff --git a/src/io/cell.nim b/src/io/cell.nim index 5bdbfb50..9e657bb6 100644 --- a/src/io/cell.nim +++ b/src/io/cell.nim @@ -91,9 +91,6 @@ func width*(line: FlexibleLine): int = func width*(cell: FixedCell): int = return cell.runes.width() -func len*(line: FlexibleLine): int = - return line.str.runeLen() - func newFormatting*(): Formatting = return Formatting(fgcolor: defaultColor, bgcolor: defaultColor) @@ -143,18 +140,19 @@ proc setLen*(line: var FlexibleLine, len: int) = if line.formats[i].pos >= len: line.formats.setLen(i) break + line.str.setLen(len) #line.formats = line.formats.filter((x) => x.pos < len) proc add*(a: var FlexibleLine, b: FlexibleLine) = - let l = a.len + let l = a.str.len a.formats.add(b.formats.map((x) => FormattingCell(formatting: x.formatting, nodes: x.nodes, pos: l + x.pos))) a.str &= b.str proc addLine*(grid: var FlexibleGrid) = grid.add(FlexibleLine()) -proc addFormat*(grid: var FlexibleGrid, y: int, format: Formatting) = - grid[y].formats.add(FormattingCell(formatting: format, pos: grid[y].len)) +proc addFormat*(grid: var FlexibleGrid, y, pos: int, format: Formatting) = + grid[y].formats.add(FormattingCell(formatting: format, pos: grid[y].str.len)) proc addFormat*(grid: var FlexibleGrid, y, pos: int, format: Formatting, nodes: seq[Node]) = grid[y].formats.add(FormattingCell(formatting: format, nodes: nodes, pos: pos)) -- cgit 1.4.1-2-gfad0