slang-users mailing list

[2004 Date Index] [2004 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: [slang-users] Reconstructing the last key sequence


Hi!

* "John E. Davis" <davis@xxxxxxxxxxxxx> [Tue 2004-03-02 06:04 PM] :

[Symbolic names of key-sequences]
> Mapping a key-sequence back to the constants is tricky, particularly if
> one allows ESC to be a separate sequence.  Then does ESC [ A represent 3
> characters or a single Up-arrow?

I think that it is safe to assume that a user prefers pressing the single
up-arrow key to entering the complicated escape sequence, so a reasonable
strategy would be "See if a corresponding key exists; if not, output the
escape sequence."

Thanks for the pointer to keydefs.sl. I looked at it and it seems to me
that the best way to do what I want is to create a table that does a
one-to-one mapping of symbolic names of function keys to key sequences. It
could then be used for forward and inverse lookups. To initialize this
table, I would try to use SLtt_tgetstr. If this function is not available
or does not give a result, I would fall back to OS-specific defaults.

I think that it would be convenient to have these defaults in future
versions of the s-lang library - e.g. have a function like SLtt_tgetstr
that optionally guesses a value if it doesn't find one in the terminfo
database. This may not be 100% reliable, but otherwise the application has
to do a similar (non-reliable) guess itself and the advantage of doing it
inside the library would be that as soon as you find better rules for the
guessing, all applications will immediately profit from it.

While we're in "wishlist mode" anyway: It would be even more convenient to
have functions that directly support the forward / inverse mapping :-)

One drawback of the approach I'm considering would be that each lookup
involves a number of string comparisons; but I expect that I will not use
it so extensively that the cost of this becomes a problem. Of course, I'm
happy to hear about better suggestions.

Kind regards
    Thomas Schultz


[2004 date index] [2004 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]