Commit Graph

341 Commits

Author SHA1 Message Date
Kartik K. Agaram 6a5864e382 redo y computations 2022-05-19 05:52:16 -07:00
Kartik K. Agaram f144bdfc20 simpler 2022-05-19 05:50:33 -07:00
Kartik K. Agaram 35d14c8aff delete another arg that can be deduced 2022-05-19 05:44:57 -07:00
Kartik K. Agaram d482694a2a delete unused arg 2022-05-19 05:41:12 -07:00
Kartik K. Agaram 18bb4624b3 ensure integer coordinates
https://love2d.org/wiki/Text says text can appear blurry otherwise.
I can't tell yet, though.
2022-05-19 04:28:08 -07:00
Kartik K. Agaram ec410d5223 bugfix: ensure Cursor_line is always on a text line
Manual test used here:

  abc
  ```lines
  {"p1":{"y":72,"x":82},"mode":"line","p2":{"y":29,"x":169}}
  ```
  def
  ```lines
  {"p1":{"y":36,"x":56},"mode":"line","p2":{"y":59,"x":163}}
  ```
  ```lines
  ```
  ghi
  jkl

Hitting page-down moves the cursor from abc to ghi. The 'ghi' line
should be fully visible on screen.
2022-05-18 18:19:27 -07:00
Kartik K. Agaram b586c7332e bugfix: position cursor up top when loading file 2022-05-18 18:18:34 -07:00
Kartik K. Agaram f91e520124 scroll past first page
Still some limitations. The text cursor has to be visible on screen, so
if you have a long series of drawings without intervening lines of text
you won't be able to scroll through them all.
2022-05-18 17:42:08 -07:00
Kartik K. Agaram dc618a419c highlight another global 2022-05-17 23:24:46 -07:00
Kartik K. Agaram b544e8c357 forgot to move this special case out 2022-05-17 23:23:26 -07:00
Kartik K. Agaram 6e152a9f3f . 2022-05-17 23:18:56 -07:00
Kartik K. Agaram c1ba40ac70 delegate update events to drawings 2022-05-17 23:16:08 -07:00
Kartik K. Agaram 10bc32e2f0 DRY some code 2022-05-17 23:10:58 -07:00
Kartik K. Agaram 4818672c11 move mouse_released events to Drawing 2022-05-17 22:55:45 -07:00
Kartik K. Agaram 92bd6839c7 split mouse_pressed events between Text and Drawing 2022-05-17 22:53:09 -07:00
Kartik K. Agaram 222a11a8dd split keyboard handling between Text and Drawing 2022-05-17 22:43:41 -07:00
Kartik K. Agaram 82742330f8 autosave in a couple more places 2022-05-17 22:26:15 -07:00
Kartik K. Agaram 23176de0e0 assume we always have a filename 2022-05-17 22:24:41 -07:00
Kartik K. Agaram 2241f33a8f . 2022-05-17 22:23:15 -07:00
Kartik K. Agaram dcfa2d04ca bugfix: duplicate character on enter 2022-05-17 22:22:45 -07:00
Kartik K. Agaram 9a42128eb4 jump between lines on left/right
Also skip past drawings.
2022-05-17 22:12:08 -07:00
Kartik K. Agaram 6c031fc1d0 split lines on enter 2022-05-17 22:05:46 -07:00
Kartik K. Agaram a787ef1716 rename 2022-05-17 22:05:21 -07:00
Kartik K. Agaram 61845c335b . 2022-05-17 22:05:00 -07:00
Kartik K. Agaram 319617141b join lines on delete 2022-05-17 21:59:48 -07:00
Kartik K. Agaram e1bc81408f move 2022-05-17 21:55:19 -07:00
Kartik K. Agaram 8d2f81948a enable pressing and holding backspace 2022-05-17 21:37:39 -07:00
Kartik K. Agaram de495ae0f1 several more modules
This is probably not ideal; let's see how it goes..
2022-05-17 21:34:55 -07:00
Kartik K. Agaram 91ce333ae0 bugfix typo 2022-05-17 20:52:00 -07:00
Kartik K. Agaram 476bbcdadf beginnings of a module for the text editor 2022-05-17 20:29:08 -07:00
Kartik K. Agaram 40b1780bca longer names for indices in long loops 2022-05-17 19:48:12 -07:00
Kartik K. Agaram 2aa8c67a22 extract a module
I want to use `drawing` for locals, so I'll use uppercase the module
name just like globals.
2022-05-17 19:41:42 -07:00
Kartik K. Agaram 9ade4d2782 finish uppercasing all globals 2022-05-17 19:38:33 -07:00
Kartik K. Agaram 45eee7ad49 start uppercasing globals
We're starting to have a few. Text editing is surprisingly more complex than drawing.
2022-05-17 19:27:54 -07:00
Kartik K. Agaram cfdd563499 let's prevent the text cursor from ever getting on a drawing 2022-05-17 19:18:23 -07:00
Kartik K. Agaram 359056eb7e bugfix typo 2022-05-17 18:58:42 -07:00
Kartik K. Agaram 12681b6307 start imposing some organization 2022-05-17 18:57:47 -07:00
Kartik K. Agaram 76efb63671 much better help color and copy 2022-05-17 18:55:26 -07:00
Kartik K. Agaram 0999ae9929 bit more polish to help screen
Still looks like ass.
2022-05-17 08:18:55 -07:00
Kartik K. Agaram 0b252a4ab7 reset zoom 2022-05-17 08:12:09 -07:00
Kartik K. Agaram 8446ec0fbb respect zoom when drawing drawings 2022-05-16 23:06:44 -07:00
Kartik K. Agaram 2194b388f8 respect zoom when printing online help 2022-05-16 23:04:39 -07:00
Kartik K. Agaram 680999087b ctrl-+ and ctrl-- to adjust font size 2022-05-16 23:01:21 -07:00
Kartik K. Agaram 643e55309e reorg 2022-05-16 22:54:44 -07:00
Kartik K. Agaram 8e074b0a93 more precise cursor positioning 2022-05-16 22:50:52 -07:00
Kartik K. Agaram e2d4edb4d8 position cursor by clicking on text
In the process, a bugfix: up/down from line to drawing or vice versa.
2022-05-16 22:42:54 -07:00
Kartik K. Agaram 97531d9d05 allow text to be typed while mouse hovers over drawing
The whole point of my keyboard shortcuts scheme is that if you press a
regular key and the mouse is not down, it goes in at the cursor.
2022-05-16 22:30:53 -07:00
Kartik K. Agaram 04dc87482d save each line's y coordinate, whether it's a drawing or not 2022-05-16 22:29:05 -07:00
Kartik K. Agaram 3a9f02c9f2 move 2022-05-16 22:28:34 -07:00
Kartik K. Agaram 2ea683f4f2 stop handling drawings in cursor_pos computations 2022-05-16 22:24:24 -07:00
Kartik K. Agaram 3af32571a5 change data model; text can now have metadata 2022-05-16 22:23:24 -07:00
Kartik K. Agaram 9a54403aa3 don't try to append text to drawings 2022-05-16 22:14:30 -07:00
Kartik K. Agaram 399fed42d8 rename 2022-05-16 22:13:38 -07:00
Kartik K. Agaram 89b3c7a64f . 2022-05-16 22:13:28 -07:00
Kartik K. Agaram 8382a4f827 make sure to show the border of a drawing immediately after creating it 2022-05-16 21:38:01 -07:00
Kartik K. Agaram 741018db1f bugfix: up/down across drawings 2022-05-16 21:36:44 -07:00
Kartik K. Agaram 5a4b8451ce show cursor even on empty lines 2022-05-16 21:35:19 -07:00
Kartik K. Agaram c06e744feb speed up some obvious common cases
This is probably not worth the effort. First sign of trouble, back it out.
2022-05-16 21:10:35 -07:00
Kartik K. Agaram 0da2ec3850 binary search to most natural up/down with proportional fonts 2022-05-16 20:55:21 -07:00
Kartik K. Agaram 63df6d04e0 up/down cursor movement 2022-05-16 20:26:27 -07:00
Kartik K. Agaram ad17f4b9e4 left/right cursor movement, deleting characters 2022-05-16 20:16:27 -07:00
Kartik K. Agaram 71cb28e474 position cursor more precisely
I don't quite follow why this magic number needs to have this precise value.
2022-05-16 18:54:54 -07:00
Kartik K. Agaram b7b2d7d0a1 always show current filename in window title 2022-05-16 18:50:32 -07:00
Kartik K. Agaram 735ad25226 always have a filename
When a filename is provided, we write to it. When it isn't we always
open the same file, and it persists between loads.
2022-05-16 18:47:26 -07:00
Kartik K. Agaram 753318f664 gracefully handle a non-existent filename at the commandline 2022-05-16 18:46:27 -07:00
Kartik K. Agaram 662096d98f couple of bugfixes to file-handling 2022-05-16 18:44:17 -07:00
Kartik K. Agaram 551985e383 delete experimental REPL
We're going to focus on a simple text editor for now.
2022-05-16 18:42:58 -07:00
Kartik K. Agaram 21a4d8a67e silly reason my screenshots had an ugly black line down the left 2022-05-16 15:41:25 -07:00
Kartik K. Agaram 8f06b74eab to open a file without a terminal, drag it on! 2022-05-16 15:26:22 -07:00
Kartik K. Agaram 34f9670215 2 regressions:
- loading a file from the command line
- don't insert empty lines when loading a file from the command line
2022-05-16 15:14:08 -07:00
Kartik K. Agaram ff1d4d988a bugfix 2022-05-16 09:45:30 -07:00
Kartik K. Agaram dc1f74b490 slightly better default sizing of drawings 2022-05-16 09:42:08 -07:00
Kartik K. Agaram f63beab657 adjust window size 2022-05-16 09:39:44 -07:00
Kartik K. Agaram ba49a5ee74 some missing transitions 2022-05-15 22:21:49 -07:00
Kartik K. Agaram e9e2ead1af esc to cancel a shape mid-click 2022-05-15 22:05:01 -07:00
Kartik K. Agaram 58ce23d843 fix a comment 2022-05-15 22:04:20 -07:00
Kartik K. Agaram 935f2a6215 autosave on keystrokes 2022-05-15 22:02:53 -07:00
Kartik K. Agaram 3be553031e bugfix: move mode 2022-05-15 21:27:00 -07:00
Kartik K. Agaram 5d74f9e9cd online contextual help 2022-05-15 15:55:21 -07:00
Kartik K. Agaram 2ee50507ff icons for current_mode 2022-05-15 15:02:35 -07:00
Kartik K. Agaram 8a6d3ce799 delete drawing using backspace
I solemnly swear that I am aware of the risk of data loss..
2022-05-15 14:47:26 -07:00
Kartik K. Agaram 4158eee7f6 experiment: only show drawing borders when they can be edited 2022-05-15 14:45:23 -07:00
Kartik K. Agaram 65cea736c3 bugfix: text sometimes getting colored like drawing borders 2022-05-15 14:42:10 -07:00
Kartik K. Agaram f98712c005 load/save remaining shapes 2022-05-15 14:37:22 -07:00
Kartik K. Agaram 49c41e0124 load/save freehand strokes
Also found a couple of bugs in the process.
2022-05-15 14:20:33 -07:00
Kartik K. Agaram 64072bfdf4 starting to load/save 2022-05-15 14:00:49 -07:00
Kartik K. Agaram 87a3753796 more intuitive point delete from polygons 2022-05-15 00:03:31 -07:00
Kartik K. Agaram 3cb9dc3e0b delete points or shapes
Deleting a point deletes all shapes that use it (but not other points in those shapes).
2022-05-14 23:55:36 -07:00
Kartik K. Agaram 424dbadc85 slightly less strange now that we have the same two ways to move points as any other operation
1. hover over point, hit C-v
2. press mouse on point, hit v
2022-05-14 23:32:58 -07:00
Kartik K. Agaram 8bef861a66 slightly strange way to move points
Hover mouse on a point, hit a hotkey (C-v), then move mouse without
clicking, and click to finalize.

