Search notes:

VIM: src/ui.c

ui.c contains functions for the user interface:

ui_inchar()

Low-level characer input function.
See also gui_inchar()

ui_wait_for_chars_or_timer

Called from gui_wait_for_chars_or_timer(), if FEAT_TIMERS is defined.
Returns OK if something was read, FAIL if the time out was reached or if it was interrupted.

Input buffer

The input buffer is a simple char_u array:
static char_u inbuf[INBUFLEN + MAX_KEY_CODE_LEN];
The variable inbufcount has the number of characters stored in the input buffer. If inbufcount == 0, the input buffer is empty and vim_is_input_buf_empty() returns TRUE.
Functions to manipulate the input buffer are
These functions are used by gui_* calls when the keyboard input is handled by a GUI.
input_available() (in getchar.c) returns TRUE if either the input or typehad buffer has some bytes.
Further interesting functions seem to be get_input_buf() and set_input_buf().
The input buffer does not only store (keyboard-) characters. For example, when vim gets focus (Windows: _OnSetFocus(), a special byte-tripplet is inserted into the input buffer: CSI, KS_EXTRA, KE_FOCUSGAINED.
See also feedkeys(), the macro USE_INPUT_BUF.
TODO: What is the relationship to the typeahead buffer (typebuf_T)?

add_to_input_buf(…)

Adds the given bytes to the input buffer.
In a Windows-GUI VIM, this functions is (among others?) called from _OnChar() (which itself is called after receiving a WM_CHAR notification in the Windows Procedure _WndProc()).

vim_is_input_buf_empty()

Returns true if inbufcount == 0 (which indicates that the input buffer is empty).

trash_input_buf()

trash_input_buf() is called when ctrl-C is pressed (and ctrl_c_interrupts is TRUE?) (but see also the handling of VK_CANCEL in process_message())
The function erases the entire input buffer.

inchar_loop()

Common code for mch_inchar() and gui_inchar(): Wait for a while or indefinitely until characters are available, dealing with timers and messages on channels.
buf may be NULL if the available characters are not to be returned, only check if they are available.
Return the number of characters that are available.
If wtime == 0 do not wait for characters.
If wtime == n wait a short time for characters.
If wtime == -1 wait forever for characters.
The parameter wait_func is a function pointer. In a GUI compilation, wait_func seems to be point to gui_wait_for_chars_or_timer().
Compare with the similarly sounding function inchar().

ui_wait_for_chars_or_timer()

Wait for a timer to fire or wait_func (a function pointer) to return non-zero.
Returns OK when something was read.
Returns FAIL when it timed out or was interrupted.
The function is only defined if at least one of the macros FEAT_TIMERS or PROTO is defined.

Index