mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 11:46:42 +01:00
dsl: exp -> expr, sym -> word
This commit is contained in:
parent
cf253c28f9
commit
ddd162f225
8 changed files with 330 additions and 325 deletions
|
|
@ -18,14 +18,14 @@ pub struct TuiKey(Option<KeyCode>, KeyModifiers);
|
|||
impl TuiKey {
|
||||
const SPLIT: char = '/';
|
||||
pub fn from_dsl (dsl: impl Dsl) -> Usually<Self> {
|
||||
if let Some(symbol) = dsl.sym()? {
|
||||
let symbol = symbol.trim();
|
||||
Ok(if symbol == ":char" {
|
||||
if let Some(word) = dsl.word()? {
|
||||
let word = word.trim();
|
||||
Ok(if word == ":char" {
|
||||
Self(None, KeyModifiers::NONE)
|
||||
} else if symbol.chars().nth(0) == Some('@') {
|
||||
} else if word.chars().nth(0) == Some('@') {
|
||||
let mut key = None;
|
||||
let mut modifiers = KeyModifiers::NONE;
|
||||
let mut tokens = symbol[1..].split(Self::SPLIT).peekable();
|
||||
let mut tokens = word[1..].split(Self::SPLIT).peekable();
|
||||
while let Some(token) = tokens.next() {
|
||||
if tokens.peek().is_some() {
|
||||
match token {
|
||||
|
|
@ -47,7 +47,7 @@ impl TuiKey {
|
|||
}
|
||||
Self(key, modifiers)
|
||||
} else {
|
||||
return Err(format!("TuiKey: unexpected: {symbol}").into())
|
||||
return Err(format!("TuiKey: unexpected: {word}").into())
|
||||
})
|
||||
} else {
|
||||
return Err(format!("TuiKey: unspecified").into())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue