mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
fix carriage return emulation and handling
This commit is contained in:
parent
161b1943eb
commit
547dbbfe6b
2 changed files with 19 additions and 5 deletions
|
|
@ -163,6 +163,7 @@ impl XousDisplay {
|
||||||
Key::Home => '∴',
|
Key::Home => '∴',
|
||||||
Key::Backspace => 0x8_u8.into(),
|
Key::Backspace => 0x8_u8.into(),
|
||||||
Key::Delete => 0x8_u8.into(),
|
Key::Delete => 0x8_u8.into(),
|
||||||
|
Key::Enter => 0xd_u8.into(),
|
||||||
Key::Space => ' ',
|
Key::Space => ' ',
|
||||||
Key::Comma => ',',
|
Key::Comma => ',',
|
||||||
Key::Period => '.',
|
Key::Period => '.',
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,7 @@ impl InputTracker {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update(&mut self, newkeys: [char; 4]) -> Result<(), xous::Error> {
|
pub fn update(&mut self, newkeys: [char; 4]) -> Result<(), xous::Error> {
|
||||||
let debug1= false;
|
let debug1= true;
|
||||||
// just draw a rectangle for the prediction area for now
|
// just draw a rectangle for the prediction area for now
|
||||||
if let Some(pc) = self.pred_canvas {
|
if let Some(pc) = self.pred_canvas {
|
||||||
if debug1{info!("IMEF: updating prediction area");}
|
if debug1{info!("IMEF: updating prediction area");}
|
||||||
|
|
@ -146,15 +146,25 @@ impl InputTracker {
|
||||||
TextBounds::BoundingBox(Rectangle::new(Point::new(0,1), ic_bounds)));
|
TextBounds::BoundingBox(Rectangle::new(Point::new(0,1), ic_bounds)));
|
||||||
input_tv.draw_border = false;
|
input_tv.draw_border = false;
|
||||||
input_tv.border_width = 1;
|
input_tv.border_width = 1;
|
||||||
input_tv.clear_area = true;
|
input_tv.clear_area = true; // need this so that the insertion point is cleared and moved
|
||||||
|
|
||||||
for &k in newkeys.iter() {
|
for &k in newkeys.iter() {
|
||||||
if debug1{info!("IMEF: got key '{}'", k);}
|
if debug1{info!("IMEF: got key '{}'", k);}
|
||||||
match k {
|
match k {
|
||||||
'\u{0000}' => (),
|
'\u{0000}' => (),
|
||||||
'\u{000d}' => {
|
'\u{000d}' => {
|
||||||
|
// TODO: send string to registered listeners
|
||||||
|
// TODO: update the predictor on carriage return
|
||||||
|
|
||||||
// carriage return case
|
// carriage return case
|
||||||
write!(self.line, "").expect("IMEF: can't clear line after carriage return");
|
if debug1{info!("IMEF: got carriage return");}
|
||||||
|
self.line.clear();
|
||||||
|
// clear all the temporary variables
|
||||||
|
self.insertion.pt.y = 0;
|
||||||
|
self.insertion.pt.x = 0;
|
||||||
|
self.insertion.line_height = 0;
|
||||||
|
self.charwidths = [0; 4096];
|
||||||
|
self.clear_area().expect("IMEF: can't clear on carriage return");
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
self.line.push(k).expect("IMEF: ran out of space pushing character into input line");
|
self.line.push(k).expect("IMEF: ran out of space pushing character into input line");
|
||||||
|
|
@ -186,8 +196,11 @@ impl InputTracker {
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
what else do we need:
|
what else do we need:
|
||||||
- current string that is being built up
|
- backspace capability
|
||||||
- cursor position in string, so we can do insertion/deletion
|
- insertion point movement and character insert
|
||||||
|
|
||||||
|
- height up request of canvas when string wraps
|
||||||
|
- registration for listening to string results
|
||||||
*/
|
*/
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue