bitfocus / companion

Bitfocus Companion enables the reasonably priced Elgato Streamdeck and other controllers to be a professional shotbox surface for an increasing amount of different presentation switchers, video playback software and broadcast equipment.
http://bitfocus.io/companion
Other
1.46k stars 489 forks source link

feat: multiline expressions #2871

Open Julusian opened 1 month ago

Julusian commented 1 month ago

This provides a bunch of improvements to expressions.

The most visible difference is that expression input fields are now displayed as multiline: image

Expression input fields will now validate their expression in the ui, and will show as red when it failed to parse (execution is not tested)

Additionally, to make this more friendly, it includes some new syntax:

Combine all of these, and you can now break up long complex expressions into multiple stages, with comments and intermediary variables. The value of the last statement is taken as the output. eg 10 20 30 is 3 statements, and the result will be 30.

The statement parsing isn't perfect js, the parser is allowing multiple statements on a single line separated by only a space. I worry that this could result in the parsing being more brittle, but I'm not sure if we should be worried about that.

Maybe next could be support for full if statements, or loops, but not as part of this PR.