Page 3 of 3

Re: Styling paragraphs/lines?

Posted: Mon Apr 15, 2024 6:33 pm
by bn
Craig,

You could also add

Code: Select all

send "scrollbarDrag" to field "fText"
to the end of the mouseUp handler of field "Make Overlay 4"

Also if the don't wrap of the field is set then adding to the script of field "fText"

Code: Select all

   if the vScrollbar of field "fText" then
      subtract the scrollbarWidth of field "fText" from item 3 of tTextFieldRect
   end if
helps

Kind regards
Bernd

Re: Styling paragraphs/lines?

Posted: Mon Apr 15, 2024 7:28 pm
by dunbarx
Bernd.

You and I can go back and forth forever tweaking this.

But what does Zax want to do? There is the "text" way, and the "kludge" way.

Which way?

Craig

Re: Styling paragraphs/lines?

Posted: Mon Apr 15, 2024 9:45 pm
by dunbarx
Waiting for Zax, cleaned up an issue with horizontal scrolling with one or more long lines of unwrapped text. Still not perfect as regards the vertical scrollbar.

When we get to v.42 we will be done.

Craig`
MakeOverlay_5.livecode.zip
(1.94 KiB) Downloaded 213 times

Re: Styling paragraphs/lines?

Posted: Mon Apr 15, 2024 9:55 pm
by bn
dunbarx wrote: Mon Apr 15, 2024 9:45 pm Waiting for Zax, cleaned up an issue with horizontal scrolling with one or more long lines of unwrapped text. Still not perfect as regards the vertical scrollbar.
Craig,

add

Code: Select all

on ScrollbarDrag
   lock screen
   put the uStartLine of field "overlay" into tStartLinle
   put the uEndLine of field "overlay" into tEndLine
   
   put the rect of field "fText" into tTextFieldRect
   
   if the hScrollBar of field "fText" then
      subtract the scrollbarWidth of field "fText" from item 4 of tTextFieldRect
   end if
   
   ## add this <--------------------------------------
   if the vScrollbar of field "fText" then
      subtract the scrollbarWidth of field "fText" from item 3 of tTextFieldRect
   end if
   -------------- end add this
   -- more code
   -- more code
   

Kind regards
Bernd

Re: Styling paragraphs/lines?

Posted: Tue Apr 16, 2024 7:25 am
by Zax
Wow, very impressive!
I didn't know about the formattedRect and your use of it opens up great perspectives for me. Also, the blendDarken ink is smart.

In absolute terms, we could dream of a future version of LC which would manage a few more HTML tags, like "<br>" for example.
In any case, thank you very much Craig and Bernd. :)

Re: Styling paragraphs/lines?

Posted: Tue Apr 16, 2024 2:02 pm
by dunbarx
Zax.

So which way are you leaning?

Craig

Re: Styling paragraphs/lines?

Posted: Tue Apr 16, 2024 2:40 pm
by richmond62
Well, I am leaning my way only because it takes less work. 8)

Re: Styling paragraphs/lines?

Posted: Tue Apr 16, 2024 2:41 pm
by Zax
It’s a personal standalone that is currently being developed.
The method which adds an overlay field is much simpler to use than the one which adds/removes ASCII 11 characters but it can be more complex if I need several highlights in a large scrolling field.
At this stage of production, I haven't decided yet.

Re: Styling paragraphs/lines?

Posted: Tue Apr 16, 2024 2:49 pm
by richmond62
Of course you could use both methods in different situations. 8)

Re: Styling paragraphs/lines?

Posted: Tue Apr 16, 2024 3:21 pm
by richmond62
I am naturally lazy, so I always look for the simplest and easiest way to do things: of course these ways are not always the best.

Re: Styling paragraphs/lines?

Posted: Tue Apr 16, 2024 5:02 pm
by dunbarx
Zax.

The kludge way can easily support multiple overlays. Just give Bernd and I free rein. :wink:

Craig

Re: Styling paragraphs/lines?

Posted: Tue Apr 16, 2024 5:51 pm
by richmond62
Why do quite a few things that might have been expected to be fundamental to LiveCode come down to awkward kludges or work-arounds?

Re: Styling paragraphs/lines?

Posted: Tue Apr 16, 2024 6:24 pm
by jacque
richmond62 wrote: Tue Apr 16, 2024 5:51 pm Why do quite a few things that might have been expected to be fundamental to LiveCode come down to awkward kludges or work-arounds?
In this case they gave us ascii 11 back in LC 5. For myself, I prefer the text method because it requires no scrolling scripts, no additional controls, etc. Whatever method is used to calculate the text block in the overlay method can also be used to replace returns. Or you should be able to note the selection position in enterField and again in closeField to define the area.

Re: Styling paragraphs/lines?

Posted: Tue Apr 16, 2024 6:35 pm
by richmond62
Indeed, all you need is ASCII 11 and no overlays or anything else.

Re: Styling paragraphs/lines?

Posted: Tue Apr 16, 2024 7:11 pm
by dunbarx
There is no question that the "text" way is the grownup way.

Craig