about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-02-04 23:57:05 -0800
committerKartik K. Agaram <vc@akkartik.com>2022-02-04 23:57:05 -0800
commita5cb7381a882c5301796cc7f33b08adef2b0b70e (patch)
treed84a60e4b00e6c2e446ba7602a88c8ba6c6e84b8
parent5e4ca1d4704590efd74e0a3e82a454d334016b48 (diff)
downloadteliva-a5cb7381a882c5301796cc7f33b08adef2b0b70e.tar.gz
experimental app: zettelkasten
https://merveilles.town/@akkartik/107742821323590471

What we have so far:
  a representation (see 'zettels')
    parent/child
    next/prev sibling
    (todo: misc cross-links)
  ability to render zettels in multiple columns based on 'view_settings'
    all zettels render with same size
    alternate backgrounds between zettels for legibility
    skip rendering duplicates (if we ever hit cycles)
  a highlighted 'current zettel'
  ability to move current zettel
    by screen location (arrow keys)
    by network structure (h/j/k/l)

Still can't edit zettels or load/save from/to disk.
-rw-r--r--zet.tlv2963
1 files changed, 2963 insertions, 0 deletions
diff --git a/zet.tlv b/zet.tlv
new file mode 100644
index 0000000..762e9a6
--- /dev/null
+++ b/zet.tlv
@@ -0,0 +1,2963 @@
+# .tlv file generated by https://github.com/akkartik/teliva
+# You may edit it if you are careful; however, you may see cryptic errors if you
+# violate Teliva's assumptions.
+#
+# .tlv files are representations of Teliva programs. Teliva programs consist of
+# sequences of definitions. Each definition is a table of key/value pairs. Keys
+# and values are both strings.
+#
+# Lines in .tlv files always follow exactly one of the following forms:
+# - comment lines at the top of the file starting with '#' at column 0
+# - beginnings of definitions starting with '- ' at column 0, followed by a
+#   key/value pair
+# - key/value pairs consisting of '  ' at column 0, containing either a
+#   spaceless value on the same line, or a multi-line value
+# - multiline values indented by more than 2 spaces, starting with a '>'
+#
+# If these constraints are violated, Teliva may unceremoniously crash. Please
+# report bugs at http://akkartik.name/contact
+- __teliva_timestamp: original
+  str_helpers:
+    >-- some string helpers from http://lua-users.org/wiki/StringIndexing
+    >
+    >-- index characters using []
+    >getmetatable('').__index = function(str,i)
+    >  if type(i) == 'number' then
+    >    return string.sub(str,i,i)
+    >  else
+    >    return string[i]
+    >  end
+    >end
+    >
+    >-- ranges using (), selected bytes using {}
+    >getmetatable('').__call = function(str,i,j)
+    >  if type(i)~='table' then
+    >    return string.sub(str,i,j)
+    >  else
+    >    local t={}
+    >    for k,v in ipairs(i) do
+    >      t[k]=string.sub(str,v,v)
+    >    end
+    >    return table.concat(t)
+    >  end
+    >end
+    >
+    >-- iterate over an ordered sequence
+    >function q(x)
+    >  if type(x) == 'string' then
+    >    return x:gmatch('.')
+    >  else
+    >    return ipairs(x)
+    >  end
+    >end
+    >
+    >-- insert within string
+    >function string.insert(str1, str2, pos)
+    >  return str1:sub(1,pos)..str2..str1:sub(pos+1)
+    >end
+    >
+    >function string.remove(s, pos)
+    >  return s:sub(1,pos-1)..s:sub(pos+1)
+    >end
+    >
+    >-- TODO: backport utf-8 support from Lua 5.3
+- __teliva_timestamp: original
+  debugy:
+    >debugy = 5
+- __teliva_timestamp: original
+  dbg:
+    >-- helper for debug by print; overlay debug information towards the right
+    >-- reset debugy every time you refresh screen
+    >function dbg(window, s)
+    >  local oldy = 0
+    >  local oldx = 0
+    >  oldy, oldx = window:getyx()
+    >  window:mvaddstr(debugy, 60, s)
+    >  debugy = debugy+1
+    >  window:mvaddstr(oldy, oldx, '')
+    >end
+- __teliva_timestamp: original
+  check_eq:
+    >function check_eq(x, expected, msg)
+    >  if x == expected then
+    >    curses.addch('.')
+    >  else
+    >    print('F - '..msg)
+    >    print('  expected '..tostring(expected)..' but got '..x)
+    >    teliva_num_test_failures = teliva_num_test_failures + 1
+    >    -- overlay first test failure on editors
+    >    if teliva_first_failure == nil then
+    >      teliva_first_failure = msg
+    >    end
+    >  end
+    >end
+- __teliva_timestamp: original
+  map:
+    >-- only for arrays
+    >function map(l, f)
+    >  result = {}
+    >  for _, x in ipairs(l) do
+    >    table.insert(result, f(x))
+    >  end
+    >  return result
+    >end
+- __teliva_timestamp: original
+  reduce:
+    >-- only for arrays
+    >function reduce(l, f, init)
+    >  result = init
+    >  for _, x in ipairs(l) do
+    >    result = f(result, x)
+    >  end
+    >  return result
+    >end
+- __teliva_timestamp: original
+  filter:
+    >-- only for arrays
+    >function filter(l, f)
+    >  result = {}
+    >  for _, x in ipairs(l) do
+    >    if f(x) then
+    >      table.insert(result, x)
+    >    end
+    >  end
+    >  return result
+    >end
+- __teliva_timestamp: original
+  find_index:
+    >function find_index(arr, x)
+    >  for n, y in ipairs(arr) do
+    >    if x == y then
+    >      return n
+    >    end
+    >  end
+    >end
+- __teliva_timestamp: original
+  trim:
+    >function trim(s)
+    >  return s:gsub('^%s*', ''):gsub('%s*$', '')
+    >end
+- __teliva_timestamp: original
+  split:
+    >function split(s, d)
+    >  result = {}
+    >  for match in (s..d):gmatch("(.-)"..d) do
+    >    table.insert(result, match);
+    >  end
+    >  return result
+    >end
+- __teliva_timestamp: original
+  spaces:
+    >function spaces(n)
+    >  for i=1,n do
+    >    curses.addch(' ')
+    >  end
+    >end
+- __teliva_timestamp: original
+  window:
+    >window = curses.stdscr()
+- __teliva_timestamp: original
+  menu:
+    >-- To show app-specific hotkeys in the menu bar, add hotkey/command
+    >-- arrays of strings to the menu array.
+    >menu = {}
+- __teliva_timestamp: original
+  update:
+    >function update(window)
+    >  local key = curses.getch()
+    >  -- process key here
+    >end
+- __teliva_timestamp: original
+  init_colors:
+    >function init_colors()
+    >  -- light background
+    >  curses.init_pair(1, 236, 250)
+    >  curses.init_pair(2, 236, 252)
+    >  -- dark background
+    >--?   curses.init_pair(1, 252, 240)
+    >--?   curses.init_pair(2, 252, 242)
+    >end
+- __teliva_timestamp: original
+  main:
+    >function main()
+    >  init_colors()
+    >
+    >  while true do
+    >    render(window)
+    >    update(window)
+    >  end
+    >end
+- __teliva_timestamp: original
+  zettels:
+    >zettels = {
+    >  a={
+    >    data="abc\ndef",
+    >    next="b",
+    >  },
+    >  b={
+    >    data="ghi\njklm",
+    >    prev="a",
+    >  },
+    >}
+- __teliva_timestamp: original
+  view_settings:
+    >view_settings = {
+    >  width=50,
+    >  height=3,
+    >}
+- __teliva_timestamp: original
+  render_zettel:
+    >function render_zettel(window, i, indent, line)
+    >  window:attrset(curses.color_pair(i%2+1))
+    >  -- exactly 3 lines of text, haiku size
+    >  spaces(1)  -- todo: glyph
+    >  spaces(indent)
+    >  window:addstr(line.data)
+    >  spaces(view_settings.width-#line.data-indent-1)
+    >  print()
+    >  spaces(view_settings.width)
+    >  print()
+    >  spaces(view_settings.width)
+    >  print()
+    >  -- one line of whitespace below
+    >  spaces(view_settings.width)
+    >  print()
+    >end
+- render:
+    >function render(window)
+    >  window:clear()
+    >  local i = 0
+    >  for _, zettel in pairs(zettels) do
+    >    render_zettel(window, i, 0, zettel)
+    >    i = i+1
+    >  end
+    >  local lines, cols = window:getmaxyx()
+    >  window:mvaddstr(lines-2, 0, '')
+    >  for i=1,3 do
+    >    window:attrset(curses.color_pair(i%2+1))
+    >    window:addstr('')
+    >    spaces(view_settings.width-string.len(''))
+    >    window:attrset(curses.color_pair(0))
+    >    window:addstr(' ')  -- margin
+    >  end
+    >  window:mvaddstr(lines-1, 0, '?')
+    >  curses.refresh()
+    >end
+  __teliva_timestamp:
+    >Thu Feb  3 23:01:24 2022
+- render_zettel:
+    >function render_zettel(window, i, indent, line)
+    >  local y=1, x=1
+    >  window:attrset(curses.color_pair(i%2+1))
+    >  -- exactly 3 lines of text, haiku size
+    >  spaces(1)  -- todo: glyph
+    >  spaces(indent)
+    >  window:addstr(line.data)
+    >  spaces(view_settings.width-#line.data-indent-1)
+    >  print()
+    >  spaces(view_settings.width)
+    >  print()
+    >  spaces(view_settings.width)
+    >  print()
+    >  -- one line of whitespace below
+    >  spaces(view_settings.width)
+    >  print()
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 21:43:16 2022
+- render:
+    >function render(window)
+    >  window:clear()
+    >  local bg=false  -- we render zettels with two slightly different background colors
+    >                  -- call them true and false; doesn't matter what they are
+    >  for _, zettel in pairs(zettels) do
+    >    render_zettel(window, bg, 0, zettel)
+    >    bg = not bg
+    >  end
+    >  local lines, cols = window:getmaxyx()
+    >  window:mvaddstr(lines-2, 0, '')
+    >  for i=1,3 do
+    >    window:attrset(curses.color_pair(i%2+1))
+    >    window:addstr('')
+    >    spaces(view_settings.width-string.len(''))
+    >    window:attrset(curses.color_pair(0))
+    >    window:addstr(' ')  -- margin
+    >  end
+    >  window:mvaddstr(lines-1, 0, '?')
+    >  curses.refresh()
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 21:45:16 2022
+- render_zettel:
+    >function render_zettel(window, bg, indent, line)
+    >  local y=1, x=1
+    >  window:attrset(curses.color_pair(bg))
+    >  -- exactly 3 lines of text, haiku size
+    >  spaces(1)  -- todo: glyph
+    >  spaces(indent)
+    >  window:addstr(line.data)
+    >  spaces(view_settings.width-#line.data-indent-1)
+    >  print()
+    >  spaces(view_settings.width)
+    >  print()
+    >  spaces(view_settings.width)
+    >  print()
+    >  -- one line of whitespace below
+    >  spaces(view_settings.width)
+    >  print()
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 21:45:37 2022
+- render_zettel:
+    >function render_zettel(window, bg, indent, line)
+    >  local y=1
+    >  local x=1
+    >  window:attrset(curses.color_pair(bg))
+    >  -- exactly 3 lines of text, haiku size
+    >  spaces(1)  -- todo: glyph
+    >  spaces(indent)
+    >  window:addstr(line.data)
+    >  spaces(view_settings.width-#line.data-indent-1)
+    >  print()
+    >  spaces(view_settings.width)
+    >  print()
+    >  spaces(view_settings.width)
+    >  print()
+    >  -- one line of whitespace below
+    >  spaces(view_settings.width)
+    >  print()
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 21:45:49 2022
+- render_zettel:
+    >function render_zettel(window, bg, indent, line)
+    >  local y=1
+    >  local x=1
+    >  window:attrset(curses.color_pair(tonumber(bg)))
+    >  -- exactly 3 lines of text, haiku size
+    >  spaces(1)  -- todo: glyph
+    >  spaces(indent)
+    >  window:addstr(line.data)
+    >  spaces(view_settings.width-#line.data-indent-1)
+    >  print()
+    >  spaces(view_settings.width)
+    >  print()
+    >  spaces(view_settings.width)
+    >  print()
+    >  -- one line of whitespace below
+    >  spaces(view_settings.width)
+    >  print()
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 21:46:00 2022
+- render_zettel:
+    >function render_zettel(window, bg, indent, line)
+    >  local y=1
+    >  local x=1
+    >  window:attrset(curses.color_pair(bg and 1 or 0))
+    >  -- exactly 3 lines of text, haiku size
+    >  spaces(1)  -- todo: glyph
+    >  spaces(indent)
+    >  window:addstr(line.data)
+    >  spaces(view_settings.width-#line.data-indent-1)
+    >  print()
+    >  spaces(view_settings.width)
+    >  print()
+    >  spaces(view_settings.width)
+    >  print()
+    >  -- one line of whitespace below
+    >  spaces(view_settings.width)
+    >  print()
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 21:46:47 2022
+- render:
+    >function render(window)
+    >  window:clear()
+    >  local bg=false  -- we render zettels with two slightly different background colors
+    >                  -- call them true and false; doesn't matter what they are
+    >  local y=0, x=0
+    >  for _, zettel in pairs(zettels) do
+    >    render_zettel(window, bg, 0, zettel)
+    >    bg = not bg
+    >  end
+    >  local lines, cols = window:getmaxyx()
+    >  window:mvaddstr(lines-2, 0, '')
+    >  for i=1,3 do
+    >    window:attrset(curses.color_pair(i%2+1))
+    >    window:addstr('')
+    >    spaces(view_settings.width-string.len(''))
+    >    window:attrset(curses.color_pair(0))
+    >    window:addstr(' ')  -- margin
+    >  end
+    >  window:mvaddstr(lines-1, 0, '?')
+    >  curses.refresh()
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 21:47:39 2022
+- render:
+    >function render(window)
+    >  window:clear()
+    >  local lines, cols = window:getmaxyx()
+    >  local bg=false  -- we render zettels with two slightly different background colors
+    >                  -- call them true and false; doesn't matter what they are
+    >  local y=0, x=0
+    >  for _, zettel in pairs(zettels) do
+    >    render_zettel(window, bg, 0, y, x zettel)
+    >    bg = not bg
+    >    y = y+view_settings.height+1
+    >    if y > lines then
+    >      y = 0
+    >      x = x+view_settings.width+1
+    >      if x > cols then break end
+    >    end
+    >  end
+    >  window:mvaddstr(lines-2, 0, '')
+    >  for i=1,3 do
+    >    window:attrset(curses.color_pair(i%2+1))
+    >    window:addstr('')
+    >    spaces(view_settings.width-string.len(''))
+    >    window:attrset(curses.color_pair(0))
+    >    window:addstr(' ')  -- margin
+    >  end
+    >  window:mvaddstr(lines-1, 0, '?')
+    >  curses.refresh()
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 21:49:37 2022
+- render:
+    >function render(window)
+    >  window:clear()
+    >  local lines, cols = window:getmaxyx()
+    >  local bg=false  -- we render zettels with two slightly different background colors
+    >                  -- call them true and false; doesn't matter what they are
+    >  local y=0 x=0
+    >  for _, zettel in pairs(zettels) do
+    >    render_zettel(window, bg, 0, y, x zettel)
+    >    bg = not bg
+    >    y = y+view_settings.height+1
+    >    if y > lines then
+    >      y = 0
+    >      x = x+view_settings.width+1
+    >      if x > cols then break end
+    >    end
+    >  end
+    >  window:mvaddstr(lines-2, 0, '')
+    >  for i=1,3 do
+    >    window:attrset(curses.color_pair(i%2+1))
+    >    window:addstr('')
+    >    spaces(view_settings.width-string.len(''))
+    >    window:attrset(curses.color_pair(0))
+    >    window:addstr(' ')  -- margin
+    >  end
+    >  window:mvaddstr(lines-1, 0, '?')
+    >  curses.refresh()
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 21:49:46 2022
+- render:
+    >function render(window)
+    >  window:clear()
+    >  local lines, cols = window:getmaxyx()
+    >  local bg=false  -- we render zettels with two slightly different background colors
+    >                  -- call them true and false; doesn't matter what they are
+    >  local y, x = 0, 0
+    >  for _, zettel in pairs(zettels) do
+    >    render_zettel(window, bg, 0, y, x zettel)
+    >    bg = not bg
+    >    y = y+view_settings.height+1
+    >    if y > lines then
+    >      y = 0
+    >      x = x+view_settings.width+1
+    >      if x > cols then break end
+    >    end
+    >  end
+    >  window:mvaddstr(lines-2, 0, '')
+    >  for i=1,3 do
+    >    window:attrset(curses.color_pair(i%2+1))
+    >    window:addstr('')
+    >    spaces(view_settings.width-string.len(''))
+    >    window:attrset(curses.color_pair(0))
+    >    window:addstr(' ')  -- margin
+    >  end
+    >  window:mvaddstr(lines-1, 0, '?')
+    >  curses.refresh()
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 21:50:09 2022
+- render:
+    >function render(window)
+    >  window:clear()
+    >  local lines, cols = window:getmaxyx()
+    >  local bg=false  -- we render zettels with two slightly different background colors
+    >                  -- call them true and false; doesn't matter what they are
+    >  local y, x = 0, 0
+    >  for _, zettel in pairs(zettels) do
+    >    render_zettel(window, bg, 0, y, x, zettel)
+    >    bg = not bg
+    >    y = y+view_settings.height+1
+    >    if y > lines then
+    >      y = 0
+    >      x = x+view_settings.width+1
+    >      if x > cols then break end
+    >    end
+    >  end
+    >  window:mvaddstr(lines-2, 0, '')
+    >  for i=1,3 do
+    >    window:attrset(curses.color_pair(i%2+1))
+    >    window:addstr('')
+    >    spaces(view_settings.width-string.len(''))
+    >    window:attrset(curses.color_pair(0))
+    >    window:addstr(' ')  -- margin
+    >  end
+    >  window:mvaddstr(lines-1, 0, '?')
+    >  curses.refresh()
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 21:50:18 2022
+- render_zettel:
+    >function render_zettel(window, bg, indent, starty, startx, zettel)
+    >  local y=1
+    >  local x=1
+    >  window:attrset(curses.color_pair(bg and 1 or 0))
+    >  -- exactly 3 lines of text, haiku size
+    >  spaces(1)  -- todo: glyph
+    >  spaces(indent)
+    >  window:addstr(line.data)
+    >  spaces(view_settings.width-#zettel.data-indent-1)
+    >  print()
+    >  spaces(view_settings.width)
+    >  print()
+    >  spaces(view_settings.width)
+    >  print()
+    >  -- one line of whitespace below
+    >  spaces(view_settings.width)
+    >  print()
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 21:50:53 2022
+- render_zettel:
+    >function render_zettel(window, bg, indent, starty, startx, zettel)
+    >  local y=1
+    >  local x=1
+    >  window:attrset(curses.color_pair(bg and 1 or 0))
+    >  -- exactly 3 lines of text, haiku size
+    >  spaces(1)  -- todo: glyph
+    >  spaces(indent)
+    >  window:addstr(zettel.data)
+    >  spaces(view_settings.width-#zettel.data-indent-1)
+    >  print()
+    >  spaces(view_settings.width)
+    >  print()
+    >  spaces(view_settings.width)
+    >  print()
+    >  -- one line of whitespace below
+    >  spaces(view_settings.width)
+    >  print()
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 21:51:03 2022
+- render_zettel:
+    >function render_zettel(window, bg, indent, starty, startx, zettel)
+    >  window:attrset(curses.color_pair(bg and 1 or 0))
+    >  for y=0,view_settings.height-1 do
+    >    for x=0,view_settings.width-1 do
+    >      window:mvaddch(y+starty, x+startx, ' ')
+    >    end
+    >  end
+    >  local y, x = 0, 0 
+    >  for i=1,#zettel.data do
+    >    local c = zettel.data[i]
+    >    if c == '\n' then
+    >      y = y+1
+    >      x = 0
+    >    else
+    >      mvaddch(y+starty, x+startx, c)
+    >      x = x+1
+    >      if x >= startx + view_settings.width then
+    >        y = y+1
+    >      end
+    >    end
+    >    if y >= starty + view_settings.height then
+    >      break
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 21:56:47 2022
+- render_zettel:
+    >function render_zettel(window, bg, indent, starty, startx, zettel)
+    >  window:attrset(curses.color_pair(bg and 1 or 0))
+    >  for y=0,view_settings.height-1 do
+    >    for x=0,view_settings.width-1 do
+    >      window:mvaddch(y+starty, x+startx, ' ')
+    >    end
+    >  end
+    >  local y, x = 0, 0 
+    >  for i=1,#zettel.data do
+    >    local c = zettel.data[i]
+    >    if c == '\n' then
+    >      y = y+1
+    >      x = 0
+    >    else
+    >      window:mvaddch(y+starty, x+startx, c)
+    >      x = x+1
+    >      if x >= startx + view_settings.width then
+    >        y = y+1
+    >      end
+    >    end
+    >    if y >= starty + view_settings.height then
+    >      break
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 21:56:55 2022
+- render_zettel:
+    >function render_zettel(window, bg, indent, starty, startx, zettel)
+    >  window:attrset(curses.color_pair(bg))
+    >  for y=0,view_settings.height-1 do
+    >    for x=0,view_settings.width-1 do
+    >      window:mvaddch(y+starty, x+startx, ' ')
+    >    end
+    >  end
+    >  local y, x = 0, 0 
+    >  for i=1,#zettel.data do
+    >    local c = zettel.data[i]
+    >    if c == '\n' then
+    >      y = y+1
+    >      x = 0
+    >    else
+    >      window:mvaddch(y+starty, x+startx, c)
+    >      x = x+1
+    >      if x >= startx + view_settings.width then
+    >        y = y+1
+    >      end
+    >    end
+    >    if y >= starty + view_settings.height then
+    >      break
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 21:57:22 2022
+- render:
+    >function render(window)
+    >  window:clear()
+    >  local lines, cols = window:getmaxyx()
+    >  local bg=1
+    >  local y, x = 0, 0
+    >  for _, zettel in pairs(zettels) do
+    >    render_zettel(window, bg, 0, y, x, zettel)
+    >    bg = 3 - bg  -- toggle between color pairs 1 and 2
+    >    y = y+view_settings.height+1
+    >    if y > lines then
+    >      y = 0
+    >      x = x+view_settings.width+1
+    >      if x > cols then break end
+    >    end
+    >  end
+    >  window:mvaddstr(lines-2, 0, '')
+    >  for i=1,3 do
+    >    window:attrset(curses.color_pair(i%2+1))
+    >    window:addstr('')
+    >    spaces(view_settings.width-string.len(''))
+    >    window:attrset(curses.color_pair(0))
+    >    window:addstr(' ')  -- margin
+    >  end
+    >  window:mvaddstr(lines-1, 0, '?')
+    >  curses.refresh()
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 21:57:54 2022
+- render_zettel:
+    >function render_zettel(window, bg, indent, starty, startx, zettel)
+    >  window:attrset(curses.color_pair(bg))
+    >  for y=0,view_settings.height-1 do
+    >    for x=0,view_settings.width-1 do
+    >      window:mvaddch(y+starty, x+startx, ' ')
+    >    end
+    >  end
+    >  local y, x = 0, 1
+    >  for i=1,#zettel.data do
+    >    local c = zettel.data[i]
+    >    if c == '\n' then
+    >      y = y+1
+    >      x = 0
+    >    else
+    >      window:mvaddch(y+starty, x+startx, c)
+    >      x = x+1
+    >      if x >= startx + view_settings.width then
+    >        y = y+1
+    >      end
+    >    end
+    >    if y >= starty + view_settings.height then
+    >      break
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 21:58:15 2022
+- render_zettel:
+    >function render_zettel(window, bg, indent, starty, startx, zettel)
+    >  window:attrset(curses.color_pair(bg))
+    >  for y=0,view_settings.height-1 do
+    >    for x=0,view_settings.width-1 do
+    >      window:mvaddch(y+starty, x+startx, ' ')
+    >    end
+    >  end
+    >  local y, x = 0, 1
+    >  for i=1,#zettel.data do
+    >    local c = zettel.data[i]
+    >    if c == '\n' then
+    >      y = y+1
+    >      x = 1
+    >    else
+    >      window:mvaddch(y+starty, x+startx, c)
+    >      x = x+1
+    >      if x >= startx + view_settings.width then
+    >        y = y+1
+    >      end
+    >    end
+    >    if y >= starty + view_settings.height then
+    >      break
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 21:58:25 2022
+- zettels:
+    >zettels = {
+    >  root="a",
+    >  a={
+    >    data="abc\ndef",
+    >    next="b",
+    >  },
+    >  b={
+    >    data="ghi\njklm",
+    >    prev="a",
+    >  },
+    >}
+  __teliva_timestamp:
+    >Fri Feb  4 21:59:29 2022
+- render:
+    >function render(window)
+    >  window:clear()
+    >  local lines, cols = window:getmaxyx()
+    >  local bg=1
+    >  local y, x = 0, 0
+    >  -- render zettels depth-first
+    >  local done = {}
+    >  while true do
+    >    render_zettel(window, bg, 0, y, x, zettel)
+    >    bg = 3 - bg  -- toggle between color pairs 1 and 2
+    >    y = y+view_settings.height+1
+    >    if y > lines then
+    >      y = 0
+    >      x = x+view_settings.width+1
+    >      if x > cols then break end
+    >    end
+    >  end
+    >  window:mvaddstr(lines-2, 0, '')
+    >  for i=1,3 do
+    >    window:attrset(curses.color_pair(i%2+1))
+    >    window:addstr('')
+    >    spaces(view_settings.width-string.len(''))
+    >    window:attrset(curses.color_pair(0))
+    >    window:addstr(' ')  -- margin
+    >  end
+    >  window:mvaddstr(lines-1, 0, '?')
+    >  curses.refresh()
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 22:15:09 2022
+- render:
+    >function render(window)
+    >  window:clear()
+    >  local lines, cols = window:getmaxyx()
+    >  local bg=1
+    >  local y, x = 0, 0
+    >  -- render zettels depth-first
+    >  local done = {}
+    >  local inprogress = {zettels.root}
+    >  while #inprogress > 0 do
+    >    local zettel = zettels[table.remove(inprogress)]
+    >    render_zettel(window, bg, 0, y, x, zettel)
+    >    if zettel.next then table.insert(zettle.next) end
+    >    if zettel.
+    >    bg = 3 - bg  -- toggle between color pairs 1 and 2
+    >    y = y+view_settings.height+1
+    >    if y > lines then
+    >      y = 0
+    >      x = x+view_settings.width+1
+    >      if x > cols then break end
+    >    end
+    >  end
+    >  window:mvaddstr(lines-2, 0, '')
+    >  for i=1,3 do
+    >    window:attrset(curses.color_pair(i%2+1))
+    >    window:addstr('')
+    >    spaces(view_settings.width-string.len(''))
+    >    window:attrset(curses.color_pair(0))
+    >    window:addstr(' ')  -- margin
+    >  end
+    >  window:mvaddstr(lines-1, 0, '?')
+    >  curses.refresh()
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 22:19:37 2022
+- render:
+    >function render(window)
+    >  window:clear()
+    >  local lines, cols = window:getmaxyx()
+    >  local bg=1
+    >  local y, x = 0, 0
+    >  -- render zettels depth-first
+    >  local done = {}
+    >  local inprogress = {zettels.root}
+    >  while #inprogress > 0 do
+    >    local zettel = zettels[table.remove(inprogress)]
+    >    render_zettel(window, bg, 0, y, x, zettel)
+    >    if zettel.next then table.insert(zettle.next) end
+    >    if zettel.child then table.insert(zettel.child) end
+    >    bg = 3 - bg  -- toggle between color pairs 1 and 2
+    >    y = y+view_settings.height+1
+    >    if y > lines then
+    >      y = 0
+    >      x = x+view_settings.width+1
+    >      if x > cols then break end
+    >    end
+    >  end
+    >  window:mvaddstr(lines-2, 0, '')
+    >  for i=1,3 do
+    >    window:attrset(curses.color_pair(i%2+1))
+    >    window:addstr('')
+    >    spaces(view_settings.width-string.len(''))
+    >    window:attrset(curses.color_pair(0))
+    >    window:addstr(' ')  -- margin
+    >  end
+    >  window:mvaddstr(lines-1, 0, '?')
+    >  curses.refresh()
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 22:20:59 2022
+- render:
+    >function render(window)
+    >  window:clear()
+    >  local lines, cols = window:getmaxyx()
+    >  local bg=1
+    >  local y, x = 0, 0
+    >  -- render zettels depth-first
+    >  local done = {}
+    >  local inprogress = {zettels.root}
+    >  while #inprogress > 0 do
+    >    local zettel = zettels[table.remove(inprogress)]
+    >    render_zettel(window, bg, 0, y, x, zettel)
+    >    if zettel.next then table.insert(zettel.next) end
+    >    if zettel.child then table.insert(zettel.child) end
+    >    bg = 3 - bg  -- toggle between color pairs 1 and 2
+    >    y = y+view_settings.height+1
+    >    if y > lines then
+    >      y = 0
+    >      x = x+view_settings.width+1
+    >      if x > cols then break end
+    >    end
+    >  end
+    >  window:mvaddstr(lines-2, 0, '')
+    >  for i=1,3 do
+    >    window:attrset(curses.color_pair(i%2+1))
+    >    window:addstr('')
+    >    spaces(view_settings.width-string.len(''))
+    >    window:attrset(curses.color_pair(0))
+    >    window:addstr(' ')  -- margin
+    >  end
+    >  window:mvaddstr(lines-1, 0, '?')
+    >  curses.refresh()
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 22:21:09 2022
+- render:
+    >function render(window)
+    >  window:clear()
+    >  local lines, cols = window:getmaxyx()
+    >  local bg=1
+    >  local y, x = 0, 0
+    >  -- render zettels depth-first
+    >  local done = {}
+    >  local inprogress = {zettels.root}
+    >  while #inprogress > 0 do
+    >    local zettel = zettels[table.remove(inprogress)]
+    >    render_zettel(window, bg, 0, y, x, zettel)
+    >    if zettel.next then table.insert(inprogress, zettel.next) end
+    >    if zettel.child then table.insert(inprogress, zettel.child) end
+    >    bg = 3 - bg  -- toggle between color pairs 1 and 2
+    >    y = y+view_settings.height+1
+    >    if y > lines then
+    >      y = 0
+    >      x = x+view_settings.width+1
+    >      if x > cols then break end
+    >    end
+    >  end
+    >  window:mvaddstr(lines-2, 0, '')
+    >  for i=1,3 do
+    >    window:attrset(curses.color_pair(i%2+1))
+    >    window:addstr('')
+    >    spaces(view_settings.width-string.len(''))
+    >    window:attrset(curses.color_pair(0))
+    >    window:addstr(' ')  -- margin
+    >  end
+    >  window:mvaddstr(lines-1, 0, '?')
+    >  curses.refresh()
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 22:21:30 2022
+- zettels:
+    >zettels = {
+    >  root="a",
+    >  a={
+    >    data="abc\ndef",
+    >    next="b",
+    >  },
+    >  b={
+    >    data="ghi\njklm",
+    >    prev="a",
+    >    next="a",
+    >  },
+    >}
+  __teliva_timestamp:
+    >Fri Feb  4 22:22:04 2022
+- render:
+    >function render(window)
+    >  window:clear()
+    >  local lines, cols = window:getmaxyx()
+    >  local bg=1
+    >  local y, x = 0, 0
+    >  -- render zettels depth-first
+    >  local done = {}
+    >  local inprogress = {zettels.root}
+    >  while #inprogress > 0 do
+    >    local currid = table.remove(inprogress)
+    >    if not done[currid] then
+    >      done[currid] = true
+    >      local zettel = zettels[currid]
+    >      render_zettel(window, bg, 0, y, x, zettel)
+    >      if zettel.next then table.insert(inprogress, zettel.next) end
+    >      if zettel.child then table.insert(inprogress, zettel.child) end
+    >      bg = 3 - bg  -- toggle between color pairs 1 and 2
+    >      y = y+view_settings.height+1
+    >      if y > lines then
+    >        y = 0
+    >        x = x+view_settings.width+1
+    >        if x > cols then break end
+    >      end
+    >    end
+    >  end
+    >  window:mvaddstr(lines-2, 0, '')
+    >  for i=1,3 do
+    >    window:attrset(curses.color_pair(i%2+1))
+    >    window:addstr('')
+    >    spaces(view_settings.width-string.len(''))
+    >    window:attrset(curses.color_pair(0))
+    >    window:addstr(' ')  -- margin
+    >  end
+    >  window:mvaddstr(lines-1, 0, '?')
+    >  curses.refresh()
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 22:23:54 2022
+- zettels:
+    >zettels = {
+    >  root="a",
+    >  a={
+    >    data="abc\ndef",
+    >    child="c",
+    >    next="b",
+    >  },
+    >  b={
+    >    data="ghi\njklm",
+    >    prev="a",
+    >    next="a",
+    >  },
+    >  c={
+    >    data="c",
+    >    parent="a",
+    >    next="d",
+    >  },
+    >  d={
+    >    data="d",
+    >    parent="a",
+    >    prev="c",
+    >  }
+    >}
+  __teliva_timestamp:
+    >Fri Feb  4 22:25:10 2022
+- render:
+    >function render(window)
+    >  window:clear()
+    >  local lines, cols = window:getmaxyx()
+    >  local bg=1
+    >  local y, x = 0, 0
+    >  -- render zettels depth-first
+    >  local done = {}
+    >  local inprogress = {zettels.root}
+    >  while #inprogress > 0 do
+    >    local currid = table.remove(inprogress)
+    >    if not done[currid] then
+    >      done[currid] = true
+    >      local zettel = zettels[currid]
+    >      render_zettel(window, bg, depth(zettel), y, x, zettel)
+    >      if zettel.next then table.insert(inprogress, zettel.next) end
+    >      if zettel.child then table.insert(inprogress, zettel.child) end
+    >      bg = 3 - bg  -- toggle between color pairs 1 and 2
+    >      y = y+view_settings.height+1
+    >      if y > lines then
+    >        y = 0
+    >        x = x+view_settings.width+1
+    >        if x > cols then break end
+    >      end
+    >    end
+    >  end
+    >  window:mvaddstr(lines-2, 0, '')
+    >  for i=1,3 do
+    >    window:attrset(curses.color_pair(i%2+1))
+    >    window:addstr('')
+    >    spaces(view_settings.width-string.len(''))
+    >    window:attrset(curses.color_pair(0))
+    >    window:addstr(' ')  -- margin
+    >  end
+    >  window:mvaddstr(lines-1, 0, '?')
+    >  curses.refresh()
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 22:26:01 2022
+- __teliva_timestamp:
+    >Fri Feb  4 22:26:41 2022
+  depth:
+    >function depth(zettel)
+    >  local result = 0
+    >  while zettel.parent do
+    >    result = result+1
+    >    zettel = zettel.parent
+    >  end
+    >end
+- render_zettel:
+    >function render_zettel(window, bg, indent, starty, startx, zettel)
+    >  window:attrset(curses.color_pair(bg))
+    >  for y=0,view_settings.height-1 do
+    >    for x=0,view_settings.width-1 do
+    >      window:mvaddch(y+starty, x+startx, ' ')
+    >    end
+    >  end
+    >  local y, x = 0, indent+1
+    >  for i=1,#zettel.data do
+    >    local c = zettel.data[i]
+    >    if c == '\n' then
+    >      y = y+1
+    >      x = indent+1
+    >    else
+    >      window:mvaddch(y+starty, x+startx, c)
+    >      x = x+1
+    >      if x >= startx + view_settings.width then
+    >        y = y+1
+    >      end
+    >    end
+    >    if y >= starty + view_settings.height then
+    >      break
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 22:27:10 2022
+- __teliva_timestamp:
+    >Fri Feb  4 22:27:28 2022
+  depth:
+    >function depth(zettel)
+    >  local result = 0
+    >  while zettel.parent do
+    >    result = result+1
+    >    zettel = zettel.parent
+    >  end
+    >  return result
+    >end
+- render_zettel:
+    >function render_zettel(window, bg, indent, starty, startx, zettel)
+    >  window:attrset(curses.color_pair(bg))
+    >  for y=0,view_settings.height-1 do
+    >    window:mvaddch(y+starty, x, ' ')
+    >    for x=1,indent do
+    >      window:mvaddch(y+starty, x+startx, '.')
+    >    for x=indent+1,view_settings.width-1 do
+    >      window:mvaddch(y+starty, x+startx, ' ')
+    >    end
+    >  end
+    >  local y, x = 0, indent+1
+    >  for i=1,#zettel.data do
+    >    local c = zettel.data[i]
+    >    if c == '\n' then
+    >      y = y+1
+    >      x = indent+1
+    >    else
+    >      window:mvaddch(y+starty, x+startx, c)
+    >      x = x+1
+    >      if x >= startx + view_settings.width then
+    >        y = y+1
+    >      end
+    >    end
+    >    if y >= starty + view_settings.height then
+    >      break
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 22:30:25 2022
+- render_zettel:
+    >function render_zettel(window, bg, indent, starty, startx, zettel)
+    >  window:attrset(curses.color_pair(bg))
+    >  for y=0,view_settings.height-1 do
+    >    window:mvaddch(y+starty, x, ' ')
+    >    for x=1,indent do
+    >      window:mvaddch(y+starty, x+startx, '.')
+    >    end
+    >    for x=indent+1,view_settings.width-1 do
+    >      window:mvaddch(y+starty, x+startx, ' ')
+    >    end
+    >  end
+    >  local y, x = 0, indent+1
+    >  for i=1,#zettel.data do
+    >    local c = zettel.data[i]
+    >    if c == '\n' then
+    >      y = y+1
+    >      x = indent+1
+    >    else
+    >      window:mvaddch(y+starty, x+startx, c)
+    >      x = x+1
+    >      if x >= startx + view_settings.width then
+    >        y = y+1
+    >      end
+    >    end
+    >    if y >= starty + view_settings.height then
+    >      break
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 22:30:29 2022
+- render_zettel:
+    >function render_zettel(window, bg, indent, starty, startx, zettel)
+    >  window:attrset(curses.color_pair(bg))
+    >  for y=0,view_settings.height-1 do
+    >    window:mvaddch(y+starty, startx, ' ')
+    >    for x=1,indent do
+    >      window:mvaddch(y+starty, x+startx, '.')
+    >    end
+    >    for x=indent+1,view_settings.width-1 do
+    >      window:mvaddch(y+starty, x+startx, ' ')
+    >    end
+    >  end
+    >  local y, x = 0, indent+1
+    >  for i=1,#zettel.data do
+    >    local c = zettel.data[i]
+    >    if c == '\n' then
+    >      y = y+1
+    >      x = indent+1
+    >    else
+    >      window:mvaddch(y+starty, x+startx, c)
+    >      x = x+1
+    >      if x >= startx + view_settings.width then
+    >        y = y+1
+    >      end
+    >    end
+    >    if y >= starty + view_settings.height then
+    >      break
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 22:30:53 2022
+- render_zettel:
+    >function render_zettel(window, bg, indent, starty, startx, zettel)
+    >  window:attrset(curses.color_pair(bg))
+    >  for y=0,view_settings.height-1 do
+    >    window:mvaddch(y+starty, startx, ' ')
+    >    for x=1,indent do
+    >      window:mvaddch(y+starty, x+startx, '.')
+    >    end
+    >    for x=0,view_settings.width-1 do
+    >      if y == 0 and x == indent then
+    >        window:mvaddch(y+starty, x+startx, '↳')
+    >      window:mvaddch(y+starty, x+startx, ' ')
+    >    end
+    >  end
+    >  local y, x = 0, indent+1
+    >  for i=1,#zettel.data do
+    >    local c = zettel.data[i]
+    >    if c == '\n' then
+    >      y = y+1
+    >      x = indent+1
+    >    else
+    >      window:mvaddch(y+starty, x+startx, c)
+    >      x = x+1
+    >      if x >= startx + view_settings.width then
+    >        y = y+1
+    >      end
+    >    end
+    >    if y >= starty + view_settings.height then
+    >      break
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 22:33:56 2022
+- render_zettel:
+    >function render_zettel(window, bg, indent, starty, startx, zettel)
+    >  window:attrset(curses.color_pair(bg))
+    >  for y=0,view_settings.height-1 do
+    >    for x=0,view_settings.width-1 do
+    >      if y == 0 and x == indent then
+    >        window:mvaddch(y+starty, x+startx, '↳')
+    >      else
+    >        window:mvaddch(y+starty, x+startx, ' ')
+    >      end
+    >    end
+    >  end
+    >  local y, x = 0, indent+1
+    >  for i=1,#zettel.data do
+    >    local c = zettel.data[i]
+    >    if c == '\n' then
+    >      y = y+1
+    >      x = indent+1
+    >    else
+    >      window:mvaddch(y+starty, x+startx, c)
+    >      x = x+1
+    >      if x >= startx + view_settings.width then
+    >        y = y+1
+    >      end
+    >    end
+    >    if y >= starty + view_settings.height then
+    >      break
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 22:34:14 2022
+- render_zettel:
+    >function render_zettel(window, bg, indent, starty, startx, zettel)
+    >  window:attrset(curses.color_pair(bg))
+    >  for y=0,view_settings.height-1 do
+    >    for x=0,view_settings.width-1 do
+    >      if y == 0 then
+    >        window:mvaddch(y+starty, x+startx, '.')
+    >      else
+    >        window:mvaddch(y+starty, x+startx, ' ')
+    >      end
+    >    end
+    >  end
+    >  local y, x = 0, indent+1
+    >  for i=1,#zettel.data do
+    >    local c = zettel.data[i]
+    >    if c == '\n' then
+    >      y = y+1
+    >      x = indent+1
+    >    else
+    >      window:mvaddch(y+starty, x+startx, c)
+    >      x = x+1
+    >      if x >= startx + view_settings.width then
+    >        y = y+1
+    >      end
+    >    end
+    >    if y >= starty + view_settings.height then
+    >      break
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 22:34:42 2022
+- render_zettel:
+    >function render_zettel(window, bg, indent, starty, startx, zettel)
+    >  window:attrset(curses.color_pair(bg))
+    >  for y=0,view_settings.height-1 do
+    >    for x=0,view_settings.width-1 do
+    >      if y == 0 and x <= indent then
+    >        window:mvaddch(y+starty, x+startx, '.')
+    >      else
+    >        window:mvaddch(y+starty, x+startx, ' ')
+    >      end
+    >    end
+    >  end
+    >  local y, x = 0, indent+1
+    >  for i=1,#zettel.data do
+    >    local c = zettel.data[i]
+    >    if c == '\n' then
+    >      y = y+1
+    >      x = indent+1
+    >    else
+    >      window:mvaddch(y+starty, x+startx, c)
+    >      x = x+1
+    >      if x >= startx + view_settings.width then
+    >        y = y+1
+    >      end
+    >    end
+    >    if y >= starty + view_settings.height then
+    >      break
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 22:35:00 2022
+- render_zettel:
+    >function render_zettel(window, bg, indent, starty, startx, zettel)
+    >  window:attrset(curses.color_pair(bg))
+    >  for y=0,view_settings.height-1 do
+    >    for x=0,view_settings.width-1 do
+    >      window:mvaddch(y+starty, x+startx, ' ')
+    >    end
+    >  end
+    >  local y, x = 0, indent+1
+    >  for i=1,#zettel.data do
+    >    local c = zettel.data[i]
+    >    if c == '\n' then
+    >      y = y+1
+    >      x = indent+1
+    >    else
+    >      window:mvaddch(y+starty, x+startx, c)
+    >      x = x+1
+    >      if x >= startx + view_settings.width then
+    >        y = y+1
+    >      end
+    >    end
+    >    if y >= starty + view_settings.height then
+    >      break
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 22:36:11 2022
+- view_settings:
+    >view_settings = {
+    >  width=50,
+    >  height=3,
+    >  hmargin=1,
+    >  vmargin=1,
+    >}
+  __teliva_timestamp:
+    >Fri Feb  4 22:37:14 2022
+- render:
+    >function render(window)
+    >  window:clear()
+    >  local lines, cols = window:getmaxyx()
+    >  local bg=1
+    >  local y, x = 0, 0
+    >  -- render zettels depth-first
+    >  local done = {}
+    >  local inprogress = {zettels.root}
+    >  while #inprogress > 0 do
+    >    local currid = table.remove(inprogress)
+    >    if not done[currid] then
+    >      done[currid] = true
+    >      local zettel = zettels[currid]
+    >      render_zettel(window, bg, depth(zettel), y, x, zettel)
+    >      if zettel.next then table.insert(inprogress, zettel.next) end
+    >      if zettel.child then table.insert(inprogress, zettel.child) end
+    >      bg = 3 - bg  -- toggle between color pairs 1 and 2
+    >      y = y + view_settings.height + view_settings.vmargin
+    >      if y > lines then
+    >        y = 0
+    >        x = x + view_settings.width + view_settings.hmargin
+    >        if x > cols then break end
+    >      end
+    >    end
+    >  end
+    >  window:mvaddstr(lines-2, 0, '')
+    >  for i=1,3 do
+    >    window:attrset(curses.color_pair(i%2+1))
+    >    window:addstr('')
+    >    spaces(view_settings.width-string.len(''))
+    >    window:attrset(curses.color_pair(0))
+    >    window:addstr(' ')  -- margin
+    >  end
+    >  window:mvaddstr(lines-1, 0, '?')
+    >  curses.refresh()
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 22:37:57 2022
+- view_settings:
+    >view_settings = {
+    >  width=50,
+    >  height=3,
+    >  hmargin=1,
+    >  vmargin=1,
+    >  indent=2,
+    >}
+  __teliva_timestamp:
+    >Fri Feb  4 22:38:11 2022
+- render_zettel:
+    >function render_zettel(window, bg, indent, starty, startx, zettel)
+    >  window:attrset(curses.color_pair(bg))
+    >  for y=0,view_settings.height-1 do
+    >    for x=0,view_settings.width-1 do
+    >      window:mvaddch(y+starty, x+startx, ' ')
+    >    end
+    >  end
+    >  local y, x = 0, indent+1
+    >  for i=1,#zettel.data do
+    >    local c = zettel.data[i]
+    >    if c == '\n' then
+    >      y = y+1
+    >      x = 1 + indent * view_settings.indent
+    >    else
+    >      window:mvaddch(y+starty, x+startx, c)
+    >      x = x+1
+    >      if x >= startx + view_settings.width then
+    >        y = y+1
+    >        x = 1 + indent * view_settings.indent
+    >      end
+    >    end
+    >    if y >= starty + view_settings.height then
+    >      break
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 22:39:18 2022
+- view_settings:
+    >view_settings = {
+    >  width=50,
+    >  height=3,
+    >  hmargin=1,
+    >  vmargin=1,
+    >  indent=8,
+    >}
+  __teliva_timestamp:
+    >Fri Feb  4 22:39:35 2022
+- render_zettel:
+    >function render_zettel(window, bg, indent, starty, startx, zettel)
+    >  window:attrset(curses.color_pair(bg))
+    >  for y=0,view_settings.height-1 do
+    >    for x=0,view_settings.width-1 do
+    >      window:mvaddch(y+starty, x+startx, ' ')
+    >    end
+    >  end
+    >  local y, x = 0, indent+1
+    >  for i=1,#zettel.data do
+    >    local c = zettel.data[i]
+    >    if c == '\n' then
+    >      y = y+1
+    >      x = indent+1
+    >    else
+    >      window:mvaddch(y+starty, x+startx, c)
+    >      x = x+1
+    >      if x >= startx + view_settings.width then
+    >        y = y+1
+    >        x = indent+1
+    >      end
+    >    end
+    >    if y >= starty + view_settings.height then
+    >      break
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 22:40:44 2022
+- render:
+    >function render(window)
+    >  window:clear()
+    >  local lines, cols = window:getmaxyx()
+    >  local bg=1
+    >  local y, x = 0, 0
+    >  -- render zettels depth-first
+    >  local done = {}
+    >  local inprogress = {zettels.root}
+    >  while #inprogress > 0 do
+    >    local currid = table.remove(inprogress)
+    >    if not done[currid] then
+    >      done[currid] = true
+    >      local zettel = zettels[currid]
+    >      render_zettel(window, bg, depth(zettel) * view_settings.indent, y, x, zettel)
+    >      if zettel.next then table.insert(inprogress, zettel.next) end
+    >      if zettel.child then table.insert(inprogress, zettel.child) end
+    >      bg = 3 - bg  -- toggle between color pairs 1 and 2
+    >      y = y + view_settings.height + view_settings.vmargin
+    >      if y > lines then
+    >        y = 0
+    >        x = x + view_settings.width + view_settings.hmargin
+    >        if x > cols then break end
+    >      end
+    >    end
+    >  end
+    >  window:mvaddstr(lines-2, 0, '')
+    >  for i=1,3 do
+    >    window:attrset(curses.color_pair(i%2+1))
+    >    window:addstr('')
+    >    spaces(view_settings.width-string.len(''))
+    >    window:attrset(curses.color_pair(0))
+    >    window:addstr(' ')  -- margin
+    >  end
+    >  window:mvaddstr(lines-1, 0, '? ')
+    >  curses.refresh()
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 22:41:06 2022
+  __teliva_note:
+    >configurable indent for child zettels
+- view_settings:
+    >view_settings = {
+    >  width=50,
+    >  height=3,
+    >  hmargin=1,
+    >  vmargin=1,
+    >  indent=2,
+    >}
+  __teliva_timestamp:
+    >Fri Feb  4 22:41:17 2022
+- render:
+    >function render(window)
+    >  window:clear()
+    >  local lines, cols = window:getmaxyx()
+    >  local bg=1
+    >  local y, x = 0, 0
+    >  -- render zettels depth-first
+    >  local done = {}
+    >  local inprogress = {zettels.root}
+    >  while #inprogress > 0 do
+    >    local currid = table.remove(inprogress)
+    >    if not done[currid] then
+    >      done[currid] = true
+    >      local zettel = zettels[currid]
+    >      local currbg = (currid == cursor) and view_settings.current_zettel_color or bg
+    >      render_zettel(window, currbg, depth(zettel) * view_settings.indent, y, x, zettel)
+    >      if zettel.next then table.insert(inprogress, zettel.next) end
+    >      if zettel.child then table.insert(inprogress, zettel.child) end
+    >      bg = 3 - bg  -- toggle between color pairs 1 and 2
+    >      y = y + view_settings.height + view_settings.vmargin
+    >      if y > lines then
+    >        y = 0
+    >        x = x + view_settings.width + view_settings.hmargin
+    >        if x > cols then break end
+    >      end
+    >    end
+    >  end
+    >  window:mvaddstr(lines-2, 0, '')
+    >  for i=1,3 do
+    >    window:attrset(curses.color_pair(i%2+1))
+    >    window:addstr('')
+    >    spaces(view_settings.width-string.len(''))
+    >    window:attrset(curses.color_pair(0))
+    >    window:addstr(' ')  -- margin
+    >  end
+    >  window:mvaddstr(lines-1, 0, '? ')
+    >  curses.refresh()
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 22:52:51 2022
+- view_settings:
+    >view_settings = {
+    >  width=50,
+    >  height=3,
+    >  hmargin=1,
+    >  vmargin=1,
+    >  indent=2,
+    >  cursor
+    >}
+  __teliva_timestamp:
+    >Fri Feb  4 22:53:04 2022
+- view_settings:
+    >view_settings = {
+    >  width=50,
+    >  height=3,
+    >  hmargin=1,
+    >  vmargin=1,
+    >  indent=2,
+    >  current_zettel_color=3
+    >}
+  __teliva_timestamp:
+    >Fri Feb  4 22:53:46 2022
+- __teliva_timestamp:
+    >Fri Feb  4 22:55:08 2022
+  init_colors:
+    >function init_colors()
+    >  -- light background
+    >  curses.init_pair(view_settings.current_zettel_bg, 236, 226)
+    >  curses.init_pair(1, 236, 250)
+    >  curses.init_pair(2, 236, 252)
+    >  -- dark background
+    >--?   curses.init_pair(view_settings.current_zettel_bg, 252, 172)
+    >--?   curses.init_pair(1, 252, 240)
+    >--?   curses.init_pair(2, 252, 242)
+    >end
+- view_settings:
+    >view_settings = {
+    >  width=50,
+    >  height=3,
+    >  hmargin=1,
+    >  vmargin=1,
+    >  indent=2,
+    >  current_zettel_bg=3,  -- color pair index
+    >}
+  __teliva_timestamp:
+    >Fri Feb  4 22:55:34 2022
+- render:
+    >function render(window)
+    >  window:clear()
+    >  local lines, cols = window:getmaxyx()
+    >  local bg=1
+    >  local y, x = 0, 0
+    >  -- render zettels depth-first
+    >  local done = {}
+    >  local inprogress = {zettels.root}
+    >  while #inprogress > 0 do
+    >    local currid = table.remove(inprogress)
+    >    if not done[currid] then
+    >      done[currid] = true
+    >      local zettel = zettels[currid]
+    >      local currbg = (currid == cursor) and view_settings.current_zettel_bg or bg
+    >      render_zettel(window, currbg, depth(zettel) * view_settings.indent, y, x, zettel)
+    >      if zettel.next then table.insert(inprogress, zettel.next) end
+    >      if zettel.child then table.insert(inprogress, zettel.child) end
+    >      bg = 3 - bg  -- toggle between color pairs 1 and 2
+    >      y = y + view_settings.height + view_settings.vmargin
+    >      if y > lines then
+    >        y = 0
+    >        x = x + view_settings.width + view_settings.hmargin
+    >        if x > cols then break end
+    >      end
+    >    end
+    >  end
+    >  window:mvaddstr(lines-2, 0, '')
+    >  for i=1,3 do
+    >    window:attrset(curses.color_pair(i%2+1))
+    >    window:addstr('')
+    >    spaces(view_settings.width-string.len(''))
+    >    window:attrset(curses.color_pair(0))
+    >    window:addstr(' ')  -- margin
+    >  end
+    >  window:mvaddstr(lines-1, 0, '? ')
+    >  curses.refresh()
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 22:55:42 2022
+- render:
+    >function render(window)
+    >  window:clear()
+    >  local lines, cols = window:getmaxyx()
+    >  local bg=1
+    >  local y, x = 0, 0
+    >  -- render zettels depth-first
+    >  local done = {}
+    >  local inprogress = {zettels.root}
+    >  while #inprogress > 0 do
+    >    local currid = table.remove(inprogress)
+    >    if not done[currid] then
+    >      done[currid] = true
+    >      local zettel = zettels[currid]
+    >      local currbg = (currid == current_zettel_id) and view_settings.current_zettel_bg or bg
+    >      render_zettel(window, currbg, depth(zettel) * view_settings.indent, y, x, zettel)
+    >      if zettel.next then table.insert(inprogress, zettel.next) end
+    >      if zettel.child then table.insert(inprogress, zettel.child) end
+    >      bg = 3 - bg  -- toggle between color pairs 1 and 2
+    >      y = y + view_settings.height + view_settings.vmargin
+    >      if y > lines then
+    >        y = 0
+    >        x = x + view_settings.width + view_settings.hmargin
+    >        if x > cols then break end
+    >      end
+    >    end
+    >  end
+    >  window:mvaddstr(lines-2, 0, '')
+    >  for i=1,3 do
+    >    window:attrset(curses.color_pair(i%2+1))
+    >    window:addstr('')
+    >    spaces(view_settings.width-string.len(''))
+    >    window:attrset(curses.color_pair(0))
+    >    window:addstr(' ')  -- margin
+    >  end
+    >  window:mvaddstr(lines-1, 0, '? ')
+    >  curses.refresh()
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 22:56:14 2022
+- current_zettel_id:
+    >current_zettel_id = ''
+  __teliva_timestamp:
+    >Fri Feb  4 22:56:28 2022
+- main:
+    >function main()
+    >  init_colors()
+    >  current_zettel_id = zettels.root
+    >
+    >  while true do
+    >    render(window)
+    >    update(window)
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 22:56:54 2022
+- __teliva_timestamp:
+    >Fri Feb  4 22:58:52 2022
+  init_colors:
+    >function init_colors()
+    >  -- light background
+    >  curses.init_pair(view_settings.current_zettel_bg, 236, 230)
+    >  curses.init_pair(1, 236, 250)
+    >  curses.init_pair(2, 236, 252)
+    >  -- dark background
+    >--?   curses.init_pair(view_settings.current_zettel_bg, 252, 130)
+    >--?   curses.init_pair(1, 252, 240)
+    >--?   curses.init_pair(2, 252, 242)
+    >end
+- view_settings:
+    >view_settings = {
+    >  -- dimensions for rendering a single zettel; extra text gets truncated
+    >  width=50,
+    >  height=3,
+    >  -- spacing between zettels
+    >  hmargin=1,
+    >  vmargin=1,
+    >  --
+    >  indent=2,  -- how children of a zettel are indicated
+    >  current_zettel_bg=3,  -- color pair index initialized in init_colors
+    >}
+  __teliva_timestamp:
+    >Fri Feb  4 23:02:58 2022
+  __teliva_note:
+    >notion of current zettel
+- update:
+    >function update(window)
+    >  local key = curses.getch()
+    >  local curr = zettels[current_zettel_id]
+    >  if key == 'j' then
+    >    if curr.child then current_zettel_id = curr.child end
+    >  elseif key == 'k' then
+    >    if curr.parent then current_zettel_id = curr.parent end
+    >  elseif key == 'h' then
+    >    if curr.prev then
+    >      current_zettel_id = curr.prev
+    >    elseif curr.parent then
+    >      current_zettel_id = curr.parent
+    >    end
+    >  elseif key == 'l' then
+    >    if curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and curr.parent.next then
+    >      current_zettel_id = curr.parent.next
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 23:10:29 2022
+- update:
+    >function update(window)
+    >  local key = curses.getch()
+    >  local curr = zettels[current_zettel_id]
+    >  if key == 'j' then
+    >    a = b+1
+    >    if curr.child then current_zettel_id = curr.child end
+    >  elseif key == 'k' then
+    >    if curr.parent then current_zettel_id = curr.parent end
+    >  elseif key == 'h' then
+    >    if curr.prev then
+    >      current_zettel_id = curr.prev
+    >    elseif curr.parent then
+    >      current_zettel_id = curr.parent
+    >    end
+    >  elseif key == 'l' then
+    >    if curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and curr.parent.next then
+    >      current_zettel_id = curr.parent.next
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 23:11:43 2022
+- update:
+    >function update(window)
+    >  local key = curses.getch()
+    >  local curr = zettels[current_zettel_id]
+    >  if key == string.byte('j') then
+    >    if curr.child then current_zettel_id = curr.child end
+    >  elseif key == 'k' then
+    >    if curr.parent then current_zettel_id = curr.parent end
+    >  elseif key == 'h' then
+    >    if curr.prev then
+    >      current_zettel_id = curr.prev
+    >    elseif curr.parent then
+    >      current_zettel_id = curr.parent
+    >    end
+    >  elseif key == 'l' then
+    >    if curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and curr.parent.next then
+    >      current_zettel_id = curr.parent.next
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 23:11:57 2022
+- update:
+    >function update(window)
+    >  local key = curses.getch()
+    >  local curr = zettels[current_zettel_id]
+    >  if key == string.byte('j') then
+    >    if curr.child then current_zettel_id = curr.child end
+    >    elseif curr.next then current_zettel_id = curr.next end
+    >  elseif key == 'k' then
+    >    if curr.parent then current_zettel_id = curr.parent end
+    >  elseif key == 'h' then
+    >    if curr.prev then
+    >      current_zettel_id = curr.prev
+    >    elseif curr.parent then
+    >      current_zettel_id = curr.parent
+    >    end
+    >  elseif key == 'l' then
+    >    if curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and curr.parent.next then
+    >      current_zettel_id = curr.parent.next
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 23:12:36 2022
+- update:
+    >function update(window)
+    >  local key = curses.getch()
+    >  local curr = zettels[current_zettel_id]
+    >  if key == string.byte('j') then
+    >    if curr.child then
+    >      current_zettel_id = curr.child
+    >    elseif curr.next then
+    >      current_zettel_id = curr.next
+    >    end
+    >  elseif key == 'k' then
+    >    if curr.parent then current_zettel_id = curr.parent end
+    >  elseif key == 'h' then
+    >    if curr.prev then
+    >      current_zettel_id = curr.prev
+    >    elseif curr.parent then
+    >      current_zettel_id = curr.parent
+    >    end
+    >  elseif key == 'l' then
+    >    if curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and curr.parent.next then
+    >      current_zettel_id = curr.parent.next
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 23:13:02 2022
+- update:
+    >function update(window)
+    >  local key = curses.getch()
+    >  local curr = zettels[current_zettel_id]
+    >  if key == string.byte('j') then
+    >    if curr.child then
+    >      current_zettel_id = curr.child
+    >    elseif curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and curr.parent.next then
+    >      current_zettel_id = curr.parent.next
+    >    end
+    >  elseif key == 'k' then
+    >    if curr.parent then current_zettel_id = curr.parent end
+    >  elseif key == 'h' then
+    >    if curr.prev then
+    >      current_zettel_id = curr.prev
+    >    elseif curr.parent then
+    >      current_zettel_id = curr.parent
+    >    end
+    >  elseif key == 'l' then
+    >    if curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and curr.parent.next then
+    >      current_zettel_id = curr.parent.next
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 23:13:30 2022
+- update:
+    >function update(window)
+    >  local key = curses.getch()
+    >  local curr = zettels[current_zettel_id]
+    >  if key == string.byte('j') then
+    >    if curr.child then
+    >      current_zettel_id = curr.child
+    >    elseif curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and curr.parent.next then
+    >      a = b+1
+    >      current_zettel_id = curr.parent.next
+    >    end
+    >  elseif key == 'k' then
+    >    if curr.parent then current_zettel_id = curr.parent end
+    >  elseif key == 'h' then
+    >    if curr.prev then
+    >      current_zettel_id = curr.prev
+    >    elseif curr.parent then
+    >      current_zettel_id = curr.parent
+    >    end
+    >  elseif key == 'l' then
+    >    if curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and curr.parent.next then
+    >      current_zettel_id = curr.parent.next
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 23:14:14 2022
+- update:
+    >function update(window)
+    >  local key = curses.getch()
+    >  local curr = zettels[current_zettel_id]
+    >  if key == string.byte('j') then
+    >    if curr.child then
+    >      current_zettel_id = curr.child
+    >    elseif curr.next then
+    >      a = b+1
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and curr.parent.next then
+    >      current_zettel_id = curr.parent.next
+    >    end
+    >  elseif key == 'k' then
+    >    if curr.parent then current_zettel_id = curr.parent end
+    >  elseif key == 'h' then
+    >    if curr.prev then
+    >      current_zettel_id = curr.prev
+    >    elseif curr.parent then
+    >      current_zettel_id = curr.parent
+    >    end
+    >  elseif key == 'l' then
+    >    if curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and curr.parent.next then
+    >      current_zettel_id = curr.parent.next
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 23:14:23 2022
+- update:
+    >function update(window)
+    >  local key = curses.getch()
+    >  local curr = zettels[current_zettel_id]
+    >  if key == string.byte('j') then
+    >    if curr.parent then
+    >      mvaddstr(30, 30, 'parent')
+    >      curses.getch()
+    >    end
+    >    if curr.child then
+    >      current_zettel_id = curr.child
+    >    elseif curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and curr.parent.next then
+    >      current_zettel_id = curr.parent.next
+    >    end
+    >  elseif key == 'k' then
+    >    if curr.parent then current_zettel_id = curr.parent end
+    >  elseif key == 'h' then
+    >    if curr.prev then
+    >      current_zettel_id = curr.prev
+    >    elseif curr.parent then
+    >      current_zettel_id = curr.parent
+    >    end
+    >  elseif key == 'l' then
+    >    if curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and curr.parent.next then
+    >      current_zettel_id = curr.parent.next
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 23:15:25 2022
+- update:
+    >function update(window)
+    >  local key = curses.getch()
+    >  local curr = zettels[current_zettel_id]
+    >  if key == string.byte('j') then
+    >    if curr.parent then
+    >      window:mvaddstr(30, 30, 'parent')
+    >      curses.getch()
+    >    end
+    >    if curr.child then
+    >      current_zettel_id = curr.child
+    >    elseif curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and curr.parent.next then
+    >      current_zettel_id = curr.parent.next
+    >    end
+    >  elseif key == 'k' then
+    >    if curr.parent then current_zettel_id = curr.parent end
+    >  elseif key == 'h' then
+    >    if curr.prev then
+    >      current_zettel_id = curr.prev
+    >    elseif curr.parent then
+    >      current_zettel_id = curr.parent
+    >    end
+    >  elseif key == 'l' then
+    >    if curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and curr.parent.next then
+    >      current_zettel_id = curr.parent.next
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 23:15:35 2022
+- update:
+    >function update(window)
+    >  local key = curses.getch()
+    >  local curr = zettels[current_zettel_id]
+    >  if key == string.byte('j') then
+    >    if curr.parent and curr.parent.next then
+    >      window:mvaddstr(30, 30, 'parent.next')
+    >      curses.getch()
+    >    end
+    >    if curr.child then
+    >      current_zettel_id = curr.child
+    >    elseif curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and curr.parent.next then
+    >      current_zettel_id = curr.parent.next
+    >    end
+    >  elseif key == 'k' then
+    >    if curr.parent then current_zettel_id = curr.parent end
+    >  elseif key == 'h' then
+    >    if curr.prev then
+    >      current_zettel_id = curr.prev
+    >    elseif curr.parent then
+    >      current_zettel_id = curr.parent
+    >    end
+    >  elseif key == 'l' then
+    >    if curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and curr.parent.next then
+    >      current_zettel_id = curr.parent.next
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 23:16:05 2022
+- update:
+    >function update(window)
+    >  local key = curses.getch()
+    >  local curr = zettels[current_zettel_id]
+    >  if key == string.byte('j') then
+    >    if curr.parent and curr.parent.next then
+    >      window:mvaddstr(30, 30, curr.parent)
+    >      curses.getch()
+    >    end
+    >    if curr.child then
+    >      current_zettel_id = curr.child
+    >    elseif curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and curr.parent.next then
+    >      current_zettel_id = curr.parent.next
+    >    end
+    >  elseif key == 'k' then
+    >    if curr.parent then current_zettel_id = curr.parent end
+    >  elseif key == 'h' then
+    >    if curr.prev then
+    >      current_zettel_id = curr.prev
+    >    elseif curr.parent then
+    >      current_zettel_id = curr.parent
+    >    end
+    >  elseif key == 'l' then
+    >    if curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and curr.parent.next then
+    >      current_zettel_id = curr.parent.next
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 23:16:28 2022
+- update:
+    >function update(window)
+    >  local key = curses.getch()
+    >  local curr = zettels[current_zettel_id]
+    >  if key == string.byte('j') then
+    >    if curr.parent then
+    >      window:mvaddstr(30, 30, curr.parent)
+    >      curses.getch()
+    >    end
+    >    if curr.child then
+    >      current_zettel_id = curr.child
+    >    elseif curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and curr.parent.next then
+    >      current_zettel_id = curr.parent.next
+    >    end
+    >  elseif key == 'k' then
+    >    if curr.parent then current_zettel_id = curr.parent end
+    >  elseif key == 'h' then
+    >    if curr.prev then
+    >      current_zettel_id = curr.prev
+    >    elseif curr.parent then
+    >      current_zettel_id = curr.parent
+    >    end
+    >  elseif key == 'l' then
+    >    if curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and curr.parent.next then
+    >      current_zettel_id = curr.parent.next
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 23:16:38 2022
+- update:
+    >function update(window)
+    >  local key = curses.getch()
+    >  local curr = zettels[current_zettel_id]
+    >  if key == string.byte('j') then
+    >    if curr.next then
+    >      window:mvaddstr(30, 30, curr.next)
+    >      curses.getch()
+    >    end
+    >    if curr.child then
+    >      current_zettel_id = curr.child
+    >    elseif curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and curr.parent.next then
+    >      current_zettel_id = curr.parent.next
+    >    end
+    >  elseif key == 'k' then
+    >    if curr.parent then current_zettel_id = curr.parent end
+    >  elseif key == 'h' then
+    >    if curr.prev then
+    >      current_zettel_id = curr.prev
+    >    elseif curr.parent then
+    >      current_zettel_id = curr.parent
+    >    end
+    >  elseif key == 'l' then
+    >    if curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and curr.parent.next then
+    >      current_zettel_id = curr.parent.next
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 23:16:55 2022
+- update:
+    >function update(window)
+    >  local key = curses.getch()
+    >  local curr = zettels[current_zettel_id]
+    >  if key == string.byte('j') then
+    >    if curr.child then
+    >      current_zettel_id = curr.child
+    >    elseif curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and zettels[curr.parent].next then
+    >      current_zettel_id = zettels[curr.parent].next
+    >    end
+    >  elseif key == 'k' then
+    >    if curr.parent then current_zettel_id = curr.parent end
+    >  elseif key == 'h' then
+    >    if curr.prev then
+    >      current_zettel_id = curr.prev
+    >    elseif curr.parent then
+    >      current_zettel_id = curr.parent
+    >    end
+    >  elseif key == 'l' then
+    >    if curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and zettels[curr.parent].next then
+    >      current_zettel_id = zettels[curr.parent].next
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 23:17:49 2022
+- update:
+    >function update(window)
+    >  local key = curses.getch()
+    >  local curr = zettels[current_zettel_id]
+    >  if key == string.byte('j') then
+    >    if curr.child then
+    >      current_zettel_id = curr.child
+    >    elseif curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and zettels[curr.parent].next then
+    >      current_zettel_id = zettels[curr.parent].next
+    >    end
+    >  elseif key == string.byte('k') then
+    >    if curr.parent then current_zettel_id = curr.parent end
+    >  elseif key == string.byte('h') then
+    >    if curr.prev then
+    >      current_zettel_id = curr.prev
+    >    elseif curr.parent then
+    >      current_zettel_id = curr.parent
+    >    end
+    >  elseif key == string.byte('l') then
+    >    if curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and zettels[curr.parent].next then
+    >      current_zettel_id = zettels[curr.parent].next
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 23:18:20 2022
+  __teliva_note:
+    >navigating between zettels
+- zettels:
+    >zettels = {
+    >  root="a",
+    >  a={
+    >    data="abc\ndef",
+    >    child="c",
+    >    next="b",
+    >  },
+    >  b={
+    >    data="ghi\njklm",
+    >    prev="a",
+    >  },
+    >  c={
+    >    data="c",
+    >    parent="a",
+    >    next="d",
+    >  },
+    >  d={
+    >    data="d",
+    >    parent="a",
+    >    prev="c",
+    >  }
+    >}
+  __teliva_timestamp:
+    >Fri Feb  4 23:21:16 2022
+- render:
+    >function render(window)
+    >  window:clear()
+    >  local lines, cols = window:getmaxyx()
+    >  local bg=1
+    >  local y, x = 0, 0
+    >  -- render zettels depth-first, while tracking relative positions
+    >  local done = {}
+    >  local inprogress = {zettels.root}
+    >  while #inprogress > 0 do
+    >    local currid = table.remove(inprogress)
+    >    if not done[currid] then
+    >      done[currid] = true
+    >      local zettel = zettels[currid]
+    >      local currbg = (currid == current_zettel_id) and view_settings.current_zettel_bg or bg
+    >      render_zettel(window, currbg, depth(zettel) * view_settings.indent, y, x, zettel)
+    >      if zettel.next then table.insert(inprogress, zettel.next) end
+    >      if zettel.child then table.insert(inprogress, zettel.child) end
+    >      bg = 3 - bg  -- toggle between color pairs 1 and 2
+    >      y = y + view_settings.height + view_settings.vmargin
+    >      if y > lines then
+    >        y = 0
+    >        x = x + view_settings.width + view_settings.hmargin
+    >        if x > cols then break end
+    >      end
+    >    end
+    >  end
+    >  window:mvaddstr(lines-2, 0, '')
+    >  for i=1,3 do
+    >    window:attrset(curses.color_pair(i%2+1))
+    >    window:addstr('')
+    >    spaces(view_settings.width-string.len(''))
+    >    window:attrset(curses.color_pair(0))
+    >    window:addstr(' ')  -- margin
+    >  end
+    >  window:mvaddstr(lines-1, 0, '? ')
+    >  curses.refresh()
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 23:28:22 2022
+- __teliva_timestamp:
+    >Fri Feb  4 23:32:33 2022
+  render_state:
+    >-- some information about what's been drawn on screen
+    >render_state = {
+    >  -- where the current zettel is, in units of zettels
+    >  curr_h = 1,
+    >  curr_w = 1,
+    >  -- what zettel is at each position on screen, in units of zettels
+    >  hw2id = {},
+    >}
+- render:
+    >function render(window)
+    >  window:clear()
+    >  local lines, cols = window:getmaxyx()
+    >  local bg=1
+    >  local y, x = 0, 0 -- units of characters (0-based)
+    >  local w, h = 1, 1 -- units of zettels (1-based)
+    >  -- render zettels depth-first, while tracking relative positions
+    >  local done = {}
+    >  local inprogress = {zettels.root}
+    >  render_state.wh2id = {{}}
+    >  while #inprogress > 0 do
+    >    local currid = table.remove(inprogress)
+    >    if not done[currid] then
+    >      done[currid] = true
+    >      table.insert(render_state.wh2id[w], currid)
+    >      local zettel = zettels[currid]
+    >      if currid == current_zettel_id then
+    >        render_state.curr_w = w
+    >        render_state.curr_h = h
+    >      end
+    >      local currbg = (currid == current_zettel_id) and view_settings.current_zettel_bg or bg
+    >      render_zettel(window, currbg, depth(zettel) * view_settings.indent, y, x, zettel)
+    >      if zettel.next then table.insert(inprogress, zettel.next) end
+    >      if zettel.child then table.insert(inprogress, zettel.child) end
+    >      bg = 3 - bg  -- toggle between color pairs 1 and 2
+    >      y = y + view_settings.height + view_settings.vmargin
+    >      h = h + 1
+    >      if y > lines then
+    >        y = 0
+    >        h = 1
+    >        x = x + view_settings.width + view_settings.hmargin
+    >        w = w + 1
+    >        table.insert(render_state.wh2id, {})
+    >        if x > cols then break end
+    >      end
+    >    end
+    >  end
+    >  window:mvaddstr(lines-2, 0, '')
+    >  for i=1,3 do
+    >    window:attrset(curses.color_pair(i%2+1))
+    >    window:addstr('')
+    >    spaces(view_settings.width-string.len(''))
+    >    window:attrset(curses.color_pair(0))
+    >    window:addstr(' ')  -- margin
+    >  end
+    >  window:mvaddstr(lines-1, 0, '? ')
+    >  curses.refresh()
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 23:37:44 2022
+- update:
+    >function update(window)
+    >  local key = curses.getch()
+    >  local curr = zettels[current_zettel_id]
+    >  -- graph-based navigation
+    >  if key == string.byte('j') then
+    >    if curr.child then
+    >      current_zettel_id = curr.child
+    >    elseif curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and zettels[curr.parent].next then
+    >      current_zettel_id = zettels[curr.parent].next
+    >    end
+    >  elseif key == string.byte('k') then
+    >    if curr.parent then current_zettel_id = curr.parent end
+    >  elseif key == string.byte('h') then
+    >    if curr.prev then
+    >      current_zettel_id = curr.prev
+    >    elseif curr.parent then
+    >      current_zettel_id = curr.parent
+    >    end
+    >  elseif key == string.byte('l') then
+    >    if curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and zettels[curr.parent].next then
+    >      current_zettel_id = zettels[curr.parent].next
+    >    end
+    >  -- screen-based navigation
+    >  elseif key == curses.KEY_UP then
+    >    if curr_h > 0 then
+    >      
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 23:40:31 2022
+- update:
+    >function update(window)
+    >  local key = curses.getch()
+    >  local curr = zettels[current_zettel_id]
+    >  -- graph-based navigation
+    >  if key == string.byte('j') then
+    >    if curr.child then
+    >      current_zettel_id = curr.child
+    >    elseif curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and zettels[curr.parent].next then
+    >      current_zettel_id = zettels[curr.parent].next
+    >    end
+    >  elseif key == string.byte('k') then
+    >    if curr.parent then current_zettel_id = curr.parent end
+    >  elseif key == string.byte('h') then
+    >    if curr.prev then
+    >      current_zettel_id = curr.prev
+    >    elseif curr.parent then
+    >      current_zettel_id = curr.parent
+    >    end
+    >  elseif key == string.byte('l') then
+    >    if curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and zettels[curr.parent].next then
+    >      current_zettel_id = zettels[curr.parent].next
+    >    end
+    >  -- screen-based navigation
+    >  elseif key == curses.KEY_UP then
+    >    if render_state.curr_h > 0 then
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 23:41:11 2022
+- update:
+    >function update(window)
+    >  local key = curses.getch()
+    >  local curr = zettels[current_zettel_id]
+    >  -- graph-based navigation
+    >  if key == string.byte('j') then
+    >    if curr.child then
+    >      current_zettel_id = curr.child
+    >    elseif curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and zettels[curr.parent].next then
+    >      current_zettel_id = zettels[curr.parent].next
+    >    end
+    >  elseif key == string.byte('k') then
+    >    if curr.parent then current_zettel_id = curr.parent end
+    >  elseif key == string.byte('h') then
+    >    if curr.prev then
+    >      current_zettel_id = curr.prev
+    >    elseif curr.parent then
+    >      current_zettel_id = curr.parent
+    >    end
+    >  elseif key == string.byte('l') then
+    >    if curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and zettels[curr.parent].next then
+    >      current_zettel_id = zettels[curr.parent].next
+    >    end
+    >  -- screen-based navigation
+    >  elseif key == curses.KEY_UP then
+    >    if render_state.curr_h > 0 then
+    >      current_zettel_id = render_state.rw2id[render_state.curr_w][render_state.curr_h - 1]
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 23:42:28 2022
+- update:
+    >function update(window)
+    >  local key = curses.getch()
+    >  local curr = zettels[current_zettel_id]
+    >  -- graph-based navigation
+    >  if key == string.byte('j') then
+    >    if curr.child then
+    >      current_zettel_id = curr.child
+    >    elseif curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and zettels[curr.parent].next then
+    >      current_zettel_id = zettels[curr.parent].next
+    >    end
+    >  elseif key == string.byte('k') then
+    >    if curr.parent then current_zettel_id = curr.parent end
+    >  elseif key == string.byte('h') then
+    >    if curr.prev then
+    >      current_zettel_id = curr.prev
+    >    elseif curr.parent then
+    >      current_zettel_id = curr.parent
+    >    end
+    >  elseif key == string.byte('l') then
+    >    if curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and zettels[curr.parent].next then
+    >      current_zettel_id = zettels[curr.parent].next
+    >    end
+    >  -- screen-based navigation
+    >  elseif key == curses.KEY_UP then
+    >    if render_state.curr_h > 0 then
+    >      current_zettel_id = render_state.hw2id[render_state.curr_w][render_state.curr_h - 1]
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 23:42:52 2022
+- update:
+    >function update(window)
+    >  local key = curses.getch()
+    >  local curr = zettels[current_zettel_id]
+    >  -- graph-based navigation
+    >  if key == string.byte('j') then
+    >    if curr.child then
+    >      current_zettel_id = curr.child
+    >    elseif curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and zettels[curr.parent].next then
+    >      current_zettel_id = zettels[curr.parent].next
+    >    end
+    >  elseif key == string.byte('k') then
+    >    if curr.parent then current_zettel_id = curr.parent end
+    >  elseif key == string.byte('h') then
+    >    if curr.prev then
+    >      current_zettel_id = curr.prev
+    >    elseif curr.parent then
+    >      current_zettel_id = curr.parent
+    >    end
+    >  elseif key == string.byte('l') then
+    >    if curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and zettels[curr.parent].next then
+    >      current_zettel_id = zettels[curr.parent].next
+    >    end
+    >  -- screen-based navigation
+    >  elseif key == curses.KEY_UP then
+    >    if render_state.curr_h > 0 then
+    >      print(#render_state.hw2id)
+    >      window:getch()
+    >      current_zettel_id = render_state.hw2id[render_state.curr_w][render_state.curr_h - 1]
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 23:43:51 2022
+- update:
+    >function update(window)
+    >  local key = curses.getch()
+    >  local curr = zettels[current_zettel_id]
+    >  -- graph-based navigation
+    >  if key == string.byte('j') then
+    >    if curr.child then
+    >      current_zettel_id = curr.child
+    >    elseif curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and zettels[curr.parent].next then
+    >      current_zettel_id = zettels[curr.parent].next
+    >    end
+    >  elseif key == string.byte('k') then
+    >    if curr.parent then current_zettel_id = curr.parent end
+    >  elseif key == string.byte('h') then
+    >    if curr.prev then
+    >      current_zettel_id = curr.prev
+    >    elseif curr.parent then
+    >      current_zettel_id = curr.parent
+    >    end
+    >  elseif key == string.byte('l') then
+    >    if curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and zettels[curr.parent].next then
+    >      current_zettel_id = zettels[curr.parent].next
+    >    end
+    >  -- screen-based navigation
+    >  elseif key == curses.KEY_UP then
+    >    if render_state.curr_h > 0 then
+    >      print(#render_state.wh2id)
+    >      window:getch()
+    >      current_zettel_id = render_state.wh2id[render_state.curr_w][render_state.curr_h - 1]
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 23:44:25 2022
+- update:
+    >function update(window)
+    >  local key = curses.getch()
+    >  local curr = zettels[current_zettel_id]
+    >  -- graph-based navigation
+    >  if key == string.byte('j') then
+    >    if curr.child then
+    >      current_zettel_id = curr.child
+    >    elseif curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and zettels[curr.parent].next then
+    >      current_zettel_id = zettels[curr.parent].next
+    >    end
+    >  elseif key == string.byte('k') then
+    >    if curr.parent then current_zettel_id = curr.parent end
+    >  elseif key == string.byte('h') then
+    >    if curr.prev then
+    >      current_zettel_id = curr.prev
+    >    elseif curr.parent then
+    >      current_zettel_id = curr.parent
+    >    end
+    >  elseif key == string.byte('l') then
+    >    if curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and zettels[curr.parent].next then
+    >      current_zettel_id = zettels[curr.parent].next
+    >    end
+    >  -- screen-based navigation
+    >  elseif key == curses.KEY_UP then
+    >    if render_state.curr_h > 0 then
+    >      current_zettel_id = render_state.wh2id[render_state.curr_w][render_state.curr_h - 1]
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 23:44:44 2022
+- update:
+    >function update(window)
+    >  local key = curses.getch()
+    >  local curr = zettels[current_zettel_id]
+    >  -- graph-based navigation
+    >  if key == string.byte('j') then
+    >    if curr.child then
+    >      current_zettel_id = curr.child
+    >    elseif curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and zettels[curr.parent].next then
+    >      current_zettel_id = zettels[curr.parent].next
+    >    end
+    >  elseif key == string.byte('k') then
+    >    if curr.parent then current_zettel_id = curr.parent end
+    >  elseif key == string.byte('h') then
+    >    if curr.prev then
+    >      current_zettel_id = curr.prev
+    >    elseif curr.parent then
+    >      current_zettel_id = curr.parent
+    >    end
+    >  elseif key == string.byte('l') then
+    >    if curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and zettels[curr.parent].next then
+    >      current_zettel_id = zettels[curr.parent].next
+    >    end
+    >  -- screen-based navigation
+    >  elseif key == curses.KEY_UP then
+    >    if render_state.curr_h > 0 then
+    >      current_zettel_id = render_state.wh2id[render_state.curr_w][render_state.curr_h - 1]
+    >    end
+    >  elseif key == curses.KEY_DOWN then
+    >    if render_state.wh2id[render_state.curr_w][render_state.curr_h + 1] then
+    >      current_zettel_id = render_state.wh2id[render_state.curr_w][render_state.curr_h + 1]
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 23:45:54 2022
+- update:
+    >function update(window)
+    >  local key = curses.getch()
+    >  local curr = zettels[current_zettel_id]
+    >  -- graph-based navigation
+    >  if key == string.byte('j') then
+    >    if curr.child then
+    >      current_zettel_id = curr.child
+    >    elseif curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and zettels[curr.parent].next then
+    >      current_zettel_id = zettels[curr.parent].next
+    >    end
+    >  elseif key == string.byte('k') then
+    >    if curr.parent then current_zettel_id = curr.parent end
+    >  elseif key == string.byte('h') then
+    >    if curr.prev then
+    >      current_zettel_id = curr.prev
+    >    elseif curr.parent then
+    >      current_zettel_id = curr.parent
+    >    end
+    >  elseif key == string.byte('l') then
+    >    if curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and zettels[curr.parent].next then
+    >      current_zettel_id = zettels[curr.parent].next
+    >    end
+    >  -- screen-based navigation
+    >  elseif key == curses.KEY_UP then
+    >    if render_state.curr_h > 0 then
+    >      current_zettel_id = render_state.wh2id[render_state.curr_w][render_state.curr_h - 1]
+    >    end
+    >  elseif key == curses.KEY_DOWN then
+    >    if render_state.wh2id[render_state.curr_w][render_state.curr_h + 1] then
+    >      current_zettel_id = render_state.wh2id[render_state.curr_w][render_state.curr_h + 1]
+    >    end
+    >  elseif key == curses.KEY_LEFT then
+    >    if render_state.curr_w > 0 then
+    >      current_zettel_id = render_state.wh2id[render_state.curr_w - 1][render_state.curr_h]
+    >    end
+    >  elseif key == curses.KEY_RIGHT then
+    >    if render_state.wh2id[render_state.curr_w + 1][render_state.curr_h] then
+    >      current_zettel_id = render_state.wh2id[render_state.curr_w + 1][render_state.curr_h]
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 23:47:48 2022
+- update:
+    >function update(window)
+    >  local key = curses.getch()
+    >  local curr = zettels[current_zettel_id]
+    >  -- graph-based navigation
+    >  if key == string.byte('j') then
+    >    if curr.child then
+    >      current_zettel_id = curr.child
+    >    elseif curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and zettels[curr.parent].next then
+    >      current_zettel_id = zettels[curr.parent].next
+    >    end
+    >  elseif key == string.byte('k') then
+    >    if curr.parent then current_zettel_id = curr.parent end
+    >  elseif key == string.byte('h') then
+    >    if curr.prev then
+    >      current_zettel_id = curr.prev
+    >    elseif curr.parent then
+    >      current_zettel_id = curr.parent
+    >    end
+    >  elseif key == string.byte('l') then
+    >    if curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and zettels[curr.parent].next then
+    >      current_zettel_id = zettels[curr.parent].next
+    >    end
+    >  -- screen-based navigation
+    >  elseif key == curses.KEY_UP then
+    >    if render_state.curr_h > 1 then
+    >      current_zettel_id = render_state.wh2id[render_state.curr_w][render_state.curr_h - 1]
+    >    end
+    >  elseif key == curses.KEY_DOWN then
+    >    if render_state.wh2id[render_state.curr_w][render_state.curr_h + 1] then
+    >      current_zettel_id = render_state.wh2id[render_state.curr_w][render_state.curr_h + 1]
+    >    end
+    >  elseif key == curses.KEY_LEFT then
+    >    if render_state.curr_w > 1 then
+    >      current_zettel_id = render_state.wh2id[render_state.curr_w - 1][render_state.curr_h]
+    >    end
+    >  elseif key == curses.KEY_RIGHT then
+    >    if render_state.wh2id[render_state.curr_w + 1][render_state.curr_h] then
+    >      current_zettel_id = render_state.wh2id[render_state.curr_w + 1][render_state.curr_h]
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 23:48:34 2022
+- update:
+    >function update(window)
+    >  local key = curses.getch()
+    >  local curr = zettels[current_zettel_id]
+    >  -- graph-based navigation
+    >  if key == string.byte('j') then
+    >    if curr.child then
+    >      current_zettel_id = curr.child
+    >    elseif curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and zettels[curr.parent].next then
+    >      current_zettel_id = zettels[curr.parent].next
+    >    end
+    >  elseif key == string.byte('k') then
+    >    if curr.parent then current_zettel_id = curr.parent end
+    >  elseif key == string.byte('h') then
+    >    if curr.prev then
+    >      current_zettel_id = curr.prev
+    >    elseif curr.parent then
+    >      current_zettel_id = curr.parent
+    >    end
+    >  elseif key == string.byte('l') then
+    >    if curr.next then
+    >      current_zettel_id = curr.next
+    >    elseif curr.parent and zettels[curr.parent].next then
+    >      current_zettel_id = zettels[curr.parent].next
+    >    end
+    >  -- screen-based navigation
+    >  elseif key == curses.KEY_UP then
+    >    if render_state.curr_h > 1 then
+    >      current_zettel_id = render_state.wh2id[render_state.curr_w][render_state.curr_h - 1]
+    >    end
+    >  elseif key == curses.KEY_DOWN then
+    >    if render_state.wh2id[render_state.curr_w][render_state.curr_h + 1] then
+    >      current_zettel_id = render_state.wh2id[render_state.curr_w][render_state.curr_h + 1]
+    >    end
+    >  elseif key == curses.KEY_LEFT then
+    >    if render_state.curr_w > 1 then
+    >      current_zettel_id = render_state.wh2id[render_state.curr_w - 1][render_state.curr_h]
+    >    end
+    >  elseif key == curses.KEY_RIGHT then
+    >    if render_state.wh2id[render_state.curr_w + 1] and render_state.wh2id[render_state.curr_w + 1][render_state.curr_h] then
+    >      current_zettel_id = render_state.wh2id[render_state.curr_w + 1][render_state.curr_h]
+    >    end
+    >  end
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 23:49:04 2022
+  __teliva_note:
+    >screen-based zettel navigation
+    >
+    >left/right arrows not tested yet
+- view_settings:
+    >view_settings = {
+    >  -- dimensions for rendering a single zettel; extra text gets truncated
+    >  width=50,
+    >  height=40,
+    >  -- spacing between zettels
+    >  hmargin=1,
+    >  vmargin=1,
+    >  --
+    >  indent=2,  -- how children of a zettel are indicated
+    >  current_zettel_bg=3,  -- color pair index initialized in init_colors
+    >}
+  __teliva_timestamp:
+    >Fri Feb  4 23:52:43 2022
+- view_settings:
+    >view_settings = {
+    >  -- dimensions for rendering a single zettel; extra text gets truncated
+    >  width=50,
+    >  height=3,
+    >  -- spacing between zettels
+    >  hmargin=1,
+    >  vmargin=1,
+    >  --
+    >  indent=2,  -- how children of a zettel are indicated
+    >  current_zettel_bg=3,  -- color pair index initialized in init_colors
+    >}
+  __teliva_timestamp:
+    >Fri Feb  4 23:53:07 2022
+- render:
+    >function render(window)
+    >  window:clear()
+    >  local lines, cols = window:getmaxyx()
+    >  local bg=1
+    >  local y, x = 0, 0 -- units of characters (0-based)
+    >  local w, h = 1, 1 -- units of zettels (1-based)
+    >  -- render zettels depth-first, while tracking relative positions
+    >  local done = {}
+    >  local inprogress = {zettels.root}
+    >  render_state.wh2id = {{}}
+    >  while #inprogress > 0 do
+    >    local currid = table.remove(inprogress)
+    >    if not done[currid] then
+    >      done[currid] = true
+    >      table.insert(render_state.wh2id[w], currid)
+    >      local zettel = zettels[currid]
+    >      if currid == current_zettel_id then
+    >        render_state.curr_w = w
+    >        render_state.curr_h = h
+    >      end
+    >      local currbg = (currid == current_zettel_id) and view_settings.current_zettel_bg or bg
+    >      render_zettel(window, currbg, depth(zettel) * view_settings.indent, y, x, zettel)
+    >      if zettel.next then table.insert(inprogress, zettel.next) end
+    >      if zettel.child then table.insert(inprogress, zettel.child) end
+    >      bg = 3 - bg  -- toggle between color pairs 1 and 2
+    >      y = y + view_settings.height + view_settings.vmargin
+    >      h = h + 1
+    >      if y > lines then
+    >        y = 0
+    >        h = 1
+    >        x = x + view_settings.width + view_settings.hmargin
+    >        w = w + 1
+    >        if x + view_settings.width > cols then break end
+    >        table.insert(render_state.wh2id, {})
+    >      end
+    >    end
+    >  end
+    >  window:mvaddstr(lines-2, 0, '')
+    >  for i=1,3 do
+    >    window:attrset(curses.color_pair(i%2+1))
+    >    window:addstr('')
+    >    spaces(view_settings.width-string.len(''))
+    >    window:attrset(curses.color_pair(0))
+    >    window:addstr(' ')  -- margin
+    >  end
+    >  window:mvaddstr(lines-1, 0, '? ')
+    >  curses.refresh()
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 23:53:57 2022
+- view_settings:
+    >view_settings = {
+    >  -- dimensions for rendering a single zettel; extra text gets truncated
+    >  width=50,
+    >  height=35,
+    >  -- spacing between zettels
+    >  hmargin=1,
+    >  vmargin=1,
+    >  --
+    >  indent=2,  -- how children of a zettel are indicated
+    >  current_zettel_bg=3,  -- color pair index initialized in init_colors
+    >}
+  __teliva_timestamp:
+    >Fri Feb  4 23:54:07 2022
+- view_settings:
+    >view_settings = {
+    >  -- dimensions for rendering a single zettel; extra text gets truncated
+    >  width=50,
+    >  height=40,
+    >  -- spacing between zettels
+    >  hmargin=1,
+    >  vmargin=1,
+    >  --
+    >  indent=2,  -- how children of a zettel are indicated
+    >  current_zettel_bg=3,  -- color pair index initialized in init_colors
+    >}
+  __teliva_timestamp:
+    >Fri Feb  4 23:54:18 2022
+- render:
+    >function render(window)
+    >  window:clear()
+    >  local lines, cols = window:getmaxyx()
+    >  local bg=1
+    >  local y, x = 0, 0 -- units of characters (0-based)
+    >  local w, h = 1, 1 -- units of zettels (1-based)
+    >  -- render zettels depth-first, while tracking relative positions
+    >  local done = {}
+    >  local inprogress = {zettels.root}
+    >  render_state.wh2id = {{}}
+    >  while #inprogress > 0 do
+    >    local currid = table.remove(inprogress)
+    >    if not done[currid] then
+    >      done[currid] = true
+    >      table.insert(render_state.wh2id[w], currid)
+    >      local zettel = zettels[currid]
+    >      if currid == current_zettel_id then
+    >        render_state.curr_w = w
+    >        render_state.curr_h = h
+    >      end
+    >      local currbg = (currid == current_zettel_id) and view_settings.current_zettel_bg or bg
+    >      render_zettel(window, currbg, depth(zettel) * view_settings.indent, y, x, zettel)
+    >      if zettel.next then table.insert(inprogress, zettel.next) end
+    >      if zettel.child then table.insert(inprogress, zettel.child) end
+    >      bg = 3 - bg  -- toggle between color pairs 1 and 2
+    >      y = y + view_settings.height + view_settings.vmargin
+    >      h = h + 1
+    >      if y + view_settings.height > lines then
+    >        y = 0
+    >        h = 1
+    >        x = x + view_settings.width + view_settings.hmargin
+    >        w = w + 1
+    >        if x + view_settings.width > cols then break end
+    >        table.insert(render_state.wh2id, {})
+    >      end
+    >    end
+    >  end
+    >  window:mvaddstr(lines-2, 0, '')
+    >  for i=1,3 do
+    >    window:attrset(curses.color_pair(i%2+1))
+    >    window:addstr('')
+    >    spaces(view_settings.width-string.len(''))
+    >    window:attrset(curses.color_pair(0))
+    >    window:addstr(' ')  -- margin
+    >  end
+    >  window:mvaddstr(lines-1, 0, '? ')
+    >  curses.refresh()
+    >end
+  __teliva_timestamp:
+    >Fri Feb  4 23:54:51 2022
+- view_settings:
+    >view_settings = {
+    >  -- dimensions for rendering a single zettel; extra text gets truncated
+    >  width=50,
+    >  height=35,
+    >  -- spacing between zettels
+    >  hmargin=1,
+    >  vmargin=1,
+    >  --
+    >  indent=2,  -- how children of a zettel are indicated
+    >  current_zettel_bg=3,  -- color pair index initialized in init_colors
+    >}
+  __teliva_timestamp:
+    >Fri Feb  4 23:54:58 2022
+- __teliva_note:
+    >tested multi-column render and nav
+  __teliva_timestamp:
+    >Fri Feb  4 23:55:10 2022
+  view_settings:
+    >view_settings = {
+    >  -- dimensions for rendering a single zettel; extra text gets truncated
+    >  width=50,
+    >  height=3,
+    >  -- spacing between zettels
+    >  hmargin=1,
+    >  vmargin=1,
+    >  --
+    >  indent=2,  -- how children of a zettel are indicated
+    >  current_zettel_bg=3,  -- color pair index initialized in init_colors
+    >}