Re: BUG? getchar(0) and getchar(1) do not detect ESC
Peter Hodge wrote: Hello all, I am having trouble with getchar() detecting ESC. If I use getchar(0) or getchar(1), it will not pick up an ESC keystroke. You can replicate this by using the command: :sleep 3 | echo getchar(0) ... and pressing ESC quickly before the getchar() function is called. In GUI Vim, I correctly see 27 returned by getchar(0), but in Terminal Vim, getchar(0) is returning '0', even though ESC has been pressed. Is this a bug in Vim? regards, Peter Here, it depends of the number of keypresses: In gvim, :sleep 10 | echo getchar(0) followed by Esc returns 27 with no beep after 10 seconds. If Esc is pressed twice during the sleep period, it returns 27 with one beep after 10 seconds. In console Vim (with the same executable), :sleep 10 | echo getchar(0) followed by Esc returns 0 with one beep after 10 seconds. If Esc is hit twice during the sleep period, it returns 27 with one beep after 10 seconds. I suspect the difference may be due to the fact that many special keys generate (in console terminals but not in gvim) byte sequences starting with Esc, so the Esc key is not really seen until the next byte has been input. Hitting Del in konsole during the sleep period gives me 80kD with no beep, not the raw keycode, which would have been ^[[3~ :set timeout timeoutlen=5000 ttimeoutlen=250 apparently doesn't make any difference. Best regards, Tony.
Re: BUG? getchar(0) and getchar(1) do not detect ESC
Peter Hodge wrote: I am having trouble with getchar() detecting ESC. If I use getchar(0) or getchar(1), it will not pick up an ESC keystroke. You can replicate this by using the command: :sleep 3 | echo getchar(0) ... and pressing ESC quickly before the getchar() function is called. In GUI Vim, I correctly see 27 returned by getchar(0), but in Terminal Vim, getchar(0) is returning '0', even though ESC has been pressed. Is this a bug in Vim? It's because Esc is the start of a key sequence and it's incomplete. Vim can't know you pressed the Esc key instead of having received the first byte of a key sequence. -- Imagine a world without hypothetical situations. /// 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///
BUG? getchar(0) and getchar(1) do not detect ESC
Hello all, I am having trouble with getchar() detecting ESC. If I use getchar(0) or getchar(1), it will not pick up an ESC keystroke. You can replicate this by using the command: :sleep 3 | echo getchar(0) ... and pressing ESC quickly before the getchar() function is called. In GUI Vim, I correctly see 27 returned by getchar(0), but in Terminal Vim, getchar(0) is returning '0', even though ESC has been pressed. Is this a bug in Vim? regards, Peter On Yahoo!7 Answers: 25 million answers and counting. Learn something new today http://www.yahoo7.com.au/answers