Styling paragraphs/lines?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Zax
Posts: 475
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Styling paragraphs/lines?

Post by Zax » Fri Apr 12, 2024 10:30 am

Hello,

I had a look at "How do I style paragraphs in a field?" here:
https://lessons.livecode.com/m/4071/l/5 ... in-a-field

So, with the following code, I have:

Code: Select all

set the bordercolor of paragraph 2 to 4 of field 1 to "green"
set the borderwidth of paragraph 2 to 4 of field 1 to 3
screen1.jpg

That's nice but how could I style several lines in order to have something like this?
screen2.jpg

Please Klaus, don't tell me it is not possible! ;)

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

Re: Styling paragraphs/lines?

Post by richmond62 » Fri Apr 12, 2024 11:05 am

Just been messing around, and it seems that "that ugly thing":
-
SShot 2024-04-12 at 12.52.51.png
-
is because of a carriage return, CR,, and if you can find a way to "fake' the new paragraph in another way that may not be a problem.

"There are many Unicode characters that cause line breaks, such as U+000A LINE FEED, U+000B VERTICAL TABULATION, U+000C FORM FEED, U+000D CARRIAGE RETURN, U+0085 NEXT LINE, U+2028 LINE SEPARATOR, and U+2029 PARAGRAPH SEPARATOR. " (random internet trawl)

Possibly the way round this is to work out WHICH type of line break character is used in your text and replace it with another one that LC does NOT recognise as a paragraph symbol.

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

Re: Styling paragraphs/lines?

Post by richmond62 » Fri Apr 12, 2024 11:16 am

Running tests:

No CR symbols.

OK: linefeeds.

Replacing Linefeeds with Paragraph Separators makes the text look exactly the same.

AND, the bordering looks the same. :(

Zax
Posts: 475
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Styling paragraphs/lines?

Post by Zax » Fri Apr 12, 2024 11:42 am

I also tried to play with htmlText and <br> without success :(

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

Re: Styling paragraphs/lines?

Post by richmond62 » Fri Apr 12, 2024 12:01 pm

Rats: vertical tabulation looks lovely, but LC doesn't understand the text in terms of paragraphs:
-
SShot 2024-04-12 at 14.00.23.png
-
Possibly you could stop looking for paragraphs and start looking for incidents of whichever paragraph demarcator you were using.
Last edited by richmond62 on Fri Apr 12, 2024 12:25 pm, edited 1 time in total.

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

Re: Styling paragraphs/lines?

Post by richmond62 » Fri Apr 12, 2024 12:13 pm

I don't suppose:
-
SShot 2024-04-12 at 14.12.35.png
-

Code: Select all

   set the bordercolor of paragraph 2 of field "ff" to "green"
   set the borderwidth of paragraph 2 of field "ff" to 3
   set the bordercolor of paragraph 4 of field "ff" to "green"
   set the borderwidth of paragraph 4 of field "ff" to 3

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

Re: Styling paragraphs/lines?

Post by richmond62 » Fri Apr 12, 2024 12:24 pm

Sacre m . . . : I even tried this:

Code: Select all

on mouseUp
   select paragraph 2 to 4 of fld "ff"
   set the bordercolor of the selectedChunk to "green"
   set the borderwidth of the selectedChunk to 3
end mouseUp
and got exactly the same thing.

Zax
Posts: 475
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Styling paragraphs/lines?

Post by Zax » Fri Apr 12, 2024 12:51 pm

richmond62 wrote:
Fri Apr 12, 2024 12:01 pm
Possibly you could stop looking for paragraphs and start looking for incidents of whichever paragraph demarcator you were using.
I don't particularly want to use "paragraphs" but I would like to apply a border (or a background for example) to several "lines" in a scrolling editable field.
As it is an editable field, the user can enter text... and carriage returns.

In absolute terms, the notion of "div" is missing in LC's html styling.

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

Re: Styling paragraphs/lines?

Post by richmond62 » Fri Apr 12, 2024 1:27 pm

I tried lines and it is seemingly NOT possible to put a border round selected lines.

It is, however, possible to set the backGroundColor to a set of selected lines.

You can do this:
-
SShot 2024-04-12 at 15.28.58.png
-

Code: Select all

on mouseUp
   set the backGroundColor of paragraph 2 to 5 of field "ff" to "green"
end mouseUp

Zax
Posts: 475
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Styling paragraphs/lines?

Post by Zax » Fri Apr 12, 2024 1:58 pm

richmond62 wrote:
Fri Apr 12, 2024 1:27 pm
It is, however, possible to set the backGroundColor to a set of selected lines.
Right, I was experimenting in this direction. I think I'll continue like this.

Thank you for all your tests, richmond62 :)

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

Re: Styling paragraphs/lines?

Post by dunbarx » Fri Apr 12, 2024 2:57 pm

Zax.

Are you wedded to using the border-whatevers?

I am thinking about using an overlay and modifying its properties to fit. Maybe a field with just the right backColor, borderColor, borderWidth and blendlevel? That way it is a single control not subject to the line and paragraph constraints you are seeing. You can easily size and locate it to fit.

Craig
Last edited by dunbarx on Fri Apr 12, 2024 3:12 pm, edited 1 time in total.

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

Re: Styling paragraphs/lines?

Post by dunbarx » Fri Apr 12, 2024 3:10 pm

Just an aside, fooling around I accidentally:

Code: Select all

set the backColor of line 4  of field 1 to "33"
A dark pink. Shades of some recent threads here, and without that history, I would have started a new thread in CAPITALS to announce this unprecedented news.

Craig

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7240
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Styling paragraphs/lines?

Post by jacque » Fri Apr 12, 2024 5:15 pm

Replace carriage returns with numToChar(11). This is a soft return which shows a blank line but treats the text as a single paragraph. Note that if you need to count lines, it will report the both visible paragraphs as a single line.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: Styling paragraphs/lines?

Post by richmond62 » Fri Apr 12, 2024 7:09 pm

Yup: vertical tabulation. Hex B.

Then, as I demonstrated above, NO paragraphs are understood at all.

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

Re: Styling paragraphs/lines?

Post by dunbarx » Fri Apr 12, 2024 8:03 pm

It seems that setting the paragraph of a portion of the text of a field "sticks" beyond what I thought was possible. With a field with several return delimited lines of text, put this in a button somewhere:

Code: Select all

on mouseup
   set the backColor of paragraph 2 of fld 1 to "red"
   wait 30
   Set the backColor of line 1 to 3 of fld 1 to "green"
   
   wait 30
   set the backColor of line 1 to 3 of fld 1 to ""
   
   wait 30
   set the backColor of paragraph 2 of fld 1 to ""
end mouseup
Paragraphs have their own domain, and are impervious to the lines that they may contain?

Craig

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”