Commit Graph

242 Commits

Author SHA1 Message Date
Kartik K. Agaram 60b74760da Merge carousel.love 2024-02-16 21:35:54 -08:00
Kartik K. Agaram 17ef130938 Merge template-live-editor-mobile 2024-02-16 21:35:26 -08:00
Kartik K. Agaram ff0d64390c Merge text0 2024-02-16 21:33:22 -08:00
Kartik K. Agaram 5fd7f01fab Merge text.love 2024-02-16 21:32:40 -08:00
Kartik K. Agaram 28aac52235 Merge lines.love 2024-02-16 21:28:08 -08:00
Kartik K. Agaram 219ee11686 ensure tapping on editor brings up soft keyboard 2024-02-16 21:16:29 -08:00
Kartik K. Agaram 5365eb8e0e Merge carousel.love 2024-02-04 17:54:05 -08:00
Kartik K. Agaram 9aea053dd1 Merge template-live-editor-mobile 2024-02-04 17:52:11 -08:00
Kartik K. Agaram e3124760b1 Merge text0 2024-02-04 17:45:48 -08:00
Kartik K. Agaram 01a13715d7 Merge text.love 2024-02-04 17:43:28 -08:00
Kartik K. Agaram 77e1b57446 Merge lines.love 2024-02-04 17:36:01 -08:00
Kartik K. Agaram 83722db5e4 bugfix: don't clear selection on M-arrow
We now treat all arrow chords as cursor movement.

