Saving external file in standalone script editor



  • If I open an external script (one that isn't inside a script processor) from the HISE file browser it pops up in a separate window, it seems the only way I can save changes to this file is to right click and select save script to file. It would be really handy if I could just press CTRL+S to update the external script file.


  • administrators

    I look into it, however if you edit an external file and press F5, it should save the file before recompiling (that's how I use it).



  • Aha I didn't realise that, problem solved!



  • It seems that when switching to a different external file or to a different callback in the drop down menu or by using the back/forward mouse controls any work that wasn't saved/compiled is lost. I think by default switching tabs should save the work and also preserve the undo history.


  • administrators

    Callbacks work, but external file changes are discarded (unfortunately this is not trivial to fix because of the way external files are handled right now). A workaround is to use multiple code editors in a tab (in this case the mouse buttons switch between the tabs), which retain the external file contents (they also retain the position and more, so in fact this is the recommended way anyway :)



  • How can I open another tab in a pop-out code editor? I don't see the little + icon


  • administrators

    You'll have to build this setup yourself using the (ridiculously flexible but yet to be documented) layout system:

    1. View -> Add new floating window
    2. Right Click on the new window and Toggle Global Layout Mode
    3. Right click on the new window and choose Tabs
    4. Add some tabs with code editors.

    You can even go further and put eg. a Console on the bottom of the window - so basically create your own scripting workspace that will be displayed in an external window. This layout can be saved and restored as JSON data.



  • Thank you, I shall enjoy this :) if one wanted to edit the C++ behind the script editor to add some functionality which modules should they be looking at? ;)


  • administrators

    This file (and its .cpp counterpart) contain the modified code editor.

    https://github.com/christophhart/HISE/blob/master/hi_scripting/scripting/components/ScriptingCodeEditor.h

    What would you like to modify?



  • I'd like to tinker with the multiple cursors if I find the time


  • administrators

    Oh good luck with that one :)



  • I like this layout customisation - I shall make a video about this:) It would be nice if we could save all our JSON layouts to a folder that HISE could read from so that we could select custom layouts from the view menu (or a sub-menu) without having to paste the JSON.


  • administrators

    That's awesome. I think a video tutorial would be the best documentation, because this subject is very point & clicky. Do you need some kind of reference on how it works or will you figure it out all by yourself?

    Having a location for custom layouts is a good idea.



  • I think I understand it all but there may be some secrets that I have yet to discover. This is the popup I've made so far: https://pasteboard.co/GDtLmyV.png

    Anything special you think should be mentioned?


  • administrators

    Yes, you can remove the close buttons for some panels in order to prevent accidentally destroying your precious workspace. Can you post the JSON, then I'll do some changes and add some comments?



  • {
      "Type": "HorizontalTile",
      "StyleData": {
      },
      "LayoutData": {
        "ID": "anonymous",
        "Size": -0.5,
        "Folded": -1,
        "Visible": true,
        "ForceFoldButton": 0,
        "MinSize": -1
      },
      "ColourData": {
      },
      "Content": [
        {
          "Type": "VerticalTile",
          "StyleData": {
          },
          "LayoutData": {
            "ID": "anonymous",
            "Size": -0.78887251,
            "Folded": -1,
            "Visible": true,
            "ForceFoldButton": 0,
            "MinSize": -1
          },
          "ColourData": {
          },
          "Content": [
            {
              "Type": "Tabs",
              "StyleData": {
              },
              "LayoutData": {
                "ID": "anonymous",
                "Size": -0.203125,
                "Folded": -1,
                "Visible": true,
                "ForceFoldButton": 0,
                "MinSize": -1
              },
              "ColourData": {
              },
              "Content": [
                {
                  "Type": "ApiCollection",
                  "StyleData": {
                  },
                  "LayoutData": {
                    "ID": "anonymous",
                    "Size": -0.5,
                    "Folded": 0,
                    "Visible": true,
                    "ForceFoldButton": 0,
                    "MinSize": -1
                  },
                  "ColourData": {
                  }
                },
                {
                  "Type": "FileBrowser",
                  "StyleData": {
                  },
                  "LayoutData": {
                    "ID": "anonymous",
                    "Size": -0.5,
                    "Folded": 0,
                    "Visible": true,
                    "ForceFoldButton": 0,
                    "MinSize": -1
                  },
                  "ColourData": {
                  }
                },
                {
                  "Type": "ModuleBrowser",
                  "StyleData": {
                  },
                  "LayoutData": {
                    "ID": "anonymous",
                    "Size": -0.5,
                    "Folded": 0,
                    "Visible": true,
                    "ForceFoldButton": 0,
                    "MinSize": -1
                  },
                  "ColourData": {
                  }
                }
              ],
              "CurrentTab": 0
            },
            {
              "Type": "Tabs",
              "StyleData": {
              },
              "LayoutData": {
                "ID": "anonymous",
                "Size": -1.1253906,
                "Folded": -1,
                "Visible": true,
                "ForceFoldButton": 0,
                "MinSize": -1
              },
              "ColourData": {
              },
              "Content": [
                {
                  "Type": "ScriptEditor",
                  "StyleData": {
                  },
                  "LayoutData": {
                    "ID": "anonymous",
                    "Size": -0.5,
                    "Folded": 0,
                    "Visible": true,
                    "ForceFoldButton": 0,
                    "MinSize": -1
                  },
                  "ColourData": {
                  },
                  "ProcessorId": "",
                  "Index": -1
                },
                {
                  "Type": "ScriptEditor",
                  "StyleData": {
                  },
                  "LayoutData": {
                    "ID": "anonymous",
                    "Size": -0.5,
                    "Folded": 0,
                    "Visible": true,
                    "ForceFoldButton": 0,
                    "MinSize": -1
                  },
                  "ColourData": {
                  },
                  "ProcessorId": "",
                  "Index": -1
                },
                {
                  "Type": "ScriptEditor",
                  "StyleData": {
                  },
                  "LayoutData": {
                    "ID": "anonymous",
                    "Size": -0.5,
                    "Folded": 0,
                    "Visible": true,
                    "ForceFoldButton": 0,
                    "MinSize": -1
                  },
                  "ColourData": {
                  },
                  "ProcessorId": "",
                  "Index": -1
                },
                {
                  "Type": "ScriptEditor",
                  "StyleData": {
                  },
                  "LayoutData": {
                    "ID": "anonymous",
                    "Size": -0.5,
                    "Folded": 0,
                    "Visible": true,
                    "ForceFoldButton": 0,
                    "MinSize": -1
                  },
                  "ColourData": {
                  },
                  "ProcessorId": "",
                  "Index": -1
                },
                {
                  "Type": "ScriptEditor",
                  "StyleData": {
                  },
                  "LayoutData": {
                    "ID": "anonymous",
                    "Size": -0.5,
                    "Folded": 0,
                    "Visible": true,
                    "ForceFoldButton": 0,
                    "MinSize": -1
                  },
                  "ColourData": {
                  },
                  "ProcessorId": "",
                  "Index": -1
                }
              ],
              "CurrentTab": 0
            }
          ]
        },
        {
          "Type": "VerticalTile",
          "StyleData": {
          },
          "LayoutData": {
            "ID": "anonymous",
            "Size": -0.21112749,
            "Folded": -1,
            "Visible": true,
            "ForceFoldButton": 0,
            "MinSize": -1
          },
          "ColourData": {
          },
          "Content": [
            {
              "Type": "Console",
              "StyleData": {
              },
              "LayoutData": {
                "ID": "anonymous",
                "Size": -0.82851562,
                "Folded": 0,
                "Visible": true,
                "ForceFoldButton": 0,
                "MinSize": -1
              },
              "ColourData": {
              }
            }
          ]
        }
      ]
    }
    


  • I've found a little bug with this, if I have my popout window on another desktop and I right-click in the API browser it will switch to the desktop with the main HISE interface on instead of opening the info where I clicked. I've only tested this on Windows.


  • administrators

    I made some of the containers not Dynamic, which causes the close button to appear and give it a more "hardcoded" style. I also changed some size values to absolute values (eg. the left panel doesn't need to increase in size when the window gets bigger). I also added a "Global Script Connector", which sets the processor of all child panels (so you don't have to set each script editor explicitely.

    This is the updated JSON:

    {
          "Type": "HorizontalTile",
          "StyleData": {
          },
          "LayoutData": {
            "ID": "anonymous",
            "Size": -0.5,
            "Folded": -1,
            "Visible": true,
            "ForceFoldButton": 0,
            "MinSize": -1
          },
          "ColourData": {
          },
          "Dynamic": false,
          "Content": [
            {
              "Type": "VerticalTile",
              "StyleData": {
              },
              "LayoutData": {
                "ID": "anonymous",
                "Size": -0.97559917,
                "Folded": -1,
                "Visible": true,
                "ForceFoldButton": 0,
                "MinSize": -1
              },
              "ColourData": {
              },
              "Dynamic": false,
              "Content": [
                {
                  "Type": "Tabs",
                  "StyleData": {
                  },
                  "LayoutData": {
                    "ID": "anonymous",
                    "Size": 357,
                    "Folded": 0,
                    "Visible": true,
                    "ForceFoldButton": 0,
                    "MinSize": -1
                  },
                  "ColourData": {
                  },
                  "Dynamic": false,
                  "Content": [
                    {
                      "Type": "ApiCollection",
                      "StyleData": {
                      },
                      "LayoutData": {
                        "ID": "anonymous",
                        "Size": -0.5,
                        "Folded": 0,
                        "Visible": true,
                        "ForceFoldButton": 0,
                        "MinSize": -1
                      },
                      "ColourData": {
                      }
                    },
                    {
                      "Type": "FileBrowser",
                      "StyleData": {
                      },
                      "LayoutData": {
                        "ID": "anonymous",
                        "Size": -0.5,
                        "Folded": 0,
                        "Visible": true,
                        "ForceFoldButton": 0,
                        "MinSize": -1
                      },
                      "ColourData": {
                      }
                    },
                    {
                      "Type": "ModuleBrowser",
                      "StyleData": {
                      },
                      "LayoutData": {
                        "ID": "anonymous",
                        "Size": -0.5,
                        "Folded": 0,
                        "Visible": true,
                        "ForceFoldButton": 0,
                        "MinSize": -1
                      },
                      "ColourData": {
                      }
                    }
                  ],
                  "CurrentTab": 2
                },
                {
                  "Type": "HorizontalTile",
                  "StyleData": {
                  },
                  "LayoutData": {
                    "ID": "anonymous",
                    "Size": -0.58047337,
                    "Folded": -1,
                    "Visible": true,
                    "ForceFoldButton": 0,
                    "MinSize": -1
                  },
                  "ColourData": {
                  },
                  "Dynamic": false,
                  "Content": [
                    {
                      "Type": "GlobalConnectorJavascriptProcessor",
                      "StyleData": {
                      },
                      "LayoutData": {
                        "ID": "anonymous",
                        "Size": 18,
                        "Folded": 0,
                        "Visible": true,
                        "ForceFoldButton": 0,
                        "MinSize": -1
                      },
                      "ColourData": {
                      },
                      "ProcessorId": "",
                      "Index": -1
                    },
                    {
                      "Type": "Tabs",
                      "StyleData": {
                      },
                      "LayoutData": {
                        "ID": "anonymous",
                        "Size": -0.5,
                        "Folded": -1,
                        "Visible": true,
                        "ForceFoldButton": 0,
                        "MinSize": -1
                      },
                      "ColourData": {
                      },
                      "Content": [
                        {
                          "Type": "ScriptEditor",
                          "StyleData": {
                          },
                          "LayoutData": {
                            "ID": "anonymous",
                            "Size": -0.5,
                            "Folded": 0,
                            "Visible": true,
                            "ForceFoldButton": 0,
                            "MinSize": -1
                          },
                          "ColourData": {
                          },
                          "ProcessorId": "",
                          "Index": -1
                        },
                        {
                          "Type": "ScriptEditor",
                          "StyleData": {
                          },
                          "LayoutData": {
                            "ID": "anonymous",
                            "Size": -0.5,
                            "Folded": 0,
                            "Visible": true,
                            "ForceFoldButton": 0,
                            "MinSize": -1
                          },
                          "ColourData": {
                          },
                          "ProcessorId": "",
                          "Index": -1
                        },
                        {
                          "Type": "ScriptEditor",
                          "StyleData": {
                          },
                          "LayoutData": {
                            "ID": "anonymous",
                            "Size": -0.5,
                            "Folded": 0,
                            "Visible": true,
                            "ForceFoldButton": 0,
                            "MinSize": -1
                          },
                          "ColourData": {
                          },
                          "ProcessorId": "",
                          "Index": -1
                        },
                        {
                          "Type": "ScriptEditor",
                          "StyleData": {
                          },
                          "LayoutData": {
                            "ID": "anonymous",
                            "Size": -0.5,
                            "Folded": 0,
                            "Visible": true,
                            "ForceFoldButton": 0,
                            "MinSize": -1
                          },
                          "ColourData": {
                          },
                          "ProcessorId": "",
                          "Index": -1
                        }
                      ],
                      "CurrentTab": 0
                    }
                  ]
                }
              ]
            },
            {
              "Type": "Console",
              "StyleData": {
              },
              "LayoutData": {
                "ID": "anonymous",
                "Size": -0.31327334,
                "Folded": 0,
                "Visible": true,
                "ForceFoldButton": 0,
                "MinSize": -1
              },
              "ColourData": {
              }
            }
          ]
        }
    


  • That's great Christoph, thanks!



  • When I add a MIDI processor and use connect to an external script, any changes I make to the script within HISE don't seem to be written to the external file.


  • administrators

    Ah, nice catch! Connecting a script to a MIDI processor is a read-only connection (that's why the script editor will be hidden in the main panel). However, it's still fully accessible in the Scripting workspace, but it will not write to the file because of the "read-onlyness".

    It has to be read only in order to make sure that multiple scripts that use the same external file have the same state.

    I "fixed" it by removing connected script processors from the editor drop down - not sure if this is a satifying answer for you though :)


Log in to reply

Looks like your connection to Saving external file in standalone script editor was lost, please wait while we try to reconnect.