about summary refs log tree commit diff stats
path: root/template.tlv
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-02-27 08:38:48 -0800
committerKartik K. Agaram <vc@akkartik.com>2022-02-27 08:41:30 -0800
commitae51b06dabbae991914aff281ff42addbcd21146 (patch)
tree7a24f1d7f22409dd1a0110cf82f1a930e64db061 /template.tlv
parent891bced5443cde47f51626d962e87df7d084a64c (diff)
downloadteliva-ae51b06dabbae991914aff281ff42addbcd21146.tar.gz
starting to make Teliva apps more testable
Tasteful apps should only perform side-effects through 'window'
arguments rather than the 'curses' module directly. It's ok however to
read constants like curses.A_NORMAL or curses.stdscr().

There are some limitations, unfortunately. Ncurses wasn't designed with
testability in mind. For example, there's no way to curs_set or
assume_default_colors without the 'curses' module. Oh well.
Diffstat (limited to 'template.tlv')
-rw-r--r--template.tlv6
1 files changed, 3 insertions, 3 deletions
diff --git a/template.tlv b/template.tlv
index ca3a0f3..1d5dd05 100644
--- a/template.tlv
+++ b/template.tlv
@@ -80,7 +80,7 @@
   check_eq:
     >function check_eq(x, expected, msg)
     >  if eq(x, expected) then
-    >    curses.addch('.')
+    >    window:addch('.')
     >  else
     >    print('F - '..msg)
     >    print('  expected '..str(expected)..' but got '..str(x))
@@ -221,7 +221,7 @@
     >    window:attrset(curses.color_pair(i))
     >    window:mvaddstr(3+i, 5, "========================")
     >  end
-    >  curses.refresh()
+    >  window:refresh()
     >end
 - __teliva_timestamp: original
   menu:
@@ -231,7 +231,7 @@
 - __teliva_timestamp: original
   update:
     >function update(window)
-    >  local key = curses.getch()
+    >  local key = window:getch()
     >  -- process key here
     >end
 - __teliva_timestamp: original