Commit Graph

1271 Commits

Author SHA1 Message Date
Kartik K. Agaram bd74e26d0b bugfix: draw edges after nodes they connect
The crash wasn't actually on the second node, it was just
indeterministic.
2023-04-18 22:52:29 -07:00
Kartik K. Agaram 103cad29a0 start drawing edges
But this only draws one edge and crashes on the second.
2023-04-18 22:43:22 -07:00
Kartik K. Agaram 770ab80074 keep edges short
This had some dead ends. I spent some time trying to use the
parametric equation of a line. But the parameter is not comparable
across two lines.
2023-04-18 22:16:49 -07:00
Kartik K. Agaram 880ecc0efd switch Nodes from array to table
We need keys to be fixed as we add/delete nodes because we're going to
start recording them next inside Nodes to encode edges.

Since there isn't a clear name for nodes in this app, I came up with a
way to autogenerate keys.
2023-04-18 17:52:19 -07:00
Kartik K. Agaram a49d4c42b0 baby steps in drawing edges from nodes 2023-04-18 02:04:36 -07:00
Kartik K. Agaram e3012d6542 make move/resize more polished+performant
This is a long-standing problem in driver.love as well:
  * each node requires an edit buffer and various decorations
  * while the mouse is down during a move/resize it's really helpful to
    see the decorations change
  * but to change decorations we have to go all the way back to A(),
    which is very slow if there's lots of nodes on the surface

Solution: create a variant of A called A1 that only does the work of A
for a single node id (index) into Nodes.

This requires tracking for every shape we render in Surface, which id it
is part of. That way we can selectively delete just shapes belonging to
a single id.

Caveat: id is a scalar, so this approach can't handle any nesting, only
a flat array of objects. But that's good enough for both driver.love and
this app.
2023-04-18 00:48:24 -07:00
Kartik K. Agaram 079af94d6e bugfix: infinite loop on negative node width 2023-04-18 00:32:20 -07:00
Kartik K. Agaram 281f838853 indicate update state
In the process we're now using sx,sy consistently everywhere.
That's a sign this is on the right track.
2023-04-18 00:27:12 -07:00
Kartik K. Agaram 9fac57319b . 2023-04-18 00:24:26 -07:00
Kartik K. Agaram 3ebf27d01b resize/move/pan all seem to be working
It's unfortunate that I use sx,xy for detection, but track x,y.
At least we can track more carefully precisely which field is which.
2023-04-18 00:04:00 -07:00
Kartik K. Agaram eb46a98742 resize handler seems to be working 2023-04-17 23:55:35 -07:00
Kartik K. Agaram d55ecf822b start implementing the mouse handler
Until now the hover actions were happening in surface coordinates sx/sy
but the mouse press action (done so far) was happening in viewport
coordinates vx/vy. Now it's consistent. Surface coordinates make more
sense since most data in memory uses them.
2023-04-17 23:28:42 -07:00
Kartik K. Agaram bcb16bbd8d mock up affordances for moving and resizing
A node will take up as much vertical space as it needs given its text.
But we can resize its width.
2023-04-17 23:22:01 -07:00
Kartik K. Agaram fc0f2f27aa don't crash when zooming out forever 2023-04-17 22:34:50 -07:00
Kartik K. Agaram 34e180836d render a single node
Give it a border, rounded corners, 10px padding on all sides.
2023-04-17 22:19:28 -07:00
Kartik K. Agaram 30f61face5 baby steps 2023-04-17 21:17:27 -07:00
Kartik K. Agaram d6dafd812a Merge luaML.love 2023-04-17 21:15:01 -07:00
Kartik K. Agaram 5d18f0b461 Merge template-live-editor 2023-04-17 21:12:15 -07:00
Kartik K. Agaram d929b1c1d7 missing definition 2023-04-17 21:10:17 -07:00
Kartik K. Agaram 4208537889 Merge template-live-editor 2023-04-16 12:02:28 -07:00
Kartik K. Agaram b138f1ff9b Merge template-live-editor 2023-04-16 11:30:56 -07:00
Kartik K. Agaram 912ca601ab new file-system format for freewheeling apps
1. No more version history, now we have just the contents of the current
   version.

2. Editing a definition no longer changes the order in which definitions
   load.

This should make repos easier to browse, and more amenable to modify.
You don't need driver.love anymore. And a stable order eliminates some
gotchas. For example:

  using driver.love, define `Foo = 3` in a definition
  define `Bar = Foo + 1`
  edit and redefine `Foo = 4`

Before this commit, you'd get an error when you restart the app.
Definitions used to be loaded in version order, and editing a definition
would move it to the end of the load order, potentially after
definitions using it. I mostly avoided this by keeping top-level
definitions independent. It's fine to refer to any definition inside a
function body, we only need to be careful with initializers for global
variables which run immediately while loading.

