- Noel Hibbard
- PowerBuilder
- Wednesday, 6 May 2020 07:29 PM UTC
I am fairly sure I am not alone in thinking the PowerScript editor needs a refresh. My editor of choice outside PowerBuilder is Microsoft VSCode. VSCode is open source and runs on the Chromium engine. The editor component of VSCode is called Monaco Editor and is available as a standalone library (MIT License) which can easily be embedded into a webpage running on almost all browsers. I actually just used it on a project for the first time today and it only took about 30mins to figure out how to implement it. Microsoft has a demo of it here:
https://microsoft.github.io/monaco-editor/index.html
It is packed with most of the VSCode features. A few:
- Syntax highlighting
- Code completion
- Ref lookups
- Function defs
- Find and replace (Ctrl+F) (with RegEx support)
- Minimap built into the scroll bar
- When highlighting a variable or function you will see colored ticks in the minimap for every occurrence
- Lots of keybindings
It obviously doesn't support PowerScript out of the box but implementing syntax highlighting is as easy as making a json config file that defines the keywords, comment character, block comment begin and end characters, ect. If you want to implement code completion, reference lookup, function definitions, ect then you will need to make use of LSP (Language Server Protocol). LSP talks to a language server which is basically just a JSON-RPC service which is called as you type. The spec is here:
https://microsoft.github.io/language-server-protocol/
Long story short, PB2019R2 introduced a new WebBrowser control based on chromium that works really well. Is there any chance of leveraging this new WebBrowser control to replace the current PowerScript editor with Monaco? Seems like it would be a fairly straight forward project. Especially if you don't bother with leveraging LSP for code completion. Even without LSP it's smart enough to autocomplete variable names and stuff like that. Just about anything would be an improvement over the current editor which borders on notepad.exe levels of uselessness.
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.