Commit Graph

1902 Commits

Author SHA1 Message Date
Kartik K. Agaram 3e72787ade clean up debug prints 2023-09-15 11:04:48 -07:00
Kartik K. Agaram c4d8a9b6c5 bugfix: crash when naming points in a drawing
This only happens when pressing C-n inside a drawing in normal (not
maximized) mode.

The reason is complicated. First, the baseline:
  * When pressing C-o:
      run.keychord: starty is not nil
      run.keychord: current drawing is nil
      Drawing.keychord C-o: doesn't set current drawing
      plan_draw (only happens in normal mode): clears starty in all lines
      Drawing.update: all good ✓

  * When pressing C-n:
      run.keychord: starty is not nil
      run.keychord: current drawing is nil
      Drawing.keychord C-n: sets current drawing  <===
      plan_draw: clears starty in all lines
      Drawing.update: BOOM

Ugh.

When is starty set? Drawing.draw. This is why I can clean it up with
abandon. But:
  frame = events -> update -> draw

  * plan_draw clears starty while processing events
  * Drawing.update blows up in here               <===
  * Drawing.draw is about to set starty

So one possible interpretation here is that this is an unfortunate
interaction of two special-cases:
  * draw should never mutate state, but it's just the most convenient
    place to track starty
  * keystrokes never set current drawing -- except rare operations like
    naming and moving points

So the current prescription: any code called from within update needs to
protect against starty being nil.

