/// Takes in `user_input` and triggers a render to the table
/// Returns the appropriate `TableEventResponse`
Takes in `user_input` and triggers a render to the table
Returns the appropriate `TableEventResponse`
Takes in ` user_input ` and triggers a render to the table Returns the appropriate ` TableEventResponse `
pub fn event_handler(
        &mut self,
        user_input: Event,
        terminal: &mut Terminal<CrosstermBackend<Stdout>>,
    ) -> TableEventResponse {
        let response;
        if let Event::Key(key) = user_input {
            response = match key.code {
                KeyCode::Char('q') | KeyCode::Esc => TableEventResponse::Terminate,
                KeyCode::Char('c') => {
                    self.data = Vec::new();
                    self.state.select(None);
                    TableEventResponse::InputHandled(user_input)
                }
                KeyCode::Up => {
                    self.previous();
                    TableEventResponse::InputHandled(user_input)
                }
                KeyCode::Down => {
                    self.next();
                    TableEventResponse::InputHandled(user_input)
                }
                KeyCode::Home => {
                    self.first();
                    TableEventResponse::InputHandled(user_input)
                }
                KeyCode::End => {
                    self.last();
                    TableEventResponse::InputHandled(user_input)
                }
                KeyCode::PageUp => {
                    self.page_up();
                    TableEventResponse::InputHandled(user_input)
                }
                KeyCode::PageDown => {
                    self.page_down();
                    TableEventResponse::InputHandled(user_input)
                }
                _ => TableEventResponse::InputIgnored(user_input),
            }
        } else if let Event::Mouse(event) = user_input {
            response = match event.kind {
                MouseEventKind::ScrollDown => {
                    self.next();
                    TableEventResponse::InputHandled(user_input)
                }
                MouseEventKind::ScrollUp => {
                    self.previous();
                    TableEventResponse::InputHandled(user_input)
                }
                _ => TableEventResponse::InputIgnored(user_input),
            }
        } else {
            response = TableEventResponse::InputIgnored(user_input)
        }
        self.render(terminal);
        response
    }
pub fn event_handler ( & mut self , user_input : Event , terminal : & mut Terminal < CrosstermBackend < Stdout > > , ) -> TableEventResponse { let response ; if let Event :: Key ( key ) = user_input { response = match key . code { KeyCode :: Char ( 'q' ) | KeyCode :: Esc => TableEventResponse :: Terminate , KeyCode :: Char ( 'c' ) => { self . data = Vec :: new ( ) ; self . state . select ( None ) ; TableEventResponse :: InputHandled ( user_input ) } KeyCode :: Up => { self . previous ( ) ; TableEventResponse :: InputHandled ( user_input ) } KeyCode :: Down => { self . next ( ) ; TableEventResponse :: InputHandled ( user_input ) } KeyCode :: Home => { self . first ( ) ; TableEventResponse :: InputHandled ( user_input ) } KeyCode :: End => { self . last ( ) ; TableEventResponse :: InputHandled ( user_input ) } KeyCode :: PageUp => { self . page_up ( ) ; TableEventResponse :: InputHandled ( user_input ) } KeyCode :: PageDown => { self . page_down ( ) ; TableEventResponse :: InputHandled ( user_input ) } _ => TableEventResponse :: InputIgnored ( user_input ) , } } else if let Event :: Mouse ( event ) = user_input { response = match event . kind { MouseEventKind :: ScrollDown => { self . next ( ) ; TableEventResponse :: InputHandled ( user_input ) } MouseEventKind :: ScrollUp => { self . previous ( ) ; TableEventResponse :: InputHandled ( user_input ) } _ => TableEventResponse :: InputIgnored ( user_input ) , } } else { response = TableEventResponse :: InputIgnored ( user_input ) } self . render ( terminal ) ; response }
Takes in `user_input` and triggers a render to the table
Returns the appropriate `TableEventResponse`
Takes in ` user_input ` and triggers a render to the table Returns the appropriate ` TableEventResponse `
&mut self
user_input
Event
terminal
&mut Terminal<CrosstermBackend<Stdout>>