-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathfullscreen.nim
43 lines (30 loc) · 948 Bytes
/
fullscreen.nim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Simple example that prints out the size of the terminal window and
# demonstrates the basic structure of a full-screen app.
import os, strformat
import illwill
proc exitProc() {.noconv.} =
illwillDeinit()
showCursor()
quit(0)
proc main() =
illwillInit(fullscreen=true)
setControlCHook(exitProc)
hideCursor()
while true:
var tb = newTerminalBuffer(terminalWidth(), terminalHeight())
var key = getKey()
case key
of Key.Escape, Key.Q: exitProc()
else: discard
tb.setForegroundColor(fgYellow)
tb.drawRect(0, 0, tb.width-1, tb.height-1)
tb.setBackgroundColor(bgRed)
tb.setForegroundColor(fgWhite, bright=true)
tb.write(1, 1, fmt"Width: {tb.width}")
tb.write(1, 2, fmt"Height: {tb.height}")
tb.resetAttributes()
tb.write(1, 4, "Press Q, Esc or Ctrl-C to quit")
tb.write(1, 5, "Resize the terminal window and see what happens :)")
tb.display()
sleep(20)
main()