launcher: Show and return failed match strings

This commit is contained in:
Kenny Levinsen
2019-08-04 14:39:23 +02:00
parent 22893fd681
commit 095c2c9aef
+16 -2
View File
@@ -67,9 +67,19 @@ impl ModuleImpl for Launcher {
let mut x_off: i32 = 0; let mut x_off: i32 = 0;
let mut width_remaining: i32 = 1280 - 64; let mut width_remaining: i32 = 1280 - 64;
if self.matches.len() == 0 && self.cur.len() > 0 {
draw_text(
ROBOTO_REGULAR,
&mut buf.subdimensions((64, 0, width_remaining as u32, 32)).unwrap(),
bg,
&Color::new(1.0, 0.5, 0.5, 1.0),
32.0,
&self.cur,
)?;
} else {
for (idx, m) in self.matches.iter().enumerate() { for (idx, m) in self.matches.iter().enumerate() {
let mut b = match buf.subdimensions((64 + x_off as u32, 0, width_remaining as u32, 32)) let mut b =
{ match buf.subdimensions((64 + x_off as u32, 0, width_remaining as u32, 32)) {
Ok(b) => b, Ok(b) => b,
Err(_) => break, Err(_) => break,
}; };
@@ -103,6 +113,7 @@ impl ModuleImpl for Launcher {
break; break;
} }
} }
}
Ok(vec![buf.get_signed_bounds()]) Ok(vec![buf.get_signed_bounds()])
} }
@@ -153,6 +164,9 @@ impl ModuleImpl for Launcher {
if self.matches.len() > self.offset { if self.matches.len() > self.offset {
println!("{}", self.matches[self.offset]); println!("{}", self.matches[self.offset]);
std::process::exit(0); std::process::exit(0);
} else {
println!("{}", self.cur);
std::process::exit(0);
} }
} }
keysyms::XKB_KEY_Right => { keysyms::XKB_KEY_Right => {