The hotkey is like a pointer tool, except you have to already be at the
thing you want to erase. And it's slightly inconvenient to move multiple
points one by one.

In the process I also fixed a bug: keychord clauses should always
specify the mouse button state.
2022-05-14 23:29:12 -07:00
Kartik K. Agaram 71fe2f28a7 changing your mind mid-shape
line->circle
circle->line
line->polygon
polygon->line
circle->polygon
polygon->circle
2022-05-14 22:41:21 -07:00
Kartik K. Agaram 8e2252db4c new mode: circle arc
We start out drawing a circle, but instead of releasing the mouse we hit
'a'.
2022-05-14 22:24:58 -07:00
Kartik K. Agaram 7cb9586204 new mode: circle 2022-05-14 22:23:02 -07:00
Kartik K. Agaram b5599f1ae7 new mode: polygon
Polygons are closed. Add vertices to them by pressing 'p' while holding
down the mouse.
2022-05-14 20:50:47 -07:00
Kartik K. Agaram cd133c170f . 2022-05-14 20:44:03 -07:00
Kartik K. Agaram 91f3aea0d9 bugfix: clipping in line and manhattan mode
Thanks Kiran and Ravi.
2022-05-14 18:40:11 -07:00
Kartik K. Agaram db1780d12a new mode: manhattan 2022-05-14 16:52:42 -07:00
Kartik K. Agaram 06daa49723 . 2022-05-14 16:52:13 -07:00
Kartik K. Agaram 89b6eda6b9 make points easier to acquire 2022-05-14 16:15:50 -07:00
Kartik K. Agaram 7d6eeed194 make point near focus 'pop' 2022-05-14 16:13:51 -07:00
Kartik K. Agaram a995e796ff snap lines to nearby points 2022-05-14 16:10:41 -07:00
Kartik K. Agaram 7d5a70379f add a level of indirection to vertices of shapes
This is like Sketchpad.
2022-05-14 16:00:21 -07:00
Kartik K. Agaram ece73b6683 . 2022-05-14 15:10:12 -07:00
Kartik K. Agaram 18bb4621c3 draw lines by default
Freehand strokes are a special case. Let's ignore them for a bit.
2022-05-14 15:09:49 -07:00
Kartik K. Agaram d55960ced0 bugfix: keep the click to create a new drawing from creating a new shape in the drawing
Easiest way to do this is to keep the screen areas for button and drawing disjoint.
2022-05-14 15:09:22 -07:00
Kartik K. Agaram d2d7e30c31 experimental approach to combining keyboard and mouse while drawing
Desired properties:
  - fluently draw lots of precise drawings
    - requires expressing lots of different kinds of constraints
  - always know what pressing a key is going to do
  - when typing, don't care where the mouse pointer is

