Re: insert-mode :map-alt-keys and 8-bit locales
A.J.Mechelynck wrote: Ilya Sher wrote: A.J.Mechelynck wrote: Alexey I. Froloff wrote: * Bram Moolenaar Bram@ [061022 17:41]: I don't want to support that, because it causes mistakes. Consider being in Insert mode and typing Esc o to open a new line or Esc n to find the next match. A timeout won't help, the two keys can be typed within ten msec. So, all plugins that imap something to Alt+Key a screwed up in all non-ascii 8-bit locales. Moreover, such maps breaks normal text entering. There is something outside your latin-1 world. Take a look around, you, 7-bit racists. - Maybe Bram Moolenaar can type at 100 keystrokes / second, I can't. Especially if one of the keys is Esc, which is far away from almost everything else. Assuming one-handed typing, (especially for Esco and Escn) which is almost always not true for vim users. Assumption that people use keyboard mappings where Esc is far away is true most of the time but not always. (Common exception is caps lock generating Esc). [snip] When I say I can't, I'm talking about me on my keyboard, where the Esc key is at top left, and the nearest keys are (²³¬) (1|) (é2@) and F1 (Between round brackets: unshifted, with Shift, and with AltGr, in that order, for a single key). I'm not assuming that _you_ cannot type 100 keystrokes per second, though I would bet that the Vimmers who can are a minority at best. ;-) I was probably not clear enough. The point is that one does not even have to type at that speed to hit pretty fast Esco if the Esc is not far away and both hands are used. ... the first condition is optional. Best regards, Tony. -- For robots (please don't mail me there): [EMAIL PROTECTED] My real email is ilya @ same domain
Re: insert-mode :map-alt-keys and 8-bit locales
Alexey Froloff wrote: * Alexey I. Froloff raorn@ [061021 17:53]: Vim should _support_ Meta-Sends-Escape mode which is A Must Have for non-ascii 8-bit locales Patch attached. New option - 'eightbitmeta' ('em'), default on. If unset, two things happen: 1. M-x is stored internaly as Escx sequence (was (x | 0x80)). 2. Alt+key puts Esckey to input buffer (GUI only). How do you distinguish between someone typing Esc key and Esc key generated by Alt+key? -- From know your smileys: :~)A man with a tape recorder up his nose /// 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: insert-mode :map-alt-keys and 8-bit locales
* Bram Moolenaar Bram@ [061022 14:27]: How do you distinguish between someone typing Esc key and Esc key generated by Alt+key? I don't. No program can do that, as Tony mentioned earlier. bash (readline) for example: M-b - backward-word Alt+b and Escb works both the same, if Alt+Key sends EscKey sequence. Consider this as a feature. With 'em' unset Vim behaves like every console application. -- Regards, Sir Raorn. signature.asc Description: Digital signature
Re: insert-mode :map-alt-keys and 8-bit locales
* Bram Moolenaar Bram@ [061022 17:41]: I don't want to support that, because it causes mistakes. Consider being in Insert mode and typing Esc o to open a new line or Esc n to find the next match. A timeout won't help, the two keys can be typed within ten msec. So, all plugins that imap something to Alt+Key a screwed up in all non-ascii 8-bit locales. Moreover, such maps breaks normal text entering. There is something outside your latin-1 world. Take a look around, you, 7-bit racists. -- Regards, Sir Raorn. signature.asc Description: Digital signature
Re: insert-mode :map-alt-keys and 8-bit locales
Alexey I. Froloff wrote: * Bram Moolenaar Bram@ [061022 14:27]: How do you distinguish between someone typing Esc key and Esc key generated by Alt+key? I don't. No program can do that, as Tony mentioned earlier. bash (readline) for example: M-b - backward-word Alt+b and Escb works both the same, if Alt+Key sends EscKey sequence. Consider this as a feature. With 'em' unset Vim behaves like every console application. I should qualify what I said before: if you have 'ttimeout' (or 'timeout') on, and 'ttimeoutlen' set to a well-chosen positive value (longer than the delay between successive bytes added by the keyboard interface for a single keypress, but shorter than your usual typing speed), Vim will be able to determine that Esc key was typed-in rather than M-key, by means of the timeout: let's say you have :set ttimeout ttimeoutlen=100 then if the delay between the Esc byte and the next one is 0.1s Vim will see it as Escape + something, not Meta-something. (By default, 'ttimeoutlen' is negative, meaning that the same, relatively long timeout applies for both special keys and mappings.) What I said before still applies in the case of key combinations which send a single byte (e.g. Meta-is-high-bit), because in that case there is no timeout. Best regards, Tony.
Re: insert-mode :map-alt-keys and 8-bit locales
Ilya Sher wrote: A.J.Mechelynck wrote: Alexey I. Froloff wrote: * Bram Moolenaar Bram@ [061022 17:41]: I don't want to support that, because it causes mistakes. Consider being in Insert mode and typing Esc o to open a new line or Esc n to find the next match. A timeout won't help, the two keys can be typed within ten msec. So, all plugins that imap something to Alt+Key a screwed up in all non-ascii 8-bit locales. Moreover, such maps breaks normal text entering. There is something outside your latin-1 world. Take a look around, you, 7-bit racists. - Maybe Bram Moolenaar can type at 100 keystrokes / second, I can't. Especially if one of the keys is Esc, which is far away from almost everything else. Assuming one-handed typing, (especially for Esco and Escn) which is almost always not true for vim users. Assumption that people use keyboard mappings where Esc is far away is true most of the time but not always. (Common exception is caps lock generating Esc). [snip] When I say I can't, I'm talking about me on my keyboard, where the Esc key is at top left, and the nearest keys are (²³¬) (1|) (é2@) and F1 (Between round brackets: unshifted, with Shift, and with AltGr, in that order, for a single key). I'm not assuming that _you_ cannot type 100 keystrokes per second, though I would bet that the Vimmers who can are a minority at best. ;-) Best regards, Tony.
Re: insert-mode :map-alt-keys and 8-bit locales
Alexey I. Froloff wrote: [...] P.S. Please, don't tell me that I should not use M-x in insert-mode mappings, tell this to script maintainers. latexSuite for example. If you have a problem with the Latex-Suite, then IMHO you should mention that, and it would do no harm to add the Latex-Suite maintainer in the CC: line. Similarly for any other package that gives you problems. If you identify the problematic mappings in the package, you may even propose a different mapping. If some package mapping interferes with some non-7-bit-ASCII letter (be it your cyrillic И or my French é) I don't think the maintainer will refuse to change the mapping, or make it configurable. Best regards, Tony.
Re: insert-mode :map-alt-keys and 8-bit locales
* A.J.Mechelynck antoine.mechelynck@ [061022 22:41]: - Maybe Bram Moolenaar can type at 100 keystrokes / second, I can't. [..skip..] http://marc.theaimsgroup.com/?l=vim-devm=116133874121615w=2 Please, read this. Twice. I can't enter CYRILLIC CAPITAL I if I have imap on M-i. - There is indeed something beyond 7-bit ASCII, but that is no I'm describing you my problem for three days. You don't even want to listen. You prefer to tell me stories about dozens and lids... - What about the part you snipped (about CSI rather than ESC)? If you look closely, you mention that two places were changed. First - GUI input processing, second - special key parser, that used in map command - both GUI and console. Can I use CSI in console? How will I know, if someone typed Esc i or pressed Alt+I? Why gvim sets eight bit instead of using CSI? By the way, default behavior is not changed, and 'to' and 'ttimeout' still works. P.S. Please, don't tell me that I should not use M-x in insert-mode mappings, tell this to script maintainers. latexSuite for example. -- Regards, Sir Raorn. signature.asc Description: Digital signature
Re: insert-mode :map-alt-keys and 8-bit locales
* A.J.Mechelynck antoine.mechelynck@ [061021 08:01]: IMHO, the way to configure it is not by hacking Vim but (at least in console Vim) by having a properly-built termcap/terminfo which tells Vim which codes correspond to which keys. IIRC, only user can tell what will Meta+Key send and it has nothing to do with term*. I'm talking about convert-meta (inputrc) and eightBitInput (xterm). but no program can discriminate between different keypresses which your keyboard driver translates to the same keycode (or keycode sequence). Vim assumes that Meta+Key always generates (Key | 0x80). Code: /* * Try to include modifiers in the key. * Changes Shift-a to 'A', Alt-A to 0xc0, etc. */ int extract_modifiers(key, modp) int key; int *modp; { ... if ((modifiers MOD_MASK_ALT) key 0x80 ... ) { key |= 0x80; modifiers = ~MOD_MASK_ALT; /* remove the META modifier */ } ... Add extra condition, '8bitmeta' option checking (which is on by default) for example. However, this will not solve all problems, I will look further. P.S. Why am I doing all this? latexsuite plugin imaps M-x keys and this generates problems in ru_RU.KOI8-R locale (8bit). This can't be fixed without hacking into latexsuite code and this bug happend only if (x | 0x80) means something in current locale. One workaround is to switch to UTF-8 locale. -- Regards, Sir Raorn. signature.asc Description: Digital signature
Re: insert-mode :map-alt-keys and 8-bit locales
Alexey I. Froloff wrote: * A.J.Mechelynck antoine.mechelynck@ [061021 08:01]: IMHO, the way to configure it is not by hacking Vim but (at least in console Vim) by having a properly-built termcap/terminfo which tells Vim which codes correspond to which keys. IIRC, only user can tell what will Meta+Key send and it has nothing to do with term*. I'm talking about convert-meta (inputrc) and eightBitInput (xterm). As you told me recently, you don't know what you're talking about. Most nontechnical users don't know (and don't care) what binary keycodes their keyboard interface is sending to their program when they hit which key combination. Only the programmers of the keyboard interface (and the admins who write keyboard-interface configuration files) can decide which keycodes correspond to which keypresses, and it takes quite some technical expertise to find out with certainty what key combinations are sent by which keypresses on which systems for all possible combinations of modifier and other keys. It might be relatively straightforward (if not necessarily easy) for programs running only on Windows or only on X11 but Vim has to cater for not only Windows, X11 and Carbon but also tens of different text consoles and console emulators. Vim relies on such things as the termcap/terminfo libraries (both builtin and disk-resident) and the $TERM environment variable to tell it what terminal it is running on, which influences how it will interpret the keycodes sent to it by the keyboard interface. If the termcap is broken or $TERM set to a wrong value (both of which happen more often than you might think), Vim will misunderstand what the keyboard sends. but no program can discriminate between different keypresses which your keyboard driver translates to the same keycode (or keycode sequence). Vim assumes that Meta+Key always generates (Key | 0x80). Code: [snip] What I'm saying, is that, if my (fr_BE) keyboard interface is sending the same keycode when I hit é (SMALL LATIN LETTER E WITH ACUTE ACCENT) and when I hit Alt-i (SMALL LATIN LETTER I with the Alt modifier), then Vim won't be able to see the difference between é and Alt-i, and in that case, if I use imap M-i {rhs} I'll get that {rhs} instead of an e-acute whenever I hit é in Insert mode. With such a keyboard interface I should avoid mapping Alt-keys in Insert mode if I want to be able to type French text: IOW, with that kind of keyboard interface, é and Alt-i are, как говорят Французы, белый колпак и колпак белый, или как говорят Англичане, шесть одного и полдюжина другого: /bonnet blanc et blanc bonnet/, or six of one and half a dozen of the other. Regards, Tony.
Re: insert-mode :map-alt-keys and 8-bit locales
On Sun, Oct 22, 2006 at 01:31:09AM +0400, Alexey I. Froloff wrote: Vim should _support_ Meta-Sends-Escape mode which is A Must Have for non-ascii 8-bit locales Patch attached. New option - 'eightbitmeta' ('em'), default on. If unset, two things happen: I like the idea, but did not test the patch yet. I did not get alt-keys work properly with the meta8 option in urxvt set. -- Martin
Re: insert-mode :map-alt-keys and 8-bit locales
Alexey Froloff wrote: There is bug in vim... According to :help :map-alt-keys : By default Vim assumes that pressing the ALT key sets the 8th bit of a typed character. This is wrong for 8-bit non-ascii locales. Example: :imap M-i something maps CYRILLIC CAPITAL I (in KOI8-R locale) instead of Alt-I. Also, vim suggests to set convert-meta to on in inputrc which is also wrong for 8-bit non-ascii locales. Finally, typing C-VM-i in insert mode gives me the same CYRILLIC CAPITAL I... I think there should be option for Meta handling... Read again: Vim _assumes_ the Alt key sets the 8th bit. If this doesn't happen, then you need to map the character that is produced instead of M-x. Vim can't know what key is actually pressed when some character with the 8th bit set arrives, unless your keyboard does what Vim expects. So either make your keyboard work as Vim expects or don't use the M-x mappings. -- If bankers can count, how come they have eight windows and only four tellers? /// 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: insert-mode :map-alt-keys and 8-bit locales
* Bram Moolenaar Bram@ [061020 23:04]: Read again: Vim _assumes_ the Alt key sets the 8th bit. What about GVim? If this doesn't happen, then you need to map the character that is produced instead of M-x. So, M-x is a shortcut for (x | 0x80)? This is not right. Not _always_ right. In general, this is wrong for all non-ascii 8-bit locales, Vim expectations is quite outdated... Vim can't know what key is actually pressed when some character with the 8th bit set arrives, Well, I am talking about _giving_ Vim this way. Will M-x be shortcut to (x | 0x80) or Escx. I'll take a look in code and try to make this configurable. -- Regards, Sir Raorn. signature.asc Description: Digital signature
Re: insert-mode :map-alt-keys and 8-bit locales
Alexey I. Froloff wrote: * Bram Moolenaar Bram@ [061020 23:04]: Read again: Vim _assumes_ the Alt key sets the 8th bit. What about GVim? When Bram talks about Vim without specifying Console or GUI version, he means all of them unless the opposite is obvious from the context. If this doesn't happen, then you need to map the character that is produced instead of M-x. So, M-x is a shortcut for (x | 0x80)? This is not right. Not _always_ right. In general, this is wrong for all non-ascii 8-bit locales, Vim expectations is quite outdated... Vim can't know what key is actually pressed when some character with the 8th bit set arrives, Well, I am talking about _giving_ Vim this way. Will M-x be shortcut to (x | 0x80) or Escx. I'll take a look in code and try to make this configurable. IMHO, the way to configure it is not by hacking Vim but (at least in console Vim) by having a properly-built termcap/terminfo which tells Vim which codes correspond to which keys. The GUI is somewhat cleverer than the console version (including, on Unix, cleverer than a GUI-enabled build running in console mode) when it comes to reading your keyboard, but no program can discriminate between different keypresses which your keyboard driver translates to the same keycode (or keycode sequence). Regards, Tony.
insert-mode :map-alt-keys and 8-bit locales
There is bug in vim... According to :help :map-alt-keys : By default Vim assumes that pressing the ALT key sets the 8th bit of a typed character. This is wrong for 8-bit non-ascii locales. Example: :imap M-i something maps CYRILLIC CAPITAL I (in KOI8-R locale) instead of Alt-I. Also, vim suggests to set convert-meta to on in inputrc which is also wrong for 8-bit non-ascii locales. Finally, typing C-VM-i in insert mode gives me the same CYRILLIC CAPITAL I... I think there should be option for Meta handling... -- Regards, Sir Raorn. signature.asc Description: Digital signature
Re: insert-mode :map-alt-keys and 8-bit locales
Alexey I. Froloff wrote: There is bug in vim... According to :help :map-alt-keys : By default Vim assumes that pressing the ALT key sets the 8th bit of a typed character. This is wrong for 8-bit non-ascii locales. Example: :imap M-i something maps CYRILLIC CAPITAL I (in KOI8-R locale) instead of Alt-I. Also, vim suggests to set convert-meta to on in inputrc which is also wrong for 8-bit non-ascii locales. Finally, typing C-VM-i in insert mode gives me the same CYRILLIC CAPITAL I... I think there should be option for Meta handling... This just means that Vim cannot distinguish between a CYRILLIC CAPITAL I sent by your keyboard because you hit the И key, or the same bit-pattern sent by your keyboard because you hit the Alt and I keys together. There's nothing Vim can do about it, all it sees is все еще то же самое... Best regards, Tony.