about summary refs log tree commit diff stats
path: root/src/io/cell.nim
diff options
context:
space:
mode:
Diffstat (limited to 'src/io/cell.nim')
-rw-r--r--src/io/cell.nim34
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
+