mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
minor tweaks to the repl demo
This commit is contained in:
parent
1449f7cb7f
commit
b5faa1eb55
4 changed files with 6 additions and 7 deletions
|
|
@ -50,9 +50,9 @@ impl<'a> ShellCmdApi<'a> for Audio {
|
||||||
440.0
|
440.0
|
||||||
};
|
};
|
||||||
let mut duration: f32 = if let Some(duration_str) = tokens.next() {
|
let mut duration: f32 = if let Some(duration_str) = tokens.next() {
|
||||||
duration_str.parse::<f32>().unwrap_or(2.0)
|
duration_str.parse::<f32>().unwrap_or(0.5)
|
||||||
} else {
|
} else {
|
||||||
2.0
|
0.5
|
||||||
};
|
};
|
||||||
if duration > 10.0 {
|
if duration > 10.0 {
|
||||||
duration = 10.0; // sanity check the duration so we don't go nuts
|
duration = 10.0; // sanity check the duration so we don't go nuts
|
||||||
|
|
|
||||||
|
|
@ -31,13 +31,12 @@ fn xmain() -> ! {
|
||||||
let xns = xous_names::XousNames::new().unwrap();
|
let xns = xous_names::XousNames::new().unwrap();
|
||||||
// unlimited connections allowed, this is a user app and it's up to the app to decide its policy
|
// unlimited connections allowed, this is a user app and it's up to the app to decide its policy
|
||||||
let sid = xns.register_name(SERVER_NAME_REPL, None).expect("can't register server");
|
let sid = xns.register_name(SERVER_NAME_REPL, None).expect("can't register server");
|
||||||
log::trace!("registered with NS -- {:?}", sid);
|
// log::trace!("registered with NS -- {:?}", sid);
|
||||||
|
|
||||||
let mut repl = Repl::new(&xns, sid);
|
let mut repl = Repl::new(&xns, sid);
|
||||||
let mut update_repl = true;
|
let mut update_repl = true;
|
||||||
let mut was_callback = false;
|
let mut was_callback = false;
|
||||||
let mut allow_redraw = false;
|
let mut allow_redraw = false;
|
||||||
log::trace!("entering main loop");
|
|
||||||
loop {
|
loop {
|
||||||
let msg = xous::receive_message(sid).unwrap();
|
let msg = xous::receive_message(sid).unwrap();
|
||||||
log::debug!("got message {:?}", msg);
|
log::debug!("got message {:?}", msg);
|
||||||
|
|
@ -63,7 +62,6 @@ fn xmain() -> ! {
|
||||||
}
|
}
|
||||||
gam::FocusState::Foreground => {
|
gam::FocusState::Foreground => {
|
||||||
allow_redraw = true;
|
allow_redraw = true;
|
||||||
update_repl = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ impl Repl{
|
||||||
gotinput_id: Some(ReplOp::Line.to_u32().unwrap()),
|
gotinput_id: Some(ReplOp::Line.to_u32().unwrap()),
|
||||||
audioframe_id: None,
|
audioframe_id: None,
|
||||||
rawkeys_id: None,
|
rawkeys_id: None,
|
||||||
focuschange_id: Some(ReplOp::Redraw.to_u32().unwrap()),
|
focuschange_id: Some(ReplOp::ChangeFocus.to_u32().unwrap()),
|
||||||
}).expect("couldn't register Ux context for repl");
|
}).expect("couldn't register Ux context for repl");
|
||||||
|
|
||||||
let content = gam.request_content_canvas(token.unwrap()).expect("couldn't get content canvas");
|
let content = gam.request_content_canvas(token.unwrap()).expect("couldn't get content canvas");
|
||||||
|
|
|
||||||
|
|
@ -363,6 +363,7 @@ impl ContextManager {
|
||||||
// immutable borrow here can't be combined with mutable borrow below
|
// immutable borrow here can't be combined with mutable borrow below
|
||||||
if let Some(old_context) = self.get_context_by_token(self.focused_context.unwrap()) {
|
if let Some(old_context) = self.get_context_by_token(self.focused_context.unwrap()) {
|
||||||
self.notify_focus_change_to(gam::FocusState::Background, old_context).unwrap();
|
self.notify_focus_change_to(gam::FocusState::Background, old_context).unwrap();
|
||||||
|
log::trace!("lowered focus to: {:?}", old_context);
|
||||||
}
|
}
|
||||||
if let Some(old_context) = self.get_context_by_token_mut(self.focused_context.unwrap()) {
|
if let Some(old_context) = self.get_context_by_token_mut(self.focused_context.unwrap()) {
|
||||||
old_context.layout.set_visibility_state(leaving_visibility, canvases);
|
old_context.layout.set_visibility_state(leaving_visibility, canvases);
|
||||||
|
|
@ -426,7 +427,7 @@ impl ContextManager {
|
||||||
self.kbd.set_vibe(context.vibe).expect("couldn't restore keyboard vibe");
|
self.kbd.set_vibe(context.vibe).expect("couldn't restore keyboard vibe");
|
||||||
|
|
||||||
self.notify_focus_change_to(gam::FocusState::Foreground, context).unwrap();
|
self.notify_focus_change_to(gam::FocusState::Foreground, context).unwrap();
|
||||||
log::debug!("raised focus to: {:?}", context);
|
log::trace!("raised focus to: {:?}", context);
|
||||||
let last_token = context.app_token;
|
let last_token = context.app_token;
|
||||||
self.last_context = self.focused_context;
|
self.last_context = self.focused_context;
|
||||||
self.focused_context = Some(last_token);
|
self.focused_context = Some(last_token);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue