RE: updated strtrans() patch for special keys

2006-05-15 Thread Zdenek Sekera
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
> Sent: 12 May 2006 21:45
> To: Eric Arnold
> Cc: vim-dev@vim.org
> Subject: Re: updated strtrans() patch for special keys
> 
> 
> Eric Arnold wrote:
> 
> > The doc page really only talks about regular control chars, leaving
> > the problem of special keys to the imagination.  Are they to be
> > considered a string of characters which are to be evaluated
> > individually against 'isprint', or are they a 
> meta-character which is
> > to be evaluated against 'isprint'?
> > 
> > 
> > strtrans({expr})*strtrans()*
> > The result is a String, which is {expr} with 
> all unprintable
> > characters translated into printable characters 
> |'isprint'|.
> > Like they are shown in a window.  Example: >
> > echo strtrans(@a)
> > <   This displays a newline in register a as "^@" instead of
> > starting a new line
> > 
> > 
> > However, if you have a ,  then having
> > 
> > €ü=02€ý,
> > 
> > show up in your window doesn't seem to be in the spirit of "all
> > unprintable characters translated".  Yes, the individual 
> components of
> > the string are in the @,~-255 range, but the key represented (left
> > mouse) is not.
> 
> The function does not have the purpose of showing key codes.  It is
> really only to turn a string into something without non-printable
> characters.  That's it.
> 
> The byte sequences used for a special character may also appear in a
> file or in a file name, they must not be interpreted as a special key
> then.
> 
> If you really want to convert a byte sequence to special key names
> another function would need to be used.

But why? Is it really the best choice to have different
function names for things that are so similar in their substance?
IMHO, the options to strtrans as suggested by E.A. would
fit the bill well and I would have to remember another
function name, another :h, etc.

---Zdenek


Re: updated strtrans() patch for special keys

2006-05-12 Thread Bram Moolenaar

Eric Arnold wrote:

> The doc page really only talks about regular control chars, leaving
> the problem of special keys to the imagination.  Are they to be
> considered a string of characters which are to be evaluated
> individually against 'isprint', or are they a meta-character which is
> to be evaluated against 'isprint'?
> 
> 
> strtrans({expr})  *strtrans()*
>   The result is a String, which is {expr} with all unprintable
>   characters translated into printable characters |'isprint'|.
>   Like they are shown in a window.  Example: >
>   echo strtrans(@a)
> < This displays a newline in register a as "^@" instead of
>   starting a new line
> 
> 
> However, if you have a ,  then having
> 
> €ü=02€ý,
> 
> show up in your window doesn't seem to be in the spirit of "all
> unprintable characters translated".  Yes, the individual components of
> the string are in the @,~-255 range, but the key represented (left
> mouse) is not.

The function does not have the purpose of showing key codes.  It is
really only to turn a string into something without non-printable
characters.  That's it.

The byte sequences used for a special character may also appear in a
file or in a file name, they must not be interpreted as a special key
then.

If you really want to convert a byte sequence to special key names
another function would need to be used.

-- 
hundred-and-one symptoms of being an internet addict:
129. You cancel your newspaper subscription.

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\download, build and distribute -- http://www.A-A-P.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///


Re: updated strtrans() patch for special keys

2006-05-12 Thread Eric Arnold

How about this idea:  have an option to strtrans() to convert *all*
keys to their <> format.  This way the output can be easily and
portably stored, and later translated back using the "\<>" evaluation.


" 'l' option = long format
" 'e' option = 'eval'able format
"
let s = 
"\\\,\,\,\,\\"
echomsg "raw=".s
echomsg "trans=".strtrans(s)
echomsg "trans l=".strtrans(s, "l" )
echomsg "trans e=".strtrans(s, "e" )
exe 'echomsg "raw2=' . s . '"'
" Output:
"
"
" raw=<03><1b>€ü<06><0d>,€kB,€ü<04> ,€ü<04>€ý<04>,€ü&€ý,
" trans=<03><1b>€ü<06><0d>,€kB,€ü<04> ,€ü<04>€ý<04>,€ü&€ý,
" trans 
l=
" trans 
e=\\\,\,\,\,\
" raw2=<03><1b>€ü<06><0d>,€kB,€ü<04> ,€ü<04>€ý<04>,€ü&€ý,


