Page 3 of 3

Re: Colored or shaded sections of code in the SE

Posted: Mon Jan 27, 2020 7:22 pm
by dunbarx
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

Re: Colored or shaded sections of code in the SE

Posted: Mon Jan 27, 2020 7:54 pm
by FourthWorld
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.

Re: Colored or shaded sections of code in the SE

Posted: Tue Jan 28, 2020 5:05 pm
by dunbarx
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.

Re: Colored or shaded sections of code in the SE

Posted: Tue Jan 28, 2020 5:20 pm
by LCMark
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...).

Re: Colored or shaded sections of code in the SE

Posted: Tue Jan 28, 2020 6:23 pm
by jacque
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.

Re: Colored or shaded sections of code in the SE

Posted: Wed Jan 29, 2020 1:39 am
by mwieder
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.

Re: Colored or shaded sections of code in the SE

Posted: Wed Jan 29, 2020 2:38 am
by FourthWorld
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?

Re: Colored or shaded sections of code in the SE

Posted: Wed Jan 29, 2020 3:04 am
by mwieder
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.