Skip to main content

Module event_pump

Module event_pump 

Source
Expand description

The main loop, minus the terminal.

run() sets the terminal up and hands EventPump::run a way to draw a frame; keys reach the pump through the same channel as worker results (crate::terminal_input), so the loop sleeps until either arrives or a deadline passes (Pacer). Everything between, including what happens to a key typed while the app is busy, lives here so it can be driven without a terminal. Keys typed while busy are held, in order, and replayed one per loop iteration once the app is idle, each through the same path a fresh key takes. Any follow-up event a replayed key produces is drained before the next held key is offered, so a queued Enter finishes its search before the key typed after it acts.

Structs§

EventPump
Owns the app, its channel and the keys held while it was busy.
Pacer
When the run loop draws, and how long it may sleep.

Enums§

Drained
What a pass over the channel found.
Ended
How the run loop ended.

Constants§

MAX_HELD_KEYS
Keys held while busy. Beyond this the newest is dropped, and the user told: the oldest may be the / that puts the rest into the query bar, and without it the tail of a typed query would replay as hotkeys.
PROGRESS_FRAME
The least time between two frames drawn for progress reports alone. A worker reporting a thousand times a second is drawn thirty times; a key or a result is drawn at once.
SPINNER_FRAME
How often a spinner turns: about 30 frames a second, plenty for a throbber.