On Thu, Feb 24, 2011 at 05:25:17AM -0500, Benjamin R. Haskell wrote: > The whole situation is pretty arbitrary. E.g. ./demo's output under > a modifyOtherKeys:2 UXTerm, compressed to one row, for <Shift>+ the > top row of my typical US 105-key or variant: > > <S-~> ! <S-@> # $ % <S-^> & * ( ) <S-_> + <Backspace> > > Why the Shift modifier on ~, @, ^, and _, but not !, #, $, etc? > (Guessing hysterical raisins.)
That sounds like a buggy implementation. Due to all the vagueness of what shift means in the context of Unicode (is ! really ! or is it Shift-1) my specification called for explicitly ignoring the state of the Shift key in the terminal, at the time the modified Unicode sequence is created. If that isn't happening, I vote bug. > Didn't realize ECMA-48 existed, though. Thanks. It's essential in these matters. :) Once you read the spec part for CSI, you realise how short and neat the entire scheme really is, how extensible it is provided you actually have a real CSI parser and not a dumb string-prefix matcher a.la. termcap/terminfo/curses combinations. > > modifyOtherKeys: 2 > > > >Except that on its own now breaks most other applications, because > >xterm is too keen to use the CSI encoding scheme on "normal" > >keypresses, such as Ctrl-D. xterm doesn't yet send the correct and > >useful sequences here, but it is not difficult to fix its code to > >do so - I have been in occasional contact with Thomas Dickey on > >this issue; I need to poke him again sometime soon to check he's > >properly looking into it. > > Cool. Works as advertised (i.e. currently not in anything other > than the `demo` program, but still interesting to see the ability is > built in). I am also recently informed by Thomas Dickey that formatOtherKeys: 1 sends a slightly nicer CSI u rather than CSI 27~ encoding > >What is needed is a hybrid scheme, whereby the simplest key > >encoding is used in a nicer way; where Ctrl-D would send the > >single 0x04 byte (so kernel's pty driver can recognise "here's an > >EOF"), but Ctrl-Shift-D sends CSI 68;5 u to encode it correctly. > > How do <Tab> and <Ctrl-i> fit into this scheme? What's the > "simplest key encoding"? <Tab> 0x08 (ASCII HT) <Ctrl-I> CSI 105;5u (i == 105 decimal in ASCII) <Ctrl-Shift-I> CSI 73;5u (I == 73 decimal in ASCII) Note that, due to what I said above, we have to ignore the shift key in these CSI u sequences; the distinction between Ctrl-I and Ctrl-Shift-I is simply that one is lowercase and one is capital. > >>how would using libtermkey be anything less than a huge PITA > >>when working on multiple systems that aren't so configured? Or > >>is this a chicken-and-egg problem? (Nothing is configured to > >>send anything other than 70's-style "<C-i>" == "<Tab>", so > >>nothing ever will be.) > > > >Rightnow, xterm will send the same byte for Tab, Ctrl-I or > >Ctrl-Shift-I. Setting modifyOtherKeys to 2 will send real > >keypresses that it can tell, but now everything else cannot. > > > >Ultimately, yes. It is chicken and egg, in order for -everything- > >to work in a happy shiney way. But even without terminal changes, > >applications can benefit from using libtermkey now. > > > >So to answer your question on "how would using libtermkey be > >anything less than a huge PITA" - it isn't. It already recognises, > >via its terminfo-driven parser, every keypress that > >terminfo/curses already recognises. It cannot be worse. It is > >strictly better than, because of the full CSI parser I mentioned > >above. > > Thanks. This paragraph combined with the first section about > parsing unknown CSI sequences is plenty convincing. (trimmed rest) Another thought occurs to me. Run vim in xterm. It recognises Ctrl-Left, because vim handles TERM=xterm specially to recognise this case. Run vim in screen in xterm. It doesn't recognise Ctrl-Left, instead interpreting it as Escape, 1; (ignored), 5C. Deletes 5 lines of text and enters insert mode. Mass fail. Run libtermkey's demo either in xterm or in screen-in-xterm. Observe that Ctrl-Left works IN BOTH CASES. This is because it always applies its CSI parser, so always understands xterm-alike CSI encoding of Ctrl-Left (et.al.). This fact -alone- should be enough to convince you. :) -- Paul "LeoNerd" Evans [email protected] ICQ# 4135350 | Registered Linux# 179460 http://www.leonerd.org.uk/
signature.asc
Description: Digital signature
