Request for character wrap (not word wrap) in fields

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, kevinmiller, robinmiller

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

Re: Request for character wrap (not word wrap) in fields

Post by richmond62 » Sun Mar 15, 2015 4:31 pm

Version with charWrap no available: it's not rocket science; it's RUDE and it's CRUDE,

BUT it works!
Attachments
wrapt.zip
Finished version
(1.51 KiB) Downloaded 124 times

netdzynr
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 61
Joined: Sat Apr 08, 2006 6:04 am
Contact:

Re: Request for character wrap (not word wrap) in fields

Post by netdzynr » Sun Mar 15, 2015 11:00 pm

If you can use LiveCode 6.5 or later, you can do this type of wrapping more dynamically using the measureText function. By placing the field within a group, you can wrap instantaneously because the resizeControl message is continuously sent to a group while it is being resized.
Attachments
live_wrap.livecode.zip
(1.92 KiB) Downloaded 116 times

rbeynon
Posts: 15
Joined: Fri Sep 21, 2007 7:07 am

Resurrection: character wrap (not word wrap) in fields

Post by rbeynon » Fri May 22, 2020 2:12 pm

I'm bringing this up once again. (still a newbie)
The request was for wrapping of a single string of char (e.g. an URL) and the general response was 'why would you want to do that?'

Well, I work with protein sequences - effectively defined by a random string of 20 different characters with no spaces or other separators, sever4al hundred char long, or even more. If I past such a sequence into a field, I don't want to 'read' it (that WOULD be silly) but I do get some feedback about overall length, key features at the start and end etc. A useful check. At the moment, I could have to do a horizontal scroll, say, of 1000 characters, to do this.

Is there are nifty way to force a field to wrap in such a way that when I paste in a character string, it wraps, at say, repeats of 80 char.?

I know it is not normal, but it's still a requirement.

Thanks in advance
Rob

rbeynon
Posts: 15
Joined: Fri Sep 21, 2007 7:07 am

Re: Request for character wrap (not word wrap) in fields

Post by rbeynon » Fri May 22, 2020 2:24 pm

OK, I missed the second page. I'm working with the solutions there (neat!) and may have a solution. Please don't waste time on me whilst I am making progress! Thanks
Rob

rbeynon
Posts: 15
Joined: Fri Sep 21, 2007 7:07 am

Re: Request for character wrap (not word wrap) in fields

Post by rbeynon » Fri May 22, 2020 2:43 pm

OK, it works until I paste in a new protein sequence. Is there an equivalent within a field to say 'on paste, trigger this script'
thank you

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

Re: Request for character wrap (not word wrap) in fields

Post by richmond62 » Fri May 22, 2020 2:57 pm

You could think about trapping the rawKey code for Paste (and this will depend on which OS you are using).

Scrub that. 8)

Try:

Code: Select all

on pasteKey

rbeynon
Posts: 15
Joined: Fri Sep 21, 2007 7:07 am

Re: Request for character wrap (not word wrap) in fields

Post by rbeynon » Fri May 22, 2020 11:31 pm

Thanks, I tried to capture pasteKey and trigger a reformat, but no luck.

More seriously, I realised that the dynamic wrapping does so by adding <return>, so this will not work in my application - might be easiest to strip out before using, I suppose.

More thought...

Rob

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

Re: Request for character wrap (not word wrap) in fields

Post by richmond62 » Sat May 23, 2020 8:36 am

Count the characters, and every 80 chars bung in a return character.

Sorry: off to buy chisels, screws, kitchen sink (seriously); otherwise I'd knock a demo together. 8)

SparkOut
Posts: 2170
Joined: Sun Sep 23, 2007 4:58 pm

Re: Request for character wrap (not word wrap) in fields

Post by SparkOut » Sat May 23, 2020 11:05 am

Code: Select all

on textChanged 
  --formatTheText
end textChanged
The textChanged message should cover what you need, a paste of new text will definitely cause the message to fire.

I understand why you want to do this, but not exactly what it is you want. Do you have an example of how any other text editor does what you want? You want wrapping, but without inserting return chars? Is this by changing the width of the field/tab/viewport to fit the required number of chars and wrap at the edge?

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 745
Joined: Wed Nov 22, 2006 3:42 pm
Location: France
Contact:

Re: Request for character wrap (not word wrap) in fields

Post by Thierry » Sat May 23, 2020 11:23 am

SparkOut wrote:
Sat May 23, 2020 11:05 am
Do you have an example of how any other text editor does what you want?
You want wrapping, but without inserting return chars?
Hi SparkOut,

here is one example with BBEdit.
First screen without any soft wrap; second with.

screenshot BBEdit.png

screenshot BBEDit soft wrap.png


the View Menu:

sunnYscrrenshot 2020-05-23 à 12.21.12.png

Regards,

Thierry
Regex LiveCode sunnYrex
https://sunny-tdz.com

SparkOut
Posts: 2170
Joined: Sun Sep 23, 2007 4:58 pm

Re: Request for character wrap (not word wrap) in fields

Post by SparkOut » Sat May 23, 2020 11:34 am

Hi Thierry
Yes, that's what I was thinking, so doesn't Scott Rossi's live_wrap stack do what is needed? (I must admit not having yet been able to try it out, but I believe it's intended to tackle the problem the way Rob wants.)

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 745
Joined: Wed Nov 22, 2006 3:42 pm
Location: France
Contact:

Re: Request for character wrap (not word wrap) in fields

Post by Thierry » Sat May 23, 2020 11:42 am

SparkOut wrote: Hi Thierry
Yes, that's what I was thinking, so doesn't Scott Rossi's live_wrap stack do what is needed?
doesn't Scott Rossi's live_wrap stack do what is needed?
Sorry, I'm not aware of such a stack... any link to it ?

Thanks,

Thierry
Regex LiveCode sunnYrex
https://sunny-tdz.com

SparkOut
Posts: 2170
Joined: Sun Sep 23, 2007 4:58 pm

Re: Request for character wrap (not word wrap) in fields

Post by SparkOut » Sat May 23, 2020 11:48 am

A few posts up this thread, by netdzynr (Scott Rossi) from 15th March 2015

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 745
Joined: Wed Nov 22, 2006 3:42 pm
Location: France
Contact:

Re: Request for character wrap (not word wrap) in fields

Post by Thierry » Sat May 23, 2020 1:38 pm

SparkOut wrote:
Sat May 23, 2020 11:48 am
A few posts up this thread, by netdzynr (Scott Rossi) from 15th March 2015
Thanks Sir,

So here is a proof of concept.
Modified code of Scott and using the textChanged message...

sunnYscrrenshot 2020-05-23 à 14.26.38.png

Copy the sequence and paste it to the bottom field; that's it.
However, there are side effects,
but I leave that as an exercise for the reader...

HTH,

Thierry
Attachments
copy_wrap_on_text_field.livecode.zip
(2.03 KiB) Downloaded 11 times
Regex LiveCode sunnYrex
https://sunny-tdz.com

Post Reply

Return to “Feature Proposals”