mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
oops, broke CI with something in *this* code
push a fix that will get CI running, but breaks this dev flow
This commit is contained in:
parent
82919637d8
commit
11932898ac
3 changed files with 65 additions and 17 deletions
|
|
@ -92,7 +92,6 @@ fn main() -> ! {
|
|||
log_server::init_wait().unwrap();
|
||||
log::set_max_level(log::LevelFilter::Debug);
|
||||
log::info!("my PID is {}", xous::process::id());
|
||||
let mut mode = VaultMode::Fido;
|
||||
|
||||
// let's try keeping this completely private as a server. can we do that?
|
||||
let sid = xous::create_server().unwrap();
|
||||
|
|
@ -175,16 +174,13 @@ fn main() -> ! {
|
|||
log::debug!("vaultux got input line: {}", s.as_str());
|
||||
match s.as_str() {
|
||||
"\u{0011}" => {
|
||||
mode = VaultMode::Fido;
|
||||
log::info!("fido");
|
||||
vaultux.set_mode(VaultMode::Fido);
|
||||
}
|
||||
"\u{0012}" => {
|
||||
mode = VaultMode::Totp;
|
||||
log::info!("totp");
|
||||
vaultux.set_mode(VaultMode::Totp);
|
||||
}
|
||||
"\u{0013}" => {
|
||||
mode = VaultMode::Password;
|
||||
log::info!("passwords");
|
||||
vaultux.set_mode(VaultMode::Password);
|
||||
}
|
||||
"\u{0014}" => {
|
||||
vaultux.raise_menu();
|
||||
|
|
|
|||
|
|
@ -22,7 +22,13 @@ pub(crate) struct VaultUx {
|
|||
|
||||
// our security token for making changes to our record on the GAM
|
||||
token: [u32; 4],
|
||||
|
||||
// current operation mode
|
||||
mode: VaultMode,
|
||||
}
|
||||
|
||||
const TITLE_HEIGHT: i16 = 32;
|
||||
|
||||
impl VaultUx{
|
||||
pub(crate) fn new(xns: &xous_names::XousNames, sid: xous::SID) -> Self {
|
||||
let gam = gam::Gam::new(xns).expect("can't connect to GAM");
|
||||
|
|
@ -52,9 +58,10 @@ impl VaultUx{
|
|||
screensize,
|
||||
margin: Point::new(4, 4),
|
||||
token,
|
||||
mode: VaultMode::Fido,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn set_mode(&mut self, mode: VaultMode) { self.mode = mode; }
|
||||
/// accept a new input string
|
||||
pub(crate) fn input(&mut self, line: &str) -> Result<(), xous::Error> {
|
||||
self.input = Some(String::from(line));
|
||||
|
|
@ -82,21 +89,64 @@ impl VaultUx{
|
|||
}
|
||||
pub(crate) fn redraw(&mut self) -> Result<(), xous::Error> {
|
||||
self.clear_area();
|
||||
let mut test_text = TextView::new(self.content,
|
||||
|
||||
// ---- draw title area ----
|
||||
let mut title_text = TextView::new(self.content,
|
||||
graphics_server::TextBounds::CenteredTop(
|
||||
Rectangle::new(
|
||||
Point::new(self.margin.x, 0),
|
||||
Point::new(self.screensize.x - self.margin.x, 48)
|
||||
Point::new(self.screensize.x - self.margin.x, TITLE_HEIGHT)
|
||||
)
|
||||
)
|
||||
);
|
||||
test_text.draw_border = false;
|
||||
test_text.clear_area = true;
|
||||
test_text.style = GlyphStyle::Large;
|
||||
write!(test_text, "FIDO").ok();
|
||||
self.gam.post_textview(&mut test_text).expect("couldn't post test text");
|
||||
title_text.draw_border = true;
|
||||
title_text.rounded_border = Some(8);
|
||||
title_text.clear_area = true;
|
||||
title_text.style = GlyphStyle::Large;
|
||||
match self.mode {
|
||||
VaultMode::Fido => write!(title_text, "FIDO").ok(),
|
||||
VaultMode::Totp => write!(title_text, "⏳1234").ok(),
|
||||
VaultMode::Password => write!(title_text, "🔐****").ok(),
|
||||
};
|
||||
self.gam.post_textview(&mut title_text).expect("couldn't post title");
|
||||
|
||||
log::trace!("repl app redraw##");
|
||||
// ---- draw list body area ----
|
||||
let available_height = self.screensize.y - TITLE_HEIGHT;
|
||||
let style = GlyphStyle::Large;
|
||||
let glyph_height = self.gam.glyph_height_hint(style).unwrap();
|
||||
let box_height = (glyph_height * 2) as i16;
|
||||
let line_count = available_height / box_height;
|
||||
|
||||
let mut test_list = Vec::new();
|
||||
for i in 0..16 {
|
||||
let test_string = format!("Test item {}\nMore info about the item.", i);
|
||||
test_list.push(test_string);
|
||||
}
|
||||
|
||||
let mut insert_at = TITLE_HEIGHT;
|
||||
for item in test_list {
|
||||
if insert_at > self.screensize.y - box_height {
|
||||
break;
|
||||
}
|
||||
let mut box_text = TextView::new(self.content,
|
||||
graphics_server::TextBounds::BoundingBox(
|
||||
Rectangle::new(
|
||||
Point::new(self.margin.x, insert_at),
|
||||
Point::new(self.screensize.x - self.margin.x, insert_at + box_height)
|
||||
)
|
||||
)
|
||||
);
|
||||
box_text.draw_border = true;
|
||||
box_text.rounded_border = None;
|
||||
box_text.clear_area = true;
|
||||
box_text.style = style;
|
||||
write!(box_text, "{}", item).ok();
|
||||
self.gam.post_textview(&mut box_text).expect("couldn't post list item");
|
||||
|
||||
insert_at += box_height;
|
||||
}
|
||||
|
||||
log::trace!("vault app redraw##");
|
||||
self.gam.redraw().expect("couldn't redraw screen");
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,9 @@ const ICONS: [&'static str; 4] = [
|
|||
pub(crate) fn icontray_server() {
|
||||
let xns = xous_names::XousNames::new().unwrap();
|
||||
// one connection only, should be the GAM
|
||||
let ime_sh_sid = xns.register_name(SERVER_NAME_ICONTRAY, Some(1)).expect("can't register server");
|
||||
// however, because the predictor is connected only on demand -- we leave this as open-ended, which
|
||||
// means anyone could send something to this server if they knew the name of it.
|
||||
let ime_sh_sid = xns.register_name(SERVER_NAME_ICONTRAY, None).expect("can't register server");
|
||||
|
||||
let mytriggers = PredictionTriggers {
|
||||
newline: false,
|
||||
|
|
|
|||
Loading…
Reference in a new issue