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,48 +262,63 @@ impl InputTracker {
match k { match k {
'\u{0000}' => (), '\u{0000}' => (),
'←' => { // move insertion point back '←' => { // move insertion point back
if self.insertion > 0 { if !self.menu_mode {
log::debug!("moving insertion point back"); if self.insertion > 0 {
self.insertion -= 1; log::debug!("moving insertion point back");
self.insertion -= 1;
}
do_redraw = true;
self.pred_phrase.clear(); // don't track predictions on edits
self.can_unpick = false;
self.last_trigger_char = None;
} else {
return Ok(Some(xous_ipc::String::<4000>::from_str("←")));
} }
do_redraw = true;
self.pred_phrase.clear(); // don't track predictions on edits
self.can_unpick = false;
self.last_trigger_char = None;
} }
'→' => { '→' => {
if self.insertion < self.characters { if !self.menu_mode {
self.insertion += 1; if self.insertion < self.characters {
self.insertion += 1;
}
do_redraw = true;
self.pred_phrase.clear();
self.can_unpick = false;
self.last_trigger_char = None;
} else {
return Ok(Some(xous_ipc::String::<4000>::from_str("→")));
} }
do_redraw = true;
self.pred_phrase.clear();
self.can_unpick = false;
self.last_trigger_char = None;
} }
'↑' => { '↑' => {
// bring the insertion point to the front of the text box if !self.menu_mode {
self.insertion = 0; // bring the insertion point to the front of the text box
do_redraw = true; self.insertion = 0;
self.pred_phrase.clear(); do_redraw = true;
self.can_unpick = false; self.pred_phrase.clear();
self.last_trigger_char = None; self.can_unpick = false;
self.last_trigger_char = None;
} else {
return Ok(Some(xous_ipc::String::<4000>::from_str("↑")));
}
} }
'↓' => { '↓' => {
// bring insertion point to the very end of the text box if !self.menu_mode {
self.insertion = self.characters; // bring insertion point to the very end of the text box
do_redraw = true; self.insertion = self.characters;
self.pred_phrase.clear(); do_redraw = true;
self.can_unpick = false; self.pred_phrase.clear();
// this means that when we resume typing after an edit, the predictor will set its insertion point self.can_unpick = false;
// at the very end, not the space prior to the last word... // this means that when we resume typing after an edit, the predictor will set its insertion point
self.last_trigger_char = Some(self.characters); // at the very end, not the space prior to the last word...
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}")));
} }
} }