Coming in 8.1.18: Script editor improvements

Coming soon to the Ignition designer (and available now in 8.1.18 nightly builds):
The first round of changes in an enhanced script editing experience (our fourth most upvoted ideas request)

So, what does that actually mean?
Well, to start, we’ve replaced the backing ‘code editor’ Java component with a new one, which has some enhanced smarts to start with; plus, as a bonus, it’s more aware of DPI scaling. This should be an automatic, seamless change across pretty much the entire designer - anywhere you’re used to editing scripts should be a lot nicer to use now :slight_smile:

This new editor has some basic niceties such as:

Inline find & replace

image

Code folding

image

Visible whitespace

image

Type Awareness

In addition, there’s new awareness of variable and parameter types [1] in the script editor, so in various contexts, such as extension functions, parameter types are hinted and autocompleted on their own.
For instance, in a script transform, quality is known to be a QualityCode object, so methods and properties of the QualityCode type are exposed:

System functions [2] and Python’s builtin functions are currently part of the enhanced type completion, with project and Python standard library scripts hopefully soon to follow:

Parameter Completion

As a nice quality-of-life change, the new editor also offers parameter completion assistance; if you auto-complete a method with multiple required parameters, you’ll automatically enter a “parameter assistance” mode, where you can tab through the parameters and enter them one at a time:
Kapture 2022-05-16 at 11.20.23
Note: If you don’t want this, you can disable it across all script editors in the right click menu:

Disabling

image

Tooltips

As a nice bonus, with richer contextual and type information comes easy support for contextual tooltips. Just hover over an extension function parameter, Python builtin, or system function, and get a useful hint:
image

[1] There’s a bit of a fib here - it’s not true type awareness (yet) - there’s no AST parsing going on. But it’s pretty good as long as you don’t actively try to break it.

[2] System functions aren’t truly type aware (e.g. return types) because of some API limitations. Module authors providing scripting functions, beware - 8.2 will break the current script providers APIs, new signatures TBD.

With all that said - we’re not done yet! Behind the scenes, there was a lot of extra work required to make this change seamless, and lay the groundwork for type-awareness. Future versions of Ignition should continue to add to this foundation.

Module authors - if you’re providing any custom script hooks in your modules, look into the ExtensionFunctionPanel or PythonTextArea classes in the 8.1.18 SDK, and feel free to post questions and tag me.

51 Likes

:+1:

Some improvements:

  • for script in Project Library, autocompletion doesn’t list system.perspective.
  • shortcuts or context menu to comment/uncomment few lines
  • shortcuts or context menu to generate a comment block for function

and of course last but not least:

  • autocompletion for custom libraries and functions
2 Likes

Ctrl-/ has always done this in the script editor (#) and the expression editor (//).

3 Likes

Yeah, I think we've talked about this before. I think the 'right' answer is to have the project library feature a dropdown where you can select what scope to bring in hints from.

"Smarter" templates for class and function definition would be good, yeah.

Yeah, this is probably the next thing to add. Future enhancements shouldn't be nearly as much trouble to add as this first round was (:crossed_fingers:) so hopefully changes like that can happen within the next few releases.

4 Likes

with a PC windows 10 and a french local, (azerty keyboard), this shortcut doesn’t work for me :frowning_face:.

1 Like

French keyboard

Image source: AZERTY - Wikipedia.

@mazeyrat, a quick web search reveals that the non-English keyboard layouts have been a problem in other softwares’ keyboard shortcuts too. The problem appears to be that you’re having to use the Shift key and this messes up the keycodes. (I can’t remember how exactly this works but the character is returned along with the status of the Ctrl, Shift and Alt keys.)

Some posts suggest that if you have a number keypad that Ctrl-/ or Ctrl-÷ or if you have a laptop with Fn numeric keyboard try Fn-Ctrl-/. (The older Dell laptops had this and it was super. I don’t know why they discontinued it.)

1 Like

Much love to the IA team for a long-awaited set of features. It looks like a lot has gone into doing this well and getting it done the right way!

Didn't think we would get Type Awareness this soon, very stoked about that!

I know this may upset some people, but when I hear about even-numbered version releases breaking things in the name of progress, I start getting excited for whatever is coming next.

5 Likes

Just part and parcel of building modules. No worries.

1 Like

In the function/class list, it could be usefull to be able to sort in alphabetical order the list of function/class names

Example: unsorted
image

The new editor has lost a very usefull shortcut: Ctrl + G:

image

3 Likes

Ah the good old sorting of lists that gets forgotten about :grin: I'm still stuck on an old version where the UDT list isn't sorted, haha

2 Likes

It would also be great if constants/non-function scoped variables showed up in the outline list as well. If you want a constant stored in a project script, that is accessed from various perspective screens. It is an annoyance to have to copy a functions path, and then replace the function name with the constant name to quickly copy and get the full path of it. VS Code does this, but sadly I can’t grab them from there either since then its missing the script path!

2 Likes

This will be back in the next nightly build (and 8.1.18 final).

1 Like

This is great, but if I could make a suggestion…

You could put together some stub or mock classes for the ignition and java imports and make these available on pypy or nexus.

Then you wouldn’t have to spend your time working and maintaining the ignition script editor, since developers could develop in whatever IDE with intellisense, such as VSCode or pycharm.

It would also allow us to write tests for our code that works outside of the ignition ecosystem. Such as automated testing and linting in GitHub.

These stubs would be great, but mocks even better because then we could write and test our code on our local workstations without needing to connect to a gateway (obviously it would eventually be deployed to the gateway)

That being said, stubs would be plenty as we could use those to write our own mocks

4 Likes

I guess I’ll show my lack of dev knowledge here, what is a stub?

1 Like

I’m going to go with empty declarations of functions from the system library so that at least you can reference the functions without seeing red everywhere :man_shrugging:

1 Like

Good job IA! Can’t wait to have this new script editor.

Oh, derp that makes sense.

Here is a community based library just for that:

7 Likes

Can’t wait new script editor. This should be real efficiency booster. I have waste so many time just for correcting typing mistakes …
Actual script editor is not for 21st century.

1 Like

That repo has been moved to the ignition-api GitHub org.

For version 7.9:

8.0:

And for 8.1:

All of these can be installed via pip, so you can use it for developing and testing your code in PyCharm or Visual Studio Code, @Bradley_Phillips. Please note that the use of venvs is recommended.

1 Like

Wondering if there will be an addition for an “indent selected” kind of button. Moving blocks of code between functions in buttons and the script editor can be very annoying if you have a long script and the indentation carries over

1 Like