@@ -6,6 +6,7 @@ use crate::cmd_runner::{CmdRunner, Output};
66use crate :: completable_input:: CompletableInput ;
77use crate :: config:: { KeyBindingsConfig , ThemeConfig } ;
88use crate :: debouncer:: debouncer_task;
9+ use crate :: help_widget:: HelpWidget ;
910use crate :: history:: History ;
1011use crate :: output_widget:: { ErrorDisplayMode , ErrorPanePlacement , OutputWidget } ;
1112use crate :: rura:: ExecuteType ;
@@ -41,19 +42,19 @@ pub struct App {
4142 rura_widget : RuraWidget ,
4243 output_widget : OutputWidget ,
4344 search_widget : SearchWidget ,
45+ help_widget : HelpWidget ,
46+ save_output_widget : SaveToFileWidget ,
47+ save_command_widget : SaveToFileWidget ,
4448 stdin : String ,
45- exit : bool ,
4649 action_rx : Receiver < Action > ,
4750 command_tx : Sender < ( String , String ) > ,
4851 key_bindings : KeyBindings ,
4952 command_line_placement : CommandLinePlacement ,
50- kb_config : KeyBindingsConfig ,
5153 input_mode : InputMode ,
5254 debouncer_tx : Sender < ( ) > ,
5355 active_mode : ActiveMode ,
5456 active_modal : ActiveModal ,
55- save_output_widget : SaveToFileWidget ,
56- save_command_widget : SaveToFileWidget ,
57+ exit : bool ,
5758}
5859
5960impl App {
@@ -127,13 +128,13 @@ impl App {
127128 action_rx,
128129 command_tx,
129130 debouncer_tx,
130- exit : false ,
131131 key_bindings : KeyBindings :: from_config ( & kb_config) ,
132132 command_line_placement,
133- kb_config,
133+ help_widget : HelpWidget :: new ( kb_config) ,
134134 input_mode : InputMode :: Normal ,
135135 active_mode : ActiveMode :: default ( ) ,
136136 active_modal : ActiveModal :: default ( ) ,
137+ exit : false ,
137138 }
138139 }
139140
@@ -677,7 +678,7 @@ impl App {
677678 self . render_live_confirm ( frame) ;
678679 }
679680 ActiveModal :: Help => {
680- self . render_help ( frame) ;
681+ frame . render_widget ( & self . help_widget , frame. area ( ) ) ;
681682 }
682683 ActiveModal :: SaveOutput => {
683684 self . save_output_widget
@@ -711,48 +712,6 @@ impl App {
711712 frame. render_widget ( popup, frame. area ( ) ) ;
712713 }
713714
714- fn render_help ( & self , frame : & mut Frame ) {
715- #[ rustfmt:: skip]
716- let lines = Text :: from ( vec ! [
717- Line :: from( format!( "{:012} - Execute full command" , self . kb_config. execute_full. first( ) . unwrap( ) . to_string( ) ) ) ,
718- Line :: from( format!( "{:012} - Execute until cursor" , self . kb_config. execute_until_current. first( ) . unwrap( ) . to_string( ) ) ) ,
719- Line :: from( format!( "{:012} - Execute before cursor" , self . kb_config. execute_until_prev. first( ) . unwrap( ) . to_string( ) ) ) ,
720- Line :: from( format!( "{:012} - Reset input" , self . kb_config. reset_input. first( ) . unwrap( ) . to_string( ) ) ) ,
721- Line :: from( "" ) ,
722- Line :: from( format!( "{:012} - Save output to file" , self . kb_config. save_output. first( ) . unwrap( ) . to_string( ) ) ) ,
723- Line :: from( format!( "{:012} - Save command to file" , self . kb_config. save_command. first( ) . unwrap( ) . to_string( ) ) ) ,
724- Line :: from( "" ) ,
725- Line :: from( format!( "{:012} - Search next" , self . kb_config. search_next. first( ) . unwrap( ) . to_string( ) ) ) ,
726- Line :: from( format!( "{:012} - Search previous" , self . kb_config. search_prev. first( ) . unwrap( ) . to_string( ) ) ) ,
727- Line :: from( format!( "{:012} - Toggle regex mode" , "alt+x" ) ) ,
728- Line :: from( format!( "{:012} - Toggle case sensitivity" , "alt+c" ) ) ,
729- Line :: from( "" ) ,
730- Line :: from( format!( "{:012} - Complete forward" , self . kb_config. complete. first( ) . unwrap( ) . to_string( ) ) ) ,
731- Line :: from( format!( "{:012} - Complete backward" , self . kb_config. complete_prev. first( ) . unwrap( ) . to_string( ) ) ) ,
732- Line :: from( "" ) ,
733- Line :: from( format!( "{:012} - Go to previous subcommand" , self . kb_config. subcommand_prev. first( ) . unwrap( ) . to_string( ) ) ) ,
734- Line :: from( format!( "{:012} - Go to next subcommand" , self . kb_config. subcommand_next. first( ) . unwrap( ) . to_string( ) ) ) ,
735- Line :: from( "" ) ,
736- Line :: from( format!( "{:012} - History previous item" , self . kb_config. history_prev. first( ) . unwrap( ) . to_string( ) ) ) ,
737- Line :: from( format!( "{:012} - History next item" , self . kb_config. history_next. first( ) . unwrap( ) . to_string( ) ) ) ,
738- Line :: from( "" ) ,
739- Line :: from( format!( "{:012} - Scroll up" , self . kb_config. scroll_up. first( ) . unwrap( ) . to_string( ) ) ) ,
740- Line :: from( format!( "{:012} - Scroll down" , self . kb_config. scroll_down. first( ) . unwrap( ) . to_string( ) ) ) ,
741- Line :: from( format!( "{:012} - Scroll page up" , self . kb_config. scroll_up_page. first( ) . unwrap( ) . to_string( ) ) ) ,
742- Line :: from( format!( "{:012} - Scroll page down" , self . kb_config. scroll_down_page. first( ) . unwrap( ) . to_string( ) ) ) ,
743- Line :: from( "" ) ,
744- Line :: from( format!( "{:012} - Scroll right" , self . kb_config. scroll_right. first( ) . unwrap( ) . to_string( ) ) ) ,
745- Line :: from( format!( "{:012} - Scroll left" , self . kb_config. scroll_left. first( ) . unwrap( ) . to_string( ) ) ) ,
746- Line :: from( "" ) ,
747- Line :: from( format!( "{:012} - Wrap output lines" , self . kb_config. toggle_wrap. first( ) . unwrap( ) . to_string( ) ) ) ,
748- ] ) ;
749-
750- let popup = Popup :: new ( lines)
751- . title ( " Keys " )
752- . style ( Style :: new ( ) . white ( ) . on_blue ( ) ) ;
753- frame. render_widget ( popup, frame. area ( ) ) ;
754- }
755-
756715 fn hints_widget ( & self ) -> Line < ' _ > {
757716 let mut spans: Vec < Span > = vec ! [ ] ;
758717
@@ -945,7 +904,7 @@ mod tests {
945904 exit : false ,
946905 key_bindings : KeyBindings :: from_config ( & kb_config) ,
947906 command_line_placement : CommandLinePlacement :: Bottom ,
948- kb_config,
907+ help_widget : HelpWidget :: new ( kb_config) ,
949908 input_mode : InputMode :: Normal ,
950909 active_mode : ActiveMode :: default ( ) ,
951910 active_modal : ActiveModal :: default ( ) ,
0 commit comments