MCPcopy Create free account
hub / github.com/ankddev/envfetch / handle_input

Function handle_input

src/interactive/controller.rs:9–33  ·  view source on GitHub ↗
(state: &mut AppState)

Source from the content-addressed store, hash-verified

7// This function is used in interactive.rs, so disable this useless warning
8#[allow(dead_code)]
9pub fn handle_input(state: &mut AppState) -> io::Result<()> {
10 if event::poll(Duration::from_millis(100))? {
11 if let Event::Key(key_event) = event::read()? {
12 if key_event.kind == KeyEventKind::Press {
13 match state.mode.clone() {
14 Mode::List => handle_list_mode(state, key_event),
15 Mode::Add => handle_add_mode(state, key_event),
16 Mode::Edit(_) => handle_edit_mode(state, key_event),
17 Mode::Delete(_) => handle_delete_mode(state, key_event),
18 }
19 }
20 }
21 }
22
23 if state.reload_requested {
24 state.reload();
25 }
26
27 if let Some(expiry) = state.message_expiry {
28 if std::time::Instant::now() > expiry {
29 state.clear_message();
30 }
31 }
32 Ok(())
33}
34
35pub fn handle_list_mode(state: &mut AppState, key: KeyEvent) {
36 match key.code {

Callers 1

runMethod · 0.85

Calls 6

handle_list_modeFunction · 0.85
handle_add_modeFunction · 0.85
handle_edit_modeFunction · 0.85
handle_delete_modeFunction · 0.85
reloadMethod · 0.80
clear_messageMethod · 0.80

Tested by

no test coverage detected