Page 3 of 5

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

Posted: Sun Mar 15, 2015 4:31 pm
by richmond62
Version with charWrap no available: it's not rocket science; it's RUDE and it's CRUDE,

BUT it works!

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

Posted: Sun Mar 15, 2015 11:00 pm
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.

Resurrection: character wrap (not word wrap) in fields

Posted: Fri May 22, 2020 2:12 pm
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

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

Posted: Fri May 22, 2020 2:24 pm
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

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

Posted: Fri May 22, 2020 2:43 pm
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

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

Posted: Fri May 22, 2020 2:57 pm
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

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

Posted: Fri May 22, 2020 11:31 pm
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

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

Posted: Sat May 23, 2020 8:36 am
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)

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

Posted: Sat May 23, 2020 11:05 am
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?

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

Posted: Sat May 23, 2020 11:23 am
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

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

Posted: Sat May 23, 2020 11:34 am
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.)

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

Posted: Sat May 23, 2020 11:42 am
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

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

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

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

Posted: Sat May 23, 2020 1:38 pm
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

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

Posted: Mon Jun 28, 2021 3:38 pm
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