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.
This commit is contained in:
Kartik K. Agaram 2022-02-27 08:38:48 -08:00
parent 891bced544
commit ae51b06dab
12 changed files with 129 additions and 129 deletions

View File

@ -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))
@ -236,7 +236,7 @@
- __teliva_timestamp: original
update:
>function update(window)
> local key = curses.getch()
> local key = window:getch()
> if key == curses.KEY_LEFT then
> if cursor > 1 then
> cursor = cursor-1
@ -261,13 +261,13 @@
> window:clear()
>
> local prompt_str = ' what is your name? '
> curses.attron(curses.A_REVERSE)
> window:attron(curses.A_REVERSE)
> window:mvaddstr(0, 0, prompt_str)
> curses.attroff(curses.A_REVERSE)
> window:attroff(curses.A_REVERSE)
> window:addstr(' ')
> curses.attron(curses.A_BOLD)
> window:attron(curses.A_BOLD)
> window:addstr(word)
> curses.attroff(curses.A_BOLD)
> window:attroff(curses.A_BOLD)
> window:mvaddstr(2, 0, '')
> local results = anagrams(word)
> if #results > 0 then
@ -281,7 +281,7 @@
> end
>
> window:mvaddstr(0, string.len(prompt_str)+cursor, '')
> curses.refresh()
> window:refresh()
>end
- __teliva_timestamp:
>Mon Feb 21 17:42:28 2022

View File

@ -62,9 +62,9 @@
- __teliva_timestamp: original
render_player:
>function render_player(y, x, player)
> curses.mvaddstr(y, x, player.user.name)
> curses.addstr(" · ")
> curses.addstr(tostring(player.rating))
> window:mvaddstr(y, x, player.user.name)
> window:addstr(" · ")
> window:addstr(tostring(player.rating))
>end
- __teliva_timestamp: original
render_square:
@ -77,15 +77,15 @@
> end
> if (rank+file)%2 == 1 then
> -- light square
> curses.attrset(curses.color_pair(1+hl))
> window:attrset(curses.color_pair(1+hl))
> else
> -- dark square
> curses.attrset(curses.color_pair(3+hl))
> window:attrset(curses.color_pair(3+hl))
> end
> curses.mvaddstr((8 - rank + 1)*3, file*5, " ")
> curses.mvaddstr((8 - rank + 1)*3+1, file*5, " ")
> curses.mvaddstr((8 - rank + 1)*3+2, file*5, " ")
> curses.attrset(curses.A_NORMAL)
> window:mvaddstr((8 - rank + 1)*3, file*5, " ")
> window:mvaddstr((8 - rank + 1)*3+1, file*5, " ")
> window:mvaddstr((8 - rank + 1)*3+2, file*5, " ")
> window:attrset(curses.A_NORMAL)
>end
- __teliva_timestamp: original
render_fen_rank:
@ -104,22 +104,22 @@
> if (rank+file)%2 == 1 then
> if x < 'Z' then
> -- white piece on light square
> curses.attrset(curses.color_pair(1+hl))
> window:attrset(curses.color_pair(1+hl))
> else
> -- black piece on light square
> curses.attrset(curses.color_pair(2+hl))
> window:attrset(curses.color_pair(2+hl))
> end
> else
> if x < 'Z' then
> -- white piece on dark square
> curses.attrset(curses.color_pair(3+hl))
> window:attrset(curses.color_pair(3+hl))
> else
> -- black piece on dark square
> curses.attrset(curses.color_pair(4+hl))
> window:attrset(curses.color_pair(4+hl))
> end
> end
> curses.mvaddstr((8 - rank + 1)*3+1, file*5+2, utf8(piece_glyph[x]))
> curses.attrset(curses.A_NORMAL)
> window:mvaddstr((8 - rank + 1)*3+1, file*5+2, utf8(piece_glyph[x]))
> window:attrset(curses.A_NORMAL)
> file = file + 1
> end
> end
@ -128,14 +128,14 @@
render_time:
>function render_time(y, x, seconds)
> if seconds == nil then return end
> curses.mvaddstr(y, x, tostring(math.floor(seconds/60)))
> curses.addstr(string.format(":%02d", seconds%60))
> window:mvaddstr(y, x, tostring(math.floor(seconds/60)))
> window:addstr(string.format(":%02d", seconds%60))
>end
- __teliva_timestamp: original
render_board:
>function render_board(current_game)
>--? curses.mvaddstr(1, 50, dump(current_game.fen))
>--? curses.mvaddstr(6, 50, dump(current_game.previously_moved_squares))
>--? window:mvaddstr(1, 50, dump(current_game.fen))
>--? window:mvaddstr(6, 50, dump(current_game.previously_moved_squares))
> render_player(2, 5, top_player(current_game))
> render_time(2, 35, current_game.bc)
> for rank=8,1,-1 do
@ -150,12 +150,12 @@
- __teliva_timestamp: original
parse_lm:
>function parse_lm(move)
>--? curses.mvaddstr(4, 50, move)
>--? window:mvaddstr(4, 50, move)
> local file1 = string.byte(move:sub(1, 1)) - 96 -- 'a'-1
> local rank1 = string.byte(move:sub(2, 2)) - 48 -- '0'
> local file2 = string.byte(move:sub(3, 3)) - 96 -- 'a'-1
> local rank2 = string.byte(move:sub(4, 4)) - 48 -- '0'
>--? curses.mvaddstr(5, 50, dump({{rank1, file1}, {rank2, file2}}))
>--? window:mvaddstr(5, 50, dump({{rank1, file1}, {rank2, file2}}))
> return {from={rank=rank1, file=file1}, to={rank=rank2, file=file2}}
>end
- __teliva_timestamp: original
@ -173,11 +173,11 @@
>--? current_game.lm = o.d.lm
> current_game.previously_moved_squares = parse_lm(o.d.lm)
>--? window:nodelay(false)
>--? curses.mvaddstr(3, 50, "paused")
>--? window:mvaddstr(3, 50, "paused")
> end
> current_game.fen_rank = split(current_game.fen, "%w+")
> render_board(current_game)
> curses.refresh()
> window:refresh()
>end
- __teliva_timestamp: original
init_colors:
@ -207,9 +207,9 @@
> url = "https://lichess.org/api/tv/feed",
> sink = function(chunk, err)
> if chunk then
> curses.clear()
> window:clear()
> render(chunk)
> curses.getch()
> window:getch()
> end
> return 1
> end,
@ -271,17 +271,17 @@
> url = "https://lichess.org/api/tv/feed",
> sink = function(chunk, err)
> if chunk then
> curses.clear()
> window:clear()
> -- main event loop is here
> render(chunk)
> curses.getch()
> window:getch()
> end
> return 1
> end,
> }
> http.request(request)
> -- degenerate event loop just to show errors in sandboxing, etc.
> while true do curses.getch(); end
> while true do window:getch(); end
>end
- __teliva_timestamp:
>Thu Feb 17 20:00:23 2022

