Commit Graph

45 Commits

Author SHA1 Message Date
Kartik K. Agaram b56590ddc9 some more reorg of the standard library
Now life.tlv and gemini.tlv are also minimizing how much of the standard
library they pull in, just to be easy to read.
2022-03-27 11:42:19 -07:00
Kartik K. Agaram 14446eefc4 helper: count permutations 2022-03-27 11:24:56 -07:00
Kartik K. Agaram dd7da2c62a helper: count 2022-03-27 10:53:41 -07:00
Kartik K. Agaram fddbe08fc8 graphviz: for basic stats, show all nodes ordered
The ordering is topological; nodes come before their dependencies.

Also some more helpful functions in the template for new apps.
2022-03-19 16:59:30 -07:00
Kartik K. Agaram 7859317ece standardize common helpers across all apps
In particular, I merged take_out in anagrams.tlv with all_but in
graphviz.
2022-03-19 00:19:58 -07:00
Kartik K. Agaram aed89b8d35 graphviz: draft notion of nodes in 'focus'
Now the REPL isn't about deciding what to calculate, but just what nodes
to calculate it for.
2022-03-18 21:22:18 -07:00
Kartik K. Agaram c21cefa888 idiom: table.insert for appending
Stop using arr[#arr+1].
2022-03-18 20:55:07 -07:00
Kartik K. Agaram 29d53c21ac graphviz: don't interpret substrings as regexes 2022-03-18 10:43:48 -07:00
Kartik K. Agaram 5c42b1de32 break.tlv: nascent live-updating stack language
Joint work with Sumeet Agarwal. In the process we discovered several
bugs in our fake window helpers for tests. Thanks Sumeet!

Previous prototypes:
  - https://archive.org/details/akkartik-2min-2020-12-06
  - https://merveilles.town/@akkartik/105759816342173743
2022-03-17 23:36:15 -07:00
Kartik K. Agaram b9c187d259 stop using tasks in start_reading/start_writing
We just need queues/streams for file I/O. No need to complect
concurrency concerns with them.
2022-03-16 17:03:38 -07:00
Kartik K. Agaram cee42880e5 zet.tlv: thoroughly test rendering single zettel 2022-03-10 15:38:26 -08:00
Kartik K. Agaram e627114751 zet.tlv: first screen tests
In the process I found a couple of bugs in fake screen primitives.
2022-03-10 04:30:58 -08:00
Kartik K. Agaram 70c3ec42bc screen tests: support bold, reverse, color
We can't test combinations of these yet because Lua 5.1 doesn't support
bitwise operators. Reason #1 to upgrade.
2022-03-08 22:42:32 -08:00
Kartik K. Agaram 38063812b6 zet.tlv: switch file writes to new API
The interface for apps looks much nicer now, see 'main' in zet.tlv.
However there are some open issues:

- It can still be confusing to the computer owner that an app tries to
  write to some temporary file that isn't mentioned anywhere.

- File renames can fail if /tmp is on a different volume.

- What happens if an app overrides start_writing()? The computer owner
  may think they've audited the caller of start_writing and give it
  blanket file permissions. Teliva tunnels through start_writing when
  computing the caller. If the app can control what start_writing does,
  the app could be performing arbitrary malicious file operations.

  Right now things actually seem perfectly secure. Overriding
  start_writing has no effect. Our approach for loading .tlv files (in
  reverse chronological order, preventing older versions from overriding
  newer ones) has the accidentally _great_ property that Teliva apps can
  never override system definitions.

  So we have a new reason to put standard libraries in a .lua file: if
  we need to prevent apps from overriding it.

  This feels like something that needs an automated test, both to make
  sure I'm running the right experiment and to ensure I don't
  accidentally cause a regression in the future. I can totally imagine a
  future rewrite that tried a different approach than
  reverse-chronological.
2022-03-07 10:55:18 -08:00
Kartik K. Agaram 503ad706fb zet.tlv: switch file reads to new API
In the process I found a couple of bugs in parsing JSON string escapes.
2022-03-07 08:22:37 -08:00
Kartik K. Agaram 6a3098d0e9 use method syntax where possible
Perhaps this is a bad idea. It feels arbitrary, what methods Lua happens
to include in string and table objects without having to go through the
respective modules.
2022-03-06 16:38:49 -08:00
Kartik K. Agaram 38ff2ddf11 move start_reading/start_writing out of template
When should code go in the template used by new apps vs the .lua files
distributed with Teliva?

- from a privilege perspective there's no difference
- from a compatibility perspective stuff in .tlv will not get upgraded
  with Teliva.
- for me the maintainer, functions in .lua files are easier to upgrade
  in a single place.
- for the reader of an app, functions in .lua files will not show up to
  be edited. They can still be overloaded, but the current version isn't
  as discoverable. Putting something in the app is a slight nudge to
  readers that they're encouraged to mess with it.
- Stuff in .lua files can use local functions and so have more internal
  complexity. Apps can also hide details within functions, but that'll
  make them more likely to run into limitations with Teliva's editing
  environment.

I'm not yet sure how to reason about the second point in practice.
  - Stuff in .tlv files I don't have to worry about compatibility
    guarantees for.
  - Stuff in .lua files I _do_ have to worry about compatibility
    guarantees for.

Perhaps this means I'm doing things exactly wrong in this commit?
Functions like map/reduce/filter/append seem more timeless, whereas I'm
still just feeling my way around with start_reading and start_writing.

We'll see. For now I'm ruled by the fourth point. Messing with tasks and
the scheduler is much more advanced than anything else in template.tlv;
it seems to make sense to add some friction to modifying them.

Bottomline: Complex sub-systems go in .lua files. Simple, self-contained
definitions go into apps. Both are probably equally burdensome now from
a compatibility perspective.
2022-03-06 09:21:32 -08:00
Kartik K. Agaram a8d0c1a56a reconcile all apps with template.tlv
They may take more or less from it (sieve.tlv in particular takes
nothing since call depth doesn't help at all there), but what they take
is in the right order so that you can compare across apps.
2022-03-06 02:42:34 -08:00
Kartik K. Agaram 68d956e31a distinguish between window global and arg 2022-03-02 22:15:01 -08:00
Kartik K. Agaram 46ef1adb08 zet.tlv: hotkeys are not alternatives
In any case, I want the convention to be '|' for alternation. '/' is
more likely to be a real hotkey.
2022-02-27 09:58:05 -08:00
Kartik K. Agaram 2546d91214 zet.tlv: streamline history 2022-02-27 09:47:09 -08:00
Kartik K. Agaram ae51b06dab starting to make Teliva apps more testable
Tasteful apps should only perform side-effects through 'window'
arguments rather than the 'curses' module directly. It's ok however to
read constants like curses.A_NORMAL or curses.stdscr().

There are some limitations, unfortunately. Ncurses wasn't designed with
testability in mind. For example, there's no way to curs_set or
assume_default_colors without the 'curses' module. Oh well.
2022-02-27 08:41:30 -08:00
Kartik K. Agaram 9421ea7151 'doc:blurb': a place to briefly describe an app
This is for what the app does, as opposed to 'doc:main', which is also
intended to include commentary about the internal organization of the
app.
2022-02-17 20:16:36 -08:00
Kartik K. Agaram 3db03840e1 zet.tlv: new shortcuts, mostly for the editor 2022-02-12 17:59:30 -08:00
Kartik K. Agaram 5e200cf96a zet.tlv: some more editor shortcuts 2022-02-12 15:56:12 -08:00
Kartik K. Agaram bbd47aaa5b zet.tlv: yet another bugfix
Need for tests growing more acute..
2022-02-11 10:40:24 -08:00
Kartik K. Agaram d7436f047d zet.tlv: fix a couple more bugs
This snapshot was demoed at https://archive.org/details/akkartik-teliva-2022-02-10
2022-02-10 23:40:51 -08:00
Kartik K. Agaram c55956bf96 zet.tlv: cross-links
We also made render dynamic, showing zettels in the first place it
encounters them in depth-first order.

Open question: how to show a collapsed outline view with the data model
I'm experimenting with. Not even clear 'outline' has meaning in the
presence of cross-links. Outliners privilege one view of the network.
Zettelkasten also does so; changing child/sibling relationships is a lot
of work. However, reading between the links it seems to try to provide
an escape hatch for rethinking connections using cross-links. I'm trying
to lean into that -- at the cost of providing outlines. We'll see if
this is a good trade-off.
2022-02-10 21:33:21 -08:00
Kartik K. Agaram 76984aa90f allow Teliva to show its sandboxing message 2022-02-10 16:30:00 -08:00
Kartik K. Agaram b0cc9a7451 zet.tlv: refine the initial UX some more
Conundrum:

I want the app to provide some sample data for people to interact with.

However, I also want them to be able to delete it to make it their own.

BUT I'm not yet convinced the app should allow deletion in general.

Besides, deleting stuff robustly and reliably is a whole other level of
programming.

Solution:

Make people edit the app to clear the initial sample zettels.

This has the "beneficial" side-effect of getting them editing apps on
Teliva.
2022-02-10 08:00:47 -08:00
Kartik K. Agaram c4402edc5b zet.tlv: copy in sample zettels 2022-02-10 07:40:04 -08:00
Kartik K. Agaram 1a40bc7f5f zet.tlv: saving/loading to/from disk 2022-02-10 07:35:54 -08:00
Kartik K. Agaram 10dab7ae17 zet.tlv 2022-02-10 07:35:28 -08:00
Kartik K. Agaram 5cab1c042d zet.tlv: resizing zettel card sizes 2022-02-10 00:04:12 -08:00
Kartik K. Agaram e827379950 zet.tlv: creating new zettels 2022-02-09 23:49:59 -08:00
Kartik K. Agaram cf521f9904 zet.tlv: bugfixes to editor cursor handling 2022-02-09 23:41:36 -08:00
Kartik K. Agaram 7786462a8d . 2022-02-09 23:27:26 -08:00
Kartik K. Agaram e552571b1e standardize key order in .tlv files
This will eliminate some spurious git diffs I keep having to clean up.
2022-02-09 09:18:05 -08:00
Kartik K. Agaram b328ffc5e5 zet.tlv: simpler UI, simpler editor 2022-02-09 08:31:20 -08:00
Kartik K. Agaram c3422e101f bugfix in rendering non-top zettels 2022-02-08 19:20:13 -08:00
Kartik K. Agaram e397220f9d Lua gotcha: iterating over strings yields strings 2022-02-08 19:19:08 -08:00
Kartik K. Agaram 33ab842ffd zet.tlv: expand editor to accomodate more text
Still won't show up in view mode for now. Soon we'll be able to adjust
zettel dimensions.
2022-02-08 18:40:59 -08:00
Kartik K. Agaram fb251c2819 zet.tlv: editing a single zettel 2022-02-08 00:28:20 -08:00
Kartik K. Agaram b639f8e68c zet.tlv: clean up history 2022-02-07 23:17:03 -08:00
Kartik K. Agaram a5cb7381a8 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.
2022-02-04 23:57:05 -08:00