Many thanks to Ryan Kessler (https://tone.support) for reporting this
issue.
2024-02-04 09:31:36 -08:00
Kartik K. Agaram 1d1a829d5b more carefully pass the 'key' arg around 2024-02-04 09:30:48 -08:00
Kartik K. Agaram 6ab646a976 Merge carousel.love 2024-01-15 03:24:51 -08:00
Kartik K. Agaram a6f69931f3 Merge template-live-editor-mobile 2024-01-15 02:52:26 -08:00
Kartik K. Agaram 1dfe2d0a1a fix another crash when increasing font size too much 2023-12-31 22:20:35 -08:00
Kartik K. Agaram c1bc2b9616 Merge template-live-editor-mobile 2023-12-29 15:26:57 -08:00
Kartik K. Agaram dad4b59ef5 Merge text0 2023-12-29 14:50:28 -08:00
Kartik K. Agaram 3b601dcbcf Merge text.love 2023-12-29 14:44:27 -08:00
Kartik K. Agaram 6bd2086b51 Merge lines.love 2023-12-29 14:29:18 -08:00
Kartik K. Agaram bd2179d8aa bugfix
scenario: run without config file, quit, run again
expected: font size remains the same on second run

Before this commit it was increasing on each run.
It turns out the font height that you pass into love.graphics.newFont()
is not the result of font:getHeight().
2023-12-29 11:52:28 -08:00
Kartik K. Agaram 0f4aea6db7 pull font into editor
Now it adjusts the current font for itself.
And it's up to the caller to adjust the current font after.
2023-12-29 11:18:41 -08:00
Kartik K. Agaram 43f9984e22 correct bugfix for mouse wheel
Sequence of events in previous scenario:
1. car.draw throws an error
2. The wrapping call_protected invokes send_errors_to_output
3. send_errors_to_output uses Text.insert_text, which was extracted from
   the paste implementation on Nov 20. But it doesn't scroll, and so the
   cursor is off screen.
4. Drawing frames never sets cursor_x or cursor_y.
5. Mouse wheel indirectly requires them to be set. Boom.
2023-12-17 13:56:26 -08:00
Kartik K. Agaram bab5b7c37c bugfix for mouse wheel
Scenario:
* Run the following code in Carousel:
  ```
  function car.draw() error('a') end
  ```
* Run it. An error pops up in the output buffer.
* Position the mouse over the output buffer and without any clicks
  scroll the mouse wheel.

Before this commit, Carousel crashed with this error:
  Error: text.lua:739: attempt to compare nil with number
  stack traceback:
    text.lua:739: in function 'nearest_cursor_pos'
    text.lua:470: in function 'down'
    edit.lua:265: in function 'mouse_wheel_move'
    on.mouse_wheel_move:6: in function 'mouse_wheel_move'
    main.lua:198: in function <main.lua:195>
    app.lua:35: in function <app.lua:35>
    app.lua:179: in function <app.lua:170>
    [C]: in function 'xpcall'
    app.lua:198: in function <app.lua:197>
    [C]: in function 'xpcall'

The code in text.lua involves a comparison to State.cursor_x, which is
nil.

I don't quite understand why cursor_x isn't set only in this narrow
situation and works fine with regular prints like in my second example
screen called 'print'. Even this code scrolls fine with the mouse wheel:
  ```
  for i=1,10 do print(i) end  -- just to make the window scroll
  error('a')
  ```
But this runs into our bug:
  ```
  for i=1,10 do print(i) end
  function car.draw() error('a') end
  ```
2023-12-17 13:40:31 -08:00
Kartik K. Agaram c29be0ffce streamline button.lua 2023-12-16 23:41:10 -08:00
Kartik K. Agaram 5cea394a37 Merge template-live-editor-mobile 2023-12-03 11:46:17 -08:00
Kartik K. Agaram d58c733a30 Merge text0 2023-12-03 11:43:26 -08:00
Kartik K. Agaram 0ec556deec Merge text.love 2023-12-03 11:41:48 -08:00
Kartik K. Agaram df2cfb820d Merge lines.love 2023-12-03 11:25:16 -08:00
Kartik K. Agaram 0d3db19c85 clearing starty is redundant in mutations
We'll end up calling Text.redraw_all anyway, which will clear starty and
much more besides.

We'll still conservatively continue clearing starty in a few places
where there's a possibility that Text.redraw_all may not be called. This
change is riskier than most.
2023-12-03 10:32:05 -08:00
Kartik K. Agaram 0862dd2f72 Merge template-live-editor-mobile 2023-12-01 22:26:00 -08:00
Kartik K. Agaram 7bbc10fffb Merge text0 2023-12-01 22:24:42 -08:00
Kartik K. Agaram 120f4ccf1b Merge text.love 2023-12-01 22:06:34 -08:00
Kartik K. Agaram 61336b491b Merge lines.love 2023-12-01 22:03:36 -08:00
Kartik K. Agaram 8a588880b7 manually maintain mouse button press state
Just checking mouse.isDown works if the editor is the entirety of the
app, as is true in this fork. However, we often want to introduce other
widgets. We'd like tapping on them to not cause the selection to flash:
  https://news.ycombinator.com/context?id=38404923&submission=38397715

The right architecture to enforce this is: have each layer of the UI
maintain its own state machine between mouse_press and mouse_release
events. And only check the state machine in the next level down rather
than lower layers or the bottommost layer of raw LÖVE.
2023-12-01 21:56:35 -08:00
Kartik K. Agaram 9b62cf0afc no selection if State didn't receive mouse_press
This change needs to get backported to all the other forks. We want to
retain the ability to draw other UI elements in our apps, and that means
we can't always assume that a mouse press and mouse release will happen
together. Instead, each layer should manage its own state machine, and
only check for events from the immediately lower layer.

This idea generalizes commit c3cdbb52a.
2023-12-01 20:46:45 -08:00
Kartik K. Agaram c3cdbb52a9 set cursor on mouse_press as well as mouse_release
Problem: on mobile devices, tapping on the editor causes the selection
to flash for a second. It looks like there's a longer time between mouse
press and release events.

Scenarios tested with this change:
* click on the editor to move the cursor
* drag-select using the mouse
* shift-select using keyboard
* shift-click to select
2023-12-01 20:26:21 -08:00
Kartik K. Agaram 5875196422 bugfix: hit 'clear' with text selected
Before this commit, selecting some text and then hitting the 'clear'
button would crash the app.
2023-12-01 19:53:14 -08:00
Kartik K. Agaram 2e66d2f0fd send errors from event handlers to output editor 2023-11-21 21:22:52 -08:00
Kartik K. Agaram 9b18e35aaa bring back syntax highlighting (but so ugly) 2023-11-21 08:53:19 -08:00
Kartik K. Agaram f580e2efca add lots of buttons to the toolbar 2023-11-20 22:23:09 -08:00
Kartik K. Agaram b0670b84ff get rid of an assertion
It's easy for cursor to go off viewport, and that seems fine. Just don't
let a cursor off screen receive keys.
2023-11-20 10:27:22 -08:00
Kartik K. Agaram f298483c7d hide file numbers in output editor 2023-11-19 21:32:40 -08:00
Kartik K. Agaram 9d5ca87168 Merge template-live-editor-mobile 2023-11-18 12:59:35 -08:00
Kartik K. Agaram 61f95a349b Merge text0 2023-11-18 12:53:21 -08:00
Kartik K. Agaram c3effcc850 Merge text.love 2023-11-18 12:49:34 -08:00
Kartik K. Agaram de66b015bc Merge lines.love 2023-11-18 12:21:30 -08:00
Kartik K. Agaram 007b965b11 audit all asserts
Each one should provide a message that will show up within LÖVE. Stop
relying on nearby prints to the terminal.

I also found some unnecessary ones.

There is some potential here for performance regressions: the format()
calls will trigger whether or not the assertion fails, and cause
allocations. So far Lua's GC seems good enough to manage the load even
with Moby Dick, even in some situations that caused issues in the past
like undo.
2023-11-18 11:32:01 -08:00
Kartik K. Agaram 5444db930f no, make the scrollbar easier to acquire 2023-11-18 05:44:39 -08:00
Kartik K. Agaram cef7497e48 remove an assertion
On touch screens I seem to sometimes send two events close together, one
on the scrollbar and one just to its left moving the cursor.
2023-11-18 05:38:47 -08:00