add arrow key bypass to menu mode

This commit is contained in:
bunnie 2022-06-17 17:56:08 +08:00
parent bc24e86f08
commit 85a43b0a7d

View file

@ -262,6 +262,7 @@ impl InputTracker {
match k { match k {
'\u{0000}' => (), '\u{0000}' => (),
'←' => { // move insertion point back '←' => { // move insertion point back
if !self.menu_mode {
if self.insertion > 0 { if self.insertion > 0 {
log::debug!("moving insertion point back"); log::debug!("moving insertion point back");
self.insertion -= 1; self.insertion -= 1;
@ -270,8 +271,12 @@ impl InputTracker {
self.pred_phrase.clear(); // don't track predictions on edits self.pred_phrase.clear(); // don't track predictions on edits
self.can_unpick = false; self.can_unpick = false;
self.last_trigger_char = None; self.last_trigger_char = None;
} else {
return Ok(Some(xous_ipc::String::<4000>::from_str("←")));
}
} }
'→' => { '→' => {
if !self.menu_mode {
if self.insertion < self.characters { if self.insertion < self.characters {
self.insertion += 1; self.insertion += 1;
} }
@ -279,16 +284,24 @@ impl InputTracker {
self.pred_phrase.clear(); self.pred_phrase.clear();
self.can_unpick = false; self.can_unpick = false;
self.last_trigger_char = None; self.last_trigger_char = None;
} else {
return Ok(Some(xous_ipc::String::<4000>::from_str("→")));
}
} }
'↑' => { '↑' => {
if !self.menu_mode {
// bring the insertion point to the front of the text box // bring the insertion point to the front of the text box
self.insertion = 0; self.insertion = 0;
do_redraw = true; do_redraw = true;
self.pred_phrase.clear(); self.pred_phrase.clear();
self.can_unpick = false; self.can_unpick = false;
self.last_trigger_char = None; self.last_trigger_char = None;
} else {
return Ok(Some(xous_ipc::String::<4000>::from_str("↑")));
}
} }
'↓' => { '↓' => {
if !self.menu_mode {
// bring insertion point to the very end of the text box // bring insertion point to the very end of the text box
self.insertion = self.characters; self.insertion = self.characters;
do_redraw = true; do_redraw = true;
@ -297,13 +310,15 @@ impl InputTracker {
// this means that when we resume typing after an edit, the predictor will set its insertion point // this means that when we resume typing after an edit, the predictor will set its insertion point
// at the very end, not the space prior to the last word... // at the very end, not the space prior to the last word...
self.last_trigger_char = Some(self.characters); self.last_trigger_char = Some(self.characters);
} else {
return Ok(Some(xous_ipc::String::<4000>::from_str("↓")));
}
} }
'\u{0011}' => { // F1 '\u{0011}' => { // F1
if !self.menu_mode { if !self.menu_mode {
self.insert_prediction(0); self.insert_prediction(0);
do_redraw = true; do_redraw = true;
} else { } else {
log::info!("menu mode return");
return Ok(Some(xous_ipc::String::<4000>::from_str("\u{0011}"))); return Ok(Some(xous_ipc::String::<4000>::from_str("\u{0011}")));
} }
} }