Commit Graph

527 Commits

Author SHA1 Message Date
Kartik K. Agaram 7a13adb52c try to get by with one feature macro
I fucking hate feature macros. Egregious discharge of our
division-of-labor-obsessed society. People should be able to introduce
names. People should be able to give up names to lower levels of
abstraction when they encounter conflicts.

Feature macros seem to exist[1] to support more than two levels of
abstraction. You try to build, one of your libraries fails to build
because of a conflict between it and one level down. You don't want to
modify this library. Just fucking https://catern.com/change_code.html
already. But no, I have to litter my code with feature macros even
though I just want the abstraction the original library provides.

[1] https://man7.org/linux/man-pages/man7/feature_test_macros.7.html
    https://lwn.net/Articles/590381
2022-01-29 12:41:20 -08:00
Kartik K. Agaram 24f0781d2b new library: luafilesystem (lfs)
https://github.com/keplerproject/luafilesystem

The new commander.tlv app demonstrates it working.
2022-01-29 12:39:53 -08:00
Kartik K. Agaram 90fc24ed04 fixup! redo lua vs prose
Forgot to include some hunks.
2022-01-29 12:22:32 -08:00
Kartik K. Agaram 1f620a28d7 more precise dependencies 2022-01-29 11:36:00 -08:00
Kartik K. Agaram e782cb1ead bugfix: editor was no longer saving anything
I made the changes reverted here out of a mistaken sense that
big-picture edits would interfere with Teliva's memory of what is
currently being edited (teliva_editor_state).
2022-01-27 00:40:33 -08:00
Kartik K. Agaram ce186e85f4 redo lua vs prose
Previously we weren't dynamically selecting how to highlight a buffer
after navigating with ctrl-g. That should work now.
2022-01-26 15:22:55 -08:00
Kartik K. Agaram 18183f3e4b indent 2022-01-26 15:20:55 -08:00
Kartik K. Agaram b493ed32b8 get Teliva working on FreeBSD 2022-01-26 09:36:06 -08:00
Kartik K. Agaram cbe85a18c7 rename the custom big picture view to doc:main 2022-01-25 23:25:05 -08:00
Kartik K. Agaram 32d86bfc7f override big picture view with doc:bp if it exists
Going to big picture from doc:bp still goes to the default
auto-generated big picture view.

While doc:bp provides some programmability, it's also far klunkier than
the default view. Rendering is worse, and it's always in edit mode
because I'm trying to avoid complicating the UX with a notion of
rendered markup. That means cursor movement is less convenient. It's
also easy to accidentally edit the big-picture view.
2022-01-25 23:07:43 -08:00
Kartik K. Agaram 7fd434a692 better default word at cursor for prose 2022-01-25 22:34:38 -08:00
Kartik K. Agaram e205057ff2 highlight [[wikiwords]] in prose
These are just hints that there's something worth jumping to. The
jumping still happens using ctrl-g.
2022-01-25 22:31:53 -08:00
Kartik K. Agaram 91d47faf23 disable Lua colors in prose 2022-01-25 21:44:01 -08:00
Kartik K. Agaram 84d76b11fa rename 2022-01-25 21:23:20 -08:00
Kartik K. Agaram 283d4dba59 new section in big picture: prose (non-code)
I've always found "Documentation" too pretentious.
2022-01-25 21:07:52 -08:00
Kartik K. Agaram 2fc48626b5 optimization: stop saving identical definitions
This is long overdue.
2022-01-25 20:53:46 -08:00
Kartik K. Agaram 2e38583da2 save doc: buffers to .tlv images 2022-01-25 20:45:00 -08:00
Kartik K. Agaram 39781351ee delete a redundant function prototype 2022-01-25 20:39:49 -08:00
Kartik K. Agaram d20e6a415f rename a function 2022-01-25 20:36:26 -08:00
Kartik K. Agaram c5f6e30042 start supporting non-code "buffers"
First step: when a "definition" starts with "doc:" it's not a
definition, just a buffer. Stop trying to interpret it as Lua.
2022-01-25 20:29:35 -08:00
Kartik K. Agaram 6d53235dfc work around a bug in NetBSD libcurses
http://gnats.netbsd.org/56664 reported.
2022-01-24 20:43:30 -08:00
Kartik K. Agaram 6a33284b07 get Teliva running on NetBSD
NetBSD still uses curses by default. One _could_ install ncurses, but I
don't have access to a NetBSD box with permissions to install ncurses,
so I'm experimenting to see how far we can get with just curses. So far
most of the apps seem to work, with the exception of one bug that I'll
commit next.
2022-01-24 20:15:43 -08:00
Kartik K. Agaram e4f934db6b delete some dead code
I'm kinda sorta able to get lcurses running on NetBSD 9.2 without this
particular hack.
2022-01-24 20:06:33 -08:00
Kartik K. Agaram a3a207d2e3 more generic build target in luasocket 2022-01-24 17:32:42 -08:00
Kartik K. Agaram 058145ee23 clarify generic 'bsd' build target
We still only have OpenBSD working.
2022-01-24 17:25:50 -08:00
Kartik K. Agaram 5258fbec7c file permissions: clear stale errors 2022-01-16 22:34:21 -08:00
Kartik K. Agaram 06edd8bda7 editing apps: clean up some stale prints 2022-01-16 22:33:41 -08:00
Kartik K. Agaram abc2ea4675 file access policy: support editing with >10 lines 2022-01-16 15:53:27 -08:00
Kartik K. Agaram 863f14041d kilo: cleaner go menu 2022-01-11 20:25:11 -08:00
Kartik K. Agaram 4eb4bc4f58 some heuristic guidance on permissions screen 2022-01-04 23:42:01 -08:00
Kartik K. Agaram ffd600b111 try running permissions advice after editing
This implies it must be side-effect free. We still need to figure out
how to convey that to the computer owner.
2022-01-04 22:33:07 -08:00
Kartik K. Agaram 855eafd1d9 slightly better error message 2022-01-04 22:09:42 -08:00
Kartik K. Agaram 64f8a1e15d reorg 2022-01-04 22:09:23 -08:00
Kartik K. Agaram 4798d97a15 feels more consistent to exit editor with ctrl-x 2022-01-04 21:52:23 -08:00
Kartik K. Agaram 08c1ea8fc4 extract function 2022-01-04 21:48:55 -08:00
Kartik K. Agaram 3d6b9b0adc load permissions properly in a third place 2022-01-04 21:41:41 -08:00
Kartik K. Agaram 4018c2e8e2 when editing a function, show its callers
No way to select between them. That complicates the UI too much when we
do so much with the cursor. But it's still useful to suggest things to
type in after ctrl-g.
2022-01-03 23:36:44 -08:00
Kartik K. Agaram 7812ebc5f1 start saving callers of functions
I think this is significantly slowing things down. Perhaps we should
sample or something.
2022-01-03 13:26:38 -08:00
Kartik K. Agaram 1c78ab3d2e comment 2022-01-03 13:24:21 -08:00
Kartik K. Agaram f6cf8f801c rename 2022-01-03 13:24:01 -08:00
Kartik K. Agaram 14ab0729c9 extract a function 2022-01-03 10:23:25 -08:00
Kartik K. Agaram 1261f3f3c9 events view: jump to a function 2022-01-03 09:58:34 -08:00
Kartik K. Agaram 0abd09dc05 rendering improvement 2022-01-02 22:52:57 -08:00
Kartik K. Agaram be0c936276 error handling when editing file permissions
Still highly non-ideal. Lua is a dynamic language, and has low ability
to detect syntax errors within functions.

Perhaps I should run a test call after every edit.
2022-01-02 22:51:27 -08:00
Kartik K. Agaram e3cef7ee56 bugfix: policies must end in newline
I believe kilo kinda naturally enforces that. We'll see.
2022-01-02 22:38:28 -08:00
Kartik K. Agaram b97291602b instrument some obvious syscalls 2022-01-02 22:36:33 -08:00
Kartik K. Agaram 49a03587ef indent 2022-01-02 22:20:48 -08:00
Kartik K. Agaram a901203227 start on a view of audit events 2022-01-02 22:13:47 -08:00
Kartik K. Agaram 74360f20be . 2022-01-02 21:39:53 -08:00
Kartik K. Agaram 2d0bb4438c editing file permissions 2022-01-02 21:33:49 -08:00
Kartik K. Agaram e07fe0c87a make some space for callers of a function 2022-01-02 20:56:09 -08:00
Kartik K. Agaram 78516d140f start parameterizing viewport for editor 2022-01-02 20:14:24 -08:00
Kartik K. Agaram 1fd7f4ad18 drop os.getenv 2022-01-02 19:59:49 -08:00
Kartik K. Agaram d0111f1839 editable file permissions
Extremely cruddy implementation:
- I'm still unclear on how to represent the advice function:
  - How to handle errors when loading user configuration?
    Currently I refuse to start.
  - Whole function? More errors to handle in header and so on. What if
    the function is renamed?
  - Just body? Needs more structured editing support.
- Lots of duplication, particularly between the permissions in the menu
  and the permissions screen.

I don't know how to show the hostname at the time of connect() or
bind(), so networking is going to remain a boolean for now. It's also
unclear what effective constraints we can impose on what gets discussed
with a specific hostname. Everything outside the computer is out of
one's control.

One trick I learned is for consistently grabbing ASan logs on abort:
It's always safe to redirect stderr with ncurses!
2022-01-02 19:59:30 -08:00
Kartik K. Agaram a2081ee612 fork a new editor widget for non-code 2022-01-02 16:55:23 -08:00
Kartik K. Agaram f6aaf2fd1d better follow kilo's naming conventions 2022-01-02 16:52:36 -08:00
Kartik K. Agaram 30a1fb202e start peeling out an editor for non-code 2022-01-02 16:48:00 -08:00
Kartik K. Agaram 18a499c5c0 . 2022-01-02 16:35:01 -08:00
Kartik K. Agaram 2b1609f09b copy tweak 2022-01-02 15:52:02 -08:00
Kartik K. Agaram df5cd41637 rename 2022-01-02 15:46:46 -08:00
Kartik K. Agaram f7b4413494 . 2022-01-02 15:15:10 -08:00
Kartik K. Agaram 762b77f68b sandbox: tweaks to warning copy 2022-01-02 12:49:31 -08:00
Kartik K. Agaram 6859450182 sandbox: color tweaks 2022-01-02 12:47:24 -08:00
Kartik K. Agaram 40a0aca6e3 spacing 2021-12-26 00:04:28 -08:00
Kartik K. Agaram 3040ede3c8 undo accidental color scheme commit 2021-12-25 22:07:15 -08:00
Kartik K. Agaram 04a062e94d start persisting sandboxing settings
Zero guarantees of compatibility at this point.
2021-12-25 21:36:31 -08:00
Kartik K. Agaram e7dc519c40 reorg 2021-12-25 21:26:47 -08:00
Kartik K. Agaram 6ae7bf91b1 network calls are now sandboxed
I _think_ I don't need to gate other socket calls; you can't do anything
without bind() and connect(). And they should be good places to dump
more precise details later about the kind of server or client connection
being attempted.
2021-12-25 20:43:19 -08:00
Kartik K. Agaram 16d949e259 file open() is now sandboxed
In the process we now also have a mechanism for Teliva to overlay errors
while apps run. Might make sense to make that available to apps as well.
But I'm starting to realize that any app access to the Teliva areas of
the screen is fraught with risk.
2021-12-25 18:55:01 -08:00
Kartik K. Agaram f5ab71b4e1 flesh out very preliminary UI
Our sandboxing model is a blunt caricature, just two booleans. But let's
see how far this gets us.

Still doesn't persist, and definitely has no effect.
2021-12-25 18:51:05 -08:00
Kartik K. Agaram 8458ba0202 fix a couple of colors 2021-12-25 16:43:50 -08:00
Kartik K. Agaram 12cb565077 delete a couple more hacky function prototypes 2021-12-25 16:21:40 -08:00
Kartik K. Agaram dbbb396003 . 2021-12-25 16:16:48 -08:00
Kartik K. Agaram a36edb74f0 mock sandbox status and some initial colors
Current plan:
  - two booleans to gate file and network access, respectively
  - false shows as green, true shows as orange
  - if _both_ booleans are true, then both show as red to indicate that
    there are no protections.
2021-12-25 16:08:31 -08:00
Kartik K. Agaram 2b5559d8eb update all places when changing color scheme 2021-12-25 15:14:33 -08:00
Kartik K. Agaram 526d37e4ac fix menu colors in all color schemes
It looks like attron doesn't actually enable colors near 256, even
though https://linux.die.net/man/3/attron suggests it does.

  > COLOR_PAIR values can only be OR'd with attributes if the pair
  > number is less than 256.
2021-12-25 14:59:18 -08:00
Kartik K. Agaram 434d36f81f a little more reorg
Put stuff people messing with Teliva apps are likely to need above the C
interface.

The state of documentation for Teliva app creators is still quite poor.
All they really have to go on is the example apps.
2021-12-25 13:44:07 -08:00
Kartik K. Agaram bb6e79aa0d reorg: pull Teliva-specific stuff out of lua.c
It should now be easier to diff against the Lua 5.1 sources upstream.
2021-12-25 13:33:37 -08:00
Kartik K. Agaram 1e63a579d7 drop stdin/stdout/stderr and Lua default files
This isn't necessarily for sandboxing, but they don't really work right
now in the presence of ncurses, and it seems better to not include
broken stuff. Maybe we can get them to coexist with ncurses down the
road.
2021-12-25 11:35:50 -08:00
Kartik K. Agaram 917646fc9f sandbox: no popen
Again, too difficult to sandbox for now.
2021-12-25 11:04:23 -08:00
Kartik K. Agaram 6af91eb0d2 tlv format for transient editor state
Stop interpreting arbitrary Lua code when loading editor state. We don't
need that power or security risk.
2021-12-25 09:27:44 -08:00
Kartik K. Agaram 1b25d58a4f sandbox: no system()
Too hard to sandbox. Maybe we'll get back to it if there's some use case
only it can satisfy.
2021-12-25 08:22:15 -08:00
Kartik K. Agaram 916857dae0 cleaner test message
Was printing over passing tests for some reason.
2021-12-23 12:30:28 -08:00
Kartik K. Agaram 348945321d errors during tests are now handled
I should have documented that I'd never actually seen that code path
trigger before. Here's a minimal test that did it just now:

  function test_foo()
    return a+1
  end

  E2: [string "test_foo"]:2: attempt to perform arithmetic on global 'a' (a nil value)

A simple missing variable doesn't do it since it just evaluates to nil.

Without this commit, the above test was silently continuing to the main
app after failing tests.
2021-12-22 15:09:57 -08:00
Kartik K. Agaram 343316dcfa more precise control over menu order
I can't believe I didn't notice this until now.
2021-12-22 00:27:50 -08:00
Kartik K. Agaram 3dda99014c fix arrow keys in big picture view on Mac
Turns out arrow keys are considered `isprint()` on Mac.
2021-12-21 23:50:56 -08:00
Kartik K. Agaram 712d80e48a bugfix: ensure definition to edit has some name 2021-12-21 21:18:16 -08:00
Kartik K. Agaram 7cf65a3bea less confusing name 2021-12-21 19:59:15 -08:00
Kartik K. Agaram 577d47a6a7 arrow keys in big picture view 2021-12-21 19:53:32 -08:00
Kartik K. Agaram 3a20c0e227 gemini: echo urls while typing in
Let's see how much we need to tweak this solution.
2021-12-21 17:52:31 -08:00
Kartik K. Agaram 41bf615f43 nail down trusted Teliva channels a little more
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.
2021-12-21 15:47:55 -08:00
Kartik K. Agaram 609730071e keep Teliva apps from pretending to be Teliva
Kind of a subtle idea. Teliva the framework is intended to be
trustworthy software that people install on their computers. The apps
people run using Teliva may be less trustworthy. The whole point of
Teliva is to provide a sandbox for running code before you trust it.

One way (of many) apps can be malicious is by subtly getting between
what people see and reality. Imagine, for example, an app that draws a
fake menu bar and offers a different hotkey to edit source code. When
someone presses that hotkey they think they're using the standard Teliva
editor but they're really using an editor within the app, which the app
uses to hide its most malicious bits from view.

Down the road Teliva will have more bits of UI, such as for asking for
permission to read sensitive data. It's important that people understand
what they're granting permission to, that apps can't tamper with the
communications channel between them and Teliva.

This is likely just one of many ways for an app to break out of its
sandbox. Teliva isn't sandboxed yet. I'm just taking my first steps on
this journey. In particular, there are other mechanisms for asking for
user input besides `getch()`. I don't yet have a big-picture view of the
Teliva sandbox.

It seems clear that I need to educate people on the difference between
different parts of screen. Depending on the app you install, most of the
screen may be a dark forest. It'll be important to know where the safe
path is, where you can speak to trusted advisors while in the forest.
2021-12-21 15:27:34 -08:00
Kartik K. Agaram d818efb7c8 pay more attention to where we display the cursor
It's still just in app control; I'm resisting the urge to introduce
"smarts".
2021-12-18 09:32:37 -08:00
Kartik K. Agaram 191538baf7 drop ASan from Makefile
Accidentally added at some point. It's a useful debugging aide, but I
don't want to require the additional dependencies on a first run.
2021-12-18 07:58:18 -08:00
Kartik K. Agaram 1d9a4fa1d5 ctrl-u: clear prose 2021-12-17 23:19:59 -08:00
Kartik K. Agaram caccafbc2c better copy on test failures 2021-12-17 22:38:00 -08:00
Kartik K. Agaram d6129cd571 correct count of test failures 2021-12-17 22:35:21 -08:00
Kartik K. Agaram 42b1bd842c keep tests from messing up big picture 2021-12-17 22:23:18 -08:00
Kartik K. Agaram c12ba48a63 one more protection against Lua stack leak 2021-12-17 22:23:18 -08:00
Kartik K. Agaram 92fe487349 experimental support for test errors 2021-12-17 22:23:17 -08:00
Kartik K. Agaram 580501b342 start of a test framework
Follows https://github.com/akkartik/wart, https://github.com/akkartik/mu0,
https://github.com/akkartik/mu1 and https://github.com/akkartik/mu.
2021-12-17 22:23:17 -08:00
Kartik K. Agaram 3921337b3f yet another stab at reorganizing stack assertions 2021-12-17 21:32:32 -08:00
Kartik K. Agaram a617b3e5ac . 2021-12-17 11:37:34 -08:00
Kartik K. Agaram 166c8e0ca0 . 2021-12-17 08:55:08 -08:00
Kartik K. Agaram 12b0a2a7b6 more protection against data loss 2021-12-17 08:46:11 -08:00
Kartik K. Agaram 59ef5da1d9 . 2021-12-17 08:39:31 -08:00
Kartik K. Agaram 18f9f4e4f4 protect against data loss in some rare situations
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.
2021-12-16 21:27:45 -08:00
Kartik K. Agaram 2a6786fee5 fix another leak in the Lua stack
This fixes a segfault when scanning through a long history of recent
changes (say > 20 changes)
2021-12-16 20:53:50 -08:00
Kartik K. Agaram f979002939 more consistently show notes in recent changes
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.
2021-12-16 20:22:12 -08:00
Kartik K. Agaram 65b38f96ba stop leaking on the Lua stack, redux
An empty stack is too rigorous a line to hold. Instead we'll just ensure
we leave the stack the way we found it.
2021-12-16 20:07:59 -08:00
Kartik K. Agaram 76ed8d30f4 Revert "stop leaking on the Lua stack"
This reverts commit 7c1b9d0b91.

The 'big hammer' isn't good enough. The recent changes view seems to
need state on the stack across invocations of the editor.
2021-12-16 04:02:37 -08:00
Kartik K. Agaram 7c1b9d0b91 stop leaking on the Lua stack
..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.
2021-12-16 02:50:32 -08:00
Kartik K. Agaram b425593af6 show all functions in big picture
We were missing functions in some larger programs.
2021-12-13 09:59:52 -08:00
Kartik K. Agaram f315e1d76a can again edit notes on changes 2021-12-11 15:30:33 -08:00
Kartik K. Agaram b9877fabdc . 2021-12-11 14:59:00 -08:00
Kartik K. Agaram 5c68906303 handle non-existent file 2021-12-11 14:01:34 -08:00
Kartik K. Agaram d25c37f86b bring back commandline args 2021-12-11 10:36:35 -08:00
Kartik K. Agaram c0c9d31688 snapshot: migrate all sample apps to new format 2021-12-11 10:22:53 -08:00
Kartik K. Agaram d5038fe514 snapshot: writing working?
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?
2021-12-11 09:37:23 -08:00
Kartik K. Agaram 052c5501ac snapshot: key/value lines after multiline strings 2021-12-11 07:20:04 -08:00
Kartik K. Agaram 0b0a58da06 snapshot: start reading a new format
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.
2021-12-11 00:43:26 -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 74fd78c5b7 . 2021-12-07 23:45:04 -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 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 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 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