Ugh X-(
2023-09-15 10:25:10 -07:00
Kartik K. Agaram bafc45b028 bugfix: crash when using mouse wheel
All the Text functions assume the cursor is always on a text line. I was
violating that invariant.

* When scrolling up, I start the cursor at the top-most line below the
  screen top.

* When scrolling down, I start the cursor at the top-most line below the
  screen bottom.

  I think it would feel slightly more natural for it to be the
  bottom-most line above the screen bottom.

  However, the Text functions maintain an invariant that the bottom-most
  line in a buffer will be text. There's no such invariant for the
  top-most line.
2023-09-15 08:52:39 -07:00
Kartik K. Agaram 0a12e4c733 change a helper slightly 2023-09-15 08:46:36 -07:00
Kartik K. Agaram 0e20565e17 clean up a slight jitter when drawing circles
Earlier the ghost while drawing wouldn't quite match the final shape.
Now the math is identical in draw_pending_shape.

It's a little unfortunate that we have this duplication of formulae.

At least there are no other stray calls of App.mouse_x in
draw_pending_shape.
2023-09-15 08:30:15 -07:00
Kartik K. Agaram ed909668f3 Merge pensieve.love 2023-09-14 22:38:23 -07:00
Kartik K. Agaram 052613c2b6 Merge lines.love 2023-09-14 22:37:16 -07:00
Kartik K. Agaram 1fd30c0462 always show line numbers in source editor
The drawing buttons are now absolutely positioned, which is a horrible
hack. But for just the source editor it seems good enough. The
alternative is to modify magic constants in all the tests :/
2023-09-14 22:27:38 -07:00
Kartik K. Agaram 5cb4be8a72 Merge pensieve.love 2023-09-10 21:56:08 -07:00
Kartik K. Agaram 985016af88 Merge lines.love 2023-09-10 21:54:52 -07:00
Kartik K. Agaram 7062963888 Revert "deemphasize the source editor"
Now that we have decent error handling, I think we can encourage people
to press ctrl+e again.

This reverts commit 4b43e9e85d.
2023-09-10 21:45:59 -07:00
Kartik K. Agaram d88239dde4 Merge pensieve.love 2023-09-09 09:39:27 -07:00
Kartik K. Agaram 12ae4f3e98 Merge lines.love 2023-09-09 09:34:44 -07:00
Kartik K. Agaram 790b7f18db yet another bugfix X-(
This time it really does work with pensieve.love
2023-09-09 09:27:56 -07:00
Kartik K. Agaram 0016d668bc two bugfixes
Annoying dangers of testing in one fork and committing upstream
(where it isn't used yet).
2023-09-09 09:09:14 -07:00
Kartik K. Agaram bcd7f6b598 new primitives for reading/writing files
These are like versions in nativefs, but only support absolute paths.
I want to be thoughtful about the precise location at each call-site.

It's a little ugly that app.lua now has a dependency on file.lua. Or
source_file.lua for the source editor.
2023-09-09 08:56:21 -07:00
Kartik K. Agaram 31266e23f5 reorder 2023-09-09 08:27:27 -07:00
Kartik K. Agaram 8146373756 Merge pensieve.love 2023-09-08 16:08:55 -07:00
Kartik K. Agaram c0e0e3fa0a more bugfixes to file search 2023-09-08 16:03:28 -07:00
Kartik K. Agaram 6e3c8f555b Merge pensieve.love 2023-09-08 15:32:25 -07:00
Kartik K. Agaram 4512f67aae get search working again
In the process, I'm getting rid of the search/ directory that cached
results and that I never ever used. This might pose an additional
migration issue: someone might need to `rm -rf` the `search/`
subdirectory in their notes.
2023-09-08 15:28:38 -07:00
Kartik K. Agaram 4729119350 Merge pensieve.love 2023-09-08 14:31:03 -07:00
Kartik K. Agaram 209dc38a9b change how we provide the notes directory
Before:
- notes directory is saveDir/data by default
  where saveDir = love.filesystem.getSaveDirectory()
- providing a commandline arg of x makes the notes directory saveDir/data.x

Now:
- there is no default directory; you get an error message instead
  telling you what to do.
- the commandline arg is the (preferably absolute) path of the notes
  directory you want to load

Unchanged: once you set the notes directory it gets remembered for
future runs.

Now the Readme is a lot simpler.

I tried to make migrating simpler, but this is complicated enough (see
Manual_tests.md)
2023-09-08 14:20:42 -07:00
Kartik K. Agaram f1b6580dc2 Merge lines.love 2023-09-08 14:11:07 -07:00
Kartik K. Agaram 87ea2af2da a few more testable file-system operations 2023-09-08 14:03:40 -07:00
Kartik K. Agaram 11d2a917f5 get rid of commandline args
Now pensieve.love always manages notes in the data/ subdirectory of the
save dir, and stores its settings in the 'config' file in the save dir.

And main.lua is now much more similar to upstream and most forks. I made
this edit using an external editor, just to keep the comparison with
lines.love in view.
2023-09-08 08:36:54 -07:00
Kartik K. Agaram 5f6184baa4 get rid of old_columns
It was a security blanket to get me to start deleting columns, and I've
never used it once.
2023-09-08 08:16:29 -07:00
Kartik K. Agaram 85a1ee9ee0 document a global constant 2023-09-08 08:01:38 -07:00
Kartik K. Agaram 3fc227e19c typo 2023-09-07 22:23:50 -07:00
Kartik K. Agaram 58fcaac2eb Merge pensieve.love 2023-09-04 15:20:26 -07:00
Kartik K. Agaram 20ec9799f6 Merge lines.love 2023-09-04 15:18:54 -07:00
Kartik K. Agaram e74b92b733 show any error after switching to source editor
Error_message is a special global. It's set when the app (Current_app = 'run')
encounters an error and switches to the source editor, and cleared when
switching from source editor back to the app.
2023-09-04 15:07:54 -07:00
Kartik K. Agaram 0bfcfd0f7d Merge pensieve.love 2023-09-04 14:02:17 -07:00
Kartik K. Agaram f274099b65 Merge lines.love 2023-09-04 13:58:58 -07:00
Kartik K. Agaram adfe94b9fc switch to source editor on error
If we're already in source editor we'll quit as before.

It's ugly that app.lua now knows about run.lua. But it's a start.
2023-09-04 13:07:53 -07:00
Kartik K. Agaram 99495355b4 stop using keyboard.isDown
It doesn't work on Android, and it's not much work to avoid.
2023-09-04 00:22:31 -07:00
Kartik K. Agaram 162d408175 bugfix: S-pagedown wasn't scrolling 2023-09-02 18:10:32 -07:00
Kartik K. Agaram e32d4cebbe Merge pensieve.love 2023-08-31 20:17:28 -07:00
Kartik K. Agaram 68f991df51 bugfix: various calls to renamed methods 2023-08-31 20:01:44 -07:00
Kartik K. Agaram f8f09e7675 Merge pensieve.love 2023-08-31 00:12:51 -07:00
Kartik K. Agaram 8e5b8efef6 Merge lines.love 2023-08-31 00:11:59 -07:00
Kartik K. Agaram 6e54ad55d9 yet another set of bugfixes
The key API change I'd underestimated: opening a file used to return nil
on failure, and now returns false.
2023-08-30 23:52:25 -07:00
Kartik K. Agaram d32fd37632 Merge pensieve.love 2023-08-30 23:49:50 -07:00
Kartik K. Agaram 1af1a173f2 bugfix: files weren't being written 2023-08-30 23:33:18 -07:00
Kartik K. Agaram 159a15b3d9 Merge pensieve.love 2023-08-30 22:43:10 -07:00
Kartik K. Agaram 6f1114c5c8 Merge lines.love 2023-08-30 22:41:18 -07:00
Kartik K. Agaram 06ad5c4e8c bugfix in source editor
We now need to explicitly select the directory we want to read from.
2023-08-30 22:30:20 -07:00
Kartik K. Agaram b3ed55c104 Merge pensieve.love 2023-08-30 22:23:50 -07:00
Kartik K. Agaram b826451091 Merge lines.love 2023-08-30 22:22:31 -07:00
Kartik K. Agaram f82c0de502 cleaner API for file-system access
Thanks to physfs and nativefs.lua

nativefs still introduces some inconsistencies with love.filesystem with
relative paths:

  * love.fs.read: reads from save dir if it exists, falls back to source dir if not
  * nativefs.read: reads from save dir if it exists, falls back to source dir if not ✓

  * love.fs.write: always writes to save dir
  * nativefs.write: always writes to source dir (since no restrictions)

  * love.fs.newFile followed by file:open('r'): reads from save dir if it exists, source dir if not
  * nativefs.newFile followed by file:open('r'): always reads from working dir

  * love.fs.newFile followed by file:open('w'): always writes to save dir
  * nativefs.newFile followed by file:open('w'): always writes to working dir

So avoid using relative paths with App primitives.
2023-08-30 19:04:06 -07:00