The Script Editor

Want to talk about something that isn't covered by another category?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

stam
Posts: 2680
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: The Script Editor

Post by stam » Thu Dec 30, 2021 7:36 pm

mwieder wrote:
Tue Dec 28, 2021 3:17 am
The most recent version of the glx2 script editor supports code folding and custom colorization.

https://github.com/mwieder/glx2ScriptEditor
Thanks @mwieder

i was very keen to try this for the code folding in particular. That works very well indeed. It is exactly the feature most of us have wanted in the default code editor and implemented very well.

Lots of smaller features are very nice as well - grouping scripts into 'folders' in the sidebar for example.
The colorisation works nicely too, but it's too unwieldy as there is no theming to allow a variety of colour themes etc. I ended up just sticking with the default, as 'custom colorisation' isn't that usable. For example, i don't like the default background - would prefer it white when not in chalkboard motif, but there seems to be no way to just alter that.

My question is really about debugging - i deliberately call a divide by 0 error to trigger this and although it drops me into glx2, there seems to be no debugging feature? Looking at documentation there is a single line suggesting this is possibly provided by PowerDebug, a $40 plugin - is that really the case? Or am I not using this correctly?

I also noticed an issue with code folding and code block highlighting: There is a nice feature that will highlight a code block for example an if-then-else block. However if code-folded, the highlight remains unchanged, now highlighting lines outside of the if-then-else block which has been folded away.

Small things like this, along with the apparent lack of native debugging (if that's really the case) make it difficult to adopt as a script editor - but please do let me know if i'm not doing this right!

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: The Script Editor

Post by mwieder » Fri Dec 31, 2021 11:07 pm

My goodness... it's been so long since I've tried to debug a script without a good debugger that I missed a step in integration. Thanks for pointing this out (and see below)
...and you can change the background color of the script editor by selecting custom colorization. At the bottom of the color selector are two selectors for the background colors of the Chalkboard and Alabaster themes.

At any rate, I pushed a new build up to github with somewhat better debugging integration using just the builtin debugging tools. And the code outline now hides properly when folding code.

stam
Posts: 2680
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: The Script Editor

Post by stam » Sat Jan 01, 2022 1:53 am

mwieder wrote:
Fri Dec 31, 2021 11:07 pm
...and you can change the background color of the script editor by selecting custom colorization. At the bottom of the color selector are two selectors for the background colors of the Chalkboard and Alabaster themes.
That's my point; i can't just change one colour, i have to accept all custom colours, which are not to my liking. So by changing 1 i have to change all. And then they won't fit the chalkboard motif etc etc. I know it's probably a major piece of work, but support for colour theming would be amazing!
mwieder wrote:
Fri Dec 31, 2021 11:07 pm
I pushed a new build up to github with somewhat better debugging integration using just the builtin debugging tools. And the code outline now hides properly when folding code.
Fantastic, thank you! I'll give it a whirl as soon as i get a chance...


In the mean time, Happy New Year and best wishes for a happier, healthier and more prosperous 2022!
Stam

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: The Script Editor

Post by mwieder » Sat Jan 01, 2022 2:14 am

Nope. Here's the trick:

If you want to change just the background in either of the two themes but not use other custom colorization,

Check the Custom colorization checkbox
At the bottom of the colorization panel select the background theme you want to change:
Select the desired background color
Now uncheck tthe "Custom colorization" checkbox at the top
and at the bottom click "Apply and Exit".

This uses the built-in colorization theme but with the custom background color you selected.

Sorry about the awkward steps here... didn't seem to be a better way to deal with it, and it's not something I expect anyone to do very often.

AndyP
Posts: 615
Joined: Wed Aug 27, 2008 12:57 pm
Location: Seeheim, Germany (ex UK)
Contact:

Re: The Script Editor

Post by AndyP » Sat Jan 01, 2022 10:27 am

I made a plugin for colour theming of the editor a while back, it's free and allows saving new colour themes so that you can switch easily between different ones.

http://2108.co.uk/script-editor-themer/

Image
Andy Piddock
https://livecode1001.blogspot.com Built with LiveCode
https://github.com/AndyPiddock/TinyIDE Mini IDE alternative
https://github.com/AndyPiddock/Seth Editor color theming
http://livecodeshare.runrev.com/stack/897/ LiveCode-Multi-Search

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3999
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: The Script Editor

Post by bn » Thu Jan 06, 2022 12:23 pm

Option-clicking or Alt-clicking a folding indicator in GLX2 Script Editor folds/unfolds all foldable structures.
Kind regards
Bernd

stam
Posts: 2680
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: The Script Editor

Post by stam » Fri Jan 07, 2022 12:31 pm

AndyP wrote:
Sat Jan 01, 2022 10:27 am
I made a plugin for colour theming of the editor a while back, it's free and allows saving new colour themes so that you can switch easily between different ones.

http://2108.co.uk/script-editor-themer/
Thanks Andy - i had tried that previously and it did work as advertised.

The main attraction for me is code-folding, which is what GLX2 has implemented very well (the only additional cosmetic feature i could ask for is if it highlighted in some way the code that would be folded - eg when hovering over the disclosure triangle it would either provide an indicator in the line numbers or highlight the text or some such).

Theming is nice but not a main priority so if i did modify/change the editor i'd go with GLX2. Will Script Editor Themer work with this?

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3999
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: The Script Editor

Post by bn » Sun Jan 09, 2022 4:26 pm

stam wrote:
Fri Jan 07, 2022 12:31 pm
The main attraction for me is code-folding, which is what GLX2 has implemented very well (the only additional cosmetic feature i could ask for is if it highlighted in some way the code that would be folded - eg when hovering over the disclosure triangle it would either provide an indicator in the line numbers or highlight the text or some such).
Hi Stam,
I find that indentation provides the info of what will be folded. Do you think that additional info as to what will be folded is needed?

Kind regards
Bernd

stam
Posts: 2680
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: The Script Editor

Post by stam » Sun Jan 09, 2022 6:11 pm

As mentioned purely cosmetic feature.
Might be useful in long script with multiple indentations where you only want to collapse some middle part of this - really not necessary but is useful if done well. XOJO for example does this - see the code folding section in their blog post here: https://blog.xojo.com/2021/07/22/new-xo ... rovements/

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3999
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: The Script Editor

Post by bn » Sun Jan 09, 2022 6:53 pm

Might be useful in long script with multiple indentations where you only want to collapse some middle part of this - really not necessary but is useful if done well. XOJO for example does this - see the code folding section in their blog post here: https://blog.xojo.com/2021/07/22/new-xo ... rovements/
Thanks for the link. It looks useful and very fancy. Though I would be hesitant to overload the poor LC field with a feature that needs a lot of administration to do right.
If I am in doubt I just collapse and expand a control structure to see what happens.

Kind regards
Bernd

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3999
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: The Script Editor

Post by bn » Sun Jan 09, 2022 8:46 pm

Stam,

I hacked GLX2ScriptEditor to show the foldable struct when right-clicking on an open disclosure triangle.

Would that be something of interest? Mind you that this works on mouseDown and disappears on mouseUp. If the end of the foldable struct is below the bottom of the script field it would not show. And obviously you could not scroll to see it.

This is visual guide far from Xojo but it can be done with minor code changes.

Kind regards
Bernd


FoldableStruct.jpg

foldableStrictII.jpg
foldableStrictII.jpg (31.98 KiB) Viewed 5754 times

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: The Script Editor

Post by mwieder » Sun Jan 09, 2022 10:38 pm

Note also that a control-shift-o on a foldable line will toggle a highlight to the foldable area.
This also works for finding the end of a parenthesis. And is bidirectional... do this on an "end repeat" for instance and then scroll up to find the "repeat" line.

matthiasr
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 190
Joined: Sat Apr 08, 2006 7:55 am
Location: Lübbecke, Germany
Contact:

Re: The Script Editor

Post by matthiasr » Mon Jan 10, 2022 5:47 pm

Mark,

you mentioned parenthesis. Do you mean i could find for example the closing parenthesis of this

Code: Select all

 put URL ("file:"&tOutputFile)
Tried here on Mac, but without success. I put the cursor after the opening one and pressed Shift-CMD-o and i tried to select the opening one and pressed the key combination. Both did not work. Finding the begin or end of a structure works.

Matthias

stam
Posts: 2680
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: The Script Editor

Post by stam » Mon Jan 10, 2022 6:17 pm

bn wrote:
Sun Jan 09, 2022 8:46 pm
I hacked GLX2ScriptEditor to show the foldable struct when right-clicking on an open disclosure triangle.
Hi Bernd,

Not sure that's going to do much, unless all possible disclosures show this (ie if a larger enclosure includes multiple collapsable code blocks, this doesn't seem to show those smaller collapsable blocks which is probably the point).

Rather than imitating XOJO which may be more tricky, how about transiently highlight text that could be collapsed when hovering over its disclosure triangle? These are non-essential changes but probably do add something... but i must say the code folding works really well!

I quite like the native debugger and the lack of it in GLX2 is a dealbreaker for me - i would really like to see this code folding in the native script editor!

@mwieder - thank you for the recent change but it's no substitute for a proper debugger! It's not possible to step through code, examine variable content etc -- unless i'm not doing it right?

Stam

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3999
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: The Script Editor

Post by bn » Mon Jan 10, 2022 6:32 pm

stam wrote:
Mon Jan 10, 2022 6:17 pm

Hi Bernd,

Not sure that's going to do much, unless all possible disclosures show this (ie if a larger enclosure includes multiple collapsable code blocks, this doesn't seem to show those smaller collapsable blocks which is probably the point).

Rather than imitating XOJO which may be more tricky, how about transiently highlight text that could be collapsed when hovering over its disclosure triangle? These are non-essential changes but probably do add something... but i must say the code folding works really well!
Stam
Hi Stam,

what the images did not show was that right-clicking in a disclosure triangle produced those lines. That means you can see what triangle collapses what lines. But not all collapsable sub structs. You would have to go to those triangles to see the collapsable lines. Only one struct is shown at any one time.

Currently Mark has something similar in the works. It is not quite finalized yet.


@Matthias
Try to select the text you want to enclose in parentheses and type "("
From the documentation:
supported characters are single quote, double quote, (, [, {

Kind regards
Bernd

Post Reply

Return to “Off-Topic”