feat(actions): television now features an Action mode

This commit is contained in:
Alexandre Pasmantier 2025-04-20 23:26:18 +02:00
parent 433d7fa270
commit 83bc66a61e
18 changed files with 58 additions and 3 deletions

View File

@ -110,6 +110,7 @@ pub struct Theme {
pub channel_mode_fg: Color,
pub remote_control_mode_fg: Color,
pub send_to_channel_mode_fg: Color,
pub action_mode_fg: Color,
}
impl Theme {
@ -181,6 +182,7 @@ struct Inner {
channel_mode_fg: String,
remote_control_mode_fg: String,
send_to_channel_mode_fg: String,
action_mode_fg: String,
}
impl<'de> Deserialize<'de> for Theme {
@ -317,6 +319,13 @@ impl<'de> Deserialize<'de> for Theme {
&inner.send_to_channel_mode_fg
))
})?,
action_mode_fg: Color::from_str(&inner.action_mode_fg)
.ok_or_else(|| {
serde::de::Error::custom(format!(
"invalid color {}",
&inner.action_mode_fg
))
})?,
})
}
}
@ -440,6 +449,7 @@ impl Into<ModeColorscheme> for &Theme {
channel: (&self.channel_mode_fg).into(),
remote_control: (&self.remote_control_mode_fg).into(),
send_to_channel: (&self.send_to_channel_mode_fg).into(),
action: (&self.action_mode_fg).into(),
}
}
}
@ -467,6 +477,7 @@ mod tests {
channel_mode_fg = "bright-white"
remote_control_mode_fg = "bright-white"
send_to_channel_mode_fg = "bright-white"
action_mode_fg = "bright-white"
"##;
let theme: Theme = toml::from_str(theme_content).unwrap();
assert_eq!(
@ -520,6 +531,7 @@ mod tests {
channel_mode_fg = "bright-white"
remote_control_mode_fg = "bright-white"
send_to_channel_mode_fg = "bright-white"
action_mode_fg = "bright-white"
"##;
let theme: Theme = toml::from_str(theme_content).unwrap();
assert_eq!(theme.background, None);
@ -553,5 +565,6 @@ mod tests {
theme.send_to_channel_mode_fg,
Color::Ansi(ANSIColor::BrightWhite)
);
assert_eq!(theme.action_mode_fg, Color::Ansi(ANSIColor::BrightWhite));
}
}

View File

@ -52,4 +52,5 @@ pub struct ModeColorscheme {
pub channel: Color,
pub remote_control: Color,
pub send_to_channel: Color,
pub action: Color,
}

View File

@ -213,6 +213,9 @@ pub fn build_keybindings_table<'a>(
colorscheme,
)
}
Mode::Action => {
todo!("Implement keybindings table for action mode");
}
}
}

View File

@ -16,6 +16,7 @@ impl Display for Mode {
Mode::Channel => write!(f, "Channel"),
Mode::RemoteControl => write!(f, "Remote Control"),
Mode::SendToChannel => write!(f, "Send to Channel"),
Mode::Action => write!(f, "Action"),
}
}
}

View File

@ -7,5 +7,6 @@ pub fn mode_color(mode: Mode, colorscheme: &ModeColorscheme) -> Color {
Mode::Channel => colorscheme.channel,
Mode::RemoteControl => colorscheme.remote_control,
Mode::SendToChannel => colorscheme.send_to_channel,
Mode::Action => colorscheme.action,
}
}

View File

