Request for character wrap (not word wrap) in fields
Moderator: Klaus
-
- Livecode Opensource Backer
- Posts: 10076
- Joined: Fri Feb 19, 2010 10:17 am
Re: Request for character wrap (not word wrap) in fields
Version with charWrap no available: it's not rocket science; it's RUDE and it's CRUDE,
BUT it works!
BUT it works!
- Attachments
-
- wrapt.zip
- Finished version
- (1.51 KiB) Downloaded 279 times
Re: Request for character wrap (not word wrap) in fields
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 294 times
Resurrection: character wrap (not word wrap) in fields
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
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
Re: Request for character wrap (not word wrap) in fields
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
Rob
Re: Request for character wrap (not word wrap) in fields
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
thank you
-
- Livecode Opensource Backer
- Posts: 10076
- Joined: Fri Feb 19, 2010 10:17 am
Re: Request for character wrap (not word wrap) in fields
You could think about trapping the rawKey code for Paste (and this will depend on which OS you are using).
Scrub that.
Try:
Scrub that.

Try:
Code: Select all
on pasteKey
Re: Request for character wrap (not word wrap) in fields
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
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
-
- Livecode Opensource Backer
- Posts: 10076
- Joined: Fri Feb 19, 2010 10:17 am
Re: Request for character wrap (not word wrap) in fields
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.
Sorry: off to buy chisels, screws, kitchen sink (seriously); otherwise I'd knock a demo together.

Re: Request for character wrap (not word wrap) in fields
Code: Select all
on textChanged
--formatTheText
end textChanged
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?
Re: Request for character wrap (not word wrap) in fields
Hi SparkOut,
here is one example with BBEdit.
First screen without any soft wrap; second with.
the View Menu:
Regards,
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
Re: Request for character wrap (not word wrap) in fields
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.)
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.)
Re: Request for character wrap (not word wrap) in fields
Sorry, I'm not aware of such a stack... any link to it ?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?
Thanks,
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
Re: Request for character wrap (not word wrap) in fields
A few posts up this thread, by netdzynr (Scott Rossi) from 15th March 2015
Re: Request for character wrap (not word wrap) in fields
Thanks Sir,
So here is a proof of concept.
Modified code of Scott and using the textChanged message...
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 183 times
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
Re: Request for character wrap (not word wrap) in fields
Zombie thread alert! 
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

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
University Lecturer
Technical Editor, MacUser (1996-2015)
360 VR media specialist