about summary refs log tree commit diff stats
path: root/commander.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 /commander.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 'commander.tlv')
-rw-r--r--commander.tlv6
1 files changed, 3 insertions, 3 deletions
diff --git a/commander.tlv b/commander.tlv
index b8292af..73709a2 100644
--- a/commander.tlv
+++ b/commander.tlv
@@ -80,7 +80,7 @@
   check_eq:
     >function check_eq(x, expected, msg)
     >  if x == expected then
-    >    curses.addch('.')
+    >    window:addch('.')
     >  else
     >    print('F - '..msg)
     >    print('  expected '..tostring(expected)..' but got '..x)
@@ -159,7 +159,7 @@
     >      print(f, attr.permissions, attr.size, attr.access, attr.modification)
     >    end
     >  end
-    >  curses.refresh()
+    >  window:refresh()
     >end
 - __teliva_timestamp: original
   menu:
@@ -169,7 +169,7 @@
 - __teliva_timestamp: original
   update:
     >function update(window)
-    >  local key = curses.getch()
+    >  local key = window:getch()
     >  -- process key here
     >end
 - __teliva_timestamp: original
id='n47' href='#n47'>47 48 49 50 51 52 53 54 55
56
57
58
59
60
61
62
63
64
65
66