After this commit you can still end up in a weird state if you modify a
definition that other later definitions use. In the above example, you
will now see Foo = 4 and Bar = 4. But when you restart, Foo = 4 and Bar
= 5. But that's no more confusing than Emacs's C-x C-e. It's still
a good idea to keep top-level definitions order-independent. It's just
confusing in a similar way to existing tools if you fail to do so. And
your tools won't tend to break as badly.

Why did I ever do my weird version history thing? I think it's my deep
aversion to risking losing any data entered. (Even though the app
currently will seem to lose data in those situations. You'd need to
leave your tools to find the data.) Now I rely on driver.love's undo to
avoid data loss, but once you shut it down you're stuck with what you
have on disk. Or in git.

I also wasn't aware for a long time of any primitives for deleting
files. This might have colored my choices a lot.
2023-04-16 11:16:47 -07:00
Kartik K. Agaram e57ffabf4b make preprocessing more obvious 2023-04-16 11:16:47 -07:00
Kartik K. Agaram b0bcea8f95 some more cleanup after the undo 2023-04-16 11:16:23 -07:00
Kartik K. Agaram 209c380852 undo previous commit 2023-04-15 17:29:55 -07:00
Kartik K. Agaram 02cdf25c1d abortive experiment: keep definitions independent
Functions can refer to each other, but global variable initializers
shouldn't.

But this doesn't work. That comment keeps growing to capture more corner
cases.

Step back. What am I trying to achieve?

I'm not trying to create a better abstraction for programming with. I'm
trying to use an existing abstraction (LÖVE) without needing additional
tools.

I'm not supporting end-user programming, only end-programmer
programming. What happens in a regular LÖVE program if you use a global
before it's defined? You get an error, and you're on the hook to fix it.
But it's obvious what's going on because a file has an obvious sequence
of definitions. But what if you have multiple files? It's easy to lose
track of order and we mostly don't care.

The important property existing dev environments care about: merely
editing a definition doesn't _change_ the order of top-level
definitions. Let's just provide this guarantee.

We'll no longer load definitions in order of their version. Just load
definitions in the order they were created. Editing a definition doesn't
change this order. Deleting and recreating a definition puts it at the
end.
2023-04-15 17:24:11 -07:00
Kartik K. Agaram 6274322412 reorg 2023-04-15 10:14:42 -07:00
Kartik K. Agaram b6cb27ddf2 clarify a comment 2023-04-15 10:12:32 -07:00
Kartik K. Agaram 967950a59f stop printing tests on terminal 2023-04-14 22:38:55 -07:00
Kartik K. Agaram 164c6c4472 Merge template-live-editor 2023-04-11 21:46:37 -07:00
Kartik K. Agaram 9b8e651dc7 Merge text0 2023-04-11 21:45:13 -07:00
Kartik K. Agaram d27e22d6fe Merge text.love 2023-04-11 21:44:21 -07:00
Kartik K. Agaram 88caf4eb31 Merge lines.love 2023-04-11 21:41:27 -07:00
Kartik K. Agaram 658f96667b primitives for writing tests 2023-04-11 21:33:33 -07:00
Kartik K. Agaram 4049176dfb couple of typos 2023-04-11 15:15:58 -07:00
Kartik K. Agaram f067b18a00 Merge template-live-editor 2023-04-10 00:52:16 -07:00
Kartik K. Agaram bfd5d61c8a Merge text0 2023-04-10 00:51:25 -07:00
Kartik K. Agaram 7bf8c28561 Merge text.love 2023-04-10 00:50:00 -07:00
Kartik K. Agaram c16998bcc6 Merge lines.love 2023-04-10 00:47:12 -07:00
Kartik K. Agaram ad7cffca27 editor documentation 2023-04-10 00:42:56 -07:00
Kartik K. Agaram 911e528856 Merge template-live-editor 2023-04-09 22:32:07 -07:00
Kartik K. Agaram 275b707546 rename 2023-04-09 22:31:12 -07:00
Kartik K. Agaram c1b86211cb prevent overriding foundational definitions 2023-04-09 22:29:44 -07:00
Kartik K. Agaram 5fb9bf282b Merge template-live-editor 2023-04-09 21:05:24 -07:00
Kartik K. Agaram 3f90c92abb Merge text0
This is the original reference for "freewheeling apps".
2023-04-09 21:03:12 -07:00
Kartik K. Agaram 04069f5fc8 Merge text.love 2023-04-09 19:17:23 -07:00
Kartik K. Agaram a0d72ffee2 Merge lines.love 2023-04-09 19:15:07 -07:00
Kartik K. Agaram d61ccafaa0 include a brief reference enabling many useful apps 2023-04-09 19:09:31 -07:00
Kartik K. Agaram 760f47c0d9 Merge template-live-editor 2023-04-09 14:16:53 -07:00
Kartik K. Agaram ffb7793338 Merge text0 2023-04-09 14:16:08 -07:00