async fn react(&mut self, crossterm: CrosstermEvent) -> Result<(), Error> {
        let _guard = self.shared.service_guard().await?;

        match crossterm {
            CrosstermEvent::Key(key) => {
                let maybe_key = key_from_crossterm(key.code);
                if let Some(main_key) = maybe_key {
                    use crossterm::event::KeyModifiers as Mod;

                    let evt = KeyEvent {
                        main_key,
                        ctrl: key.modifiers.intersects(Mod::CONTROL),
                        alt: key.modifiers.intersects(Mod::ALT),
                        shift: key.modifiers.intersects(Mod::SHIFT),
                    };

                    self.send(Event::Key(evt));
                }
            },

            CrosstermEvent::Resize(width, height) => {
                let size = Vec2 { x: width, y: height };
                let mut locked_screen = self.shared.screen().lock().await;
                let prev_size_valid = self.is_size_valid();
                locked_screen
                    .check_resize(size, &mut self.stdout_guard)
                    .await?;

                if self.is_size_valid() {
                    let evt = ResizeEvent { size: Some(size) };
                    self.send(Event::Resize(evt));
                } else if prev_size_valid {
                    let evt = ResizeEvent { size: None };
                    self.send(Event::Resize(evt));
                }
            },

            _ => (),
        }

        Ok(())
    }
/// Reacts to a single event. Input uses the crossterm encoding for the
/// event.
Reacts to a single event. Input uses the crossterm encoding for the
event.
Reacts to a single event . Input uses the crossterm encoding for the event .
async fn react(&mut self, crossterm: CrosstermEvent) -> Result<(), Error> {
        let _guard = self.shared.service_guard().await?;
        match crossterm {
            CrosstermEvent::Key(key) => {
                let maybe_key = key_from_crossterm(key.code);
                if let Some(main_key) = maybe_key {
                    use crossterm::event::KeyModifiers as Mod;
                    let evt = KeyEvent {
                        main_key,
                        ctrl: key.modifiers.intersects(Mod::CONTROL),
                        alt: key.modifiers.intersects(Mod::ALT),
                        shift: key.modifiers.intersects(Mod::SHIFT),
                    };
                    self.send(Event::Key(evt));
                }
            },
            CrosstermEvent::Resize(width, height) => {
                let size = Vec2 { x: width, y: height };
                let mut locked_screen = self.shared.screen().lock().await;
                let prev_size_valid = self.is_size_valid();
                locked_screen
                    .check_resize(size, &mut self.stdout_guard)
                    .await?;
                if self.is_size_valid() {
                    let evt = ResizeEvent { size: Some(size) };
                    self.send(Event::Resize(evt));
                } else if prev_size_valid {
                    let evt = ResizeEvent { size: None };
                    self.send(Event::Resize(evt));
                }
            },
            _ => (),
        }
        Ok(())
    }
async fn react ( & mut self , crossterm : CrosstermEvent ) -> Result < ( ) , Error > { let _guard = self . shared . service_guard ( ) . await ? ; match crossterm { CrosstermEvent :: Key ( key ) => { let maybe_key = key_from_crossterm ( key . code ) ; if let Some ( main_key ) = maybe_key { use crossterm :: event :: KeyModifiers as Mod ; let evt = KeyEvent { main_key , ctrl : key . modifiers . intersects ( Mod :: CONTROL ) , alt : key . modifiers . intersects ( Mod :: ALT ) , shift : key . modifiers . intersects ( Mod :: SHIFT ) , } ; self . send ( Event :: Key ( evt ) ) ; } } , CrosstermEvent :: Resize ( width , height ) => { let size = Vec2 { x : width , y : height } ; let mut locked_screen = self . shared . screen ( ) . lock ( ) . await ; let prev_size_valid = self . is_size_valid ( ) ; locked_screen . check_resize ( size , & mut self . stdout_guard ) . await ? ; if self . is_size_valid ( ) { let evt = ResizeEvent { size : Some ( size ) } ; self . send ( Event :: Resize ( evt ) ) ; } else if prev_size_valid { let evt = ResizeEvent { size : None } ; self . send ( Event :: Resize ( evt ) ) ; } } , _ => ( ) , } Ok ( ( ) ) }
Reacts to a single event.
Reacts to a single event .
&mut self
crossterm
CrosstermEvent
&mut self
crossterm
CrosstermEvent