about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-11-06 12:54:00 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-11-06 12:55:26 -0700
commit396684ebf1f8bb7751d14452f1b56fe6a27eb1f1 (patch)
tree4c230b2d82183f2d6e9b7067ecdcf6d59d917102
parentee85ad384f17e7270f6bfe42ed146406938131a1 (diff)
downloadteliva-396684ebf1f8bb7751d14452f1b56fe6a27eb1f1.tar.gz
new example: counter app
-rw-r--r--counter.teliva32
-rw-r--r--hanoi.lua1
-rw-r--r--hanoi.teliva1
3 files changed, 32 insertions, 2 deletions
diff --git a/counter.teliva b/counter.teliva
new file mode 100644
index 0000000..7331d34
--- /dev/null
+++ b/counter.teliva
@@ -0,0 +1,32 @@
+local curses = require "curses"
+
+n = 0
+
+local function render(window)
+  window:clear()
+  window:attron(curses.A_BOLD)
+  window:attron(curses.color_pair(6))
+  window:mvaddstr(10, 10, "     ")
+  window:mvaddstr(10, 11, n)
+  window:attroff(curses.color_pair(6))
+  window:attroff(curses.A_BOLD)
+  curses.refresh()
+end
+
+menu = {Enter="increment"}
+local function update(window)
+  local key = curses.getch()
+  if key == 10 then
+    n = n+1
+  end
+end
+
+local window = curses.stdscr()
+for i=1,7 do
+  curses.init_pair(i, 0, i)
+end
+
+while true do
+  render(window)
+  update(window)
+end
diff --git a/hanoi.lua b/hanoi.lua
index 0c1d60f..f216570 100644
--- a/hanoi.lua
+++ b/hanoi.lua
@@ -1,6 +1,5 @@
 local curses = require "curses"
 
-menu = {a="abc"}
 tower = {{6, 5, 4, 3, 2}, {}, {}}
 
 local function len(array)
diff --git a/hanoi.teliva b/hanoi.teliva
index d0ae354..04b4491 100644
--- a/hanoi.teliva
+++ b/hanoi.teliva
@@ -1,6 +1,5 @@
 local curses = require "curses"
 
-menu = {a="abc"}
 tower = {{6, 5, 4, 3, 2}, {}, {}}
 
 local function len(array)