mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
regex search/replace instances of xous_ipc::String to String
This commit is contained in:
parent
0ef93e3bcd
commit
15722a314a
8 changed files with 59 additions and 59 deletions
|
|
@ -21,8 +21,9 @@ xous-names = { package = "xous-api-names", version = "0.9.61" }
|
||||||
|
|
||||||
num-derive = { version = "0.3.3", default-features = false }
|
num-derive = { version = "0.3.3", default-features = false }
|
||||||
num-traits = { version = "0.2.14", default-features = false }
|
num-traits = { version = "0.2.14", default-features = false }
|
||||||
rkyv = { version = "0.4.3", default-features = false, features = [
|
rkyv = { version = "0.8.8", default-features = false, features = [
|
||||||
"const_generics",
|
"std",
|
||||||
|
"alloc",
|
||||||
] }
|
] }
|
||||||
|
|
||||||
tts-frontend = { path = "../tts" }
|
tts-frontend = { path = "../tts" }
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
use gam::*;
|
use gam::*;
|
||||||
use ime_plugin_api::ImefOpcode;
|
use ime_plugin_api::ImefOpcode;
|
||||||
use num_traits::*;
|
use num_traits::*;
|
||||||
use xous_ipc::String;
|
use String;
|
||||||
|
|
||||||
// imef_conn must come from outside the scope of the macro because of hygeine rules.
|
// imef_conn must come from outside the scope of the macro because of hygeine rules.
|
||||||
macro_rules! emoji_item {
|
macro_rules! emoji_item {
|
||||||
($emoji:expr, $imef_conn:ident) => {
|
($emoji:expr, $imef_conn:ident) => {
|
||||||
MenuItem {
|
MenuItem {
|
||||||
name: String::from_str(&$emoji.to_string()),
|
name: String::from(&$emoji.to_string()),
|
||||||
action_conn: Some($imef_conn),
|
action_conn: Some($imef_conn),
|
||||||
action_opcode: ImefOpcode::ProcessKeys.to_u32().unwrap(),
|
action_opcode: ImefOpcode::ProcessKeys.to_u32().unwrap(),
|
||||||
action_payload: MenuPayload::Scalar([
|
action_payload: MenuPayload::Scalar([
|
||||||
|
|
@ -36,7 +36,7 @@ pub(crate) fn emoji_menu(imef_conn: xous::CID) {
|
||||||
emoji_item!('😅', imef_conn),
|
emoji_item!('😅', imef_conn),
|
||||||
emoji_item!('🤣', imef_conn),
|
emoji_item!('🤣', imef_conn),
|
||||||
MenuItem {
|
MenuItem {
|
||||||
name: String::from_str("Close Menu"),
|
name: String::from("Close Menu"),
|
||||||
action_conn: None,
|
action_conn: None,
|
||||||
action_opcode: 0,
|
action_opcode: 0,
|
||||||
action_payload: MenuPayload::Scalar([0, 0, 0, 0]),
|
action_payload: MenuPayload::Scalar([0, 0, 0, 0]),
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ struct InputTracker {
|
||||||
/// our current prediction engine
|
/// our current prediction engine
|
||||||
predictor: Option<PredictionPlugin>,
|
predictor: Option<PredictionPlugin>,
|
||||||
/// the name & token of our engine, so we can disconnect later on
|
/// the name & token of our engine, so we can disconnect later on
|
||||||
pub predictor_conn: Option<(xous_ipc::String<64>, [u32; 4])>,
|
pub predictor_conn: Option<(String, [u32; 4])>,
|
||||||
/// cached copy of the predictor's triggers for predictions. Only valid if predictor is not None
|
/// cached copy of the predictor's triggers for predictions. Only valid if predictor is not None
|
||||||
pred_triggers: Option<PredictionTriggers>,
|
pred_triggers: Option<PredictionTriggers>,
|
||||||
/// set if we're in a state where a backspace should trigger an unpredict
|
/// set if we're in a state where a backspace should trigger an unpredict
|
||||||
|
|
@ -276,10 +276,10 @@ impl InputTracker {
|
||||||
newkeys: [char; 4],
|
newkeys: [char; 4],
|
||||||
force_redraw: bool,
|
force_redraw: bool,
|
||||||
api_token: [u32; 4],
|
api_token: [u32; 4],
|
||||||
) -> Result<Option<xous_ipc::String<4000>>, xous::Error> {
|
) -> Result<Option<String>, xous::Error> {
|
||||||
let debug1 = false;
|
let debug1 = false;
|
||||||
let mut update_predictor = force_redraw;
|
let mut update_predictor = force_redraw;
|
||||||
let mut retstring: Option<xous_ipc::String<4000>> = None;
|
let mut retstring: Option<String> = None;
|
||||||
if let Some(ic) = self.input_canvas {
|
if let Some(ic) = self.input_canvas {
|
||||||
if debug1 {
|
if debug1 {
|
||||||
info!("updating input area");
|
info!("updating input area");
|
||||||
|
|
@ -311,7 +311,7 @@ impl InputTracker {
|
||||||
self.can_unpick = false;
|
self.can_unpick = false;
|
||||||
self.last_trigger_char = None;
|
self.last_trigger_char = None;
|
||||||
} else {
|
} else {
|
||||||
return Ok(Some(xous_ipc::String::<4000>::from_str("←")));
|
return Ok(Some(String::from("←")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'→' => {
|
'→' => {
|
||||||
|
|
@ -324,7 +324,7 @@ impl InputTracker {
|
||||||
self.can_unpick = false;
|
self.can_unpick = false;
|
||||||
self.last_trigger_char = None;
|
self.last_trigger_char = None;
|
||||||
} else {
|
} else {
|
||||||
return Ok(Some(xous_ipc::String::<4000>::from_str("→")));
|
return Ok(Some(String::from("→")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'↑' => {
|
'↑' => {
|
||||||
|
|
@ -336,7 +336,7 @@ impl InputTracker {
|
||||||
self.can_unpick = false;
|
self.can_unpick = false;
|
||||||
self.last_trigger_char = None;
|
self.last_trigger_char = None;
|
||||||
} else {
|
} else {
|
||||||
return Ok(Some(xous_ipc::String::<4000>::from_str("↑")));
|
return Ok(Some(String::from("↑")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'↓' => {
|
'↓' => {
|
||||||
|
|
@ -351,7 +351,7 @@ impl InputTracker {
|
||||||
// prior to the last word...
|
// prior to the last word...
|
||||||
self.last_trigger_char = Some(self.characters);
|
self.last_trigger_char = Some(self.characters);
|
||||||
} else {
|
} else {
|
||||||
return Ok(Some(xous_ipc::String::<4000>::from_str("↓")));
|
return Ok(Some(String::from("↓")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'\u{0011}' => {
|
'\u{0011}' => {
|
||||||
|
|
@ -360,7 +360,7 @@ impl InputTracker {
|
||||||
self.insert_prediction(0);
|
self.insert_prediction(0);
|
||||||
do_redraw = true;
|
do_redraw = true;
|
||||||
} else {
|
} else {
|
||||||
retstring = Some(xous_ipc::String::<4000>::from_str("\u{0011}"));
|
retstring = Some(String::from("\u{0011}"));
|
||||||
do_redraw = true;
|
do_redraw = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -370,7 +370,7 @@ impl InputTracker {
|
||||||
self.insert_prediction(1);
|
self.insert_prediction(1);
|
||||||
do_redraw = true;
|
do_redraw = true;
|
||||||
} else {
|
} else {
|
||||||
retstring = Some(xous_ipc::String::<4000>::from_str("\u{0012}"));
|
retstring = Some(String::from("\u{0012}"));
|
||||||
do_redraw = true;
|
do_redraw = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -380,7 +380,7 @@ impl InputTracker {
|
||||||
self.insert_prediction(2);
|
self.insert_prediction(2);
|
||||||
do_redraw = true;
|
do_redraw = true;
|
||||||
} else {
|
} else {
|
||||||
retstring = Some(xous_ipc::String::<4000>::from_str("\u{0013}"));
|
retstring = Some(String::from("\u{0013}"));
|
||||||
do_redraw = true;
|
do_redraw = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -390,7 +390,7 @@ impl InputTracker {
|
||||||
self.insert_prediction(3);
|
self.insert_prediction(3);
|
||||||
do_redraw = true;
|
do_redraw = true;
|
||||||
} else {
|
} else {
|
||||||
retstring = Some(xous_ipc::String::<4000>::from_str("\u{0014}"));
|
retstring = Some(String::from("\u{0014}"));
|
||||||
do_redraw = true;
|
do_redraw = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -471,7 +471,7 @@ impl InputTracker {
|
||||||
}
|
}
|
||||||
'\u{000d}' => {
|
'\u{000d}' => {
|
||||||
// carriage return
|
// carriage return
|
||||||
let mut ret = xous_ipc::String::<4000>::new();
|
let mut ret = String::new();
|
||||||
write!(ret, "{}", self.line.as_str()).expect("couldn't copy input line to output");
|
write!(ret, "{}", self.line.as_str()).expect("couldn't copy input line to output");
|
||||||
retstring = Some(ret);
|
retstring = Some(ret);
|
||||||
|
|
||||||
|
|
@ -479,12 +479,12 @@ impl InputTracker {
|
||||||
if trigger.newline {
|
if trigger.newline {
|
||||||
self.predictor
|
self.predictor
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.feedback_picked(xous_ipc::String::<4000>::from_str(&self.line))
|
.feedback_picked(String::from(&self.line))
|
||||||
.expect("couldn't send feedback to predictor");
|
.expect("couldn't send feedback to predictor");
|
||||||
} else if trigger.punctuation {
|
} else if trigger.punctuation {
|
||||||
self.predictor
|
self.predictor
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.feedback_picked(xous_ipc::String::<4000>::from_str(&self.pred_phrase))
|
.feedback_picked(String::from(&self.pred_phrase))
|
||||||
.expect("couldn't send feedback to predictor");
|
.expect("couldn't send feedback to predictor");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -528,9 +528,7 @@ impl InputTracker {
|
||||||
if self.pred_phrase.len() > 0 {
|
if self.pred_phrase.len() > 0 {
|
||||||
self.predictor
|
self.predictor
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.feedback_picked(xous_ipc::String::<4000>::from_str(
|
.feedback_picked(String::from(&self.pred_phrase))
|
||||||
&self.pred_phrase,
|
|
||||||
))
|
|
||||||
.expect("couldn't send feedback to predictor");
|
.expect("couldn't send feedback to predictor");
|
||||||
self.pred_phrase.clear();
|
self.pred_phrase.clear();
|
||||||
self.can_unpick = true;
|
self.can_unpick = true;
|
||||||
|
|
@ -541,9 +539,7 @@ impl InputTracker {
|
||||||
if self.pred_phrase.len() > 0 {
|
if self.pred_phrase.len() > 0 {
|
||||||
self.predictor
|
self.predictor
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.feedback_picked(xous_ipc::String::<4000>::from_str(
|
.feedback_picked(String::from(&self.pred_phrase))
|
||||||
&self.pred_phrase,
|
|
||||||
))
|
|
||||||
.expect("couldn't send feedback to predictor");
|
.expect("couldn't send feedback to predictor");
|
||||||
self.pred_phrase.clear();
|
self.pred_phrase.clear();
|
||||||
self.can_unpick = true;
|
self.can_unpick = true;
|
||||||
|
|
@ -700,7 +696,7 @@ impl InputTracker {
|
||||||
if update_predictor {
|
if update_predictor {
|
||||||
if self.pred_phrase.len() > 0 || self.menu_mode {
|
if self.pred_phrase.len() > 0 || self.menu_mode {
|
||||||
if let Some(pred) = self.predictor {
|
if let Some(pred) = self.predictor {
|
||||||
pred.set_input(xous_ipc::String::<4000>::from_str(&self.pred_phrase))
|
pred.set_input(String::from(&self.pred_phrase))
|
||||||
.expect("couldn't update predictor with current input");
|
.expect("couldn't update predictor with current input");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -786,7 +782,7 @@ impl InputTracker {
|
||||||
p_tv.ellipsis = true;
|
p_tv.ellipsis = true;
|
||||||
p_tv.style = gam::SYSTEM_STYLE;
|
p_tv.style = gam::SYSTEM_STYLE;
|
||||||
write!(p_tv.text, "{}", pred_str).expect("can't write the prediction string");
|
write!(p_tv.text, "{}", pred_str).expect("can't write the prediction string");
|
||||||
log::trace!("posting string with length {}", p_tv.text.as_str().unwrap().len());
|
log::trace!("posting string with length {}", p_tv.text.as_str().len());
|
||||||
self.gam.post_textview(&mut p_tv).expect("couldn't post prediction text");
|
self.gam.post_textview(&mut p_tv).expect("couldn't post prediction text");
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
|
@ -853,14 +849,14 @@ fn main() -> ! {
|
||||||
if let Some(pred) = tracker.get_predictor() {
|
if let Some(pred) = tracker.get_predictor() {
|
||||||
pred.release(api_token.take().unwrap().api_token); // api token *should* be Some() if pred is Some()
|
pred.release(api_token.take().unwrap().api_token); // api token *should* be Some() if pred is Some()
|
||||||
if let Some((name, token)) = tracker.predictor_conn {
|
if let Some((name, token)) = tracker.predictor_conn {
|
||||||
xns.disconnect_with_token(name.as_str().unwrap(), token)
|
xns.disconnect_with_token(name.as_str(), token)
|
||||||
.expect("couldn't disconnect from previous predictor. Something is wrong with internal state!");
|
.expect("couldn't disconnect from previous predictor. Something is wrong with internal state!");
|
||||||
}
|
}
|
||||||
tracker.predictor_conn = None;
|
tracker.predictor_conn = None;
|
||||||
tracker.set_predictor(None);
|
tracker.set_predictor(None);
|
||||||
}
|
}
|
||||||
if let Some(s) = descriptor.predictor {
|
if let Some(s) = descriptor.predictor {
|
||||||
match xns.request_connection_with_token(s.as_str().unwrap()) {
|
match xns.request_connection_with_token(s.as_str()) {
|
||||||
Ok((pc, token)) => {
|
Ok((pc, token)) => {
|
||||||
let pred = ime_plugin_api::PredictionPlugin { connection: Some(pc) };
|
let pred = ime_plugin_api::PredictionPlugin { connection: Some(pc) };
|
||||||
match pred.acquire(descriptor.predictor_token) {
|
match pred.acquire(descriptor.predictor_token) {
|
||||||
|
|
@ -874,13 +870,13 @@ fn main() -> ! {
|
||||||
}
|
}
|
||||||
tracker.set_predictor(Some(pred));
|
tracker.set_predictor(Some(pred));
|
||||||
tracker.predictor_conn = Some((
|
tracker.predictor_conn = Some((
|
||||||
xous_ipc::String::<64>::from_str(s.as_str().unwrap()),
|
String::from(s.as_str()),
|
||||||
token.expect("didn't get the disconnect token!"),
|
token.expect("didn't get the disconnect token!"),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
_ => error!(
|
_ => error!(
|
||||||
"can't find predictive engine {}, retaining existing one.",
|
"can't find predictive engine {}, retaining existing one.",
|
||||||
s.as_str().unwrap()
|
s.as_str()
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ xous-names = { package = "xous-api-names", version = "0.9.61" } # used by the IM
|
||||||
|
|
||||||
num-derive = { version = "0.3.3", default-features = false }
|
num-derive = { version = "0.3.3", default-features = false }
|
||||||
num-traits = { version = "0.2.14", default-features = false }
|
num-traits = { version = "0.2.14", default-features = false }
|
||||||
rkyv = { version = "0.4.3", default-features = false, features = [
|
rkyv = { version = "0.8.8", default-features = false, features = [
|
||||||
"const_generics",
|
"std",
|
||||||
|
"alloc",
|
||||||
] }
|
] }
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,13 @@ mod rkyv_enum;
|
||||||
use num_traits::{FromPrimitive, ToPrimitive};
|
use num_traits::{FromPrimitive, ToPrimitive};
|
||||||
pub use rkyv_enum::*;
|
pub use rkyv_enum::*;
|
||||||
use xous::{send_message, Message, CID};
|
use xous::{send_message, Message, CID};
|
||||||
use xous_ipc::{Buffer, String};
|
use xous_ipc::Buffer;
|
||||||
|
|
||||||
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
||||||
pub struct Prediction {
|
pub struct Prediction {
|
||||||
pub index: u32,
|
pub index: u32,
|
||||||
pub valid: bool,
|
pub valid: bool,
|
||||||
pub string: String<1000>,
|
pub string: String,
|
||||||
pub api_token: [u32; 4],
|
pub api_token: [u32; 4],
|
||||||
}
|
}
|
||||||
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
||||||
|
|
@ -61,10 +61,10 @@ impl From<usize> for PredictionTriggers {
|
||||||
#[derive(Debug, num_derive::FromPrimitive, num_derive::ToPrimitive)]
|
#[derive(Debug, num_derive::FromPrimitive, num_derive::ToPrimitive)]
|
||||||
pub enum Opcode {
|
pub enum Opcode {
|
||||||
/// update with the latest input candidate. Replaces the previous input.
|
/// update with the latest input candidate. Replaces the previous input.
|
||||||
Input, //(String<4000>),
|
Input, //(String),
|
||||||
|
|
||||||
/// feed back to the IME plugin as to what was picked, so predictions can be updated
|
/// feed back to the IME plugin as to what was picked, so predictions can be updated
|
||||||
Picked, //(String<4000>),
|
Picked, //(String),
|
||||||
|
|
||||||
/// Undo the last Picked value. To be used when a user hits backspace after picking a prediction
|
/// Undo the last Picked value. To be used when a user hits backspace after picking a prediction
|
||||||
/// note that repeated calls to Unpick will have an implementation-defined behavior
|
/// note that repeated calls to Unpick will have an implementation-defined behavior
|
||||||
|
|
@ -88,9 +88,9 @@ pub enum Opcode {
|
||||||
pub trait PredictionApi {
|
pub trait PredictionApi {
|
||||||
fn get_prediction_triggers(&self) -> Result<PredictionTriggers, xous::Error>;
|
fn get_prediction_triggers(&self) -> Result<PredictionTriggers, xous::Error>;
|
||||||
fn unpick(&self) -> Result<(), xous::Error>;
|
fn unpick(&self) -> Result<(), xous::Error>;
|
||||||
fn set_input(&self, s: String<4000>) -> Result<(), xous::Error>;
|
fn set_input(&self, s: String) -> Result<(), xous::Error>;
|
||||||
fn feedback_picked(&self, s: String<4000>) -> Result<(), xous::Error>;
|
fn feedback_picked(&self, s: String) -> Result<(), xous::Error>;
|
||||||
fn get_prediction(&self, index: u32, api_token: [u32; 4]) -> Result<Option<String<4000>>, xous::Error>;
|
fn get_prediction(&self, index: u32, api_token: [u32; 4]) -> Result<Option<String>, xous::Error>;
|
||||||
/// gets an exclusive lock on the predictor. Returns an error if the predictor is already locked.
|
/// gets an exclusive lock on the predictor. Returns an error if the predictor is already locked.
|
||||||
fn acquire(&self, api_token: Option<[u32; 4]>) -> Result<[u32; 4], xous::Error>;
|
fn acquire(&self, api_token: Option<[u32; 4]>) -> Result<[u32; 4], xous::Error>;
|
||||||
/// releases the lock. Also clears any sensitive data that may be in the predictor.
|
/// releases the lock. Also clears any sensitive data that may be in the predictor.
|
||||||
|
|
@ -137,7 +137,7 @@ impl PredictionApi for PredictionPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_input(&self, s: String<4000>) -> Result<(), xous::Error> {
|
fn set_input(&self, s: String) -> Result<(), xous::Error> {
|
||||||
match self.connection {
|
match self.connection {
|
||||||
Some(cid) => {
|
Some(cid) => {
|
||||||
let buf = Buffer::into_buf(s).or(Err(xous::Error::InternalError))?;
|
let buf = Buffer::into_buf(s).or(Err(xous::Error::InternalError))?;
|
||||||
|
|
@ -148,7 +148,7 @@ impl PredictionApi for PredictionPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn feedback_picked(&self, s: String<4000>) -> Result<(), xous::Error> {
|
fn feedback_picked(&self, s: String) -> Result<(), xous::Error> {
|
||||||
match self.connection {
|
match self.connection {
|
||||||
Some(cid) => {
|
Some(cid) => {
|
||||||
let buf = Buffer::into_buf(s).or(Err(xous::Error::InternalError))?;
|
let buf = Buffer::into_buf(s).or(Err(xous::Error::InternalError))?;
|
||||||
|
|
@ -161,10 +161,10 @@ impl PredictionApi for PredictionPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// this function could disclose sensitive data, so it requires an API token to call
|
/// this function could disclose sensitive data, so it requires an API token to call
|
||||||
fn get_prediction(&self, index: u32, api_token: [u32; 4]) -> Result<Option<String<4000>>, xous::Error> {
|
fn get_prediction(&self, index: u32, api_token: [u32; 4]) -> Result<Option<String>, xous::Error> {
|
||||||
match self.connection {
|
match self.connection {
|
||||||
Some(cid) => {
|
Some(cid) => {
|
||||||
let prediction = Prediction { index, string: String::<1000>::new(), valid: false, api_token };
|
let prediction = Prediction { index, string: String::new(), valid: false, api_token };
|
||||||
let mut buf = Buffer::into_buf(prediction).or(Err(xous::Error::InternalError))?;
|
let mut buf = Buffer::into_buf(prediction).or(Err(xous::Error::InternalError))?;
|
||||||
buf.lend_mut(cid, Opcode::Prediction.to_u32().unwrap())
|
buf.lend_mut(cid, Opcode::Prediction.to_u32().unwrap())
|
||||||
.or(Err(xous::Error::InternalError))?;
|
.or(Err(xous::Error::InternalError))?;
|
||||||
|
|
@ -175,7 +175,7 @@ impl PredictionApi for PredictionPlugin {
|
||||||
Return::Prediction(pred) => {
|
Return::Prediction(pred) => {
|
||||||
log::trace!("|API: got {:?}", pred);
|
log::trace!("|API: got {:?}", pred);
|
||||||
if pred.valid {
|
if pred.valid {
|
||||||
let mut ret = String::<4000>::new();
|
let mut ret = String::new();
|
||||||
use core::fmt::Write as CoreWrite;
|
use core::fmt::Write as CoreWrite;
|
||||||
write!(ret, "{}", pred.string).unwrap();
|
write!(ret, "{}", pred.string).unwrap();
|
||||||
Ok(Some(ret))
|
Ok(Some(ret))
|
||||||
|
|
@ -242,7 +242,7 @@ pub enum ImefOpcode {
|
||||||
ConnectBackend,
|
ConnectBackend,
|
||||||
|
|
||||||
/// register a listener for finalized inputs
|
/// register a listener for finalized inputs
|
||||||
RegisterListener, //(String<64>),
|
RegisterListener, //(String),
|
||||||
|
|
||||||
/// internal use for passing keyboard events from the keyboard callback
|
/// internal use for passing keyboard events from the keyboard callback
|
||||||
ProcessKeys,
|
ProcessKeys,
|
||||||
|
|
@ -257,22 +257,22 @@ pub enum ImefOpcode {
|
||||||
}
|
}
|
||||||
#[derive(Debug, num_derive::FromPrimitive, num_derive::ToPrimitive)]
|
#[derive(Debug, num_derive::FromPrimitive, num_derive::ToPrimitive)]
|
||||||
pub enum ImefCallback {
|
pub enum ImefCallback {
|
||||||
GotInputLine, //(String<4000>),
|
GotInputLine, //(String),
|
||||||
Drop,
|
Drop,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Copy, Clone)]
|
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Clone)]
|
||||||
pub struct ImefDescriptor {
|
pub struct ImefDescriptor {
|
||||||
pub input_canvas: Option<graphics_server::Gid>,
|
pub input_canvas: Option<graphics_server::Gid>,
|
||||||
pub prediction_canvas: Option<graphics_server::Gid>,
|
pub prediction_canvas: Option<graphics_server::Gid>,
|
||||||
pub predictor: Option<String<64>>,
|
pub predictor: Option<String>,
|
||||||
pub token: [u32; 4], // token used to lookup our connected app inside the GAM
|
pub token: [u32; 4], // token used to lookup our connected app inside the GAM
|
||||||
pub predictor_token: Option<[u32; 4]>,
|
pub predictor_token: Option<[u32; 4]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ImeFrontEndApi {
|
pub trait ImeFrontEndApi {
|
||||||
fn connect_backend(&self, descriptor: ImefDescriptor) -> Result<(), xous::Error>;
|
fn connect_backend(&self, descriptor: ImefDescriptor) -> Result<(), xous::Error>;
|
||||||
fn hook_listener_callback(&mut self, cb: fn(String<4000>)) -> Result<(), xous::Error>;
|
fn hook_listener_callback(&mut self, cb: fn(String)) -> Result<(), xous::Error>;
|
||||||
fn redraw(&self, force_all: bool) -> Result<(), xous::Error>;
|
fn redraw(&self, force_all: bool) -> Result<(), xous::Error>;
|
||||||
fn send_keyevent(&self, keys: [char; 4]) -> Result<(), xous::Error>;
|
fn send_keyevent(&self, keys: [char; 4]) -> Result<(), xous::Error>;
|
||||||
fn conn(&self) -> xous::CID;
|
fn conn(&self) -> xous::CID;
|
||||||
|
|
@ -281,7 +281,7 @@ pub trait ImeFrontEndApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const SERVER_NAME_IME_FRONT: &str = "_IME front end_";
|
pub const SERVER_NAME_IME_FRONT: &str = "_IME front end_";
|
||||||
static mut INPUT_CB: Option<fn(String<4000>)> = None;
|
static mut INPUT_CB: Option<fn(String)> = None;
|
||||||
|
|
||||||
pub struct ImeFrontEnd {
|
pub struct ImeFrontEnd {
|
||||||
cid: CID,
|
cid: CID,
|
||||||
|
|
@ -363,7 +363,7 @@ impl ImeFrontEndApi for ImeFrontEnd {
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hook_listener_callback(&mut self, cb: fn(String<4000>)) -> Result<(), xous::Error> {
|
fn hook_listener_callback(&mut self, cb: fn(String)) -> Result<(), xous::Error> {
|
||||||
if unsafe { INPUT_CB }.is_some() {
|
if unsafe { INPUT_CB }.is_some() {
|
||||||
return Err(xous::Error::MemoryInUse); // can't hook it twice
|
return Err(xous::Error::MemoryInUse); // can't hook it twice
|
||||||
}
|
}
|
||||||
|
|
@ -410,7 +410,7 @@ fn callback_server(sid0: usize, sid1: usize, sid2: usize, sid3: usize) {
|
||||||
match FromPrimitive::from_usize(msg.body.id()) {
|
match FromPrimitive::from_usize(msg.body.id()) {
|
||||||
Some(ImefCallback::GotInputLine) => {
|
Some(ImefCallback::GotInputLine) => {
|
||||||
let buffer = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
|
let buffer = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
|
||||||
let inputline = buffer.to_original::<String<4000>, _>().unwrap();
|
let inputline = buffer.to_original::<String, _>().unwrap();
|
||||||
unsafe {
|
unsafe {
|
||||||
if let Some(cb) = INPUT_CB {
|
if let Some(cb) = INPUT_CB {
|
||||||
cb(inputline)
|
cb(inputline)
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,9 @@ xous-names = { package = "xous-api-names", version = "0.9.61" }
|
||||||
|
|
||||||
num-derive = { version = "0.3.3", default-features = false }
|
num-derive = { version = "0.3.3", default-features = false }
|
||||||
num-traits = { version = "0.2.14", default-features = false }
|
num-traits = { version = "0.2.14", default-features = false }
|
||||||
rkyv = { version = "0.4.3", default-features = false, features = [
|
rkyv = { version = "0.8.8", default-features = false, features = [
|
||||||
"const_generics",
|
"std",
|
||||||
|
"alloc",
|
||||||
] }
|
] }
|
||||||
|
|
||||||
utralib = { version = "0.1.24", optional = true, default-features = false }
|
utralib = { version = "0.1.24", optional = true, default-features = false }
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,9 @@ xous-names = { package = "xous-api-names", version = "0.9.61" }
|
||||||
|
|
||||||
num-derive = { version = "0.3.3", default-features = false }
|
num-derive = { version = "0.3.3", default-features = false }
|
||||||
num-traits = { version = "0.2.14", default-features = false }
|
num-traits = { version = "0.2.14", default-features = false }
|
||||||
rkyv = { version = "0.4.3", default-features = false, features = [
|
rkyv = { version = "0.8.8", default-features = false, features = [
|
||||||
"const_generics",
|
"std",
|
||||||
|
"alloc",
|
||||||
] }
|
] }
|
||||||
|
|
||||||
tts-frontend = { path = "../tts" }
|
tts-frontend = { path = "../tts" }
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use ime_plugin_api::*;
|
||||||
use num_traits::FromPrimitive;
|
use num_traits::FromPrimitive;
|
||||||
use tts_frontend::*;
|
use tts_frontend::*;
|
||||||
use xous::msg_scalar_unpack;
|
use xous::msg_scalar_unpack;
|
||||||
use xous_ipc::{Buffer, String};
|
use xous_ipc::Buffer;
|
||||||
|
|
||||||
fn main() -> ! {
|
fn main() -> ! {
|
||||||
log_server::init_wait().unwrap();
|
log_server::init_wait().unwrap();
|
||||||
|
|
@ -59,7 +59,7 @@ fn main() -> ! {
|
||||||
Some(Opcode::Input) => {}
|
Some(Opcode::Input) => {}
|
||||||
Some(Opcode::Picked) => {
|
Some(Opcode::Picked) => {
|
||||||
let buffer = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
|
let buffer = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
|
||||||
let s = buffer.as_flat::<String<4000>, _>().unwrap();
|
let s = buffer.as_flat::<String, _>().unwrap();
|
||||||
tts.tts_simple(s.as_str()).unwrap();
|
tts.tts_simple(s.as_str()).unwrap();
|
||||||
}
|
}
|
||||||
Some(Opcode::Prediction) => {
|
Some(Opcode::Prediction) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue