Draw source name
This commit is contained in:
parent
673fef7c84
commit
bc48bf122e
2 changed files with 11 additions and 8 deletions
|
@ -1,4 +1,5 @@
|
||||||
use log::debug;
|
use log::debug;
|
||||||
|
use rayon::result;
|
||||||
|
|
||||||
use super::theme::{Theme, ThemedContextExt};
|
use super::theme::{Theme, ThemedContextExt};
|
||||||
|
|
||||||
|
@ -68,7 +69,7 @@ impl<'a> Painter<'a> {
|
||||||
ctx.theme_text(&input, false, &[], &self.theme);
|
ctx.theme_text(&input, false, &[], &self.theme);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn result_box<T>(&self, x: T, y: T, result: &'a str, indices: &[usize], selected: bool)
|
pub fn result_box<T>(&self, x: T, y: T, source: &'a str, result: &'a str, indices: &[usize], selected: bool)
|
||||||
where T: Into<f64>
|
where T: Into<f64>
|
||||||
{
|
{
|
||||||
let ctx = self.context;
|
let ctx = self.context;
|
||||||
|
@ -83,7 +84,9 @@ impl<'a> Painter<'a> {
|
||||||
|
|
||||||
// draw text
|
// draw text
|
||||||
ctx.move_to (x+0.2, y+0.8);
|
ctx.move_to (x+0.2, y+0.8);
|
||||||
ctx.theme_text(&result, selected, indices, &self.theme)
|
ctx.theme_text(&source, selected, &[], &self.theme);
|
||||||
|
ctx.move_to (x+3.5, y+0.8);
|
||||||
|
ctx.theme_text(&result, selected, indices, &self.theme);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn divider<T>(&self, x: T, y: T)
|
pub fn divider<T>(&self, x: T, y: T)
|
||||||
|
|
12
src/ui/ui.rs
12
src/ui/ui.rs
|
@ -86,7 +86,7 @@ pub fn draw(window: &Window, input: &str, result: Vec<(&Entry, Vec<usize>)>, sel
|
||||||
result.iter().enumerate()
|
result.iter().enumerate()
|
||||||
.for_each(|(i, r)| {
|
.for_each(|(i, r)| {
|
||||||
let e = r.0;
|
let e = r.0;
|
||||||
painter.result_box(0, 1+(i as u32), &e.name, &r.1, selection==i);
|
painter.result_box(0, 1+(i as u32), &e.source, &e.name, &r.1, selection==i);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,14 +101,14 @@ pub fn redraw_quick(window: &Window, result: Vec<(&Entry, Vec<usize>)>, selectio
|
||||||
.for_each(|(i, r)| {
|
.for_each(|(i, r)| {
|
||||||
let e = r.0;
|
let e = r.0;
|
||||||
// clear first and last as these may produce artifacts otherwise
|
// clear first and last as these may produce artifacts otherwise
|
||||||
if i == 0 { painter.result_box(0, 1+(i as u32), &e.name, &r.1, false) }
|
if i == 0 { painter.result_box(0, 1+(i as u32), &e.source, &e.name, &r.1, false) }
|
||||||
if i == result.len()-1 { painter.result_box(0, 1+(i as u32), &e.name, &r.1, false) }
|
if i == result.len()-1 { painter.result_box(0, 1+(i as u32), &e.source, &e.name, &r.1, false) }
|
||||||
|
|
||||||
// clear boxes around selection as these could be the old selection
|
// clear boxes around selection as these could be the old selection
|
||||||
if selection > 0 && i == (selection-1) { painter.result_box(0, 1+(i as u32), &e.name, &r.1, false) }
|
if selection > 0 && i == (selection-1) { painter.result_box(0, 1+(i as u32), &e.source, &e.name, &r.1, false) }
|
||||||
if i == (selection+1) { painter.result_box(0, 1+(i as u32), &e.name, &r.1, false) }
|
if i == (selection+1) { painter.result_box(0, 1+(i as u32), &e.source, &e.name, &r.1, false) }
|
||||||
|
|
||||||
// mark selection, note that this negates any unmarking above in case they are the same
|
// mark selection, note that this negates any unmarking above in case they are the same
|
||||||
if i == selection { painter.result_box(0, 1+(i as u32), &e.name, &r.1, true) }
|
if i == selection { painter.result_box(0, 1+(i as u32), &e.source, &e.name, &r.1, true) }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue