Colored or shaded sections of code in the SE

Something you want to see in a LiveCode product? Want a new forum set up for a specific topic? Talk about it here.

Moderator: Klaus

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10303
Joined: Wed May 06, 2009 2:28 pm

Re: Colored or shaded sections of code in the SE

Post by dunbarx » Mon Jan 27, 2020 7:22 pm

I never intended to get mired into the htmlText properties of the SE. Doing this:

Code: Select all

answer the htmlText of fld 1 of stack "revNewScriptEditor 1"
gives a nice rendition of the, er, htmlText of fld 1 of stack "revNewScriptEditor 1"

But you cannot store that in a custom property and get it back in one piece. That is why I am now in with markers, a la Hermann.

Simply setting the backColor(s) of the selectedChunk(s) without markers is fine in a single session. I have a gadget to do that, just because it works so easily and seamlessly. The colors (light pastels, please. No red) are set in sequence from a short list without duplication. It is just a gadget.

I repeat my feature request to add just the basics of this functionality to the SE overall. It sounds like a lot of work, though. Does any other program support this sort of thing?

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Colored or shaded sections of code in the SE

Post by FourthWorld » Mon Jan 27, 2020 7:54 pm

dunbarx wrote:
Mon Jan 27, 2020 7:22 pm
I repeat my feature request to add just the basics of this functionality to the SE overall. It sounds like a lot of work, though. Does any other program support this sort of thing?
If a programming language exists in which the language itself requires binary styling structures, I'm unfamiliar with it. Most use plain text, giving rise to the serious challenges inherent in feature requests dependent on styling metadata that Hermann listed. Given the tremendous work that would be needed to support this, and that the payoff would be a feature that may be quite useful but AFAIK has only been requested once in the 30 years I've been working with this family of languages, I would not hold my breath for its implementation.

A more common solution for easily identifying and navigating distinct script sessions is to use handler names as section identifiers, e.g.:

Code: Select all

on  ________MESSAGES__________
end ________MESSAGES__________
This produces a handler list that can look something like this:
________MESSAGES__________
mouseUp
mouseRelease
________FILE I/O_____________
GetFileInfo
GetFileData
CheckPermissions
________UTILITIES____________
q
iif
err
log
...with the extra advantage that clicking the line in the handler list takes you immediately to that section.

A workaround, to be sure. But works in any script editor in any xTalk dialect as-is, with no extra work required from the core engineering team or any other work from anyone at all.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10303
Joined: Wed May 06, 2009 2:28 pm

Re: Colored or shaded sections of code in the SE

Post by dunbarx » Tue Jan 28, 2020 5:05 pm

Details.

Though adding or deleting lines by hand in the SE in a section where the backColor has been set does not affect the overall integrity of the color of that section, pasting clears the backColor. Oddly, it does not affect any other section that has had its color set, only the section that received the paste.

So in my gadget, I simply hit the keystroke shortcut again, and restore between the markers. But I find it odd...

Craig

EDIT. I don't make theses things up. Now it does not lose its color. I did restart in the meantime.
Last edited by dunbarx on Tue Jan 28, 2020 5:59 pm, edited 1 time in total.

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1232
Joined: Thu Apr 11, 2013 11:27 am

Re: Colored or shaded sections of code in the SE

Post by LCMark » Tue Jan 28, 2020 5:20 pm

The S/E intercepts all things that will mutate the field so that it can provide multiple levels of undo/redo and colorize the script 'on-the-fly'. So when you paste into a section, it will re-colorize the relevant lines thus losing the styling which has been added behind its back.

This is why what you want is very hard to achieve, at least without rethinking the entire way the S/E field behaviors work (and even then I suspect it would not be very easy at all to marry things like script colorization, undo/redo with custom styles applied by the user arbitrarily...).

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Colored or shaded sections of code in the SE

Post by jacque » Tue Jan 28, 2020 6:23 pm

A more common solution for easily identifying and navigating distinct script sessions is to use handler names as section identifiers,
I've been doing this for years, I learned it from Ken Ray. Very handy.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: Colored or shaded sections of code in the SE

Post by mwieder » Wed Jan 29, 2020 1:39 am

In the glx2 script editor I implemented this by overlaying a translucent colored rectangle over part of the script. But I had my own code to patch, and didn't have to deal with the innards of the IDE's script editor scripts.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Colored or shaded sections of code in the SE

Post by FourthWorld » Wed Jan 29, 2020 2:38 am

mwieder wrote:
Wed Jan 29, 2020 1:39 am
In the glx2 script editor I implemented this by overlaying a translucent colored rectangle over part of the script.
How does it remember the offsets between sessions?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

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

Re: Colored or shaded sections of code in the SE

Post by mwieder » Wed Jan 29, 2020 3:04 am

I don't remember. May not have needed to save between sessions, since it was only using that feature as an alternative to more serious code folding. Click on an if/switch/repeat construct and the whole thing would be highlighted.

OTOH, glx2 saved a custom propertyset in the object whose script was being edited, and the line numbers could be there.

Post Reply