Discussion:
Show invisible characters (tab, space, return) in field
Kaveh Bazargan via use-livecode
2018-12-07 23:44:47 UTC
Permalink
Is there any way of seeing invisible characters in a text field, similar to
the view in text editors and word processors?
--
Kaveh Bazargan
Director
River Valley Technologies <http://rivervalleytechnologies.com/> • Twitter
<https://twitter.com/kaveh1000> • LinkedIn
<https://www.linkedin.com/in/bazargankaveh/>
Bob Sneidar via use-livecode
2018-12-08 00:21:23 UTC
Permalink
Not natively. You would have to replace every non-printing character (that's what you mean by invisible I suppose) with a square digbat or something. If you want to filter for only printable characters, I have a function that dies that, and also there are regex strings for that sort of thing.

Bob S
Post by Kaveh Bazargan via use-livecode
Is there any way of seeing invisible characters in a text field, similar to
the view in text editors and word processors?
--
Kaveh Bazargan
Kaveh Bazargan via use-livecode
2018-12-08 01:12:18 UTC
Permalink
Thanks Bob. I did mean non-printing characters. I think just space, tab and
return.

The problem with replacing with with a character is that of course it is
not a space any more, so text would not wrap as normal. I need the user to
edit as normal and with normal functionality but see the normally invisible
characters. So seems I would need a native solution. :-(

On Sat, 8 Dec 2018 at 00:22, Bob Sneidar via use-livecode <
Post by Bob Sneidar via use-livecode
Not natively. You would have to replace every non-printing character
(that's what you mean by invisible I suppose) with a square digbat or
something. If you want to filter for only printable characters, I have a
function that dies that, and also there are regex strings for that sort of
thing.
Bob S
On Dec 7, 2018, at 15:44 , Kaveh Bazargan via use-livecode <
Is there any way of seeing invisible characters in a text field, similar
to
the view in text editors and word processors?
--
Kaveh Bazargan
_______________________________________________
use-livecode mailing list
Please visit this url to subscribe, unsubscribe and manage your
http://lists.runrev.com/mailman/listinfo/use-livecode
--
Kaveh Bazargan
Director
River Valley Technologies <http://rivervalleytechnologies.com/> • Twitter
<https://twitter.com/kaveh1000> • LinkedIn
<https://www.linkedin.com/in/bazargankaveh/>
Paul Dupuis via use-livecode
2018-12-08 01:25:30 UTC
Permalink
You can set the imageSource of the non-printing characters. They will
remain spaces, tabs, and returns, but can have a small image (you will
have to make or find) displayed in their place. See imageSource in the
Dictionary.

set the imageSource of character to {imageID |imageName |imageURL |empty}
Post by Kaveh Bazargan via use-livecode
Thanks Bob. I did mean non-printing characters. I think just space, tab and
return.
The problem with replacing with with a character is that of course it is
not a space any more, so text would not wrap as normal. I need the user to
edit as normal and with normal functionality but see the normally invisible
characters. So seems I would need a native solution. :-(
On Sat, 8 Dec 2018 at 00:22, Bob Sneidar via use-livecode <
Post by Bob Sneidar via use-livecode
Not natively. You would have to replace every non-printing character
(that's what you mean by invisible I suppose) with a square digbat or
something. If you want to filter for only printable characters, I have a
function that dies that, and also there are regex strings for that sort of
thing.
Bob S
On Dec 7, 2018, at 15:44 , Kaveh Bazargan via use-livecode <
Is there any way of seeing invisible characters in a text field, similar
to
the view in text editors and word processors?
--
Kaveh Bazargan
_______________________________________________
use-livecode mailing list
Please visit this url to subscribe, unsubscribe and manage your
http://lists.runrev.com/mailman/listinfo/use-livecode
Kaveh Bazargan via use-livecode
2018-12-08 09:08:45 UTC
Permalink
Thank you. Did not know about that. It works, but seems for a specific char
or chars.

I have tried:

on mouseup
lock screen
repeat with i = 1 to the number of chars of fld "text"
if char i of fld "text" is return then
set the imagesource of char i of fld "text" to "myreturn"
end if
end repeat
end mouseup

but of course it is slow and would be slower if I want to replace spaces.

Additionally, if I cut and pasted in the field I need to replace the chars
in the pasted text again...

What I am looking for is a native replacement of a return, say, with a
visible characters wherever it appears.

On Sat, 8 Dec 2018 at 01:26, Paul Dupuis via use-livecode <
Post by Paul Dupuis via use-livecode
You can set the imageSource of the non-printing characters. They will
remain spaces, tabs, and returns, but can have a small image (you will
have to make or find) displayed in their place. See imageSource in the
Dictionary.
set the imageSource of character to {imageID |imageName |imageURL |empty}
Post by Kaveh Bazargan via use-livecode
Thanks Bob. I did mean non-printing characters. I think just space, tab
and
Post by Kaveh Bazargan via use-livecode
return.
The problem with replacing with with a character is that of course it is
not a space any more, so text would not wrap as normal. I need the user
to
Post by Kaveh Bazargan via use-livecode
edit as normal and with normal functionality but see the normally
invisible
Post by Kaveh Bazargan via use-livecode
characters. So seems I would need a native solution. :-(
On Sat, 8 Dec 2018 at 00:22, Bob Sneidar via use-livecode <
Post by Bob Sneidar via use-livecode
Not natively. You would have to replace every non-printing character
(that's what you mean by invisible I suppose) with a square digbat or
something. If you want to filter for only printable characters, I have a
function that dies that, and also there are regex strings for that sort
of
Post by Kaveh Bazargan via use-livecode
Post by Bob Sneidar via use-livecode
thing.
Bob S
On Dec 7, 2018, at 15:44 , Kaveh Bazargan via use-livecode <
Is there any way of seeing invisible characters in a text field,
similar
Post by Kaveh Bazargan via use-livecode
Post by Bob Sneidar via use-livecode
to
the view in text editors and word processors?
--
Kaveh Bazargan
_______________________________________________
use-livecode mailing list
Please visit this url to subscribe, unsubscribe and manage your
http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
Please visit this url to subscribe, unsubscribe and manage your
http://lists.runrev.com/mailman/listinfo/use-livecode
--
Kaveh Bazargan
Director
River Valley Technologies <http://rivervalleytechnologies.com/> • Twitter
<https://twitter.com/kaveh1000> • LinkedIn
<https://www.linkedin.com/in/bazargankaveh/>
David V Glasgow via use-livecode
2018-12-08 12:01:39 UTC
Permalink
Hello folks,

I am writing an academic paper on an analysis of internet predator messages undertaken using an LC app.

A few of the filtered terms I used incorporated wildcards (I avoided regular expressions). I need to reference a published source for the implementation of wildcards within LC, if such a thing exists.

Does it?

Cheers,

David Glasgow
hh via use-livecode
2018-12-08 14:21:49 UTC
Permalink
Post by Kaveh Bazargan via use-livecode
What I am looking for is a native replacement of a return, say,
with a visible characters wherever it appears.
You have to replace return with <visibleChar>&return if you wish
to preserve the line breaks.

Similarly
• have you to replace space with <visibleChar>&space if you wish
to preserve the word breaks,
• have you to replace tab with <visibleChar>&tab if you wish
to preserve the indents.

You could use unicodeChars for such a making of "whitespace" visible.
If you do it in a variable this is very fast, slower but still fast
for making such "whitespace" (space, tab, return) again invisible.

Of course this removes any styling from the variable. If you need to
preserve styles then you could try
"replace in field <preserving|replacing> styles".
But then it becomes very slow.

Here the fast unicode-symbols-in-variable method. It has moreover the
advantage that you can copy and paste such "visible-whitespace-text".

on mouseUp b
put the millisecs into m1
lock screen; lock messages
put fld 1 into txt
put numToCodePoint(0x00B7)&numToCodePoint(0x200A) into s0
put numToCodePoint(0x23CE)&cr into c0
put numToCodePoint(0x21E5)&tab into t0
if b=3 then
replace tab with t0 in txt
replace cr with c0 in txt
replace space with s0 in txt
else
replace s0 with space in txt
replace c0 with cr in txt
replace t0 with tab in txt
end if
put txt into fld 1
put the millisecs - m1 into fld "timing"
end mouseUp

Note.
The above is *VERY* basic. Your text could also contain other variants
of tabs (right, left ...), spaces (unicode spaces, e.g. non-breaking)
and returns (mixed LF/CR, paragraph signs).
hh via use-livecode
2018-12-08 15:06:07 UTC
Permalink
I need the user to edit as normal and with normal functionality but see the normally
invisible characters. So seems I would need a native solution. :-(
This works for me (TMHO, this demonstrates the beauty of LC).
Script your field with the following.

on rawkeyDown k
switch k
case 32 -- space
put numToCodePoint(0x00B7)&numToCodePoint(0x200A) into the selection
break
case 65293 -- return
put numToCodePoint(0x23CE)&cr into the selection
break
case 65289 -- tab
-- put tab&numToCodePoint(0x21E5) into the selection -- alternate
put numToCodePoint(0x21E5)&tab into the selection
break
default
pass rawkeydown
end switch
end rawkeyDown

For converting the whole field *or a visible part of it* (you could use a check button)
use the replace-script of my last post. For a few lines (< 500), put into a temporary
field, conversion preserving styles is still fast.
Kaveh Bazargan via use-livecode
2018-12-08 15:58:18 UTC
Permalink
Thank you for spending the time on this. Like all your posts it is an
education! Great idea to convert just a visible part of text! I am going to
study well and work on this.

On the live conversion, you are adding a unicode character before a space,
say. That means two characters and therefore two character widths. Is there
a way of making spaces zero width, or the new characters overlapping the
space etc? Ideally I want the text widths of lines to be the same with and
without the visible chars.

On Sat, 8 Dec 2018 at 15:06, hh via use-livecode <
Post by Kaveh Bazargan via use-livecode
I need the user to edit as normal and with normal functionality but see
the normally
invisible characters. So seems I would need a native solution. :-(
This works for me (TMHO, this demonstrates the beauty of LC).
Script your field with the following.
on rawkeyDown k
switch k
case 32 -- space
put numToCodePoint(0x00B7)&numToCodePoint(0x200A) into the selection
break
case 65293 -- return
put numToCodePoint(0x23CE)&cr into the selection
break
case 65289 -- tab
-- put tab&numToCodePoint(0x21E5) into the selection -- alternate
put numToCodePoint(0x21E5)&tab into the selection
break
default
pass rawkeydown
end switch
end rawkeyDown
For converting the whole field *or a visible part of it* (you could use a check button)
use the replace-script of my last post. For a few lines (< 500), put into a temporary
field, conversion preserving styles is still fast.
_______________________________________________
use-livecode mailing list
Please visit this url to subscribe, unsubscribe and manage your
http://lists.runrev.com/mailman/listinfo/use-livecode
--
Kaveh Bazargan
Director
River Valley Technologies <http://rivervalleytechnologies.com/> • Twitter
<https://twitter.com/kaveh1000> • LinkedIn
<https://www.linkedin.com/in/bazargankaveh/>
hh via use-livecode
2018-12-08 15:59:47 UTC
Permalink
You could moreover add the following to the field's script.

on rawkeyup k
switch k
case 65288 -- backspace
put word 4 of the selectedChunk into cx
if char cx of me is among the items of \
(numToCodePoint(0x23CE),numToCodePoint(0x21E5),numToCodePoint(0x00B7))
then delete char cx of me
break
case 65535 -- forward delete
put word 2 of the selectedChunk into cx
if char cx of me is among the items of (numToCodePoint(0x200A),cr,tab)
then delete char cx of me
break
default
pass rawkeyup
end switch
end rawkeyUp

There is still more to do, e.g. when typing after a return symbol...
Hope you are (as I did) sharing your working edit code when done.
Post by hh via use-livecode
I need the user to edit as normal and with normal functionality but see the normally
invisible characters. So seems I would need a native solution. :-(
This works for me (TMHO, this demonstrates the beauty of LC).
Script your field with the following.
on rawkeyDown k
switch k
case 32 -- space
put numToCodePoint(0x00B7)&numToCodePoint(0x200A) into the selection
break
case 65293 -- return
put numToCodePoint(0x23CE)&cr into the selection
break
case 65289 -- tab
-- put tab&numToCodePoint(0x21E5) into the selection -- alternate
put numToCodePoint(0x21E5)&tab into the selection
break
default
pass rawkeydown
end switch
end rawkeyDown
Kaveh Bazargan via use-livecode
2018-12-08 16:28:30 UTC
Permalink
On Sat, 8 Dec 2018 at 16:00, hh via use-livecode <
Post by hh via use-livecode
You could moreover add the following to the field's script.
on rawkeyup k
switch k
case 65288 -- backspace
put word 4 of the selectedChunk into cx
if char cx of me is among the items of \
(numToCodePoint(0x23CE),numToCodePoint(0x21E5),numToCodePoint(0x00B7))
then delete char cx of me
break
case 65535 -- forward delete
put word 2 of the selectedChunk into cx
if char cx of me is among the items of
(numToCodePoint(0x200A),cr,tab)
then delete char cx of me
break
default
pass rawkeyup
end switch
end rawkeyUp
There is still more to do, e.g. when typing after a return symbol...
Hope you are (as I did) sharing your working edit code when done.
I have a long way to go before I have anything useful as I am still trying
to grasp the excellent information. But of course I will share if I have
anything to add to these.
--
Kaveh Bazargan
Director
River Valley Technologies <http://rivervalleytechnologies.com/> • Twitter
<https://twitter.com/kaveh1000> • LinkedIn
<https://www.linkedin.com/in/bazargankaveh/>
Kaveh Bazargan via use-livecode
2018-12-08 21:03:34 UTC
Permalink
Hi Hermann

There is a also a zero width character. :-) that is 200B. So using a
monospace font all chars line up.

And even more interesting, when I press the backspace key, it generally
treats the composite pair as one character, so jumps back over both with
one backspace!!

On Sat, 8 Dec 2018 at 16:28, Kaveh Bazargan <
Post by Kaveh Bazargan via use-livecode
On Sat, 8 Dec 2018 at 16:00, hh via use-livecode <
Post by hh via use-livecode
You could moreover add the following to the field's script.
on rawkeyup k
switch k
case 65288 -- backspace
put word 4 of the selectedChunk into cx
if char cx of me is among the items of \
(numToCodePoint(0x23CE),numToCodePoint(0x21E5),numToCodePoint(0x00B7))
then delete char cx of me
break
case 65535 -- forward delete
put word 2 of the selectedChunk into cx
if char cx of me is among the items of
(numToCodePoint(0x200A),cr,tab)
then delete char cx of me
break
default
pass rawkeyup
end switch
end rawkeyUp
There is still more to do, e.g. when typing after a return symbol...
Hope you are (as I did) sharing your working edit code when done.
I have a long way to go before I have anything useful as I am still trying
to grasp the excellent information. But of course I will share if I have
anything to add to these.
--
Kaveh Bazargan
Director
River Valley Technologies <http://rivervalleytechnologies.com/> • Twitter
<https://twitter.com/kaveh1000> • LinkedIn
<https://www.linkedin.com/in/bazargankaveh/>
--
Kaveh Bazargan
Director
River Valley Technologies <http://rivervalleytechnologies.com/> • Twitter
<https://twitter.com/kaveh1000> • LinkedIn
<https://www.linkedin.com/in/bazargankaveh/>
hh via use-livecode
2018-12-08 16:23:42 UTC
Permalink
Post by Kaveh Bazargan via use-livecode
On the live conversion, you are adding a unicode character before
a space, say. That means two characters and therefore two character
widths. Is there a way of making spaces zero width, or the new characters
overlapping the space etc? Ideally I want the text widths of lines to be
the same with and without the visible chars.
No. I don't replace a space with a unicode char and a space but with a
unicode char and *the smallest word-breaking space in unicode (hair space)*.

You could try to use an accent to a space but this isn't word breaking any
more.

The zero width space is non word-breaking in LC and an opportunity of word
breaking elsewhere.
What you should have also in mind with these solutions is that it must be
clear for the user what he is selecting, so inserting zero width chars will
make selecting random down to 2 chars.

The only char with a negative space in unicode I know of is the
MONGOLIAN VOWEL SEPARATOR, see http://jkorpela.fi/chars/spaces.html
All these spaces are possible if someone copies text from a UTF-8 web page
and pastes into your field!!

As you don't have access to a word break table you have to write your own
word-breaking algorithm ...
hh via use-livecode
2018-12-08 21:25:57 UTC
Permalink
Post by Kaveh Bazargan via use-livecode
There is a also a zero width character. :-) that is 200B.
So using a monospace font all chars line up.
This works if and only if your field has dontWrap true, else your
line will not (soft-)break at the new "spaces" between the words.

But then (if dontWrap is true) you don't need any additional word-break
char, you could then simply use the middot numToCodePoint(0x00B7) instead
of space.
Post by Kaveh Bazargan via use-livecode
... The zero width space is non word-breaking in LC and an opportunity of word
breaking elsewhere...
Loading...