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 <s-leftmouse>, 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("\<c-s-cr>,\<s-tab>,\<c-space>,\<c-s-up>,\<c-s-2leftmouse>\<c=
> -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 ///