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.

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6453
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Colored or shaded sections of code in the SE

Post by dunbarx » Fri Jan 24, 2020 7:22 pm

I would love to be able to set the backColor of, say, lines 600 to 700 of a script in the SE. I know this could get out of hand, but it would be a pleasure to hilite sections of code so I can locate them more easily when scrolling.

I know that all handlers are listed, and one can go to them directly. But I am talking about sections within a single long handler.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 3978
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Colored or shaded sections of code in the SE

Post by richmond62 » Fri Jan 24, 2020 8:52 pm

Dunno why this one "flips a bluey" when I attempt to execute it, especially
as the scriptEditor passes it initially:

Code: Select all

on mouseUp
   set the backGroundColor of the script of button "hls" to green
end mouseUp
this is also no good:

Code: Select all

on mouseUp
   set the backGroundColor of the scriptEditor of button "hls" to green
end mouseUp
I suppose at this point one should ask a very direct question:

Is a script in a scriptEditor window a scrolling list field?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6453
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Colored or shaded sections of code in the SE

Post by dunbarx » Fri Jan 24, 2020 9:43 pm

Richmond.

Just so. The SE is just a stack. I love saying that.

One can set the backColor of just a portion of the vertical extent of the text of any field. So this works:

Code: Select all

set the backColor of line 5 to 10 of fld 1 of stack "RevNewScriptEditor 1" to "red"
But this requires an external gadget to do so and the color does not stick. I want to have that gadget inside the SE. In other words, select a portion of the SE text, and then open a color wheel to select a color, and then HAVE IT SAVED.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 3978
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Colored or shaded sections of code in the SE

Post by richmond62 » Fri Jan 24, 2020 9:58 pm

I want to have that gadget inside the SE.
Sounds good.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6453
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Only some of the SE properties are saved between sessions

Post by dunbarx » Fri Jan 24, 2020 10:22 pm

I opened a thread in the "feature Request" pane:
viewtopic.php?f=6&t=33578

which made me wonder why some properties (like the text) of the SE are saved between sessions, but something like:

Code: Select all

set the backColor of line 5 to 10 of fld 1 of stack "RevNewScriptEditor 1" to "red"
save stack "RevNewScriptEditor 1" 
is not. Just wondering...

Craig

EDIT.

"Between sessions" refers to having the SE closed and re-opening. One can set the backColor of one tab of several and close it. As long as the SE is still open at all, reopening the original tab will still show the colored text. But close the SE itself, and the property is reset to empty.
Last edited by dunbarx on Fri Jan 24, 2020 10:49 pm, edited 2 times in total.

Klaus
Posts: 11471
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Only some of the SE properties are saved between sessions

Post by Klaus » Fri Jan 24, 2020 10:32 pm

Hi Craig,

all (new) script editor windows/stacks are CLONED from an original stack, which I don't know the name of. :?
So you have to edit THAT stack to make any changes "stick".


Best

Klaus

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6453
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Only some of the SE properties are saved between sessions

Post by dunbarx » Fri Jan 24, 2020 10:44 pm

Klaus.

Thanks, I think I heard about that a while ago.

Since the SE is just a stack, I can:

Code: Select all

 answer the selectedChunk  of fld 1 of stack "RevNewScriptEditor 1"
No problem. And if I set the backColor of several sections of text, I can:

Code: Select all

 answer the htmlText  of fld 1 of stack "RevNewScriptEditor 1"
and store that somewhere. But even if I could save to that clone, it still is too cumbersome to use from "outside" the SE.

So it stays a feature request.

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7247
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Colored or shaded sections of code in the SE

Post by FourthWorld » Fri Jan 24, 2020 11:07 pm

You could make a plug-in that loads a frontscript which responds to a keystroke of your choice.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6453
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Colored or shaded sections of code in the SE

Post by dunbarx » Fri Jan 24, 2020 11:23 pm

Richard.

