Commit Graph

423 Commits

Author SHA1 Message Date
Kartik K. Agaram 5872a7be09 . 2021-12-16 02:52:52 -08:00
Kartik K. Agaram 7c1b9d0b91 stop leaking on the Lua stack
..even if at the expense of leaking on the heap. Because the Lua stack
has very limited space (~20 slots). When it overflows, we segfault.
2021-12-16 02:50:32 -08:00
Kartik K. Agaram b425593af6 show all functions in big picture
We were missing functions in some larger programs.
2021-12-13 09:59:52 -08:00
Kartik K. Agaram d043d67744 tweak Hanoi colors yet again 2021-12-13 09:43:25 -08:00
Kartik K. Agaram f315e1d76a can again edit notes on changes 2021-12-11 15:30:33 -08:00
Kartik K. Agaram b9877fabdc . 2021-12-11 14:59:00 -08:00
Kartik K. Agaram 706bdf63c1 delete an old file for comparison 2021-12-11 14:55:19 -08:00
Kartik K. Agaram 5c68906303 handle non-existent file 2021-12-11 14:01:34 -08:00
Kartik K. Agaram d25c37f86b bring back commandline args 2021-12-11 10:36:35 -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 d5038fe514 snapshot: writing working?
This is a complete mess. I want to abstract reading multiline strings
behind a function, but the lookahead requirements for that are quite
stringent. What's a reasonable abstraction here?
2021-12-11 09:37:23 -08:00
Kartik K. Agaram 052c5501ac snapshot: key/value lines after multiline strings 2021-12-11 07:20:04 -08:00
Kartik K. Agaram 0b0a58da06 snapshot: start reading a new format
I really wanted to avoid getting into defining or parsing new file
formats. However, using the entire power of Lua is not ideal, as
described earlier in Konrad Hinsen's bug. In addition to everything
else, it's a vector for arbitrary code execution when someone loads an
untrusted image.

I could use JSON, but it requires ugly string escaping. Seems cleaner to
just use YAML. But YAML is complex and needs its own dependencies. If
I'm going to do my own, might as well make the multi-line string format
really clear.

I can't yet write the new format.
2021-12-11 00:43:26 -08:00
Kartik K. Agaram 469ad4e546 clearer description of editing experience 2021-12-10 14:22:25 -08:00
Kartik K. Agaram 47c8e9df22 comment 2021-12-08 22:37:54 -08:00
Kartik K. Agaram 653f9cc874 minor colorscheme tweak 2021-12-08 22:34:01 -08:00
Kartik K. Agaram 5a237bbcca display line numbers
Not my aesthetic choice, but essential at the moment for quickly
interpreting Lua errors.
2021-12-08 22:31:30 -08:00
Kartik K. Agaram 8a70fbd171 fix a use-after-free
Introduced Nov 28. Let's see if my intermittent segfaults stop now.
2021-12-08 16:47:59 -08:00
Kartik K. Agaram 71ce944e81 couple more primitives after Advent day 8 2021-12-08 00:40:22 -08:00
Kartik K. Agaram 74fd78c5b7 . 2021-12-07 23:45:04 -08:00
Kartik K. Agaram b8c199f298 make it easy to print arrays:
map(l, prn)
2021-12-07 18:04:55 -08:00
Kartik K. Agaram 083b698765 new primitive: array append 2021-12-07 18:04:23 -08:00
Kartik K. Agaram de2152e313 new primitive: string split 2021-12-07 17:29:00 -08:00
Kartik K. Agaram 20373578f4 cleaner 2021-12-07 17:28:46 -08:00
Kartik K. Agaram 46aa8c2cf8 slightly improve experience on Konrad Hinsen's bug
Steps to reproduce:
* Run teliva with some app.
* Press ctrl-e to edit the app.
* Select some function.
* Press ctrl-g and type in some Lua keyword like 'function' or 'while'
  (Since the first word in a function is often 'function', it becomes
  the default if you press ctrl-g immediately after entering the editor
  for a function.)
* Type nothing. Run the app.

Desired behavior: app continues to run. The definition for the keyword
is silently ignored (in future we may want to provide an error message)

Behavior before this commit: app silently exited with non-zero status,
and refused to restart thereafter until the .tlv file was manually
edited to delete the definition for the Lua keyword.

Behavior after this commit: app throws an error message like these:

  * For `function`:
    ```
    src/teliva: x.tlv:99: '(' expected near '='
    sorry, you'll need to edit the image directly. press any key to exit.
    ```

  * For `while`:
    ```
    src/teliva: x.tlv:99: unexpected symbol near 'while'
    sorry, you'll need to edit the image directly. press any key to exit.
    ```

You still need to edit the .tlv file manually, but the steps for
recovery are a bit more discoverable.

To fix this properly I also need to fix a looming security hole I've
been thinking about for some time. The long-term goal of Teliva is to
put the human running apps in control of what they do, by sandboxing
accesses to the file system, network and so on. However, even after we
build gates on all of Lua's standard libraries, we're still parsing .tlv
files as Lua, with all of its power available.

