-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: unescape keys that were previously escaped
- Loading branch information
Showing
3 changed files
with
75 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
bitflags::bitflags! { | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
pub struct KeyAttribute: u8 { | ||
const None = 0b00000000; | ||
const Send = 0b00000001; | ||
const OnRelease = 0b00000010; | ||
const Both = Self::Send.bits() | Self::OnRelease.bits(); | ||
} | ||
} | ||
|
||
#[derive(Debug, Clone)] | ||
pub enum Token { | ||
Modifier(Modifier), | ||
Key(Key), | ||
} | ||
|
||
#[derive(Debug, Clone)] | ||
pub struct Modifier(String); | ||
#[derive(Debug, Clone)] | ||
pub struct Key { | ||
pub key: String, | ||
pub attribute: KeyAttribute, | ||
} | ||
|
||
impl Token { | ||
pub fn new_key(key: String, attribute: KeyAttribute) -> Self { | ||
Self::Key(Key { key, attribute }) | ||
} | ||
pub fn new_key_from_string(key: String) -> Self { | ||
Self::Key(Key { | ||
key, | ||
attribute: KeyAttribute::None, | ||
}) | ||
} | ||
pub fn new_modifier(modifier: String) -> Self { | ||
Self::Modifier(Modifier(modifier)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters