about summary refs log tree commit diff stats
path: root/src/lua.c
Commit message (Collapse)AuthorAgeFilesLines
* fix arrow keys in big picture view on MacKartik K. Agaram2021-12-211-5/+5
| | | | Turns out arrow keys are considered `isprint()` on Mac.
* bugfix: ensure definition to edit has some nameKartik K. Agaram2021-12-211-4/+6
|
* less confusing nameKartik K. Agaram2021-12-211-5/+3
|
* arrow keys in big picture viewKartik K. Agaram2021-12-211-12/+104
|
* nail down trusted Teliva channels a little moreKartik K. Agaram2021-12-211-1/+6
| | | | | | | | | | | | | | | | | | | | | | In each session, Teliva has to bootstrap a trusted channel with the computer owner while running arbitrarily untrusted code. So let's get really, really precise about what the trusted channel consists of: - the bottom-most row of screen containing the menu - the keystrokes the owner types in - ncurses COLOR_PAIR slots 254 (menu) and 255 (error) One reason the menu colors are important: we don't want people to get used to apps that hide the menu colors by setting default foreground/background to invisible and then drawing their own menu one row up. The error COLOR_PAIR I don't see any reason to carve out right now, but it seems like a good idea for Teliva the framework to not get into the habit of apps doing some things for it. I'm not sure how realistic all this is (I feel quite ill-equipped to think about security), but it seems worthwhile to err on the side of paranoia. Teliva will be paranoid so people don't have to be.
* pay more attention to where we display the cursorKartik K. Agaram2021-12-181-1/+2
| | | | | It's still just in app control; I'm resisting the urge to introduce "smarts".
* better copy on test failuresKartik K. Agaram2021-12-171-1/+4
|
* correct count of test failuresKartik K. Agaram2021-12-171-1/+1
|
* keep tests from messing up big pictureKartik K. Agaram2021-12-171-0/+19
|
* one more protection against Lua stack leakKartik K. Agaram2021-12-171-6/+6
|
* experimental support for test errorsKartik K. Agaram2021-12-171-3/+8
|
* start of a test frameworkKartik K. Agaram2021-12-171-0/+35
| | | | | Follows https://github.com/akkartik/wart, https://github.com/akkartik/mu0, https://github.com/akkartik/mu1 and https://github.com/akkartik/mu.
* yet another stab at reorganizing stack assertionsKartik K. Agaram2021-12-171-9/+14
|
* .Kartik K. Agaram2021-12-171-0/+3
|
* .Kartik K. Agaram2021-12-171-4/+4
|
* more protection against data lossKartik K. Agaram2021-12-171-2/+2
|
* protect against data loss in some rare situationsKartik K. Agaram2021-12-161-3/+32
| | | | | | | | | | | Examples: - you try to write file but disk is full - you have two Teliva files being edited at the same time Both are situations where it's impossible to avoid some data loss. However, we should now at least have some valid state of the .tlv file saved to disk where we'd previously end up with a zero-size file or garbage.
* fix another leak in the Lua stackKartik K. Agaram2021-12-161-2/+9
| | | | | This fixes a segfault when scanning through a long history of recent changes (say > 20 changes)
* more consistently show notes in recent changesKartik K. Agaram2021-12-161-1/+5
| | | | | | | | | Teliva emits timestamps in multi-line format end in a newline. As a result, notes get rendered on the next line and are then immediately overwritten by the contents of the definition. This bug was masked by my hacky 'original' timestamps which don't use multi-line format.
* stop leaking on the Lua stack, reduxKartik K. Agaram2021-12-161-11/+19
| | | | | An empty stack is too rigorous a line to hold. Instead we'll just ensure we leave the stack the way we found it.
* Revert "stop leaking on the Lua stack"Kartik K. Agaram2021-12-161-2/+2
| | | | | | | This reverts commit 7c1b9d0b91295323b5ed5ec3e09b46566288bc75. The 'big hammer' isn't good enough. The recent changes view seems to need state on the stack across invocations of the editor.
* stop leaking on the Lua stackKartik K. Agaram2021-12-161-2/+2
| | | | | ..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.
* show all functions in big pictureKartik K. Agaram2021-12-131-2/+6
| | | | We were missing functions in some larger programs.
* can again edit notes on changesKartik K. Agaram2021-12-111-4/+4
|
* bring back commandline argsKartik K. Agaram2021-12-111-1/+18
|
* snapshot: writing working?Kartik K. Agaram2021-12-111-34/+7
| | | | | | 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?
* snapshot: start reading a new formatKartik K. Agaram2021-12-111-26/+3
| | | | | | | | | | | | | | | 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.
* .Kartik K. Agaram2021-12-071-1/+1
|
* cleanerKartik K. Agaram2021-12-071-2/+2
|
* slightly improve experience on Konrad Hinsen's bugKartik K. Agaram2021-12-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* fix colors in startup errorsKartik K. Agaram2021-12-061-0/+1
|
* slightly more obvious menu copyKartik K. Agaram2021-12-061-4/+21
| | | | Still sucks, though..
* more configurable colorsKartik K. Agaram2021-12-061-18/+20
| | | | | Also start using 256 colors, under the assumption most people will have them.
* grey rather than harsh white backgroundKartik K. Agaram2021-12-041-2/+2
|
* start showing call stack on errorsKartik K. Agaram2021-12-041-19/+54
| | | | | | | | 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.
* another fix for colorsKartik K. Agaram2021-12-031-2/+2
| | | | | I'd assumed that assume_default_colors updates fg/bg -1, but it doesn't. Looks like I can't ever use -1 colors.
* less ambiguous menusKartik K. Agaram2021-12-031-5/+5
| | | | | Doesn't make sense to use '/' as a delimiter when we have hotkeys involving '/'.
* get rid of `Esc` hotkeyKartik K. Agaram2021-12-031-4/+4
| | | | | For a variety of historical reasons, terminals pause every time you press `Esc`. Let's get rid of that lag.
* improve support for backspaceKartik K. Agaram2021-12-031-4/+7
| | | | | | | 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.
* error message when no app is providedKartik K. Agaram2021-12-031-194/+6
| | | | Also strip out a bunch of Lua's commandline parsing.
* .Kartik K. Agaram2021-12-031-2/+3
|
* legible colors across all terminal configurationsKartik K. Agaram2021-12-031-1/+1
| | | | | | | | | | | | | 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.
* show state of screen on runtime errorKartik K. Agaram2021-12-031-0/+7
| | | | This is essential when debugging.
* .Kartik K. Agaram2021-12-031-1/+1
|
* extract a helperKartik K. Agaram2021-12-031-18/+32
|
* fix a slight portability issue, maybeKartik K. Agaram2021-12-021-1/+1
| | | | | | | | 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
* better cross-platform backspace supportKartik K. Agaram2021-11-301-4/+4
| | | | | | | | 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.
* .Kartik K. Agaram2021-11-291-7/+7
|
* fix regression in showing error messagesKartik K. Agaram2021-11-291-4/+4
|
* let people fix bad images from within TelivaKartik K. Agaram2021-11-291-10/+26
| | | | | | | | | Short of syntax errors that keep us from parsing the teliva_program table, we should now be able to recover gracefully from everything. Yesterday I started to try to add this to load_definitions before realizing most errors are only noticed while running `main`. But I didn't think of recovering from the docall of `main` until this morning.