Commit Graph

33 Commits

Author SHA1 Message Date
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
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
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
dc05a10e23 life: move starting pattern around on the screen
This assumes we're doing it early soon after opening a new pattern, when
it hasn't yet reached the margins. Quick and dirty, but seems good
enough.
2021-11-10 14:26:38 -08:00
Kartik K. Agaram
22f1624728 better support light backgrounds
Thanks nicolas decoster for reporting this issue.
2021-11-07 08:04:33 -08:00
Kartik K. Agaram
a8668eaf9f game of life
This required me to figure out some unicode-related nuances, but no new
primitives.
2021-11-06 21:49:23 -07:00
Kartik K. Agaram
62ecf17870 escape hatch to quit with a pending error 2021-11-06 14:41:11 -07:00
Kartik K. Agaram
cba53ec9f6 reorg editor transitions 2021-11-06 13:22:05 -07:00
Kartik K. Agaram
3305ac0b90 start showing error messages in editor
Before we'd end up in cryptic situations where error messages would get
hidden when the program got out of ncurses mode.

Now it's a little nicer with error messages showing up at the bottom of
the editor.

But there's still a problem: there's no way to abort without fixing an
error.
2021-11-06 13:10:22 -07:00
Kartik K. Agaram
ee85ad384f simple interface for adding to app menu
We're not going to enforce that the menu items actually do what they
advertise. It's just a way to draw on the bottom line of screen,
something apps aren't otherwise allowed to do.
2021-11-06 12:44:47 -07:00
Kartik K. Agaram
6fc0e72cb3 utterly ghastly way to rerun script after edit 2021-11-05 22:39:36 -07:00
Kartik K. Agaram
6b8da095b1 stitch editor in 2021-11-05 22:12:24 -07:00
Kartik K. Agaram
dd434b2e1c drop test array data structure 2021-11-05 22:09:15 -07:00
Kartik K. Agaram
4ad3390ce3 . 2021-11-05 22:07:46 -07:00
Kartik K. Agaram
ee3f6e8a22 colors: init_pair/color_pair 2021-11-05 19:43:40 -07:00
Kartik K. Agaram
cab996b194 make some space for the global menu
We'll eventually need some interface to add entries to it.
2021-11-05 18:43:37 -07:00
Kartik K. Agaram
bf7baffa30 metatables seem to be a separate namespace from globals 2021-11-05 11:52:59 -07:00
Kartik K. Agaram
8552ad4ced starting on curses library
First piece of working new vocabulary:
  print(curses:cols())

Just pulling in code from lcurses for the most part. But I'm trying to
understand its internals as I gradually add them in, after my more blunt
first approach of packaging up lcurses/ext failed.

Overall plan for Teliva's API:
- start out with a 'curses' library that does what people who are used
  to ncurses/lcurses expect.
- over time create a more opinionated library called 'screen' or
  'window' or something.
2021-11-05 10:30:07 -07:00
Kartik K. Agaram
37b05c2957 https://www.lua.org/pil/28.3.html
a = array.new(1000)
for i=1,1000 do
  a:set(i, 1/i)
  end
print(a:get(10))  -- 0.1
2021-11-05 09:17:54 -07:00
Kartik K. Agaram
b4d86665b8 https://www.lua.org/pil/28.2.html 2021-11-05 08:54:19 -07:00
Kartik K. Agaram
f53ca6f804 confirmed that this is the same
And it seems simpler to me.
2021-11-05 08:31:43 -07:00
Kartik K. Agaram
712dc16b23 going through chapter 28 of https://www.lua.org/pil
User-defined C data.

I think I have some understanding of the Lua stack now. It's a different
kind of verbose, error-prone syntax than Mu that requires me to play
computer in my head. But I don't fully grok metatables yet. At least not
well enough to grok everything that's going on in lcurses/ext.
2021-11-05 08:31:43 -07:00
Kartik K. Agaram
e35454c9a8 I don't yet understand the stack 2021-10-24 14:20:37 -07:00
Kartik K. Agaram
c80bafed74 trying to make sense of how bindings are created
lua_State contains these StkId fields (stack, stack_last, base, top)
that expand to a pointer of a struct containing a Lua value and an int.
Unclear how it's used, or how you build a stack out of it.
2021-10-24 09:23:54 -07:00
Kartik K. Agaram
9792ac1e09 drop support for '-' filename
lua.c now no longer refers to stdin/stdout/stderr.
2021-10-22 21:00:26 -07:00
Kartik K. Agaram
1445cbc5b1 ncurses I/O in lua.c
Currently working:
  > print(1)
  1
   > print(2)
  2

Print's newline doesn't return to column 0 yet.

Ctrl-d no longer works. Ctrl-c exits cleanly.
2021-10-22 20:54:34 -07:00
Kartik K. Agaram
d92a484b91 kill lua_readline abstraction 2021-10-22 20:37:56 -07:00
Kartik K. Agaram
9eb951608b purge notion of commandline history 2021-10-22 20:30:13 -07:00
Kartik K. Agaram
74f8cd15bb new fork of Lua 5.1
https://www.lua.org
2021-10-22 19:24:44 -07:00