Commit Graph

18 Commits

Author SHA1 Message Date
Kartik K. Agaram 52ae23784b new API for file operations
File operations now always return a channel (or nil on error or
permission denied).

When start_reading() from a filename, you can repeatedly :recv() from
the channel it returns.
When :recv() returns nil, you're at the end of the file. Stop.

When you start_writing() to a filename, you can repeatedly :send() to
the channel it returns.
When you're done writing, :close() the channel. Writes to the file won't
be externally visible until you do.

To make this work I'm now always starting up the scheduler, so I need to
fix sieve.tlv.

Transparently running the scheduler is an abstraction, and whenever I
create an abstraction I always worry about how it might fail. There's
a hopefully-clear error when you read past end of a file.
2022-03-05 18:04:35 -08:00
Kartik K. Agaram 2d6b88204b anagrams.tlv: now fully responsive
If we press a key the computation now restarts instantly.

There's no fiction of multi-threading in Teliva. If the application
doesn't work right, it beach-balls. If it doesn't beach-ball under
normal circumstances you're more certain it'll never beach-ball. It's
more work up-front, but there's less variability in outcomes.
2022-03-05 16:15:32 -08:00
Kartik K. Agaram c53df5c4cc basic support for testing writes to screen 2022-03-03 22:10:58 -08:00
Kartik K. Agaram 81849716fa fake keyboard constructor 2022-03-02 22:18:26 -08:00
Kartik K. Agaram 68d956e31a distinguish between window global and arg 2022-03-02 22:15:01 -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 42526cb15d import https://github.com/majek/lua-channels
Also a little test program to demo channels in action.
2022-02-26 22:48:48 -08:00
Kartik K. Agaram 3e1fa8c5a7 a little program for kids: anagrams of names 2022-02-21 19:06:16 -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 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 343316dcfa more precise control over menu order
I can't believe I didn't notice this until now.
2021-12-22 00:27:50 -08:00
Kartik K. Agaram 53f235fd26 minor tweaks 2021-12-21 15:06:43 -08:00
Kartik K. Agaram dcef2347dd document dbg 2021-12-18 19:33:54 -08:00
Kartik K. Agaram 9fe884c03a streamline an app; pull useful stuff into template 2021-12-18 08:41:19 -08:00
Kartik K. Agaram 68e008526a expand Teliva's "standard library"
Lua is often not very functional. Available primitives often mutate data
destructively rather than create new values. Perhaps I shouldn't be
trying to go against the grain. We'll see. The above changes are based
on using Teliva intensively for 2 weeks of Advent of Code 2021. But that
isn't quite the ideal use case for Teliva.
2021-12-16 02:53:17 -08:00
Kartik K. Agaram 5872a7be09 . 2021-12-16 02:52:52 -08:00
Kartik K. Agaram c0c9d31688 snapshot: migrate all sample apps to new format 2021-12-11 10:22:53 -08:00
Kartik K. Agaram dff7a5226f a starting point for new apps 2021-11-27 21:08:05 -08:00