Commit Graph

510 Commits

Author SHA1 Message Date
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
Kartik K. Agaram
87443b9815 extract a helper 2021-12-03 15:54:35 -08:00
Kartik K. Agaram
148fe6dfbd more speculatively efficient advent.tlv 2021-12-02 20:40:51 -08:00
Kartik K. Agaram
3f930ed73e fix a slight portability issue, maybe
When installing using NixOS[1], the screen looks wrong. It looks like
attrset(A_NORMAL) does not undo color changes with some versions of
dependencies.

[1] https://github.com/marianoguerra/marianoguerra.github.io/blob/master/advent-of-future-of-code/days/day-02.md
2021-12-02 01:49:57 -08:00
Kartik K. Agaram
e001212e99 stop inserting ctrl- keys into programs 2021-11-30 17:44:01 -08:00
Kartik K. Agaram
cbe7d1bf40 fix advent.tlv
Thanks sejo.
2021-11-30 17:16:15 -08:00
Kartik K. Agaram
51ba37665c some little shortcuts for Advent of Code
https://archive.org/details/akkartik-teliva-2021-11-30
2021-11-30 15:02:09 -08:00
Kartik K. Agaram
f5a6f434c5 better cross-platform backspace support
I wish I could just hide KEY_BACKSPACE and prevent myself from using it
by accident.

Then again, I'm not making this smarts available in Teliva programs
themselves. Just for the Teliva environment.
2021-11-30 09:56:06 -08:00
Kartik K. Agaram
ce3ad17a05 kilo bugfix: syntax highlight final word in line
Kilo likely never ran into this because it's only been tested on C,
which uses semi-colons at the end of each statement.
2021-11-29 22:49:47 -08:00
Kartik K. Agaram
85e06b7b0f gotcha: silent string concatenation 2021-11-29 22:49:45 -08:00
Kartik K. Agaram
61accc5b8e . 2021-11-29 22:48:14 -08:00
Kartik K. Agaram
d7a1792768 a couple more global curses bindings 2021-11-29 22:40:42 -08:00
Kartik K. Agaram
b6bca6ac14 fix regression in showing error messages 2021-11-29 22:38:46 -08:00
Kartik K. Agaram
fa52f129fb . 2021-11-29 22:06:54 -08:00