Page 1 of 3

Styling paragraphs/lines?

Posted: Fri Apr 12, 2024 10:30 am
by Zax
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! ;)

Re: Styling paragraphs/lines?

Posted: Fri Apr 12, 2024 11:05 am
by richmond62
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.

Re: Styling paragraphs/lines?

Posted: Fri Apr 12, 2024 11:16 am
by richmond62
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. :(

Re: Styling paragraphs/lines?

Posted: Fri Apr 12, 2024 11:42 am
by Zax
I also tried to play with htmlText and <br> without success :(

Re: Styling paragraphs/lines?

Posted: Fri Apr 12, 2024 12:01 pm
by richmond62
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.

Re: Styling paragraphs/lines?

Posted: Fri Apr 12, 2024 12:13 pm
by richmond62
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

Re: Styling paragraphs/lines?

Posted: Fri Apr 12, 2024 12:24 pm
by richmond62
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.

Re: Styling paragraphs/lines?

Posted: Fri Apr 12, 2024 12:51 pm
by Zax
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.

Re: Styling paragraphs/lines?

Posted: Fri Apr 12, 2024 1:27 pm
by richmond62
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

Re: Styling paragraphs/lines?

Posted: Fri Apr 12, 2024 1:58 pm
by Zax
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 :)

Re: Styling paragraphs/lines?

Posted: Fri Apr 12, 2024 2:57 pm
by dunbarx
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

Re: Styling paragraphs/lines?

Posted: Fri Apr 12, 2024 3:10 pm
by dunbarx
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

Re: Styling paragraphs/lines?

Posted: Fri Apr 12, 2024 5:15 pm
by jacque
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.

Re: Styling paragraphs/lines?

Posted: Fri Apr 12, 2024 7:09 pm
by richmond62
Yup: vertical tabulation. Hex B.

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

Re: Styling paragraphs/lines?

Posted: Fri Apr 12, 2024 8:03 pm
by dunbarx
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