mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 04:06:45 +01:00
keymap macros
This commit is contained in:
parent
d39cce271f
commit
a50e022ab6
8 changed files with 233 additions and 199 deletions
|
|
@ -46,9 +46,7 @@ impl Device for Rows {
|
|||
self.focused = true;
|
||||
self.items[self.focus].handle(&AppEvent::Blur)?;
|
||||
},
|
||||
_ => {
|
||||
println!("{event:?}");
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
|
|
@ -94,9 +92,42 @@ impl Columns {
|
|||
|
||||
impl Device for Columns {
|
||||
fn handle (&mut self, event: &AppEvent) -> Usually<()> {
|
||||
if self.focused {
|
||||
self.items[self.focus].handle(event)
|
||||
if !self.focused {
|
||||
match event {
|
||||
AppEvent::Input(Event::Key(KeyEvent { code: KeyCode::Esc, .. })) => {
|
||||
self.focused = true;
|
||||
self.items[self.focus].handle(&AppEvent::Blur)?;
|
||||
Ok(())
|
||||
},
|
||||
_ => self.items[self.focus].handle(event)
|
||||
}
|
||||
} else {
|
||||
match event {
|
||||
AppEvent::Input(event) => match event {
|
||||
Event::Key(KeyEvent { code: KeyCode::Left, .. }) => {
|
||||
if self.focus == 0 {
|
||||
self.focus = self.items.len();
|
||||
}
|
||||
self.focus = self.focus - 1;
|
||||
},
|
||||
Event::Key(KeyEvent { code: KeyCode::Right, .. }) => {
|
||||
self.focus = self.focus + 1;
|
||||
if self.focus >= self.items.len() {
|
||||
self.focus = 0;
|
||||
}
|
||||
},
|
||||
Event::Key(KeyEvent { code: KeyCode::Enter, .. }) => {
|
||||
self.focused = false;
|
||||
self.items[self.focus].handle(&AppEvent::Focus)?;
|
||||
},
|
||||
Event::Key(KeyEvent { code: KeyCode::Esc, .. }) => {
|
||||
self.focused = true;
|
||||
self.items[self.focus].handle(&AppEvent::Blur)?;
|
||||
},
|
||||
_ => {}
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
@ -111,7 +142,7 @@ impl Device for Columns {
|
|||
height: area.height
|
||||
})?;
|
||||
if self.focused && i == self.focus {
|
||||
draw_box_styled(buf, result, Some(Style::default().yellow()));
|
||||
draw_box_styled(buf, result, Some(Style::default().green()));
|
||||
}
|
||||
w = w + result.width;
|
||||
h = h.max(result.height);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue