@@ -7,7 +7,7 @@ pub mod kitty_keyboard;
7
7
use crate :: crosswords:: vi_mode:: ViMotion ;
8
8
use crate :: crosswords:: Mode ;
9
9
use bitflags:: bitflags;
10
- use rio_backend:: config:: bindings:: KeyBinding as ConfigKeyBinding ;
10
+ use rio_backend:: config:: bindings:: { Bindings , KeyBinding as ConfigKeyBinding } ;
11
11
use rio_backend:: config:: keyboard:: Keyboard as ConfigKeyboard ;
12
12
use rio_window:: event:: MouseButton ;
13
13
use rio_window:: keyboard:: Key :: * ;
@@ -162,6 +162,7 @@ bitflags! {
162
162
const SEARCH = 0b0001_0000 ;
163
163
const DISAMBIGUATE_KEYS = 0b0010_0000 ;
164
164
const ALL_KEYS_AS_ESC = 0b0100_0000 ;
165
+ const LEADER = 0b1000_0000 ;
165
166
}
166
167
}
167
168
@@ -181,6 +182,7 @@ impl BindingMode {
181
182
mode. contains ( Mode :: REPORT_ALL_KEYS_AS_ESC ) ,
182
183
) ;
183
184
binding_mode. set ( BindingMode :: VI , mode. contains ( Mode :: VI ) ) ;
185
+ binding_mode. set ( BindingMode :: LEADER , mode. contains ( Mode :: LEADER ) ) ;
184
186
binding_mode
185
187
}
186
188
}
@@ -553,7 +555,7 @@ pub fn default_mouse_bindings() -> Vec<MouseBinding> {
553
555
}
554
556
555
557
pub fn default_key_bindings (
556
- unprocessed_config_key_bindings : Vec < ConfigKeyBinding > ,
558
+ unprocessed_config_key_bindings : Bindings ,
557
559
use_navigation_key_bindings : bool ,
558
560
config_keyboard : ConfigKeyboard ,
559
561
) -> Vec < KeyBinding > {
@@ -937,31 +939,41 @@ fn convert(config_key_binding: ConfigKeyBinding) -> Result<KeyBinding, String> {
937
939
"~alt" => res_mode. not_mode |= BindingMode :: ALT_SCREEN ,
938
940
"vi" => res_mode. mode |= BindingMode :: VI ,
939
941
"~vi" => res_mode. not_mode |= BindingMode :: VI ,
942
+ "leader" => res_mode. mode |= BindingMode :: LEADER ,
940
943
_ => {
941
944
res_mode. not_mode |= BindingMode :: empty ( ) ;
942
945
res_mode. mode |= BindingMode :: empty ( ) ;
943
946
}
944
947
}
945
948
}
946
-
947
- Ok ( KeyBinding {
949
+ let key_binding = KeyBinding {
948
950
trigger,
949
951
mods : res,
950
952
action,
951
953
mode : res_mode. mode ,
952
954
notmode : res_mode. not_mode ,
953
- } )
955
+ } ;
956
+
957
+ // panic!("Parsed key binding: {:?}", key_binding);
958
+
959
+ Ok ( key_binding)
954
960
}
955
961
956
962
pub fn config_key_bindings (
957
- config_key_bindings : Vec < ConfigKeyBinding > ,
963
+ config_key_bindings : Bindings ,
958
964
mut bindings : Vec < KeyBinding > ,
959
965
) -> Vec < KeyBinding > {
960
- if config_key_bindings. is_empty ( ) {
966
+ if config_key_bindings. keys . is_empty ( ) {
961
967
return bindings;
962
968
}
963
969
964
- for ckb in config_key_bindings {
970
+ if let Some ( leader) = config_key_bindings. leader {
971
+ let mut binding = convert ( leader) . unwrap ( ) ;
972
+ binding. mode |= BindingMode :: LEADER ;
973
+ bindings. push ( binding) ;
974
+ }
975
+
976
+ for ckb in config_key_bindings. keys {
965
977
match convert ( ckb) {
966
978
Ok ( key_binding) => match key_binding. action {
967
979
Action :: None | Action :: ReceiveChar => {
0 commit comments