Solution: load .tlv files as some sort of JSON-like subset of Lua. Maybe
I should just use JSON, and rely on code that's already in Teliva, even
if I'm introducing a new notation in the process.
2021-12-07 08:50:28 -08:00
Kartik K. Agaram 0e8a160eee map/reduce/filter helpers 2021-12-06 22:10:44 -08:00
Kartik K. Agaram 978f698bfd fix colors in startup errors 2021-12-06 22:10:10 -08:00
Kartik K. Agaram bba3559b06 slightly more obvious menu copy
Still sucks, though..
2021-12-06 20:35:39 -08:00
Kartik K. Agaram 8423192eee improve backspace copy 2021-12-06 20:15:04 -08:00
Kartik K. Agaram 6b307fba2b tweak solarized-esque scheme 2021-12-06 20:13:17 -08:00
Kartik K. Agaram a0c66dbe31 more configurable colors
Also start using 256 colors, under the assumption most people will have
them.
2021-12-06 16:53:11 -08:00
Kartik K. Agaram 8807168729 grey rather than harsh white background 2021-12-04 20:54:01 -08:00
Kartik K. Agaram 0429cfca74 clearer usage message 2021-12-04 20:38:49 -08:00
Kartik K. Agaram d9cf3433d9 start showing call stack on errors
It turns out Lua has been providing us this information all along! I'd
just not created the space on screen to show it. Make it persist better.

Kilo now no longer tracks its own status messages, which is a regression
in a rare condition.
2021-12-04 14:12:36 -08:00
Kartik K. Agaram 810e160136 another fix for colors
I'd assumed that assume_default_colors updates fg/bg -1, but it doesn't.
Looks like I can't ever use -1 colors.
2021-12-03 23:12:02 -08:00
Kartik K. Agaram 294c135d3f elaborate a little more on install instructions
Thanks to Mariano Guerra for the Nix command, and to Konrad Hinsen for
the Guix command.
2021-12-03 20:55:32 -08:00
Kartik K. Agaram 267489c19f support the comment/uncomment hotkey on Macs
^/ works on Linux but not on Mac
^- emits the same character code on Mac
^_ seems to be the underlying character code, and works on both
ctrl-7 also emits the same character code
2021-12-03 20:19:32 -08:00
Kartik K. Agaram 950957619c less ambiguous menus
Doesn't make sense to use '/' as a delimiter when we have hotkeys
involving '/'.
2021-12-03 20:13:52 -08:00
Kartik K. Agaram bbab1a7c10 get rid of `Esc` hotkey
For a variety of historical reasons, terminals pause every time you
press `Esc`. Let's get rid of that lag.
2021-12-03 19:45:51 -08:00
Kartik K. Agaram fe5f542991 typos 2021-12-03 19:11:52 -08:00
Kartik K. Agaram 138282549e experimenting with different keys
On a Thinkpad X13, the `delete` key emits `^[[3~` outside of Teliva.
Within Teliva, ncurses converts it to character code 330 (0x14a), which
it fails to recognize as KEY_BACKSPACE. Why?

My backspace is converted to character code 263, which ncurses does
recognize as KEY_BACKSPACE.

ctrl-h is character code 8.

Both 330 and 263 are valid Unicode code points, which feels really ugly
and ambiguous.
2021-12-03 18:38:17 -08:00
Kartik K. Agaram d3a12fb7f1 stop showing frequent save messages 2021-12-03 18:30:24 -08:00
Kartik K. Agaram a796070c9b show ^h in a couple more menus 2021-12-03 18:23:40 -08:00
Kartik K. Agaram 31af4bd1fd improve support for backspace
I still don't understand the entire state space here, so I'm trying to
err on the side of improving discoverability of the `ctrl-h` escape
hatch. Without requiring too wide a window to show all hotkeys on the
menu.
2021-12-03 18:05:25 -08:00
Kartik K. Agaram 4c196576aa error message when no app is provided
Also strip out a bunch of Lua's commandline parsing.
2021-12-03 17:34:21 -08:00
Kartik K. Agaram 8ea7a3bde5 . 2021-12-03 17:23:37 -08:00
Kartik K. Agaram 516ac2fa8e describe the manual process to obtain a dark bg
https://github.com/akkartik/teliva/issues/1
2021-12-03 17:19:40 -08:00
Kartik K. Agaram 947abf2ba3 legible colors across all terminal configurations
So far I've been trying to make Teliva follow the default colorscheme of
the terminal, but that easily ends up with illegible color combinations.
New plan: always start with a light background within Teliva. People who
want a dark background will currently need to mess with C sources.

This should somewhat fix https://github.com/akkartik/teliva/issues/1.
It's still not clear whether the default should be a dark or light
background. While dark background is more common in terminals, I believe
newcomers to terminals will prefer a light background. Then again, I'm
biased since I use a light background in my terminals.
2021-12-03 16:59:25 -08:00
Kartik K. Agaram 6f6595b39a show state of screen on runtime error
This is essential when debugging.
2021-12-03 16:12:51 -08:00
Kartik K. Agaram c7dea9f5a3 . 2021-12-03 16:00:59 -08:00