diff options
author | bptato <nincsnevem662@gmail.com> | 2021-08-10 15:19:32 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2021-08-10 15:19:32 +0200 |
commit | a5f7da0428fdb74d9691cd6d589047478f422898 (patch) | |
tree | 0bbea58202a8f509c83378a4b57bbe419131c7d5 /src/io/cell.nim | |
parent | 3d24875924b088e5d771e4b901f692659c5281c0 (diff) | |
download | chawan-a5f7da0428fdb74d9691cd6d589047478f422898.tar.gz |
Some refactoring
Diffstat (limited to 'src/io/cell.nim')
-rw-r--r-- | src/io/cell.nim | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/io/cell.nim b/src/io/cell.nim new file mode 100644 index 00000000..d4a55b14 --- /dev/null +++ b/src/io/cell.nim @@ -0,0 +1,34 @@ +import unicode + +import types/color + +type + Cell* = object of RootObj + fgcolor*: CellColor + bgcolor*: CellColor + italic*: bool + bold*: bool + underline*: bool + + FlexibleCell* = object of Cell + rune*: Rune + + FlexibleGrid* = seq[seq[FlexibleCell]] + + FixedCell* = object of Cell + runes*: seq[Rune] + + FixedGrid* = seq[FixedCell] + +proc setText*(grid: var FlexibleGrid, x: int, y: int, text: seq[Rune]) = + while grid.len <= y: + grid.add(newSeq[FlexibleCell]()) + + while grid[y].len < x + text.len: + grid[y].add(FlexibleCell()) + + var i = 0 + while i < text.len: + grid[y][i].rune = text[i] + inc i + |