Commit Graph

38 Commits

Author SHA1 Message Date
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 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 ef9c42084d switch menu bars to reverse video 2021-11-07 10:29:29 -08:00
Kartik K. Agaram 2b7ffea316 fix menu colors
I had it switching to a dark background on me.
2021-11-07 08:06:42 -08:00
Kartik K. Agaram 40fdaf2a2a more obvious phrasing
Early returns are only worthwhile if they're utterly obvious.
2021-11-07 06:30:15 -08:00
Kartik K. Agaram 51d6ae77d2 fix a regression in commit ee85ad384f 2021-11-07 06:28:24 -08:00
Kartik K. Agaram d79c83f209 . 2021-11-07 06:05:55 -08:00
Kartik K. Agaram 8d1e5f6475 . 2021-11-06 19:21:10 -07:00
Kartik K. Agaram 5619f0117a window:nodelay() for non-blocking input 2021-11-06 19:21:01 -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 2964a5e74a refactor menu drawing 2021-11-06 12:41:14 -07:00
Kartik K. Agaram 52d73ff930 clean up first paint of editor 2021-11-05 22:40:12 -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 5da9f27079 menu entry: cleanly exit 2021-11-05 19:50:12 -07:00
Kartik K. Agaram ee3f6e8a22 colors: init_pair/color_pair 2021-11-05 19:43:40 -07:00
Kartik K. Agaram 6c9e26e07c . 2021-11-05 19:26:05 -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 78898d2716 move getch out of window scope
The window only matters for output, which seems like a stupid interface.
2021-11-05 17:54:45 -07:00
Kartik K. Agaram c0307fae88 resist the temptation to add to the Lua API
Instead we'll include code in the Lua app itself, to minimize the
differences between what runs on regular Lua and what runs on Teliva.
2021-11-05 16:41:31 -07:00
Kartik K. Agaram d04ecfeaf3 hanoi.lua _almost_ working 2021-11-05 13:34:38 -07:00
Kartik K. Agaram 44258f7657 window:getch()
But how do we get curses.getch() to work?
I don't see it implemented in lcurses.
2021-11-05 13:23:14 -07:00
Kartik K. Agaram b882d405ca curses print constants
Very satisfying to debug the difference between lcurses putting the
module table in an upvalue. Since I implicitly call initstr() rather
than define it as a primitive, I don't need to bother with that. I am
awesome. Lua is awesome for giving me that sense.
2021-11-05 13:13:25 -07:00
Kartik K. Agaram a7351c723e grouping 2021-11-05 13:08:12 -07:00
Kartik K. Agaram 13784eb757 mvaddch/mvaddstr
I think we now have all the output functions/methods we need. Just some
constants remaining.
2021-11-05 12:57:13 -07:00
Kartik K. Agaram 6f96d30641 attron/attroff 2021-11-05 12:48:27 -07:00
Kartik K. Agaram a4ce7ffbd0 window:getmaxyx() 2021-11-05 12:25:31 -07:00
Kartik K. Agaram 595a963671 . 2021-11-05 12:21:16 -07:00
Kartik K. Agaram debe292277 window:clear() 2021-11-05 12:16:31 -07:00
Kartik K. Agaram d1c9bff737 reindent
I'm trying to follow the style of lua sources even when they're not my
preference. lcurses code is a bit different.
2021-11-05 12:06:14 -07:00
Kartik K. Agaram ffaf456654 ohh, that word 'index' was key 2021-11-05 12:03:27 -07:00
Kartik K. Agaram ac6c9319f9 oh, that's just a cosmetic thing
So why isn't this working?
  a = curses:stdscr()
  a:addstr(abc)

The error is "attempt to index global 'a' (a userdata value)"
2021-11-05 12:00:37 -07:00
Kartik K. Agaram f2d61064fb copy metatable name from lcurses
Makes no difference to the results of:
  print(curses:stdscr())
2021-11-05 11:54:55 -07:00
Kartik K. Agaram c4c3b93bf5 snapshot
Not quite working. curses.stdscr() is returning userdata, not a window.

This is true even of the raw array example from the book. So we need to
learn something new here. How does lcurses's Pinitscr return a special
window object? From what I can tell it's just putting the results of
lc_newwin() on the stack. Which is the same as my curses_newwin() here.
2021-11-05 11:46:47 -07:00
Kartik K. Agaram f761d0ae36 stdscr binding
print(curses.stdscr())
print(curses:stdscr())
2021-11-05 10:51:47 -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