On 5/12/06, Eric Arnold <[EMAIL PROTECTED]> wrote:

The doc page really only talks about regular control chars, leaving
the problem of special keys to the imagination.  Are they to be
considered a string of characters which are to be evaluated
individually against 'isprint', or are they a meta-character which is
to be evaluated against 'isprint'?


strtrans({expr})*strtrans()*
The result is a String, which is {expr} with all unprintable
characters translated into printable characters |'isprint'|.
Like they are shown in a window.  Example: >
echo strtrans(@a)
<   This displays a newline in register a as "^@" instead of
starting a new line


However, if you have a ,  then having

€ü€ý,

show up in your window doesn't seem to be in the spirit of "all
unprintable characters translated".  Yes, the individual components of
the string are in the @,~-255 range, but the key represented (left
mouse) is not.

strtrans() already changes the length of the string by adding  ^ to
char,  or the hex equiv, which "breaks" the control chars for
subsequent direct re-use.  It's really a short step toward making a
fully readable string by translating special keys also.

Note that the translation of special keys won't affect those same
characters printing directly to the screen if they are not part of a
K_SPECIAL sequence.  If they are part of such a sequence, they have
only the meaning of the key, and so having the raw values print to the
screen doesn't seem useful a readable context.

I don't know if people are relying on special keys to be preserved by
strtrans(), unlike control keys, but if so, should it be an option?
Since there currently isn't a clean way of doing this in Vim, is seems
like belongs somewhere.



On 5/12/06, Bram Moolenaar <[EMAIL PROTECTED]> wrote:
>
> Eric Arnold wrote:
>
> > It wasn't handling certain keys.  This works now:
> >
> > echo strtrans("\,\,\,\,\\ > -notakey>")
>
> That already worked.  You apparently have wrong expectations of what
> strtrans() does.  The docs say: "like they are shown in a window".  Thus
> special keys must not be translated back to their <> form.
>
> --
> You cannot have a baby in one month by getting nine women pregnant.
>
>  /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net   \\\
> ///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
> \\\download, build and distribute -- http://www.A-A-P.org///
>  \\\help me help AIDS victims -- http://ICCF-Holland.org///
>



Re: updated strtrans() patch for special keys

2006-05-12 Thread Eric Arnold

The doc page really only talks about regular control chars, leaving
the problem of special keys to the imagination.  Are they to be
considered a string of characters which are to be evaluated
individually against 'isprint', or are they a meta-character which is
to be evaluated against 'isprint'?


strtrans({expr})*strtrans()*
The result is a String, which is {expr} with all unprintable
characters translated into printable characters |'isprint'|.
Like they are shown in a window.  Example: >
echo strtrans(@a)
 wrote:


Eric Arnold wrote:

> It wasn't handling certain keys.  This works now:
>
> echo strtrans("\,\,\,\,\\ -notakey>")

That already worked.  You apparently have wrong expectations of what
strtrans() does.  The docs say: "like they are shown in a window".  Thus
special keys must not be translated back to their <> form.

--
You cannot have a baby in one month by getting nine women pregnant.

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\download, build and distribute -- http://www.A-A-P.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///



Re: updated strtrans() patch for special keys

2006-05-12 Thread Bram Moolenaar

Eric Arnold wrote:

> It wasn't handling certain keys.  This works now:
> 
> echo strtrans("\,\,\,\,\\ -notakey>")

That already worked.  You apparently have wrong expectations of what
strtrans() does.  The docs say: "like they are shown in a window".  Thus
special keys must not be translated back to their <> form.

-- 
You cannot have a baby in one month by getting nine women pregnant.

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\download, build and distribute -- http://www.A-A-P.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///