@@ -366,23 +366,33 @@ impl App {
366366 // let at_port_selection = matches!(self.menu, Menu::PortSelection);
367367 // TODO soon, redo this variable's name + use
368368 let mut at_port_selection = false ;
369+ let mut at_terminal = false ;
369370 // Filter for when we decide to handle user *text input*.
370371 match self . menu {
371372 Menu :: Terminal ( TerminalPrompt :: None ) => {
372- match self
373- . user_input
374- . input_box
375- . handle_event ( & ratatui:: crossterm:: event:: Event :: Key ( key) )
376- {
377- // If we changed something in the value when handling the key event,
378- // we should clear the user_history selection.
379- Some ( StateChanged {
380- value,
381- cursor : _cursor,
382- } ) if value => {
383- self . user_input . history . clear_selection ( ) ;
384- }
385- _ => ( ) ,
373+ at_terminal = true ;
374+ match key. code {
375+ // Consuming Ctrl+A so input_box.handle_event doesn't move my cursor.
376+ KeyCode :: Char ( 'a' ) if ctrl_pressed => ( ) ,
377+ KeyCode :: Delete | KeyCode :: Backspace if self . user_input . all_text_selected => ( ) ,
378+
379+ _ => match self
380+ . user_input
381+ . input_box
382+ . handle_event ( & ratatui:: crossterm:: event:: Event :: Key ( key) )
383+ {
384+ // If we changed something in the value when handling the key event,
385+ // we should clear the user_history selection.
386+ Some ( StateChanged { value : true , .. } ) => {
387+ self . user_input . history . clear_selection ( ) ;
388+ self . user_input . all_text_selected = false ;
389+ }
390+
391+ Some ( StateChanged { cursor : true , .. } ) => {
392+ self . user_input . all_text_selected = false ;
393+ }
394+ _ => ( ) ,
395+ } ,
386396 }
387397 }
388398 Menu :: Terminal ( TerminalPrompt :: DisconnectPrompt ) => ( ) ,
@@ -409,6 +419,13 @@ impl App {
409419 }
410420 _ => self . shutdown ( ) ,
411421 } ,
422+ 'a' | 'A'
423+ if ctrl_pressed
424+ && at_terminal
425+ && !self . user_input . input_box . value ( ) . is_empty ( ) =>
426+ {
427+ self . user_input . all_text_selected = true ;
428+ }
412429 'w' | 'W' if ctrl_pressed => {
413430 self . buffer . state . text_wrapping = !self . buffer . state . text_wrapping ;
414431 self . buffer . scroll_by ( 0 ) ;
@@ -460,7 +477,9 @@ impl App {
460477 // TODO Ctrl+A -> Backspace | Delete to clear input buffer
461478 KeyCode :: PageUp if ctrl_pressed || shift_pressed => self . buffer . scroll_by ( i32:: MAX ) ,
462479 KeyCode :: PageDown if ctrl_pressed || shift_pressed => self . buffer . scroll_by ( i32:: MIN ) ,
463- KeyCode :: Delete | KeyCode :: Backspace if ctrl_pressed && shift_pressed => {
480+ KeyCode :: Delete | KeyCode :: Backspace
481+ if ( ctrl_pressed && shift_pressed) || self . user_input . all_text_selected =>
482+ {
464483 self . user_input . reset ( ) ;
465484 }
466485 KeyCode :: PageUp => self . buffer . scroll_page_up ( ) ,
@@ -501,6 +520,7 @@ impl App {
501520 }
502521 }
503522 fn up_pressed ( & mut self ) {
523+ self . user_input . all_text_selected = false ;
504524 match self . popup {
505525 None => ( ) ,
506526 Some ( Popup :: PortSettings ) => {
@@ -528,6 +548,7 @@ impl App {
528548 self . post_menu_scroll ( true ) ;
529549 }
530550 fn down_pressed ( & mut self ) {
551+ self . user_input . all_text_selected = false ;
531552 match self . popup {
532553 None => ( ) ,
533554 Some ( Popup :: PortSettings ) => {
@@ -1032,13 +1053,19 @@ impl App {
10321053 frame. render_widget ( signals_line, line_area. offset ( Offset { x : 3 , y : 0 } ) ) ;
10331054 }
10341055
1035- let input_style = match & self . failed_send_at {
1036- Some ( instant) if instant. elapsed ( ) < FAILED_SEND_VISUAL_TIME => Style :: new ( ) . on_red ( ) ,
1056+ let input_style = match ( & self . failed_send_at , self . user_input . all_text_selected ) {
1057+ ( Some ( instant) , _) if instant. elapsed ( ) < FAILED_SEND_VISUAL_TIME => {
1058+ Style :: new ( ) . on_red ( )
1059+ }
1060+ ( Some ( instant) , true ) if instant. elapsed ( ) < FAILED_SEND_VISUAL_TIME => {
1061+ Style :: new ( ) . reversed ( ) . on_red ( )
1062+ }
1063+ ( _, true ) => Style :: new ( ) . reversed ( ) ,
10371064 _ => Style :: new ( ) ,
10381065 } ;
10391066
10401067 let input_symbol = Span :: raw ( ">" ) . style ( if self . serial_healthy {
1041- input_style. green ( )
1068+ input_style. not_reversed ( ) . green ( )
10421069 } else {
10431070 input_style. red ( )
10441071 } ) ;
@@ -1059,7 +1086,7 @@ impl App {
10591086 . scroll ( ( 0 , scroll as u16 ) )
10601087 . style ( input_style) ;
10611088 frame. render_widget ( input_text, input_area) ;
1062- if !disconnect_prompt_shown {
1089+ if !disconnect_prompt_shown && self . popup . is_none ( ) {
10631090 frame. set_cursor_position ( (
10641091 // Put cursor past the end of the input text
10651092 input_area. x
0 commit comments