From: Ian Jackson Date: Tue, 30 Mar 2021 09:34:52 +0000 (+0100) Subject: Revert "clock: Refactor Show" X-Git-Tag: otter-0.5.0~374 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=38146f38cda2c58cb1493b82b2b16e7d18fb94f9;p=otter.git Revert "clock: Refactor Show" We don't actually need this to fix the expired clock nick text, just to actually put the text colour in! This reverts commit b2ddd5e4b16d497623813ffc9e3e4b84baa3565b. Signed-off-by: Ian Jackson --- diff --git a/src/clock.rs b/src/clock.rs index 667542a3..f918a26d 100644 --- a/src/clock.rs +++ b/src/clock.rs @@ -449,29 +449,24 @@ impl PieceTrait for Clock { const Y: &[f32] = &[ 7., 0. ]; struct Show { - text_override: Option<&'static str>, - background: &'static str, - sigil: &'static str, + text: &'static str, + background: &'static str, + sigil: &'static str, } impl URenderState { fn show(self) -> Show { use URS::*; - let (text_override, background, sigil) = match self { - Running => (None, "yellow", "▶" /* > */ ), - ActiveHeld => (None, "yellow", "‖" /* || */ ), - OtherFlag => (None, "yellow", ":" ), - Inactive => (None, "white", ":" ), - Stopped => (None, "lightblue", "□" /* [] */ ), - Reset => (None, "lightgreen", "○" /* O */ ), - Flag => (Some("white"), "red", "⚑" /* F */ ), + let (text, background, sigil) = match self { + Running => ("black", "yellow", "▶" /* > */ ), + ActiveHeld => ("black", "yellow", "‖" /* || */ ), + OtherFlag => ("black", "yellow", ":" ), + Inactive => ("black", "white", ":" ), + Stopped => ("black", "lightblue", "□" /* [] */ ), + Reset => ("black", "lightgreen", "○" /* O */ ), + Flag => ("white", "red", "⚑" /* F */ ), }; - Show { text_override, background, sigil } - } - } - impl Show { - fn text(&self) -> &'static str { - self.text_override.unwrap_or("black") + Show { text, background, sigil } } } @@ -509,12 +504,12 @@ impl PieceTrait for Clock { "##); hwrite!(f, r##" {}{}{}"##, - y, font, pointer, Html::lit(show.text()), + y, font, pointer, Html::lit(show.text), mins_pad, HtmlStr::from_html_str(&mins), Html::lit(show.sigil) )?; hwrite!(f, r##" {:02}"##, - y, font, pointer, Html::lit(show.text()), + y, font, pointer, Html::lit(show.text), secs )?; let nick_y = y - 0.5;