Tweak Compose button
This commit is contained in:
@ -28,11 +28,26 @@ pub enum Button {
|
||||
Mod(Modifier),
|
||||
Key(Key),
|
||||
ModTap(Key, Modifier),
|
||||
Compose(Key, Key, Option<Key>),
|
||||
Compose2(CompShift, Key, CompShift, Key),
|
||||
Compose3(CompShift, Key, CompShift, Key, CompShift, Key),
|
||||
Layer(LayerShift, LayerDir, u16),
|
||||
None,
|
||||
}
|
||||
|
||||
/// Whether a key should be shift modified as part of a compose chain.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum CompShift {
|
||||
/// Do not shift the key.
|
||||
#[default]
|
||||
Lower,
|
||||
|
||||
/// Shift the key.
|
||||
Upper,
|
||||
|
||||
/// Shift the key if shift is being held down.
|
||||
Variable,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum LayerDir {
|
||||
Left,
|
||||
@ -49,12 +64,22 @@ pub enum LayerShift {
|
||||
|
||||
impl Display for Button {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let cs = |cs: &CompShift| match cs {
|
||||
CompShift::Lower => "",
|
||||
CompShift::Upper => "⇧",
|
||||
CompShift::Variable => "⇧?",
|
||||
};
|
||||
|
||||
match self {
|
||||
Button::Mod(modifier) => Debug::fmt(&modifier, f),
|
||||
Button::Key(key) => write!(f, "{key:?}"),
|
||||
Button::ModTap(key, modifier) => write!(f, "{key:?}/{modifier}"),
|
||||
Button::Compose(k1, k2, None) => write!(f, "⎄ {k1:?} {k2:?}"),
|
||||
Button::Compose(k1, k2, Some(k3)) => write!(f, "⎄ {k1:?} {k2:?} {k3:?}"),
|
||||
Button::Compose2(cs1, k1, cs2, k2) => {
|
||||
write!(f, "⎄ {}{k1:?} {}{k2:?}", cs(cs1), cs(cs2))
|
||||
}
|
||||
Button::Compose3(cs1, k1, cs2, k2, cs3, k3) => {
|
||||
write!(f, "⎄ {}{k1:?} {}{k2:?} {}{k3:?}", cs(cs1), cs(cs2), cs(cs3))
|
||||
}
|
||||
Button::Layer(..) => write!(f, "Lr"),
|
||||
Button::None => write!(f, "Ø"),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user