mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
chat UI rawkeys toggle menu_mode & raise app/msg menus
This commit is contained in:
parent
ce8c7f51c3
commit
ff68567140
3 changed files with 89 additions and 39 deletions
|
|
@ -1,6 +1,11 @@
|
||||||
use enumset::EnumSetType;
|
use enumset::EnumSetType;
|
||||||
use rkyv::{Archive, Deserialize, Serialize};
|
use rkyv::{Archive, Deserialize, Serialize};
|
||||||
|
|
||||||
|
// shorthand for the function keys F1 - F4
|
||||||
|
pub const F1: char = '\u{0011}';
|
||||||
|
pub const F2: char = '\u{0012}';
|
||||||
|
pub const F3: char = '\u{0013}';
|
||||||
|
pub const F4: char = '\u{0014}';
|
||||||
|
|
||||||
|
|
||||||
// these are used to increment and decrement the selected post
|
// these are used to increment and decrement the selected post
|
||||||
|
|
|
||||||
|
|
@ -306,41 +306,14 @@ pub fn server(
|
||||||
unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
|
unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
|
||||||
let s = buffer.as_flat::<xous_ipc::String<4000>, _>().unwrap();
|
let s = buffer.as_flat::<xous_ipc::String<4000>, _>().unwrap();
|
||||||
match s.as_str() {
|
match s.as_str() {
|
||||||
"\u{0011}" => {
|
"\u{0011}" => {}
|
||||||
log::info!("click F1 : raise app menu");
|
"\u{0012}" => {}
|
||||||
ui.event(Event::F1);
|
"\u{0013}" => {}
|
||||||
ui.raise_menu();
|
"\u{0014}" => {}
|
||||||
}
|
"↑" => {}
|
||||||
"\u{0012}" => {
|
"↓" => {}
|
||||||
log::info!("click F2 : noop : suggestions welcome!");
|
"←" => {}
|
||||||
ui.event(Event::F2);
|
"→" => {}
|
||||||
}
|
|
||||||
"\u{0013}" => {
|
|
||||||
log::info!("click F3: noop : suggestions welcome!");
|
|
||||||
ui.event(Event::F3);
|
|
||||||
}
|
|
||||||
"\u{0014}" => {
|
|
||||||
log::info!("click F4 : raise msg menu : pull request welcome!");
|
|
||||||
ui.event(Event::F4);
|
|
||||||
}
|
|
||||||
"↑" => {
|
|
||||||
ui.event(Event::Up);
|
|
||||||
ui.post_select(POST_SELECTED_PREV);
|
|
||||||
ui.redraw().expect("failed to redraw chat");
|
|
||||||
}
|
|
||||||
"↓" => {
|
|
||||||
ui.event(Event::Down);
|
|
||||||
ui.post_select(POST_SELECTED_NEXT);
|
|
||||||
ui.redraw().expect("failed to redraw chat");
|
|
||||||
}
|
|
||||||
"←" => {
|
|
||||||
log::info!("click ← : noop : suggestions welcome!");
|
|
||||||
ui.event(Event::Left);
|
|
||||||
}
|
|
||||||
"→" => {
|
|
||||||
log::info!("click → : noop : suggestions welcome!");
|
|
||||||
ui.event(Event::Right);
|
|
||||||
}
|
|
||||||
_ => {
|
_ => {
|
||||||
drop(buffer);
|
drop(buffer);
|
||||||
if let Some(cid) = app_cid {
|
if let Some(cid) = app_cid {
|
||||||
|
|
@ -352,6 +325,66 @@ pub fn server(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Some(ChatOp::GamRawkeys) => {
|
||||||
|
log::info!("got ChatOp::GamRawkeys");
|
||||||
|
xous::msg_scalar_unpack!(msg, k1, k2, k3, k4, {
|
||||||
|
log::info!("got Chat UI RawKey :{}:{}:{}:{}:", k1, k2, k3, k4);
|
||||||
|
match core::char::from_u32(k1 as u32).unwrap_or('\u{0000}') {
|
||||||
|
F1 => {
|
||||||
|
log::info!("click F1 : pull request welcome!");
|
||||||
|
ui.event(Event::F1);
|
||||||
|
}
|
||||||
|
F2 => {
|
||||||
|
log::info!("click F2 : pull request welcome!");
|
||||||
|
ui.event(Event::F2);
|
||||||
|
}
|
||||||
|
F3 => {
|
||||||
|
log::info!("click F3 : pull request welcome!");
|
||||||
|
ui.event(Event::F3);
|
||||||
|
}
|
||||||
|
F4 => {
|
||||||
|
log::info!("click F4 : pull request welcome!");
|
||||||
|
ui.event(Event::F4);
|
||||||
|
}
|
||||||
|
'↑' => {
|
||||||
|
log::info!("click ↑ : previous post");
|
||||||
|
ui.set_menu_mode(true); // ← & → activate menus
|
||||||
|
ui.post_select(POST_SELECTED_PREV);
|
||||||
|
ui.redraw().expect("failed to redraw chat");
|
||||||
|
ui.event(Event::Up);
|
||||||
|
},
|
||||||
|
'↓' => {
|
||||||
|
log::info!("click ↓ : next post");
|
||||||
|
ui.post_select(POST_SELECTED_NEXT);
|
||||||
|
ui.redraw().expect("failed to redraw chat");
|
||||||
|
ui.event(Event::Down);
|
||||||
|
}
|
||||||
|
'←' => {
|
||||||
|
log::info!("click ← : raise app menu");
|
||||||
|
if ui.get_menu_mode() {
|
||||||
|
ui.raise_app_menu();
|
||||||
|
}
|
||||||
|
ui.event(Event::Left);
|
||||||
|
}
|
||||||
|
'→' => {
|
||||||
|
log::info!("click → : raise msg menu : pull request welcome!");
|
||||||
|
if ui.get_menu_mode() {
|
||||||
|
ui.raise_msg_menu();
|
||||||
|
}
|
||||||
|
ui.event(Event::Right);
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
ui.set_menu_mode(false); // ← & → move input cursor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if let Some(cid) = app_cid {
|
||||||
|
if let Some(opcode) = opcode_rawkeys {
|
||||||
|
log::info!("Forwarding msg to Chat App: {:?}", msg);
|
||||||
|
msg.forward(cid, opcode).expect("failed to fwd rawkey");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Some(ChatOp::GamRedraw) => {
|
Some(ChatOp::GamRedraw) => {
|
||||||
log::info!("ChatOp::GamRedraw");
|
log::info!("ChatOp::GamRedraw");
|
||||||
if allow_redraw {
|
if allow_redraw {
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ pub(crate) struct Ui {
|
||||||
bubble_space: i16, // spacing between text bubbles
|
bubble_space: i16, // spacing between text bubbles
|
||||||
|
|
||||||
// variables that define a menu
|
// variables that define a menu
|
||||||
|
menu_mode: bool,
|
||||||
app_menu: String,
|
app_menu: String,
|
||||||
menu_mgr: MenuMatic,
|
menu_mgr: MenuMatic,
|
||||||
|
|
||||||
|
|
@ -95,8 +96,6 @@ impl Ui {
|
||||||
})
|
})
|
||||||
.expect("couldn't register Ux context for chat")
|
.expect("couldn't register Ux context for chat")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
gam.toggle_menu_mode(token)
|
|
||||||
.expect("couldnt't toggle menu mode");
|
|
||||||
let xns = XousNames::new().unwrap();
|
let xns = XousNames::new().unwrap();
|
||||||
let modals = Modals::new(&xns).unwrap();
|
let modals = Modals::new(&xns).unwrap();
|
||||||
let canvas = gam
|
let canvas = gam
|
||||||
|
|
@ -105,11 +104,11 @@ impl Ui {
|
||||||
let screensize = gam
|
let screensize = gam
|
||||||
.get_canvas_bounds(canvas)
|
.get_canvas_bounds(canvas)
|
||||||
.expect("couldn't get dimensions of content canvas");
|
.expect("couldn't get dimensions of content canvas");
|
||||||
|
// TODO this is a stub - implement F1-4 actions and autocompletes
|
||||||
let _icontray = Icontray::new(
|
let _icontray = Icontray::new(
|
||||||
Some(xous::connect(sid).unwrap()),
|
Some(xous::connect(sid).unwrap()),
|
||||||
[app_name, "F2", "F3", "F4"],
|
["F1", "F2", "F3", "F4"],
|
||||||
);
|
);
|
||||||
|
|
||||||
let pddb = pddb::Pddb::new();
|
let pddb = pddb::Pddb::new();
|
||||||
pddb.try_mount();
|
pddb.try_mount();
|
||||||
let menu_mgr = menu_matic(
|
let menu_mgr = menu_matic(
|
||||||
|
|
@ -139,6 +138,7 @@ impl Ui {
|
||||||
bubble_margin: Point::new(4, 4),
|
bubble_margin: Point::new(4, 4),
|
||||||
bubble_radius: 4,
|
bubble_radius: 4,
|
||||||
bubble_space: 4,
|
bubble_space: 4,
|
||||||
|
menu_mode: true,
|
||||||
app_menu: app_menu.to_owned(),
|
app_menu: app_menu.to_owned(),
|
||||||
menu_mgr: menu_mgr,
|
menu_mgr: menu_mgr,
|
||||||
token: token,
|
token: token,
|
||||||
|
|
@ -465,7 +465,13 @@ impl Ui {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
pub fn get_menu_mode(&self) -> bool {
|
||||||
|
self.menu_mode
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_menu_mode(&mut self, menu_mode: bool) {
|
||||||
|
self.menu_mode = menu_mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -571,6 +577,12 @@ impl Ui {
|
||||||
log::info!("raised app menu");
|
log::info!("raised app menu");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Show the Msg Menu (→ key)
|
||||||
|
///
|
||||||
|
pub(crate) fn raise_msg_menu(&mut self) {
|
||||||
|
log::warn!("msg menu not implemented - pull-requests welcome");
|
||||||
|
}
|
||||||
|
|
||||||
/// Redraw posts on the screen.
|
/// Redraw posts on the screen.
|
||||||
///
|
///
|
||||||
/// Up to three attempts are made to layout the Posts:
|
/// Up to three attempts are made to layout the Posts:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue