about summary refs log tree commit diff stats
path: root/src/io/cell.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2021-12-19 13:53:11 +0100
committerbptato <nincsnevem662@gmail.com>2021-12-19 13:53:11 +0100
commit6747131cd3dab85a711f4f96dde92e15e5979c8f (patch)
tree838eaaace84da32897c8c1da3e9e986b3a85a42f /src/io/cell.nim
parent9a3cd69ea8b99b04cb64800b75f4d2aa3e81fc84 (diff)
downloadchawan-6747131cd3dab85a711f4f96dde92e15e5979c8f.tar.gz
Fix pager mode formatting
Diffstat (limited to 'src/io/cell.nim')
-rw-r--r--src/io/cell.nim10
1 files changed, 4 insertions, 6 deletions
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))