Less important:
  - discoverability, learnability. Provide a hotkey for help.

Current plan:
  - chorded keys to modify drawings while mouse button is not pressed
  - unchorded keys to modify drawings only while mouse button is pressed
  - make changes while drawing a shape by pressing a key while mouse
    button is pressed
  - make changes to a drawing by hovering mouse pointer at a shape and
    pressing a key (unary operators)
  - add constraints after drawing by hovering mouse pointer at a shape,
    pressing a key and moving mouse pointer to a second shape (binary
    operators)
  - almost any change can be made to a shape after it's drawn (inspired
    by Sketchpad)
  - keys pressed while drawing a shape act as abbreviations to
    performing the action after drawing

First example in this PR:
  - you press mouse button, start drawing freehand
  - you realize you want a simple line, not a freehand stroke
  - without releasing the mouse button, you press 'l'
  - now you're drawing a straight line

You could also release the mouse button and finish the stroke, then
press 'ctrl-l' while hovering the mouse pointer on the stroke to turn it
into a line.

There's an asymmetry here. Strokes require a lot more information, so
while you can turn a stroke into a line, you can't turn a line into a
stroke.

Strokes are an exception where you can't switch to freehand mode after
you start drawing. You have to press C-f before drawing.
2022-05-14 13:57:19 -07:00
Kartik K. Agaram 361d80b55f bugfix 2022-05-14 13:56:52 -07:00
Kartik K. Agaram eaa3820241 beginnings of support for multiple shapes 2022-05-14 13:08:33 -07:00
Kartik K. Agaram 422dd3c3b7 color close to drawing 2022-05-14 12:21:59 -07:00
Kartik K. Agaram a1893a44d0 Devine's suggestion to try to live with just freehand
https://merveilles.town/@neauoire/108301005736317873

