diff --git a/src/clock.rs b/src/clock.rs index 395a876..d465f15 100644 --- a/src/clock.rs +++ b/src/clock.rs @@ -63,7 +63,7 @@ impl ModuleImpl for Clock { bg, &Color::new(1.0, 1.0, 1.0, 1.0), 256.0, - vec![120, 120, 64, 120, 120], + &[120, 120, 64, 120, 120], &format!("{:02}:{:02}", time.hour(), time.minute()), )?; diff --git a/src/launcher.rs b/src/launcher.rs index 2dba043..a8365ad 100644 --- a/src/launcher.rs +++ b/src/launcher.rs @@ -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,