pub fn update_state(&self, state: &mut State, timer: &Timer) {
        state.background = self.settings.background;
        state.display_two_rows = self.settings.text.is_split() && self.settings.display_two_rows;
        state.left_center_color = self.settings.left_center_color;
        state.right_color = self.settings.right_color;

        let (left_center, right) = match &self.settings.text {
            Text::Center(center) => (center.as_str(), None),
            Text::Split(left, right) => (left.as_str(), Some(right.as_str())),
            Text::Variable(var_name, is_split) => {
                let value = timer
                    .run()
                    .metadata()
                    .custom_variable(&var_name)
                    .map(|var| var.value.as_str())
                    .filter(|value| !value.trim_start().is_empty())
                    .unwrap_or(formatter::DASH);

                if *is_split {
                    (var_name.as_str(), Some(value))
                } else {
                    (value, None)
                }
            }
        };

        // FIXME: We may not want to keep using an enum for this. This is really
        // painful to deal with, and we still don't reuse memory in every case.
        match (&mut state.text, left_center, right) {
            (TextState::Center(old), new, None) => {
                old.clear();
                old.push_str(new);
            }
            (TextState::Center(old), new_l, Some(new_r)) => {
                let mut new_l_mem = mem::take(old);
                new_l_mem.clear();
                new_l_mem.push_str(new_l);
                state.text = TextState::Split(new_l_mem, new_r.to_owned());
            }
            (TextState::Split(l, r), new_l, Some(new_r)) => {
                l.clear();
                l.push_str(new_l);
                r.clear();
                r.push_str(new_r);
            }
            (TextState::Split(l, _), new_center, None) => {
                let mut new_center_mem = mem::take(l);
                new_center_mem.clear();
                new_center_mem.push_str(new_center);
                state.text = TextState::Center(new_center_mem);
            }
        }
    }
/// Updates the component's state based on the timer provided.
Updates the component's state based on the timer provided.
Updates the component ' s state based on the timer provided .
pub fn update_state(&self, state: &mut State, timer: &Timer) {
        state.background = self.settings.background;
        state.display_two_rows = self.settings.text.is_split() && self.settings.display_two_rows;
        state.left_center_color = self.settings.left_center_color;
        state.right_color = self.settings.right_color;
        let (left_center, right) = match &self.settings.text {
            Text::Center(center) => (center.as_str(), None),
            Text::Split(left, right) => (left.as_str(), Some(right.as_str())),
            Text::Variable(var_name, is_split) => {
                let value = timer
                    .run()
                    .metadata()
                    .custom_variable(&var_name)
                    .map(|var| var.value.as_str())
                    .filter(|value| !value.trim_start().is_empty())
                    .unwrap_or(formatter::DASH);
                if *is_split {
                    (var_name.as_str(), Some(value))
                } else {
                    (value, None)
                }
            }
        };
        // FIXME: We may not want to keep using an enum for this. This is really
        // painful to deal with, and we still don't reuse memory in every case.
        match (&mut state.text, left_center, right) {
            (TextState::Center(old), new, None) => {
                old.clear();
                old.push_str(new);
            }
            (TextState::Center(old), new_l, Some(new_r)) => {
                let mut new_l_mem = mem::take(old);
                new_l_mem.clear();
                new_l_mem.push_str(new_l);
                state.text = TextState::Split(new_l_mem, new_r.to_owned());
            }
            (TextState::Split(l, r), new_l, Some(new_r)) => {
                l.clear();
                l.push_str(new_l);
                r.clear();
                r.push_str(new_r);
            }
            (TextState::Split(l, _), new_center, None) => {
                let mut new_center_mem = mem::take(l);
                new_center_mem.clear();
                new_center_mem.push_str(new_center);
                state.text = TextState::Center(new_center_mem);
            }
        }
    }
pub fn update_state ( & self , state : & mut State , timer : & Timer ) { state . background = self . settings . background ; state . display_two_rows = self . settings . text . is_split ( ) && self . settings . display_two_rows ; state . left_center_color = self . settings . left_center_color ; state . right_color = self . settings . right_color ; let ( left_center , right ) = match & self . settings . text { Text :: Center ( center ) => ( center . as_str ( ) , None ) , Text :: Split ( left , right ) => ( left . as_str ( ) , Some ( right . as_str ( ) ) ) , Text :: Variable ( var_name , is_split ) => { let value = timer . run ( ) . metadata ( ) . custom_variable ( & var_name ) . map ( | var | var . value . as_str ( ) ) . filter ( | value | ! value . trim_start ( ) . is_empty ( ) ) . unwrap_or ( formatter :: DASH ) ; if * is_split { ( var_name . as_str ( ) , Some ( value ) ) } else { ( value , None ) } } } ; // FIXME: We may not want to keep using an enum for this. This is really // painful to deal with, and we still don't reuse memory in every case. match ( & mut state . text , left_center , right ) { ( TextState :: Center ( old ) , new , None ) => { old . clear ( ) ; old . push_str ( new ) ; } ( TextState :: Center ( old ) , new_l , Some ( new_r ) ) => { let mut new_l_mem = mem :: take ( old ) ; new_l_mem . clear ( ) ; new_l_mem . push_str ( new_l ) ; state . text = TextState :: Split ( new_l_mem , new_r . to_owned ( ) ) ; } ( TextState :: Split ( l , r ) , new_l , Some ( new_r ) ) => { l . clear ( ) ; l . push_str ( new_l ) ; r . clear ( ) ; r . push_str ( new_r ) ; } ( TextState :: Split ( l , _ ) , new_center , None ) => { let mut new_center_mem = mem :: take ( l ) ; new_center_mem . clear ( ) ; new_center_mem . push_str ( new_center ) ; state . text = TextState :: Center ( new_center_mem ) ; } } }
Updates the component's state based on the timer provided.
Updates the component ' s state based on the timer provided .
&self
state
&mut State
timer
&Timer
&self
state
&mut State
timer
&Timer