Drawbacks:
  Smoothing eliminates high-frequency noise but not low-frequency bumps.
  Making a drawing end at the start point is very challenging.

Still perhaps a useful addition to the toolbox for now. I'm going to
need a cambrian explosion of tools in the toolbox for a while before I
prune.
2022-05-14 12:14:41 -07:00
Kartik K. Agaram 5e39aea97d revert: back to freehand 2022-05-14 11:59:54 -07:00
Kartik K. Agaram e3eac12f85 switch from freehand to just straight lines 2022-05-13 20:42:00 -07:00
Kartik K. Agaram 79bbda9e48 store device-independent coordinates inside drawings 2022-05-12 08:29:57 -07:00
Kartik K. Agaram 2e0929fab4 slightly tweak boundary between concerns 2022-05-12 08:29:00 -07:00
Kartik K. Agaram 07e2b7b897 fix a typo 2022-05-12 08:27:41 -07:00
Kartik K. Agaram eef22f4242 make space for multiple kinds of width 2022-05-12 07:55:14 -07:00
Kartik K. Agaram d42be8e613 fix 2 bugs in line selection 2022-05-11 22:48:53 -07:00
Kartik K. Agaram fbba31ff7a turn strokes into horizontal and vertical lines 2022-05-11 22:35:36 -07:00
Kartik K. Agaram ccf7ecc502 refactor 2022-05-11 22:29:21 -07:00
Kartik K. Agaram 61292c439b simplest possible way to straighten strokes 2022-05-11 22:27:47 -07:00
Kartik K. Agaram 91fe5cd980 more lightweight; select just the stroke at the mouse 2022-05-11 22:15:54 -07:00
Kartik K. Agaram 5011395bf1 selecting a stroke 2022-05-11 22:01:51 -07:00
Kartik K. Agaram e83f219107 bugfix: restrict strokes to the drawing they started in 2022-05-11 21:57:36 -07:00
Kartik K. Agaram 4850e78568 reorg 2022-05-11 21:55:06 -07:00
Kartik K. Agaram 83b893df8c spacing 2022-05-11 21:54:45 -07:00
Kartik K. Agaram a405f9e777 inline 2022-05-11 21:52:57 -07:00
Kartik K. Agaram 1ff2711fd9 rename 2022-05-11 21:52:09 -07:00
Kartik K. Agaram ba0d0028ea clean up repl functionality
Now we have separate keywords for returning vs drawing something.
2022-05-11 13:12:13 -07:00
Kartik K. Agaram d8e5a1ce12 clip drawings inside the border 2022-05-11 13:01:13 -07:00
Kartik K. Agaram 3bc61ed13f lighter border for figures 2022-05-11 13:01:13 -07:00
Kartik K. Agaram 475bbd70ef intermingle freehand line drawings with text 2022-05-11 13:01:13 -07:00
Kartik K. Agaram 3019442c02 confirm that we have access to all of the love API
love.graphics.line(1, 1, 500, 500)

However, we're now no longer printing results or errors. Time now to
design the data model. When do we (re)evaluate code. When do we display
results. Where do errors go.
2022-05-02 08:37:04 -07:00
Kartik K. Agaram 4ad1cc4b54 don't rely on defaults 2022-05-02 08:32:31 -07:00
Kartik K. Agaram 0230726813 backspace 2022-05-02 08:28:33 -07:00
Kartik K. Agaram 4aa2003c94 handle chords
For shift we'll mostly rely on love.textinput. For the rest I've created
a simple driver.
2022-05-02 08:24:24 -07:00
Kartik K. Agaram 57d87f2353 little Lua repl on hitting ctrl-r 2022-05-02 07:23:36 -07:00
Kartik K. Agaram a501b5ea23 ctrl- and alt- combinations 2022-05-02 06:59:41 -07:00
Kartik K. Agaram 886717f51f handle space key
We're going to run into a few of these..
2022-05-01 23:35:15 -07:00
Kartik K. Agaram 32eed397e7 note card 2022-05-01 23:34:36 -07:00
Kartik K. Agaram 7768e8eb76 show cursor 2022-05-01 23:34:25 -07:00
Kartik K. Agaram 51eb86c673 love2d scaffold 2022-05-01 21:56:08 -07:00