OSC evaluation of any line of code
Xon77 opened this issue · comments
The new OSC eval feature in v.3.13 by @thgrund #116, which allows to evaluate the editor code based on the mouse cursor position, is great.
This feature could be extended by adding one or two arguments that also change the mouse cursor position with row/column coordinates, in order to be able to evaluate any line of code via OSC. And, If a line is not provided as argument, it would consider the current mouse cursor position.
It would allow to control Tidal code through OSC or MIDI in another way as the feature request:
tidalcycles/Tidal#716
To be even more complete, I wonder if it would be possible to choose a different pane and tab of the editor, if provided as argument, to be really able to evaluate any line of code. The argument could be the address of the file or a way to identify each pane and tab.
I opened a pull request, now the second osc parameter identifies the row position where the cursor should be moved before the code evaluation.
I didn't include column because I was wondering it was really useful...
Thank you so much!
I think the column could be useful to be able to jump to a position in a line e.g. to change quickly a specific parameter, with which one wants to play.
As previously said, the ability choose a different pane and tab of the editor, if a third parameter is provided as argument, could be interesting, e.g. for those using different tabs to separate each track.
I don't know however what could be the type of the third argument: the address of the file or another way to identify each pane and tab...
And maybe, the pane/tab change is another feature request, if it currently impossible or makes too complicate the current function...
uhm... maybe that will complicate too much the meaning of the message...
what about define 3 messages:
- editor (takes something that permits the editor switch)
- goto (takes row/column coordinates and move the cursor)
- eval (evaluate the code)
@thgrund what do you think?
I think it's dangerous to send multiple messages because OSC is used by default with UDP and therefore you can't make sure that the order is always kept. Ideally key/value pairs should be used as arguments in a single message.
On JS side I always had the problem that I got an array back from SC and I could not use the OSC results automatically as a dictionary. You could see if the OSC npm package has a way to handle this or you could re-map the result array.
I didn't think abuot that, you're right.
I think it's better to parse osc arguments as a dictionary, not too hard to implement.
Ok, updated osc parsing, now parameters will compose a dictionary.
Row/column specification is ok, only the editors/panes one is missing.
I think the editor/panes stuff is another issue. I guess this has nothing to do with the topic "OSC evaluation of any line of code" and it could be trickier.
I will do the PR, if you don't see any problems with that.
no problem, just merged my pr so you can work on that.
opened #129