HISE Logo Forum
    • Categories
    • Register
    • Login

    New feature: Code templates

    Scheduled Pinned Locked Moved Feature Requests
    11 Posts 8 Posters 602 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Christoph HartC
      Christoph Hart
      last edited by

      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:

      snippets.gif

      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:

      Link Preview Image
      HISE | Docs

      favicon

      (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!

      d.healeyD virtuscapeaudioV StraticahS oskarshO 4 Replies Last reply Reply Quote 14
      • d.healeyD
        d.healey @Christoph Hart
        last edited by

        @Christoph-Hart Nice, reminds me of the snippets feature in Sublime Text

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        1 Reply Last reply Reply Quote 0
        • N
          Noahdeetz
          last edited by Noahdeetz

          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.

          1 Reply Last reply Reply Quote 0
          • virtuscapeaudioV
            virtuscapeaudio @Christoph Hart
            last edited by

            @Christoph-Hart Thanks Christoph!! Nice one.

            1 Reply Last reply Reply Quote 0
            • StraticahS
              Straticah @Christoph Hart
              last edited by

              @Christoph-Hart amazing!

              building user interfaces in HISE :)
              web: www.vst-design.com

              Christoph HartC 1 Reply Last reply Reply Quote 0
              • Christoph HartC
                Christoph Hart @Straticah
                last edited by

                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
                  },
                
                N 1 Reply Last reply Reply Quote 0
                • N
                  Noahdeetz @Christoph Hart
                  last edited by

                  @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"?

                  1 Reply Last reply Reply Quote 0
                  • DabDabD
                    DabDab
                    last edited by DabDab

                    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.

                    ScreenRecording2024-09-12112510-ezgif.com-video-to-gif-converter.gif

                    Bollywood Music Producer and Trance Producer.

                    1 Reply Last reply Reply Quote 0
                    • oskarshO
                      oskarsh @Christoph Hart
                      last edited by

                      @Christoph-Hart good work!

                      HISE Developer for hire :)

                      1 Reply Last reply Reply Quote 0
                      • A
                        aaronventure
                        last edited by

                        The switch statement is probably a good contender here.

                        1 Reply Last reply Reply Quote 1
                        • DabDabD
                          DabDab
                          last edited by

                          @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.

                          ScreenRecording2024-09-12112510-ezgif.com-video-to-gif-converter.gif

                          New commits has fixed the issue..
                          Now it is working. Now I have two questions .

                          1. 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 ?

                          Bollywood Music Producer and Trance Producer.

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post

                          49

                          Online

                          1.7k

                          Users

                          11.7k

                          Topics

                          102.3k

                          Posts