View File

@ -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

View File

@ -32,7 +32,7 @@
> window:mvaddstr(10, 11, n)
> window:attroff(curses.color_pair(6))
> window:attroff(curses.A_BOLD)
> curses.refresh()
> window:refresh()
>end
- __teliva_timestamp: original
menu:
@ -42,7 +42,7 @@
- __teliva_timestamp: original
update:
>function update(window)
> local key = curses.getch()
> local key = window:getch()
> if key == 10 then
> n = n+1
> end

View File

@ -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()

View File

@ -26,7 +26,7 @@
> for i,t in ipairs(tower) do
> render_tower(window, line, i*col, i, t)
> end
> curses.refresh()
> window:refresh()
>end
- __teliva_timestamp: original
lines:
@ -103,9 +103,9 @@
update:
>function update(window)
> window:mvaddstr(lines(window)-2, 5, "tower to remove top disk from? ")
> local from = curses.getch() - 96
> local from = window:getch() - 96
> window:mvaddstr(lines(window)-1, 5, "tower to stack it on? ")
> local to = curses.getch() - 96
> local to = window:getch() - 96
> make_move(from, to)
>end
- __teliva_timestamp: original

View File

@ -110,14 +110,14 @@
render:
>function render(window)
> window:clear()
> curses.attron(curses.color_pair(1))
> window:attron(curses.color_pair(1))
> for line=1,lines do
> for col=1,cols do
> window:addstr(utf8(glyph[grid_char_to_glyph_index(grid_char(line, col))]))
> end
> end
> curses.attroff(curses.color_pair(1))
> curses.refresh()
> window:attroff(curses.color_pair(1))
> window:refresh()
>end
- __teliva_timestamp: original
state:
@ -291,7 +291,7 @@
> -- main loop
> while true do
> render(window)
> c = curses.getch()
> c = window:getch()
> update(window, c)
> step()
> end

View File

@ -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)
@ -161,7 +161,7 @@
> window:attrset(curses.color_pair(i))
> window:mvaddstr(3+i, 5, "========================")
> end
> curses.refresh()
> window:refresh()
>end
- __teliva_timestamp: original
menu:
@ -171,7 +171,7 @@
- __teliva_timestamp: original
update:
>function update(window)
> local key = curses.getch()
> local key = window:getch()
> -- process key here
>end
- __teliva_timestamp: original

View File

@ -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
@ -271,7 +271,7 @@
> task.spawn(main_task)
> task.scheduler()
> print('out of scheduler')
> curses.getch()
> window:getch()
>end
- __teliva_timestamp:
>Sat Feb 26 21:50:11 2022
@ -368,7 +368,7 @@
> task.scheduler()
> print('key pressed; done')
> window:nodelay(false)
> curses.getch()
> window:getch()
>end
- __teliva_timestamp:
>Sat Feb 26 22:09:47 2022
@ -384,7 +384,7 @@
> while true do
> window:addstr(primes:recv())
> window:addstr(' ')
> local c = curses.getch()
> local c = window:getch()
> if c then break end -- key pressed
> local y, x = window:getyx()
> if y > h-1 then

View File

@ -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

View File

@ -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)
@ -205,7 +205,7 @@
> window:addstr(string.len(toot))
> window:attroff(curses.A_BOLD)
> end
> curses.refresh()
> window:refresh()
>end
- __teliva_timestamp: original
render_delimiter:
@ -288,7 +288,7 @@
- __teliva_timestamp: original
update:
>function update(window)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> if key == curses.KEY_LEFT then
> if cursor > 1 then

120
zet.tlv
View File

@ -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)
@ -150,7 +150,7 @@
spaces:
>function spaces(n)
> for i=1,n do
> curses.addch(' ')
> window:addch(' ')
> end
>end
- __teliva_timestamp: original
@ -277,7 +277,7 @@
- __teliva_timestamp: original
update:
>function update(window)
> local key = curses.getch()
> local key = window:getch()
> local curr = zettels[current_zettel_id]
> -- graph-based navigation
> if key == string.byte('j') then
@ -372,7 +372,7 @@
> window:addstr(' ') -- margin
> end
> window:mvaddstr(lines-1, 0, '? ')
> curses.refresh()
> window:refresh()
>end
- __teliva_timestamp: original
view_settings:
@ -467,7 +467,7 @@
- __teliva_timestamp: original
editz_update:
>function editz_update(window, prose, cursor)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> if key == curses.KEY_LEFT then
> if cursor > 1 then
@ -741,7 +741,7 @@
> window:attrset(curses.color_pair(0))
> window:addstr(' ') -- margin
> end
> curses.refresh()
> window:refresh()
>end
- __teliva_timestamp:
>Wed Feb 9 08:15:35 2022
@ -849,7 +849,7 @@
>editz_render is now much simpler
editz_update:
>function editz_update(window, prose, cursor)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> if key == curses.KEY_LEFT then
> if cursor > 1 then
@ -893,7 +893,7 @@
>no need for chords once we drop the commandline
update:
>function update(window)
> local key = curses.getch()
> local key = window:getch()
> local curr = zettels[current_zettel_id]
> -- graph-based navigation
> if key == string.byte('j') then
@ -998,7 +998,7 @@
>feels natural to immediately start editing them
update:
>function update(window)
> local key = curses.getch()
> local key = window:getch()
> local curr = zettels[current_zettel_id]
> assert(curr, string.format('cursor fell off the edge of the world: %s', type(current_zettel_id)))
> -- graph-based navigation
@ -1091,7 +1091,7 @@
>Thu Feb 10 00:01:58 2022
update:
>function update(window)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> local curr = zettels[current_zettel_id]
> assert(curr, string.format('cursor fell off the edge of the world: %s', type(current_zettel_id)))
@ -1230,7 +1230,7 @@
>bugfix: handle missing parent/child/sib
update:
>function update(window)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> local curr = zettels[current_zettel_id]
> assert(curr, string.format('cursor fell off the edge of the world: %s', type(current_zettel_id)))
@ -1488,7 +1488,7 @@
>Thu Feb 10 20:32:38 2022
update:
>function update(window)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> local curr = zettels[current_zettel_id]
> assert(curr, string.format('cursor fell off the edge of the world: %s', type(current_zettel_id)))
@ -1669,7 +1669,7 @@
> bg = 3 - bg
> x = x + view_settings.width + view_settings.hmargin
> end
> curses.refresh()
> window:refresh()
>end
- __teliva_timestamp:
>Thu Feb 10 20:40:08 2022
@ -1768,7 +1768,7 @@
> bg = 3 - bg
> x = x + view_settings.width + view_settings.hmargin
> end
> curses.refresh()
> window:refresh()
>end
- __teliva_timestamp:
>Thu Feb 10 20:55:19 2022
@ -1878,7 +1878,7 @@
> bg = 8 - bg -- toggle between color pairs 3 and 5
> x = x + view_settings.width + view_settings.hmargin
> end
> curses.refresh()
> window:refresh()
>end
- __teliva_timestamp:
>Thu Feb 10 21:02:41 2022
@ -2008,7 +2008,7 @@
> bg = 8 - bg -- toggle between color pairs 3 and 5
> x = x + view_settings.width + view_settings.hmargin
> end
> curses.refresh()
> window:refresh()
>end
- __teliva_timestamp:
>Thu Feb 10 21:19:26 2022
@ -2016,7 +2016,7 @@
>bugfix: cross-links should be bidirectional
update:
>function update(window)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> local curr = zettels[current_zettel_id]
> assert(curr, string.format('cursor fell off the edge of the world: %s', type(current_zettel_id)))
@ -2154,7 +2154,7 @@
>clear stash after linking
update:
>function update(window)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> local curr = zettels[current_zettel_id]
> assert(curr, string.format('cursor fell off the edge of the world: %s', type(current_zettel_id)))
@ -2374,7 +2374,7 @@
>bugfix in parent link when inserting child
update:
>function update(window)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> local curr = zettels[current_zettel_id]
> assert(curr, string.format('cursor fell off the edge of the world: %s', type(current_zettel_id)))
@ -2537,7 +2537,7 @@
>Sat Feb 12 15:05:20 2022
editz_update:
>function editz_update(window, prose, cursor, original_prose)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> if key == curses.KEY_LEFT then
> if cursor > 1 then
@ -2627,7 +2627,7 @@
>Sat Feb 12 15:11:15 2022
editz_update:
>function editz_update(window, prose, cursor, original_prose)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> -- cursor movement
> if key == curses.KEY_LEFT then
@ -2698,7 +2698,7 @@
>Sat Feb 12 15:31:27 2022
editz_update:
>function editz_update(window, prose, cursor, original_prose)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> -- cursor movement
> if key == curses.KEY_LEFT then
@ -2743,7 +2743,7 @@
>Sat Feb 12 15:48:35 2022
editz_update:
>function editz_update(window, prose, cursor, original_prose)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> -- cursor movement
> if key == curses.KEY_LEFT then
@ -2789,7 +2789,7 @@
>Sat Feb 12 15:49:49 2022
editz_update:
>function editz_update(window, prose, cursor, original_prose)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> -- cursor movement
> if key == curses.KEY_LEFT then
@ -2839,7 +2839,7 @@
>Sat Feb 12 15:53:52 2022
editz_update:
>function editz_update(window, prose, cursor, original_prose)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> -- cursor movement
> if key == curses.KEY_LEFT then
@ -2896,7 +2896,7 @@
>editor: move to start of line, move/delete to end of line
editz_update:
>function editz_update(window, prose, cursor, original_prose)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> -- cursor movement
> if key == curses.KEY_LEFT then
@ -2949,7 +2949,7 @@
>Sat Feb 12 16:50:36 2022
editz_update:
>function editz_update(window, prose, cursor, original_prose)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> -- cursor movement
> if key == curses.KEY_LEFT then
@ -3013,7 +3013,7 @@
>Sat Feb 12 16:58:41 2022
editz_update:
>function editz_update(window, prose, cursor, original_prose)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> -- cursor movement
> if key == curses.KEY_LEFT then
@ -3086,7 +3086,7 @@
>Sat Feb 12 16:59:37 2022
editz_update:
>function editz_update(window, prose, cursor, original_prose)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> -- cursor movement
> if key == curses.KEY_LEFT then
@ -3156,7 +3156,7 @@
>Sat Feb 12 17:00:00 2022
editz_update:
>function editz_update(window, prose, cursor, original_prose)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> -- cursor movement
> if key == curses.KEY_LEFT then
@ -3228,7 +3228,7 @@
>editor: word-movement shortcuts
editz_update:
>function editz_update(window, prose, cursor, original_prose)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> -- cursor movement
> if key == curses.KEY_LEFT then
@ -3417,13 +3417,13 @@
> bg = 8 - bg -- toggle between color pairs 3 and 5
> x = x + view_settings.width + view_settings.hmargin
> end
> curses.refresh()
> window:refresh()
>end
- __teliva_timestamp:
>Sat Feb 12 17:17:45 2022
update:
>function update(window)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> local curr = zettels[current_zettel_id]
> assert(curr, string.format('cursor fell off the edge of the world: %s', type(current_zettel_id)))
@ -3566,7 +3566,7 @@
>scroll as needed when moving along the graph
update:
>function update(window)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> local curr = zettels[current_zettel_id]
> assert(curr, string.format('cursor fell off the edge of the world: %s', type(current_zettel_id)))
@ -3721,7 +3721,7 @@
>Sat Feb 12 17:21:48 2022
update:
>function update(window)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> local curr = zettels[current_zettel_id]
> assert(curr, string.format('cursor fell off the edge of the world: %s', type(current_zettel_id)))
@ -3882,7 +3882,7 @@
>Now we should be able to navigate either with j/k or h/l.
update:
>function update(window)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> local curr = zettels[current_zettel_id]
> assert(curr, string.format('cursor fell off the edge of the world: %s', type(current_zettel_id)))
@ -4074,7 +4074,7 @@
>Sat Feb 12 17:46:09 2022
update:
>function update(window)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> local curr = zettels[current_zettel_id]
> assert(curr, string.format('cursor fell off the edge of the world: %s', type(current_zettel_id)))
@ -4249,7 +4249,7 @@
>Sat Feb 12 17:47:08 2022
update:
>function update(window)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> local curr = zettels[current_zettel_id]
> assert(curr, string.format('cursor fell off the edge of the world: %s', type(current_zettel_id)))
@ -4424,7 +4424,7 @@
>Sat Feb 12 17:48:38 2022
update:
>function update(window)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> local curr = zettels[current_zettel_id]
> assert(curr, string.format('cursor fell off the edge of the world: %s', type(current_zettel_id)))
@ -4441,7 +4441,7 @@
> end
> if key ~= string.byte('e') then
> window:mvaddstr(30, 60, renderstate.history)
> curses.getch()
> window:getch()
> render_state.history:insert({first_zettel=view_settings.first_zettel, current_zettel_id=current_zettel_id})
> end
> -- move along the graph
@ -4601,7 +4601,7 @@
>Sat Feb 12 17:48:50 2022
update:
>function update(window)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> local curr = zettels[current_zettel_id]
> assert(curr, string.format('cursor fell off the edge of the world: %s', type(current_zettel_id)))
@ -4618,7 +4618,7 @@
> end
> if key ~= string.byte('e') then
> window:mvaddstr(30, 60, render_state.history)
> curses.getch()
> window:getch()
> render_state.history:insert({first_zettel=view_settings.first_zettel, current_zettel_id=current_zettel_id})
> end
> -- move along the graph
@ -4778,7 +4778,7 @@
>Sat Feb 12 17:49:04 2022
update:
>function update(window)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> local curr = zettels[current_zettel_id]
> assert(curr, string.format('cursor fell off the edge of the world: %s', type(current_zettel_id)))
@ -4796,7 +4796,7 @@
> if key ~= string.byte('e') then
> window:mvaddstr(30, 60, '')
> print(render_state.history)
> curses.getch()
> window:getch()
> render_state.history:insert({first_zettel=view_settings.first_zettel, current_zettel_id=current_zettel_id})
> end
> -- move along the graph
@ -4956,7 +4956,7 @@
>Sat Feb 12 17:49:34 2022
update:
>function update(window)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> local curr = zettels[current_zettel_id]
> assert(curr, string.format('cursor fell off the edge of the world: %s', type(current_zettel_id)))
@ -4974,7 +4974,7 @@
> if key ~= string.byte('e') then
> window:mvaddstr(30, 60, '')
> print(render_state.history)
> curses.getch()
> window:getch()
> local history = render_state.history
> history:insert({first_zettel=view_settings.first_zettel, current_zettel_id=current_zettel_id})
> end
@ -5135,7 +5135,7 @@
>Sat Feb 12 17:50:49 2022
update:
>function update(window)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> local curr = zettels[current_zettel_id]
> assert(curr, string.format('cursor fell off the edge of the world: %s', type(current_zettel_id)))
@ -5310,7 +5310,7 @@
>Sat Feb 12 17:52:42 2022
update:
>function update(window)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> local curr = zettels[current_zettel_id]
> assert(curr, string.format('cursor fell off the edge of the world: %s', type(current_zettel_id)))
@ -5320,9 +5320,9 @@
> -- does NOT undo mutations
> if #render_state.history > 0 then
> local previous_state = render_state.history[-1]
> curses.mvaddstr(30, 60, '')
> window:mvaddstr(30, 60, '')
> print(previous_state)
> curses.getch()
> window:getch()
> view_settings.first_zettel = previous_state.first_zettel
> current_zettel_id = render_state.history[-1].current_zettel_id
> table.remove(render_state.history)
@ -5489,7 +5489,7 @@
>Sat Feb 12 17:54:43 2022
update:
>function update(window)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> local curr = zettels[current_zettel_id]
> assert(curr, string.format('cursor fell off the edge of the world: %s', type(current_zettel_id)))
@ -5498,11 +5498,11 @@
> -- previous zettel moved to
> -- does NOT undo mutations
> if #render_state.history > 0 then
> curses.mvaddstr(30, 60, '')
> window:mvaddstr(30, 60, '')
> print(#render_state.history)
> local previous_state = render_state.history[-1]
> print(previous_state)
> curses.getch()
> window:getch()
> view_settings.first_zettel = previous_state.first_zettel
> current_zettel_id = render_state.history[-1].current_zettel_id
> table.remove(render_state.history)
@ -5669,7 +5669,7 @@
>Sat Feb 12 17:55:42 2022
update:
>function update(window)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> local curr = zettels[current_zettel_id]
> assert(curr, string.format('cursor fell off the edge of the world: %s', type(current_zettel_id)))
@ -5845,7 +5845,7 @@
>Sat Feb 12 17:56:13 2022
update:
>function update(window)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> local curr = zettels[current_zettel_id]
> assert(curr, string.format('cursor fell off the edge of the world: %s', type(current_zettel_id)))
@ -5855,7 +5855,7 @@
> -- does NOT undo mutations
> if #render_state.history > 0 then
> print(render_state.history[1])
> curses.getch()
> window:getch()
> local previous_state = render_state.history[#render_state.history]
> view_settings.first_zettel = previous_state.first_zettel
> current_zettel_id = render_state.history[-1].current_zettel_id
@ -6023,7 +6023,7 @@
>Sat Feb 12 17:56:25 2022
update:
>function update(window)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> local curr = zettels[current_zettel_id]
> assert(curr, string.format('cursor fell off the edge of the world: %s', type(current_zettel_id)))
@ -6032,9 +6032,9 @@
> -- previous zettel moved to
> -- does NOT undo mutations
> if #render_state.history > 0 then
> curses.mvaddstr(30, 60, '')
> window:mvaddstr(30, 60, '')
> print(render_state.history[1])
> curses.getch()
> window:getch()
> local previous_state = render_state.history[#render_state.history]
> view_settings.first_zettel = previous_state.first_zettel
> current_zettel_id = render_state.history[-1].current_zettel_id
@ -6202,7 +6202,7 @@
>Sat Feb 12 17:57:15 2022
update:
>function update(window)
> local key = curses.getch()
> local key = window:getch()
> local h, w = window:getmaxyx()
> local curr = zettels[current_zettel_id]
> assert(curr, string.format('cursor fell off the edge of the world: %s', type(current_zettel_id)))