brownplt / code.pyret.org

Website for serving Pyret to folks.
Other
24 stars 45 forks source link

An initial attempt to fix #534 #535

Closed blerner closed 5 months ago

blerner commented 5 months ago

The request is to render the displayed version of a Pyret value instead of its to-repr rendering. Note that this interacts oddly with mouse handlers and key handlers, since displayed values are interactive but so is a reactor, and keyboard focus can get screwed up. There's also no limit to the size of the window; we might want to impose a maximum size and a overflow: scroll on these...but I don't understand the cssFunction well enough to know how to apply that.

Potentially fixes #534

blerner commented 5 months ago

Here's a screenshot of a silly example. Note that you cannot get interactivity with the Pyret values in here unless there is no on-mouse handler, since that'll steal mouse focus first.

r = reactor:
  init: table: n, o, p end,
  on-key: 
    {(t, _):
      t.add-row(t.row({ x: random(100), y: random(200) }, { x: random(100), y: random(200) }, { x: random(100), y: random(200) }))
    },
end

r.interact()

image

blerner commented 5 months ago

@shriram ^

@jpolitz please review; I think this is safe since the original toRepr call was already in a safeCall, so this should be stack-safe, but I'm not sure what other interactions might break because of this.

jpolitz commented 5 months ago

Huh, cool. I can't see this being worse than what we have.