@@ -7,7 +7,7 @@ pub mod kitty_keyboard;
77use crate :: crosswords:: vi_mode:: ViMotion ;
88use crate :: crosswords:: Mode ;
99use bitflags:: bitflags;
10- use rio_backend:: config:: bindings:: KeyBinding as ConfigKeyBinding ;
10+ use rio_backend:: config:: bindings:: { Bindings , KeyBinding as ConfigKeyBinding } ;
1111use rio_backend:: config:: keyboard:: Keyboard as ConfigKeyboard ;
1212use rio_window:: event:: MouseButton ;
1313use rio_window:: keyboard:: Key :: * ;
@@ -162,6 +162,7 @@ bitflags! {
162162 const SEARCH = 0b0001_0000 ;
163163 const DISAMBIGUATE_KEYS = 0b0010_0000 ;
164164 const ALL_KEYS_AS_ESC = 0b0100_0000 ;
165+ const LEADER = 0b1000_0000 ;
165166 }
166167}
167168
@@ -181,6 +182,7 @@ impl BindingMode {
181182 mode. contains ( Mode :: REPORT_ALL_KEYS_AS_ESC ) ,
182183 ) ;
183184 binding_mode. set ( BindingMode :: VI , mode. contains ( Mode :: VI ) ) ;
185+ binding_mode. set ( BindingMode :: LEADER , mode. contains ( Mode :: LEADER ) ) ;
184186 binding_mode
185187 }
186188}
@@ -553,7 +555,7 @@ pub fn default_mouse_bindings() -> Vec<MouseBinding> {
553555}
554556
555557pub fn default_key_bindings (
556- unprocessed_config_key_bindings : Vec < ConfigKeyBinding > ,
558+ unprocessed_config_key_bindings : Bindings ,
557559 use_navigation_key_bindings : bool ,
558560 config_keyboard : ConfigKeyboard ,
559561) -> Vec < KeyBinding > {
@@ -942,31 +944,41 @@ fn convert(config_key_binding: ConfigKeyBinding) -> Result<KeyBinding, String> {
942944 "~alt" => res_mode. not_mode |= BindingMode :: ALT_SCREEN ,
943945 "vi" => res_mode. mode |= BindingMode :: VI ,
944946 "~vi" => res_mode. not_mode |= BindingMode :: VI ,
947+ "leader" => res_mode. mode |= BindingMode :: LEADER ,
945948 _ => {
946949 res_mode. not_mode |= BindingMode :: empty ( ) ;
947950 res_mode. mode |= BindingMode :: empty ( ) ;
948951 }
949952 }
950953 }
951-
952- Ok ( KeyBinding {
954+ let key_binding = KeyBinding {
953955 trigger,
954956 mods : res,
955957 action,
956958 mode : res_mode. mode ,
957959 notmode : res_mode. not_mode ,
958- } )
960+ } ;
961+
962+ // panic!("Parsed key binding: {:?}", key_binding);
963+
964+ Ok ( key_binding)
959965}
960966
961967pub fn config_key_bindings (
962- config_key_bindings : Vec < ConfigKeyBinding > ,
968+ config_key_bindings : Bindings ,
963969 mut bindings : Vec < KeyBinding > ,
964970) -> Vec < KeyBinding > {
965- if config_key_bindings. is_empty ( ) {
971+ if config_key_bindings. keys . is_empty ( ) {
966972 return bindings;
967973 }
968974
969- for ckb in config_key_bindings {
975+ if let Some ( leader) = config_key_bindings. leader {
976+ let mut binding = convert ( leader) . unwrap ( ) ;
977+ binding. mode |= BindingMode :: LEADER ;
978+ bindings. push ( binding) ;
979+ }
980+
981+ for ckb in config_key_bindings. keys {
970982 match convert ( ckb) {
971983 Ok ( key_binding) => match key_binding. action {
972984 Action :: None | Action :: ReceiveChar => {
0 commit comments