I am currently setting colors of often-used sections of a long script by hand, to see how I like the overall effect. It makes finding the sections I am currently working on much easier to spot during scrolling. This, again, only sticks in the current SE session.

But I still am not sure how to save the effects between sessions. I assume that each script is saved separately in whatever master stack Klaus mentioned, so that in a new session, reopening any script shows its current state.

The htmlText of each script is saved, since the colors of the various states of text are. For example, the foreColor of text following a comment. But it seems that the backColor is not. It would not be so bad to set these by hand as I am working, if only they came back the next day.

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7247
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Colored or shaded sections of code in the SE

Post by FourthWorld » Fri Jan 24, 2020 11:45 pm

The script property itself is plain text. So if you want to store an htmltext copy you'll have to work out how to keep them in sync.

Htmltext does include the backgroundColor where set; indeed, htmltext was designed to reproduce everything in styled text with complete fidelity. I won't be able to know why it's not showing there without a sample stack or code.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 3978
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Colored or shaded sections of code in the SE

Post by richmond62 » Sat Jan 25, 2020 9:17 am

Well, up to a point.

Text size is not maintained:
-
Screenshot 2020-01-25 at 10.16.09.png

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7247
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Colored or shaded sections of code in the SE

Post by FourthWorld » Sat Jan 25, 2020 9:32 am

1. HtmlText is not HTML. Very different goals for each. HtmlText exists solely to provide a text representation of a all field contents with complete fidelity needed to reproduce them in another LiveCode field. Attempting to view htmlText in a web browser expecting HTML will sometimes produce something similar to what you'd hoped for, but often not. You can test the completeness of htmlText by setting the htmlText of another field to the htmlText of your sample field.

2. HtmlText will only include properties within the text itself, not field properties. If no text run within the field has had its textFont or textSize assigned, it will render with the textFont and textSize of the field the text is in. While those field properties will affect appearance, they are not part of the text within the field, and therefore will not be part of the htmlText representing the styled text.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 3978
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Colored or shaded sections of code in the SE

Post by richmond62 » Sat Jan 25, 2020 9:43 am

Presumably that means that LiveCode cannot export HTML.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7247
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Colored or shaded sections of code in the SE

Post by FourthWorld » Sat Jan 25, 2020 11:03 am

richmond62 wrote:
Sat Jan 25, 2020 9:43 am
Presumably that means that LiveCode cannot export HTML.
Yes. HtmlText serves a very different goal from HTML.

In fact, there was a time when the team was considering changing the name of the property to something like "xmlText", to better clarify its unique role within LC, and that it's HTML-like but isn't true HTML. Alas, they have a reputation for maintaining greater backward compatibility than most scripting engines and they want to protect that, and "xmlText" is still not quite the best term given some of the nuances of both htmlText and XML. So for better or worse, the property remains named "htmlText".

That said, one can massage htmlText to become web-ready HTML. A lot of the work I do involves that.

When HTML is the output, depending on what you're doing with it starting with htmlText is a good foundation. But for a wide range of other tasks involving manipulating styled text, I can't say enough good things about working with a field's styledText array. Like anything else, it takes a little practice to get the hang of, but once you do it's such a clean an efficient way to process styled text runs.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2226
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Colored or shaded sections of code in the SE

Post by [-hh] » Sun Jan 26, 2020 2:43 pm

FourthWorld wrote:HtmlText will only include properties within the text itself, not field properties. If no text run within the field has had its textFont or textSize assigned, it will render with the textFont and textSize of the field the text is in. While those field properties will affect appearance, they are not part of the text within the field, and therefore will not be part of the htmlText representing the styled text.
LC returns inherited properties when using the attribute "effective".
So yes, those field properties are not part of the htmltext. But they are part of

Code: Select all

the effective htmltext of <field>
Whether this generated code translates to similar display in browsers is another story...
shiftLock happens

Post Reply

Return to “Feature Requests”