Skip to content
This repository has been archived by the owner on Feb 25, 2023. It is now read-only.

Idea: autoselect enclosing function when evaluating a single line in the editor #17

Open
hamoid opened this issue Jul 4, 2020 · 3 comments

Comments

@hamoid
Copy link

hamoid commented Jul 4, 2020

Currently, when editing a Processing based program, I can press Ctrl+Shift+X to reevaluate the selection.

This works if I select the whole draw function for example.

But if I don't select anything, it will give an error because evaluating p.stroke(255, 0, 0) out of any context fails (p is unknown).

The SuperCollider IDE solves this by implementing a feature that autoselects the enclosing function. That would very convenient for experimentation. In my example, I can keep changing the RGB values of stroke and press Ctrl+Shift+X to observe the results.

One approach would be: if nothing is selected, start scanning from the caret position backwards until function is found, then forwards until the matching } is found (accounting for if statements and for loops), then evaluate that block leaving the caret position untouched.

@victordiaz
Copy link
Owner

I would love to see that!
I'm just wondering how would it work in a case where I want to execute only one line within some brackets (In this case I dont need the internal context)

The live execution works in more use cases than Processing, so how it work for more scenarios? Maybe different shortcuts?

By the way @hamoid , what is the default shortcut for other live coding environments?

@hamoid
Copy link
Author

hamoid commented Jul 5, 2020

I think shortcuts involving [enter] would be nice. Like ctrl+enter, shift+enter, alt+enter or ctrl+shift+enter... something like that.

This is what I have in SuperCollider, but I don't remember the defaults:
2020-07-05-103556_885x128_scrot

There could be two shortcuts: one for the current line, and one for the current selection or the surrounding function if there's no selection.

@victordiaz victordiaz transferred this issue from victordiaz/PHONK Jul 11, 2020
@victordiaz
Copy link
Owner

I changed the shortcut to Control + Enter by default. It feels much nicer

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants