diff options
author | bptato <nincsnevem662@gmail.com> | 2021-08-28 23:15:46 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2021-08-28 23:15:46 +0200 |
commit | 9996586865f931b6da19779520eb7671eddc6c4d (patch) | |
tree | 626f98684ffc9b8aba51f863cec72ad4962c0d01 /src/io/cell.nim | |
parent | 672ceca5730f6ff1b17a715f88214ff2a8e895c3 (diff) | |
download | chawan-9996586865f931b6da19779520eb7671eddc6c4d.tar.gz |
Rewrite renderer (still non-functional)
Diffstat (limited to 'src/io/cell.nim')
-rw-r--r-- | src/io/cell.nim | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/io/cell.nim b/src/io/cell.nim index d4a55b14..6ea887e3 100644 --- a/src/io/cell.nim +++ b/src/io/cell.nim @@ -1,6 +1,7 @@ import unicode import types/color +import utils/twtstr type Cell* = object of RootObj @@ -13,7 +14,9 @@ type FlexibleCell* = object of Cell rune*: Rune - FlexibleGrid* = seq[seq[FlexibleCell]] + FlexibleLine* = seq[FlexibleCell] + + FlexibleGrid* = seq[FlexibleLine] FixedCell* = object of Cell runes*: seq[Rune] @@ -32,3 +35,9 @@ proc setText*(grid: var FlexibleGrid, x: int, y: int, text: seq[Rune]) = grid[y][i].rune = text[i] inc i +func newFixedGrid*(w: int, h: int = 1): FixedGrid = + return newSeq[FixedCell](w * h) + +func width*(line: FlexibleLine): int = + for c in line: + result += c.rune.width() |