aboutsummaryrefslogtreecommitdiff
path: root/src/tile.nim
diff options
context:
space:
mode:
Diffstat (limited to 'src/tile.nim')
-rw-r--r--src/tile.nim8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/tile.nim b/src/tile.nim
index f82c21d..a931f66 100644
--- a/src/tile.nim
+++ b/src/tile.nim
@@ -1,10 +1,13 @@
1import terminal, unicode, strutils 1import terminal, unicode, strutils
2 2
3type Point* = tuple 3type Point* = tuple
4 ## represents coordinates in the terminal
4 x: int 5 x: int
5 y: int 6 y: int
6 7
7proc drawHorizontalLine*(origin: Point, length: int, symbol = "─") = 8proc drawHorizontalLine*(origin: Point, length: int, symbol = "─") =
9 ## Draws a horizontal line of ``length`` times ``symbol`` on the screen.
10 ## The left end of the line is ``origin``.
8 if origin.x < terminalWidth() and 11 if origin.x < terminalWidth() and
9 origin.x + length > 0 and 12 origin.x + length > 0 and
10 origin.y < terminalHeight() and 13 origin.y < terminalHeight() and
@@ -16,6 +19,8 @@ proc drawHorizontalLine*(origin: Point, length: int, symbol = "─") =
16 stdout.write(symbol) 19 stdout.write(symbol)
17 20
18proc drawVerticalLine*(origin: Point, length: int, symbol = "│") = 21proc drawVerticalLine*(origin: Point, length: int, symbol = "│") =
22 ## Draws a vertical line of ``length`` times ``symbol`` on the screen.
23 ## The top end of the line is ``origin``
19 if origin.y < terminalHeight() and 24 if origin.y < terminalHeight() and
20 origin.y + length > 0 and 25 origin.y + length > 0 and
21 origin.x < terminalWidth() and 26 origin.x < terminalWidth() and
@@ -58,6 +63,9 @@ proc writeLeftAligned*(origin: Point,
58 resetAttributes() 63 resetAttributes()
59 64
60type Tile* = ref object of RootObj 65type Tile* = ref object of RootObj
66 ## A generic type representing a tile in a terminal. Contains a ``help``
67 ## string to be presented to users and a ``focussed`` flag indicating the
68 ## tile's focus status.
61 help*: string 69 help*: string
62 focussed*: bool 70 focussed*: bool
63 71