launcher: Use draw_text_individual_colors
This commit is contained in:
+12
-25
@@ -1,6 +1,6 @@
|
||||
use crate::buffer::Buffer;
|
||||
use crate::color::Color;
|
||||
use crate::draw::{draw_text, ROBOTO_REGULAR};
|
||||
use crate::draw::{draw_text, draw_text_individual_colors, ROBOTO_REGULAR};
|
||||
use crate::module::{Input, ModuleImpl};
|
||||
|
||||
use std::io::Read;
|
||||
@@ -69,34 +69,21 @@ impl ModuleImpl for Launcher {
|
||||
let size = if idx == self.offset && self.cur.len() > 0 {
|
||||
let l = self.cur.len();
|
||||
let off = m.to_lowercase().find(&self.cur.to_lowercase()).unwrap();
|
||||
let s1 = draw_text(
|
||||
let mut colors = Vec::with_capacity(m.len());
|
||||
for pos in 0..m.len() {
|
||||
if pos >= off && pos < off + l {
|
||||
colors.push(Color::new(1.0, 1.0, 1.0, 1.0));
|
||||
} else {
|
||||
colors.push(Color::new(0.75, 0.75, 0.75, 1.0));
|
||||
}
|
||||
}
|
||||
draw_text_individual_colors(
|
||||
ROBOTO_REGULAR,
|
||||
&mut b,
|
||||
bg,
|
||||
&Color::new(0.75, 0.75, 0.75, 1.0),
|
||||
&colors,
|
||||
32.0,
|
||||
&m[0..off],
|
||||
)?;
|
||||
let mut b2 = b.subdimensions((s1.0+1, 0, width_remaining as u32 - s1.0-1, 32))?;
|
||||
let s2 = draw_text(
|
||||
ROBOTO_REGULAR,
|
||||
&mut b2,
|
||||
bg,
|
||||
&Color::new(1.0, 1.0, 1.0, 1.0),
|
||||
32.0,
|
||||
&m[off..off+l],
|
||||
)?;
|
||||
let mut b3 = b.subdimensions((s1.0+s2.0+2, 0, width_remaining as u32 - s1.0- s2.0 - 2, 32))?;
|
||||
let s3 = draw_text(
|
||||
ROBOTO_REGULAR,
|
||||
&mut b3,
|
||||
bg,
|
||||
&Color::new(0.75, 0.75, 0.75, 1.0),
|
||||
32.0,
|
||||
&m[off+l..],
|
||||
)?;
|
||||
|
||||
(s1.0 + s2.0 + s3.0 + 3, s1.1 + s2.1 + s3.1)
|
||||
&m)?
|
||||
} else {
|
||||
draw_text(
|
||||
ROBOTO_REGULAR,
|
||||
|
||||
Reference in New Issue
Block a user