Commit Graph

31 Commits

Author SHA1 Message Date
Kartik K. Agaram 5530995188 reliably exit on confirmation
Until now you had to press ctrl-x twice in rapid succession to exit if
an app turned on non-blocking keyboard with nodelay(true). This became
particularly noticeable after the previous change to anagrams.tlv, which
could no longer exit.
2022-03-05 14:44:37 -08:00
Kartik K. Agaram 057f4a2870 anagrams.tlv: slightly more responsive
Now we cancel screen-painting if any key is pressed.

However it looks like just computing the list of anagrams can take a
long time.
2022-03-05 09:47:47 -08:00
Kartik K. Agaram 9722f44a94 clearer copy for confirmation dialog 2022-03-03 22:25:43 -08:00
Kartik K. Agaram 2b50b7289e no further confirmation once editing commences 2022-03-03 21:43:22 -08:00
Kartik K. Agaram dd5bc9e3ac ask for confirmation on _any_ teliva shortcut
This feels more intrusive. Let's see how we like it. Will I start having
ctrl-x ctrl-x in my muscle memory?
2022-03-03 18:34:15 -08:00
Kartik K. Agaram afb3f46db7 always ask for confirmation on exit
Let's see if we can live with this rather than some way to let apps
indicate if they want confirmation or not..
2022-03-01 23:10:46 -08:00
Kartik K. Agaram 52372d1812 delete curses primitives to read whole lines
They make it seem like you can use them to create simple REPL apps, but
you can't, because standard Teliva shortcuts won't work.

I _could_ make them work by emulating them using getch(), but that feels
like an unnecessary abstraction for now.
2022-02-21 17:06:34 -08:00
Kartik K. Agaram 504573a0de move most Teliva menus to the right
The problem I'm running into is that apps might want to perform their
own editing. So I can't take up prime estate like the ctrl-e hotkey or a
menu name of 'edit'.

I'm still prioritizing rendering Teliva's edit and permissions menu. If
the window is too narrow the app's settings will be overwritten and
Teliva's hotkeys will be preferentially displayed. Seems safer.
2022-02-07 22:54:17 -08:00
Kartik K. Agaram 664b94f414 include keys typed into audit log
This will help people cross-correlate when the app performs specific
calls.
2022-02-01 21:19:51 -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 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 12cb565077 delete a couple more hacky function prototypes 2021-12-25 16:21:40 -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 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 d7a1792768 a couple more global curses bindings 2021-11-29 22:40:42 -08:00
Kartik K. Agaram fa52f129fb . 2021-11-29 22:06:54 -08:00
Kartik K. Agaram 36d3d10b1a let people fix bad images from within Teliva
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.
2021-11-29 08:16:47 -08:00
Kartik K. Agaram cec57992b7 start streamlining architecture
All the spaghetti is hiding another issue: when we load editor state,
that code path currently never leads to importing the edited buffer back
into the image.

Yet another attempt at drawing the state diagram:
  Wgetch -> switch_to_editor -> select_view
  select_view -> load_editor_state | big_picture_view
  load_editor_state -> edit_from -> editorProcessKeypress
  big_picture_view -> edit_image -> edit_buffer -> resumeEdit* -> load_editor_buffer -> editorProcessKeypress
  big_picture_view -> recent_changes
  recent_changes -> big_picture_view | edit_buffer

The problem is that load_editor_state doesn't eventually call
load_editor_buffer the way its sibling big_picture_view does.

For starters, it's confusing that switch_to_editor calls
big_picture_view which calls other editor functions. What is 'editor'
here, anyway?

Let's rename switch_to_editor to developer_mode. So the app starts out
in user mode, and might eventually transition to developer mode.
Developer mode is a black hole; to leave it and return to user mode we
restart the entire app.

The architecture in my mind is now:
  - Teliva consists of user mode and developer mode
  - Developer mode consists of multiple views
  - Each view, when it needs to edit something:
      - initializes kilo
      - loads a buffer into it
      - resumes editing the buffer as necessary
2021-11-28 14:07:44 -08:00
Kartik K. Agaram 8fd568647a clear editor state across user-visible restarts
Teliva's constantly restarting without the user being aware of it. So
far I figured saving history across the user actually exiting and
restarting Teliva was just a happy "feature". However, it looks like
that's actually more complex to implement. Keeping editor state across
user-visible restarts results in these problems:

- opening the editor after restart has the cursor position messed up, no
  matter what definition you open.
- more seriously, opening the editor after restart can't seem to get to
  the big-picture view anymore.

Rather than try to debug what's going on, I'm going to just cordon off
that part of the state space for now.
2021-11-28 11:38:06 -08:00
Kartik K. Agaram 41803e4afc use header everywhere 2021-11-28 11:11:30 -08:00
Kartik K. Agaram 7814c1c98a now building on OpenBSD
Still emitting a bunch of warnings on OpenBSD, though.
2021-11-27 07:58:58 -08:00
Kartik K. Agaram ff43b5bae1 fix build on Mac 2021-11-27 00:41:17 -08:00
Kartik K. Agaram f5221ba651 one more curses binding 2021-11-25 20:51:38 -08:00
Kartik K. Agaram 76329c0206 standardize warning flags everywhere
I'd like to enable -Wextra as well, but that creates some false
positives.

I've at least made my changes clean w.r.t. -Wextra.

Now we have 4 remaining warnings with gcc 9.3 that seem genuine. Need to
fix those.
2021-11-22 19:01:07 -08:00
Kartik K. Agaram d6ff198e78 get rid of a distracting name
No distinction now between the C and Lua versions of the curses library.
We build them all together in one place.
2021-11-20 16:33:41 -08:00
Kartik K. Agaram b618bfc7cf port changes from minimal to maximal version
From lcurseslib.c to lcurses/ directory.
2021-11-20 16:33:41 -08:00
Kartik K. Agaram b43747ecef inline lcurses maximally rather than minimally
Until now we had just the bare minimum bindings needed for the demos
built so far. Now we have all of lcurses building in place with minimal
changes.

The changes in this commit can run hanoi.lua when inlined into Lua 5.1,
but don't work with Teliva.
2021-11-19 19:11:03 -08:00