@ -29,6 +29,7 @@ pub enum Mode {
Channel,
RemoteControl,
SendToChannel,
Action,
}
pub struct Television {
@ -187,6 +188,9 @@ impl Television {
Mode::RemoteControl | Mode::SendToChannel => {
self.remote_control.as_mut().unwrap().find(pattern);
}
Mode::Action => {
todo!("Action mode not implemented yet");
}
}
}
@ -209,6 +213,9 @@ impl Television {
}
None
}
Mode::Action => {
todo!("Action mode not implemented yet");
}
}
}
@ -238,6 +245,9 @@ impl Television {
self.remote_control.as_ref().unwrap().total_count(),
&mut self.rc_picker,
),
Mode::Action => {
todo!("Action mode not implemented yet");
}
};
if result_count == 0 {
return;
@ -258,6 +268,9 @@ impl Television {
self.remote_control.as_ref().unwrap().total_count(),
&mut self.rc_picker,
),
Mode::Action => {
todo!("Action mode not implemented yet");
}
};
if result_count == 0 {
return;
@ -275,6 +288,9 @@ impl Television {
Mode::RemoteControl | Mode::SendToChannel => {
self.rc_picker.reset_selection();
}
Mode::Action => {
todo!("Action mode not implemented yet");
}
}
}
@ -284,6 +300,9 @@ impl Television {
Mode::RemoteControl | Mode::SendToChannel => {
self.rc_picker.reset_input();
}
Mode::Action => {
todo!("Action mode not implemented yet");
}
}
}
}
@ -422,6 +441,9 @@ impl Television {
Mode::RemoteControl | Mode::SendToChannel => {
&mut self.rc_picker.input
}
Mode::Action => {
todo!("Action mode not implemented yet");
}
};
input.handle(convert_action_to_input_request(action).unwrap());
match action {
@ -459,7 +481,7 @@ impl Television {
self.reset_picker_selection();
self.mode = Mode::Channel;
}
Mode::SendToChannel => {}
_ => {}
}
}
@ -480,6 +502,7 @@ impl Television {
self.reset_picker_selection();
self.mode = Mode::Channel;
}
Mode::Action => {}
}
}
@ -528,6 +551,9 @@ impl Television {
self.change_channel(new_channel);
}
}
Mode::Action => {
todo!("Action mode not implemented yet");
}
}
Ok(())
}

View File

@ -19,3 +19,4 @@ preview_title_fg = '#fab387'
channel_mode_fg = '#f5c2e7'
remote_control_mode_fg = '#a6e3a1'
send_to_channel_mode_fg = '#89dceb'
action_mode_fg = '#f38ba8'

View File

@ -19,3 +19,4 @@ preview_title_fg = 'bright-magenta'
channel_mode_fg = 'green'
remote_control_mode_fg = 'yellow'
send_to_channel_mode_fg = 'cyan'
action_mode_fg = 'red'

View File

@ -19,3 +19,4 @@ preview_title_fg = '#50FA7B'
channel_mode_fg = '#8BE9FD'
remote_control_mode_fg = '#FFB86C'
send_to_channel_mode_fg = '#FF79C6'
action_mode_fg = '#FF5555'

View File

@ -19,3 +19,4 @@ preview_title_fg = '#b8bb26'
channel_mode_fg = '#b16286'
remote_control_mode_fg = '#8ec07c'
send_to_channel_mode_fg = '#458588'
action_mode_fg = '#fb4934'

View File

@ -19,4 +19,4 @@ preview_title_fg = '#98971a'
channel_mode_fg = '#d65d0e'
remote_control_mode_fg = '#689d6a'
send_to_channel_mode_fg = '#458588'
action_mode_fg = '#af3a03'

View File

@ -19,3 +19,4 @@ preview_title_fg = '#fd971f'
channel_mode_fg = '#fd971f'
remote_control_mode_fg = '#a6e22e'
send_to_channel_mode_fg = '#66d9ef'
action_mode_fg = '#f92672'

View File

@ -19,3 +19,4 @@ preview_title_fg = '#8fbcbb'
channel_mode_fg = '#b48ead'
remote_control_mode_fg = '#a3be8c'
send_to_channel_mode_fg = '#d08770'
action_mode_fg = '#bf616a'

View File

@ -19,3 +19,4 @@ preview_title_fg = '#61afef'
channel_mode_fg = '#61afef'
remote_control_mode_fg = '#98c379'
send_to_channel_mode_fg = '#c678dd'
action_mode_fg = '#e06c75'

View File

@ -19,3 +19,4 @@ preview_title_fg = '#859900'
channel_mode_fg = '#2aa198'
remote_control_mode_fg = '#859900'
send_to_channel_mode_fg = '#dc322f'
action_mode_fg = '#cb4b16'

View File

@ -19,3 +19,4 @@ preview_title_fg = '#859900'
channel_mode_fg = '#2aa198'
remote_control_mode_fg = '#859900'
send_to_channel_mode_fg = '#dc322f'
action_mode_fg = '#cb4b16'

View File

@ -20,3 +20,4 @@ preview_title_fg = '#d2a374'
channel_mode_fg = '#8faf77'
remote_control_mode_fg = '#d2a374'
send_to_channel_mode_fg = '#d2788c'
action_mode_fg = '#d2788c'

View File

@ -19,4 +19,4 @@ preview_title_fg = '#bb9af7'
channel_mode_fg = '#faba4a'
remote_control_mode_fg = '#9ece6a'
send_to_channel_mode_fg = '#a4daff'
action_mode_fg = '#f7768e'