Next: , Previous: , Up: Hemlock’s Lisp Environment   [Contents][Index]


14.2 Keyboard Input

Keyboard input interacts with a number of other parts of the editor. Since the command loop works by reading from the keyboard, keyboard input is the initial cause of everything that happens. Also, Hemlock redisplays in the low-level input loop when there is no available input from the user.

Variable: *editor-input*
Variable: real-editor-input
Hemlock Variable: Input Hook
Hemlock Variable: Abort Hook

editor-input is an object on which Hemlock’s I/O routines operate. You can get input, clear input, return input, and listen for input. Input appears as key-events.

real-editor-input holds the initial value of editor-input. This is useful for reading from the user when editor-input is rebound (such as within a keyboard macro.)

Hemlock invokes the functions in Input Hook each time someone reads a key-event from real-editor-input. These take no arguments.

Function: get-key-event editor-input &optional ignore-abort-attempts-p

This function returns a key-event as soon as it is available on editor-input. Editor-input is either editor-input or real-editor-input. Ignore-abort-attempts-p indicates whether C-g and C-G throw to the editor’s top-level command loop; when this is non-nil, this function returns those key-events when the user types them. Otherwise, it aborts the editor’s current state, returning to the command loop.

When the user aborts, Hemlock invokes the functions in Abort Hook. These functions take no arguments. When aborting, Hemlock ignores the Input Hook.

Function: unget-key-event key-event editor-input

This function returns key-event to editor-input, so the next invocation of get-key-event will return key-event. If key-event is #k"C-g" or #k"C-G", then whether get-key-event returns it depends on that function’s second argument. Editor-input is either editor-input or real-editor-input.

Function: clear-editor-input editor-input

This function flushes any pending input on editor-input. Editor-input is either editor-input or real-editor-input.

Function: listen-editor-input editor-input

This function returns whether there is any input available on editor-input. Editor-input is either editor-input or real-editor-input.

Function: editor-sleep time

Return either after time seconds have elapsed or when input is available on editor-input.

Variable: *key-event-history*

This is a Hemlock ring buffer (see page rings) that holds the last 60 key-events read from the keyboard.

Variable: *last-key-event-typed*

Commands use this variable to realize the last key-event the user typed to invoke the commands. Before Hemlock ever reads any input, the value is nil. This variable usually holds the last key-event read from the keyboard, but it is also maintained within keyboard macros allowing commands to behave the same on each repetition as they did in the recording invocation.

Variable: *input-transcript*

If this is non-nil then it should be an adjustable vector with a fill-pointer. When it is non-nil, Hemlock pushes all input read onto this vector.


Next: Hemlock Streams, Previous: Entering and Leaving the Editor, Up: Hemlock’s Lisp Environment   [Contents][Index]