chiark / gitweb /
Revert "clock: Refactor Show"
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 30 Mar 2021 09:34:52 +0000 (10:34 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 30 Mar 2021 09:34:52 +0000 (10:34 +0100)
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 <ijackson@chiark.greenend.org.uk>
src/clock.rs

index 667542a33d84d0aeddc820d24262b638dd2218a0..f918a26dee06d48d23bb25ffe88ce931e71b8a78 100644 (file)
@@ -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",     "&#x25b6;" /* >  */ ),
-          ActiveHeld => (None,          "yellow",     "&#x2016;" /* || */ ),
-          OtherFlag  => (None,          "yellow",     ":"                 ),
-          Inactive   => (None,          "white",      ":"                 ),
-          Stopped    => (None,          "lightblue",  "&#x25a1;" /* [] */ ),
-          Reset      => (None,          "lightgreen", "&#x25cb;" /* O  */ ),
-          Flag       => (Some("white"), "red",        "&#x2691;" /* F  */ ),
+        let (text, background, sigil) = match self {
+          Running    => ("black",  "yellow",     "&#x25b6;" /* >  */ ),
+          ActiveHeld => ("black",  "yellow",     "&#x2016;" /* || */ ),
+          OtherFlag  => ("black",  "yellow",     ":"                 ),
+          Inactive   => ("black",  "white",      ":"                 ),
+          Stopped    => ("black",  "lightblue",  "&#x25a1;" /* [] */ ),
+          Reset      => ("black",  "lightgreen", "&#x25cb;" /* O  */ ),
+          Flag       => ("white",  "red",        "&#x2691;" /* 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##"
   <text x="1" y="{}" {} {} fill="{}" >{}{}{}</text>"##,
-             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##"
   <text x="14" y="{}" {} {} fill="{}" >{:02}</text>"##,
-             y, font, pointer, Html::lit(show.text()),
+             y, font, pointer, Html::lit(show.text),
              secs
       )?;
       let nick_y = y - 0.5;