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

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4003
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Styling paragraphs/lines?

Post by bn » Mon Apr 15, 2024 6:33 pm

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

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

Re: Styling paragraphs/lines?

Post by dunbarx » Mon Apr 15, 2024 7:28 pm

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

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

Re: Styling paragraphs/lines?

Post by dunbarx » 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.

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

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

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4003
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Styling paragraphs/lines?

Post by bn » Mon Apr 15, 2024 9:55 pm

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

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

Re: Styling paragraphs/lines?

Post by Zax » Tue Apr 16, 2024 7:25 am

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. :)

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

Re: Styling paragraphs/lines?

Post by dunbarx » Tue Apr 16, 2024 2:02 pm

Zax.

So which way are you leaning?

Craig

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

Re: Styling paragraphs/lines?

Post by richmond62 » Tue Apr 16, 2024 2:40 pm

Well, I am leaning my way only because it takes less work. 8)

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

Re: Styling paragraphs/lines?

Post by Zax » Tue Apr 16, 2024 2:41 pm

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.

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

Re: Styling paragraphs/lines?

Post by richmond62 » Tue Apr 16, 2024 2:49 pm

Of course you could use both methods in different situations. 8)

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

Re: Styling paragraphs/lines?

Post by richmond62 » Tue Apr 16, 2024 3:21 pm

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.

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

Re: Styling paragraphs/lines?

Post by dunbarx » Tue Apr 16, 2024 5:02 pm

Zax.

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

Craig

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

Re: Styling paragraphs/lines?

Post by richmond62 » 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?

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

Re: Styling paragraphs/lines?

Post by jacque » Tue Apr 16, 2024 6:24 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: Styling paragraphs/lines?

Post by richmond62 » Tue Apr 16, 2024 6:35 pm

Indeed, all you need is ASCII 11 and no overlays or anything else.

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

Re: Styling paragraphs/lines?

Post by dunbarx » Tue Apr 16, 2024 7:11 pm

There is no question that the "text" way is the grownup way.

Craig

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”