On 12/03/10 05:14, anna wrote:
Hi all,
I am wondering that under what condition a keystroke is dropped in
Vim? Sometimes, when I source (:so) a script which takes time, this
will make my keystrokes are dropped. However, when I type in insert
mode so fast, and although I map that keystrokes to a function with
long execution, there is no keystroke dropped. What is the difference
here? Or is it because it is in command-line, then the keystroke is
droppped?
Any information related to this matter is really appreciated. Thank
you.
Anna
When a command is being executed, Vim (temporarily) doesn't "listen" to
the keyboard. Normally, if you type at that moment, your keyhits are
stored in a "keyboard input queue" in the OS, and possibly transferred
to a "typeahead buffer" in Vim, and they wait there until the time comes
to act upon them. However, if those key queues become full (in Dos the
standard keyboard queue in the BIOS was only 15 characters long),
anything more that you type may get lost. Also, I think that some
operations (such as hitting Ctrl-Break or maybe Ctrl-C) may clear the
typeahead queue even if there is something in it.
Most commands run quite fast, but there are exceptions. Sourcing a
complex script may be one, or running commands (or sourcing scripts)
which invoke external commands. Running ":helptags $VIMRUNTIME/doc" to
rebuild Vim's main help tagfile takes a significant time; as long as
such a long-duration ex-command hasn't finished, the cursor remains,
unblinking, where it was on the command-line when <Enter> was hit to
start it (at least until or unless something displayed by the command
erases the command-line area). Similarly, :vimgrep (when there are many
files to process) can take quite long, so long that, even at zero
verbosity, every second or so it will tell you which file it is
examining so that you don't imagine that Vim is hung.
A vim-script can test if keyboard input is available, and possibly
consume the (first or only) keypress if there is one, see :help
getchar(). Conversely, it can also stuff keycodes into the typeahead
buffer, see :help feedkeys(). And it can request user input via the
various input*() functions, see :help input*(<Ctrl-D> or :help input*(<Tab>
Finally (but I don't think that it applies to the case you mention) you
can force Vim to drop some keystrokes by mapping them to <Nop>, or the
OS may gobble up some keystrokes for its own use and not pass them over
to Vim. And with a less-than-perfect keyboard such as the one I'm using
at the moment, some keys, when hit with too little force or not squarely
on, may fail to generate an electrical contact.
Best regards,
Tony.
--
Life would be so much easier if we could just look at the source code.
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php