Format Rust sources at 100 columns

This commit is contained in:
Samuel Onoja committed 2026-10-22 01:28:03 +01:00
1 parent 4661f595f8
commit 610478f8c7
336 files changed
+23497 -7892

No files matched your search

+28 -8
View File
@@ -42,7 +42,12 @@ impl BindingSet {
alt: bool,
shift: bool,
) -> Option<&Binding> {
let modifiers = BindingModifiers { logo, ctrl, alt, shift };
let modifiers = BindingModifiers {
logo,
ctrl,
alt,
shift,
};
let physical = self.keyboard.get(&BindingIdentity {
modifiers,
match_mode: BindingMatch::Physical,
@@ -96,7 +101,10 @@ mod tests {
let code = Keycode::new(38);
let bindings = vec![
binding_for(BindingTrigger::Keysym(keysyms::KEY_b), BindingAction::Close),
binding_for(BindingTrigger::Physical(code), BindingAction::ToggleFloating),
binding_for(
BindingTrigger::Physical(code),
BindingAction::ToggleFloating,
),
binding_for(BindingTrigger::Keysym(keysyms::KEY_a), BindingAction::Exit),
binding_for(BindingTrigger::Keysym(keysyms::KEY_b), BindingAction::None),
];
@@ -125,7 +133,10 @@ mod tests {
let config = Config::default();
let mut bindings = config.bindings(&config.input_settings().unwrap()).unwrap();
bindings.extend([
binding_for(BindingTrigger::Physical(Keycode::new(38)), BindingAction::None),
binding_for(
BindingTrigger::Physical(Keycode::new(38)),
BindingAction::None,
),
binding_for(BindingTrigger::Keysym(keysyms::KEY_a), BindingAction::Close),
binding_for(
BindingTrigger::Swipe {
@@ -138,7 +149,8 @@ mod tests {
let index = BindingSet::from(bindings);
for bits in 0..16 {
let (logo, ctrl, alt, shift) = (bits & 1 != 0, bits & 2 != 0, bits & 4 != 0, bits & 8 != 0);
let (logo, ctrl, alt, shift) =
(bits & 1 != 0, bits & 2 != 0, bits & 4 != 0, bits & 8 != 0);
for code in 8..100 {
for symbols in [
@@ -164,7 +176,10 @@ mod tests {
#[test]
fn replacing_bindings_discards_old_index_entries() {
let code = Keycode::new(38);
let mut bindings = BindingSet::from(vec![binding_for(BindingTrigger::Physical(code), BindingAction::Close)]);
let mut bindings = BindingSet::from(vec![binding_for(
BindingTrigger::Physical(code),
BindingAction::Close,
)]);
assert_eq!(
bindings.action_for_key(code, &[], false, false, false, false),
Some(&BindingAction::Close)
@@ -173,7 +188,10 @@ mod tests {
BindingTrigger::Keysym(keysyms::KEY_b),
BindingAction::None,
)]);
assert_eq!(bindings.action_for_key(code, &[], false, false, false, false), None);
assert_eq!(
bindings.action_for_key(code, &[], false, false, false, false),
None
);
assert_eq!(
bindings.action_for_key(code, &[keysyms::KEY_b], false, false, false, false),
Some(&BindingAction::None)
@@ -182,9 +200,11 @@ mod tests {
#[test]
fn cloning_spawn_actions_shares_the_command_storage() {
let action = BindingAction::Spawn(vec!["foot".into(), "--app-id".into(), "work".into()].into());
let action =
BindingAction::Spawn(vec!["foot".into(), "--app-id".into(), "work".into()].into());
let cloned = action.clone();
let (BindingAction::Spawn(original), BindingAction::Spawn(cloned)) = (&action, cloned) else {
let (BindingAction::Spawn(original), BindingAction::Spawn(cloned)) = (&action, cloned)
else {
unreachable!();
};
assert!(Arc::ptr_eq(original, &cloned));
+48 -14
View File
@@ -75,16 +75,24 @@ impl Config {
if configured.disabled
|| identity.match_mode == BindingMatch::Swipe
|| !identities.insert(identity.clone())
|| (identity.match_mode == BindingMatch::Keysym && identity.key == keysyms::KEY_Escape)
|| (identity.match_mode == BindingMatch::Keysym
&& identity.key == keysyms::KEY_Escape)
|| (identity.match_mode == BindingMatch::Physical
&& (0..keymap.num_layouts_for_key(Keycode::new(identity.key))).any(|layout| {
(0..keymap.num_levels_for_key(Keycode::new(identity.key), layout)).any(|level| {
keymap
.key_get_syms_by_level(Keycode::new(identity.key), layout, level)
.iter()
.any(|symbol| symbol.raw() == keysyms::KEY_Escape)
})
}))
&& (0..keymap.num_layouts_for_key(Keycode::new(identity.key))).any(
|layout| {
(0..keymap.num_levels_for_key(Keycode::new(identity.key), layout))
.any(|level| {
keymap
.key_get_syms_by_level(
Keycode::new(identity.key),
layout,
level,
)
.iter()
.any(|symbol| symbol.raw() == keysyms::KEY_Escape)
})
},
))
{
return Err(ConfigError::Binding(format!(
"invalid, duplicate or reserved mode binding {:?}",
@@ -95,12 +103,17 @@ impl Config {
}
modes.maps.insert(mode.name.clone(), bindings.into());
}
for binding in default.iter().chain(modes.maps.values().flat_map(|map| map.iter())) {
for binding in default
.iter()
.chain(modes.maps.values().flat_map(|map| map.iter()))
{
if let BindingAction::BindingMode(name) = &binding.action
&& name != "default"
&& !modes.maps.contains_key(name)
{
return Err(ConfigError::Binding(format!("unknown binding mode {name:?}")));
return Err(ConfigError::Binding(format!(
"unknown binding mode {name:?}"
)));
}
}
Ok(modes)
@@ -131,7 +144,14 @@ mod tests {
assert!(modes.set("resize"));
let selected = modes.bindings(&default);
assert_eq!(
selected.action_for_key(Keycode::new(43), &[keysyms::KEY_h], false, false, false, false),
selected.action_for_key(
Keycode::new(43),
&[keysyms::KEY_h],
false,
false,
false,
false
),
Some(&BindingAction::Resize(Direction::Left))
);
assert_eq!(
@@ -139,11 +159,25 @@ mod tests {
Some(&BindingAction::Resize(Direction::Up))
);
assert_eq!(
selected.action_for_key(Keycode::new(43), &[keysyms::KEY_h], true, false, false, false),
selected.action_for_key(
Keycode::new(43),
&[keysyms::KEY_h],
true,
false,
false,
false
),
None
);
assert_eq!(
selected.action_for_key(Keycode::new(36), &[keysyms::KEY_Return], true, false, false, false),
selected.action_for_key(
Keycode::new(36),
&[keysyms::KEY_Return],
true,
false,
false,
false
),
None
);
assert!(!modes.set("missing"));