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.

Moderator: Klaus

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10422
Joined: Fri Feb 19, 2010 10:17 am

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

Post by richmond62 »

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 1014 times
netdzynr
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 62
Joined: Sat Apr 08, 2006 6:04 am
Contact:

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

Post by netdzynr »

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 1037 times
rbeynon
Posts: 15
Joined: Fri Sep 21, 2007 7:07 am

Resurrection: character wrap (not word wrap) in fields

Post by rbeynon »

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 »

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 »

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: 10422
Joined: Fri Feb 19, 2010 10:17 am

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

Post by richmond62 »

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 »

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: 10422
Joined: Fri Feb 19, 2010 10:17 am

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

Post by richmond62 »

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: 2987
Joined: Sun Sep 23, 2007 4:58 pm

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

Post by SparkOut »

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: 875
Joined: Wed Nov 22, 2006 3:42 pm

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

Post by Thierry »

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
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SparkOut
Posts: 2987
Joined: Sun Sep 23, 2007 4:58 pm

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

Post by SparkOut »

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: 875
Joined: Wed Nov 22, 2006 3:42 pm

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

Post by Thierry »

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
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SparkOut
Posts: 2987
Joined: Sun Sep 23, 2007 4:58 pm

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

Post by SparkOut »

A few posts up this thread, by netdzynr (Scott Rossi) from 15th March 2015
Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 875
Joined: Wed Nov 22, 2006 3:42 pm

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

Post by Thierry »

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 853 times
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
thatkeith
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 383
Joined: Mon Mar 01, 2010 7:13 pm
Contact:

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

Post by thatkeith »

Zombie thread alert! :D

URLs are a great example of strings that are almost always a solid run of chars with no spaces and can be really rather long – or at least long enough to require a rather wide text field, something that's often really unsuitable for the rest of the UI. I'd like to present a field for someone to type or paste in a URL, and I'd like to be able to show it to them in an editable form that wraps into multiple lines if necessary (without throwing in return chars).

Basically, something like allowCharWrap or a logical equivalent would be marvellous, defaulting to off but ready to be invoked when the need arises.

[sigh]

k
Technical Writer, Meta
University Lecturer
Technical Editor, MacUser (1996-2015)
360 VR media specialist
Post Reply