diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2022-02-27 08:38:48 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2022-02-27 08:41:30 -0800 |
commit | ae51b06dabbae991914aff281ff42addbcd21146 (patch) | |
tree | 7a24f1d7f22409dd1a0110cf82f1a930e64db061 /gemini.tlv | |
parent | 891bced5443cde47f51626d962e87df7d084a64c (diff) | |
download | teliva-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 'gemini.tlv')
-rw-r--r-- | gemini.tlv | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/gemini.tlv b/gemini.tlv index 34d1404..55b8a02 100644 --- a/gemini.tlv +++ b/gemini.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) @@ -208,14 +208,14 @@ > if state.highlight_index == 0 or i == state.highlight_index then > -- highlighted link > state.highlight_index = i -- TODO: ugly state update while rendering, just for first render after gemini_get - > curses.attron(curses.A_REVERSE) + > window:attron(curses.A_REVERSE) > render_link(window, y, line) - > curses.attroff(curses.A_REVERSE) + > window:attroff(curses.A_REVERSE) > else > -- link - > curses.attron(curses.A_BOLD) + > window:attron(curses.A_BOLD) > render_link(window, y, line) - > curses.attroff(curses.A_BOLD) + > window:attroff(curses.A_BOLD) > end > else > -- non-link @@ -257,7 +257,7 @@ > window:mvaddstr(screen_rows-1, 9, result) > window:attron(curses.A_REVERSE) > -- window:refresh() - > local key = curses.getch() + > local key = window:getch() > window:attrset(curses.A_NORMAL) > if key >= 32 and key < 127 then > local screen_rows, screen_cols = window:getmaxyx() @@ -318,7 +318,7 @@ - __teliva_timestamp: original update: >function update(window) - > local key = curses.getch() + > local key = window:getch() > local screen_rows, screen_cols = window:getmaxyx() > if key == curses.KEY_DOWN then > next_link() |