New feature: Code templates
-
What's the best way to return to coding after a vacation break? Yes, adding a fun feature that is easy on the brain cells. So here I present to you:
Code snippet templates
These extend the autocomplete items with templates of commonly used code snippets. Check out how it creates a CSS definition for a button LAF within seconds:
These are the features:
- use the stock templates that come with HISE or add your own templates in a JSON file for the ultimate customization
- use the preselect range feature to create multiple selections after inserting the template
Docs:
HISE | Glossary | Code snippet templates
Use code snippet templates in the script editor
(docs.hise.audio)
Have fun! Also I'm happy to accept snippets to be added to the default list, so post them if you find them useful!
-
@Christoph-Hart Nice, reminds me of the snippets feature in Sublime Text
-
Nice feature!
A possible snippet could be for a callback function that is assigned to an array of params that has an index! I find that I've been writing those a lot.
-
@Christoph-Hart Thanks Christoph!! Nice one.
-
@Christoph-Hart amazing!
-
A possible snippet could be for a callback function that is assigned to an array of params that has an index! I find that I've been writing those a lot.
Like this?
{ "name": "multi button callback (...)", "language": "HiseScript", "code": "inline function on$UI_CONTROL$s(component, value)\n{\n\tlocal index = $UI_CONTROL$s.indexOf(component);\n\n\tConsole.print(index + \": \" + value);\n};\n\nconst var $UI_CONTROL$s = Content.getAllComponents(\"$UI_CONTROL$\");\n\nfor(b in $UI_CONTROL$s)\n\tb.setControlCallback(on$UI_CONTROL$s);", "description": "This template will create a list of all UI components that match the regex expression and assign a callback with an index to them. \n>Use Ctrl+D to select all instances of `UI_CONTROL`, then enter the **common** string that all UI controls share.", "priority": 100 },
-
@Christoph-Hart Yep that looks great!
Idk if it was just an example name but would there be a way to generalize it more than a "multi button callback"?
maybe something like "multi-parameter callback"?
-
I am stuck in a situation where the above GIF not working. I gave it a try after following the @Christoph-Hart GIF. But Autocomplete is not working. What am I missing ?
BTW, I have updated to the latest code. -
@Christoph-Hart good work!
-
The switch statement is probably a good contender here.
-
@DabDab said in New feature: Code templates:
I am stuck in a situation where the above GIF not working. I gave it a try after following the @Christoph-Hart GIF. But Autocomplete is not working. What am I missing ?
BTW, I have updated to the latest code.New commits has fixed the issue..
Now it is working. Now I have two questions .-
How can I select multiple text at a time that @Christoph-Hart has shown here ?
Interface: The CSS renderer is still experimental, so use with precaution.
What are the precaution ?
-