Commit Graph

219 Commits

Author SHA1 Message Date
Kartik K. Agaram e990682fb2 . 2021-11-13 22:48:14 -08:00
Kartik K. Agaram 55302fd877 . 2021-11-13 22:45:44 -08:00
Kartik K. Agaram a0dbc38c34 generalize kilo's hard-coded multiline C syntax 2021-11-13 22:39:28 -08:00
Kartik K. Agaram 308cb7acbe . 2021-11-13 22:02:30 -08:00
Kartik K. Agaram 485cd25739 fix for editor highlighting
Bug introduced during the transition to ncurses.
2021-11-13 22:00:50 -08:00
Kartik K. Agaram a7139a6b14 clean up after the editor
Even though we don't need to leave ncurses mode, there's still a process
boundary to clean up before.
2021-11-13 21:33:12 -08:00
Kartik K. Agaram da76ec44f1 . 2021-11-13 21:25:52 -08:00
Kartik K. Agaram 88f4b1bb2b . 2021-11-13 21:23:14 -08:00
Kartik K. Agaram 90f86daf1c kill highlighting flags
Looks like they were never used in original Kilo.
2021-11-13 21:20:30 -08:00
Kartik K. Agaram a655059c8d replace Kilo's raw terminal handling with ncurses
This was on my todo list. What made it urgent was finding that calling
getch() even once while in ncurses caused Kilo to stop detecting arrow
keys. No need to debug that sort of nonsense.
2021-11-13 21:20:30 -08:00
Kartik K. Agaram 625a66e196 avoid side-effects on the Lua stack 2021-11-13 17:48:04 -08:00
Kartik K. Agaram 12b2a44cf6 stop leaking memory 2021-11-13 17:46:08 -08:00
Kartik K. Agaram 398112f756 memory corruption bug
I was saving an address on the stack to a global, and it was getting
clobbered later. This is the sort of thing I completely eliminated in
https://github.com/akkartik/mu :/

Now I'm taking a leaf out of the Mu playbook and leaking a little bit of
memory every time I switch definitions.
2021-11-13 17:42:39 -08:00
Kartik K. Agaram 51378afb2a . 2021-11-13 16:53:39 -08:00
Kartik K. Agaram c34db20756 very rudimentary definition browser
Never shows definitions that were never called. Including non-functions.
2021-11-13 16:36:12 -08:00
Kartik K. Agaram 7a24bed432 . 2021-11-13 16:28:13 -08:00
Kartik K. Agaram 998e666958 . 2021-11-13 16:13:05 -08:00
Kartik K. Agaram 5bf5e47077 . 2021-11-13 16:13:05 -08:00
Kartik K. Agaram 647a2520d6 shield kilo.c from teliva_editbuffer detail 2021-11-13 16:13:05 -08:00
Kartik K. Agaram ee0e7c36f5 . 2021-11-13 15:11:03 -08:00
Kartik K. Agaram 4e62aa95b0 . 2021-11-13 15:07:28 -08:00
Kartik K. Agaram cbd5e7d552 . 2021-11-13 15:07:14 -08:00
Kartik K. Agaram e06a7b1a7b . 2021-11-13 15:00:49 -08:00
Kartik K. Agaram 33b705282d . 2021-11-13 14:59:22 -08:00
Kartik K. Agaram 7623e7069a clean up experiment from previous commit 2021-11-13 10:10:16 -08:00
Kartik K. Agaram 5a44605143 instrumenting function calls with their depth 2021-11-13 08:16:41 -08:00
Kartik K. Agaram 0f4faf0e53 start using static linkage like the rest of Lua 2021-11-13 05:14:41 -08:00
Kartik K. Agaram 49a09cceec learning about Lua's debug infrastructure
https://www.lua.org/pil/23.2.html
2021-11-11 22:05:15 -08:00
Kartik K. Agaram d72eae5978 create empty file when navigating to empty definition 2021-11-11 17:41:37 -08:00
Kartik K. Agaram e7f33de81e fix incorrect hotkey in menu 2021-11-11 17:32:50 -08:00
Kartik K. Agaram f6c7bf6fd0 ctrl-g to edit a different definition 2021-11-11 17:29:40 -08:00
Kartik K. Agaram 4d20e71c80 gracefully handle missing definition 2021-11-11 17:04:29 -08:00
Kartik K. Agaram 8398f8e2d1 . 2021-11-11 17:00:18 -08:00
Kartik K. Agaram a76cd9067a global for current definition being edited 2021-11-11 16:47:09 -08:00
Kartik K. Agaram d303c6efb0 pass lua_State into editor 2021-11-11 16:42:02 -08:00
Kartik K. Agaram 0d6378aa51 delete a helper that hides stack side effects 2021-11-11 16:32:08 -08:00
Kartik K. Agaram 7b389ce41e extract a few helper functions 2021-11-11 16:16:55 -08:00
Kartik K. Agaram 2d05f5090f . 2021-11-11 16:15:06 -08:00
Kartik K. Agaram 15e0ac70f9 . 2021-11-11 16:09:46 -08:00
Kartik K. Agaram 3e7ff252af reorg 2021-11-11 15:50:52 -08:00
Kartik K. Agaram 1f6ac6597c . 2021-11-11 08:56:45 -08:00
Kartik K. Agaram f43a1c7da0 edit a single hard-coded definition in the image
src/teliva counter.tlv
C-e  # switch to editor
C-e  # save and quit
C-x  # exit

counter.tlv now has the same logical contents, though the whitespace has
changed, and the order of keys is different.

The implementation is utterly ghastly. For one, I'm unnecessarily
interfacing with kilo through the file system.
2021-11-10 23:20:59 -08:00
Kartik K. Agaram 3d6c80e08e . 2021-11-10 22:40:36 -08:00
Kartik K. Agaram 9a49b92703 . 2021-11-10 22:15:13 -08:00
Kartik K. Agaram efbb57d339 new .tlv image format
Plan is for this to be the default representation for Teliva programs.
Text-friendly but not meant to be edited directly as text. Will
eventually include both code and data definitions, both current snapshot
and past revision history.

Right now .tlv files seem to run. Error checking is non-existent,
because I don't understand Lua's idioms around 'status' yet. Opening the
editor expectedly segfaults.

This commit is the most mind-bending bit of code I've written in a long
time.
2021-11-10 22:09:12 -08:00
Kartik K. Agaram 8dcf08565d main function for other apps besides life.teliva 2021-11-10 16:48:42 -08:00
Kartik K. Agaram 0344a4c9a1 extract side-effect from 'update' 2021-11-10 16:39:33 -08:00
Kartik K. Agaram d5e2d7a0fd .
one more implication:
- the menu table. It feels natural to define it alongside keyboard
  input. However, it may then not be initialized during the first paint
  of the app.

I'm not sure how I feel about the menu data structure being defined far
away from the `update` function. Recipe for it to go out of date.
2021-11-10 16:36:01 -08:00
Kartik K. Agaram aec68ea8a2 no, initialize globals in symmetry with functions
Current plan: definitions can have arbitrary code. They'll be loaded
lazily when a specific name is invoked but has no binding. Implications:

- It'll be the responsibility of the code to define the name it's saved
  in. "Phony" names will result in some fragments of code repeatedly
  executing.

- Assigning a global to nil is a way to retrigger its initialization the
  next time it's needed.

I'm not sure how I feel about this sort of incompatibility with Lua. I
suppose we could avoid it by also tracking what definitions have already
been loaded in a run.
2021-11-10 16:28:37 -08:00
Kartik K. Agaram 82ffc6e20c put all code into some function 2021-11-10 15:56:05 -08:00