Make rich text example editable

This commit is contained in:
Jeremy Soller 2022-10-27 14:52:10 -06:00
parent cce821e99f
commit b9c01f1a81
No known key found for this signature in database
GPG key ID: 87F211AF2BE4C2FE

View file

@ -157,6 +157,21 @@ fn main() {
for event in window.events() {
match event.to_option() {
EventOption::Key(event) => match event.scancode {
orbclient::K_LEFT if event.pressed => buffer.action(TextAction::Left),
orbclient::K_RIGHT if event.pressed => buffer.action(TextAction::Right),
orbclient::K_UP if event.pressed => buffer.action(TextAction::Up),
orbclient::K_DOWN if event.pressed => buffer.action(TextAction::Down),
orbclient::K_HOME if event.pressed => buffer.action(TextAction::Home),
orbclient::K_END if event.pressed => buffer.action(TextAction::End),
orbclient::K_PGUP if event.pressed => buffer.action(TextAction::PageUp),
orbclient::K_PGDN if event.pressed => buffer.action(TextAction::PageDown),
orbclient::K_ENTER if event.pressed => buffer.action(TextAction::Enter),
orbclient::K_BKSP if event.pressed => buffer.action(TextAction::Backspace),
orbclient::K_DEL if event.pressed => buffer.action(TextAction::Delete),
_ => (),
},
EventOption::TextInput(event) => buffer.action(TextAction::Insert(event.character)),
EventOption::Mouse(mouse) => {
mouse_x = mouse.x;
mouse_y = mouse.y;