mirror of
https://github.com/alexpasmantier/television.git
synced 2025-06-06 03:25:23 +00:00
feat(actions): television now features an Action
mode
This commit is contained in:
parent
433d7fa270
commit
83bc66a61e
@ -110,6 +110,7 @@ pub struct Theme {
|
|||||||
pub channel_mode_fg: Color,
|
pub channel_mode_fg: Color,
|
||||||
pub remote_control_mode_fg: Color,
|
pub remote_control_mode_fg: Color,
|
||||||
pub send_to_channel_mode_fg: Color,
|
pub send_to_channel_mode_fg: Color,
|
||||||
|
pub action_mode_fg: Color,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Theme {
|
impl Theme {
|
||||||
@ -181,6 +182,7 @@ struct Inner {
|
|||||||
channel_mode_fg: String,
|
channel_mode_fg: String,
|
||||||
remote_control_mode_fg: String,
|
remote_control_mode_fg: String,
|
||||||
send_to_channel_mode_fg: String,
|
send_to_channel_mode_fg: String,
|
||||||
|
action_mode_fg: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'de> Deserialize<'de> for Theme {
|
impl<'de> Deserialize<'de> for Theme {
|
||||||
@ -317,6 +319,13 @@ impl<'de> Deserialize<'de> for Theme {
|
|||||||
&inner.send_to_channel_mode_fg
|
&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(),
|
channel: (&self.channel_mode_fg).into(),
|
||||||
remote_control: (&self.remote_control_mode_fg).into(),
|
remote_control: (&self.remote_control_mode_fg).into(),
|
||||||
send_to_channel: (&self.send_to_channel_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"
|
channel_mode_fg = "bright-white"
|
||||||
remote_control_mode_fg = "bright-white"
|
remote_control_mode_fg = "bright-white"
|
||||||
send_to_channel_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();
|
let theme: Theme = toml::from_str(theme_content).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@ -520,6 +531,7 @@ mod tests {
|
|||||||
channel_mode_fg = "bright-white"
|
channel_mode_fg = "bright-white"
|
||||||
remote_control_mode_fg = "bright-white"
|
remote_control_mode_fg = "bright-white"
|
||||||
send_to_channel_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();
|
let theme: Theme = toml::from_str(theme_content).unwrap();
|
||||||
assert_eq!(theme.background, None);
|
assert_eq!(theme.background, None);
|
||||||
@ -553,5 +565,6 @@ mod tests {
|
|||||||
theme.send_to_channel_mode_fg,
|
theme.send_to_channel_mode_fg,
|
||||||
Color::Ansi(ANSIColor::BrightWhite)
|
Color::Ansi(ANSIColor::BrightWhite)
|
||||||
);
|
);
|
||||||
|
assert_eq!(theme.action_mode_fg, Color::Ansi(ANSIColor::BrightWhite));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,4 +52,5 @@ pub struct ModeColorscheme {
|
|||||||
pub channel: Color,
|
pub channel: Color,
|
||||||
pub remote_control: Color,
|
pub remote_control: Color,
|
||||||
pub send_to_channel: Color,
|
pub send_to_channel: Color,
|
||||||
|
pub action: Color,
|
||||||
}
|
}
|
||||||
|
@ -213,6 +213,9 @@ pub fn build_keybindings_table<'a>(
|
|||||||
colorscheme,
|
colorscheme,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Mode::Action => {
|
||||||
|
todo!("Implement keybindings table for action mode");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ impl Display for Mode {
|
|||||||
Mode::Channel => write!(f, "Channel"),
|
Mode::Channel => write!(f, "Channel"),
|
||||||
Mode::RemoteControl => write!(f, "Remote Control"),
|
Mode::RemoteControl => write!(f, "Remote Control"),
|
||||||
Mode::SendToChannel => write!(f, "Send to Channel"),
|
Mode::SendToChannel => write!(f, "Send to Channel"),
|
||||||
|
Mode::Action => write!(f, "Action"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,5 +7,6 @@ pub fn mode_color(mode: Mode, colorscheme: &ModeColorscheme) -> Color {
|
|||||||
Mode::Channel => colorscheme.channel,
|
Mode::Channel => colorscheme.channel,
|
||||||
Mode::RemoteControl => colorscheme.remote_control,
|
Mode::RemoteControl => colorscheme.remote_control,
|
||||||
Mode::SendToChannel => colorscheme.send_to_channel,
|
Mode::SendToChannel => colorscheme.send_to_channel,
|
||||||
|
Mode::Action => colorscheme.action,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ pub enum Mode {
|
|||||||
Channel,
|
Channel,
|
||||||
RemoteControl,
|
RemoteControl,
|
||||||
SendToChannel,
|
SendToChannel,
|
||||||
|
Action,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Television {
|
pub struct Television {
|
||||||
@ -187,6 +188,9 @@ impl Television {
|
|||||||
Mode::RemoteControl | Mode::SendToChannel => {
|
Mode::RemoteControl | Mode::SendToChannel => {
|
||||||
self.remote_control.as_mut().unwrap().find(pattern);
|
self.remote_control.as_mut().unwrap().find(pattern);
|
||||||
}
|
}
|
||||||
|
Mode::Action => {
|
||||||
|
todo!("Action mode not implemented yet");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,6 +213,9 @@ impl Television {
|
|||||||
}
|
}
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
Mode::Action => {
|
||||||
|
todo!("Action mode not implemented yet");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,6 +245,9 @@ impl Television {
|
|||||||
self.remote_control.as_ref().unwrap().total_count(),
|
self.remote_control.as_ref().unwrap().total_count(),
|
||||||
&mut self.rc_picker,
|
&mut self.rc_picker,
|
||||||
),
|
),
|
||||||
|
Mode::Action => {
|
||||||
|
todo!("Action mode not implemented yet");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
if result_count == 0 {
|
if result_count == 0 {
|
||||||
return;
|
return;
|
||||||
@ -258,6 +268,9 @@ impl Television {
|
|||||||
self.remote_control.as_ref().unwrap().total_count(),
|
self.remote_control.as_ref().unwrap().total_count(),
|
||||||
&mut self.rc_picker,
|
&mut self.rc_picker,
|
||||||
),
|
),
|
||||||
|
Mode::Action => {
|
||||||
|
todo!("Action mode not implemented yet");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
if result_count == 0 {
|
if result_count == 0 {
|
||||||
return;
|
return;
|
||||||
@ -275,6 +288,9 @@ impl Television {
|
|||||||
Mode::RemoteControl | Mode::SendToChannel => {
|
Mode::RemoteControl | Mode::SendToChannel => {
|
||||||
self.rc_picker.reset_selection();
|
self.rc_picker.reset_selection();
|
||||||
}
|
}
|
||||||
|
Mode::Action => {
|
||||||
|
todo!("Action mode not implemented yet");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,6 +300,9 @@ impl Television {
|
|||||||
Mode::RemoteControl | Mode::SendToChannel => {
|
Mode::RemoteControl | Mode::SendToChannel => {
|
||||||
self.rc_picker.reset_input();
|
self.rc_picker.reset_input();
|
||||||
}
|
}
|
||||||
|
Mode::Action => {
|
||||||
|
todo!("Action mode not implemented yet");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -422,6 +441,9 @@ impl Television {
|
|||||||
Mode::RemoteControl | Mode::SendToChannel => {
|
Mode::RemoteControl | Mode::SendToChannel => {
|
||||||
&mut self.rc_picker.input
|
&mut self.rc_picker.input
|
||||||
}
|
}
|
||||||
|
Mode::Action => {
|
||||||
|
todo!("Action mode not implemented yet");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
input.handle(convert_action_to_input_request(action).unwrap());
|
input.handle(convert_action_to_input_request(action).unwrap());
|
||||||
match action {
|
match action {
|
||||||
@ -459,7 +481,7 @@ impl Television {
|
|||||||
self.reset_picker_selection();
|
self.reset_picker_selection();
|
||||||
self.mode = Mode::Channel;
|
self.mode = Mode::Channel;
|
||||||
}
|
}
|
||||||
Mode::SendToChannel => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -480,6 +502,7 @@ impl Television {
|
|||||||
self.reset_picker_selection();
|
self.reset_picker_selection();
|
||||||
self.mode = Mode::Channel;
|
self.mode = Mode::Channel;
|
||||||
}
|
}
|
||||||
|
Mode::Action => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -528,6 +551,9 @@ impl Television {
|
|||||||
self.change_channel(new_channel);
|
self.change_channel(new_channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Mode::Action => {
|
||||||
|
todo!("Action mode not implemented yet");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -19,3 +19,4 @@ preview_title_fg = '#fab387'
|
|||||||
channel_mode_fg = '#f5c2e7'
|
channel_mode_fg = '#f5c2e7'
|
||||||
remote_control_mode_fg = '#a6e3a1'
|
remote_control_mode_fg = '#a6e3a1'
|
||||||
send_to_channel_mode_fg = '#89dceb'
|
send_to_channel_mode_fg = '#89dceb'
|
||||||
|
action_mode_fg = '#f38ba8'
|
||||||
|
@ -19,3 +19,4 @@ preview_title_fg = 'bright-magenta'
|
|||||||
channel_mode_fg = 'green'
|
channel_mode_fg = 'green'
|
||||||
remote_control_mode_fg = 'yellow'
|
remote_control_mode_fg = 'yellow'
|
||||||
send_to_channel_mode_fg = 'cyan'
|
send_to_channel_mode_fg = 'cyan'
|
||||||
|
action_mode_fg = 'red'
|
||||||
|
@ -19,3 +19,4 @@ preview_title_fg = '#50FA7B'
|
|||||||
channel_mode_fg = '#8BE9FD'
|
channel_mode_fg = '#8BE9FD'
|
||||||
remote_control_mode_fg = '#FFB86C'
|
remote_control_mode_fg = '#FFB86C'
|
||||||
send_to_channel_mode_fg = '#FF79C6'
|
send_to_channel_mode_fg = '#FF79C6'
|
||||||
|
action_mode_fg = '#FF5555'
|
||||||
|
@ -19,3 +19,4 @@ preview_title_fg = '#b8bb26'
|
|||||||
channel_mode_fg = '#b16286'
|
channel_mode_fg = '#b16286'
|
||||||
remote_control_mode_fg = '#8ec07c'
|
remote_control_mode_fg = '#8ec07c'
|
||||||
send_to_channel_mode_fg = '#458588'
|
send_to_channel_mode_fg = '#458588'
|
||||||
|
action_mode_fg = '#fb4934'
|
||||||
|
@ -19,4 +19,4 @@ preview_title_fg = '#98971a'
|
|||||||
channel_mode_fg = '#d65d0e'
|
channel_mode_fg = '#d65d0e'
|
||||||
remote_control_mode_fg = '#689d6a'
|
remote_control_mode_fg = '#689d6a'
|
||||||
send_to_channel_mode_fg = '#458588'
|
send_to_channel_mode_fg = '#458588'
|
||||||
|
action_mode_fg = '#af3a03'
|
||||||
|
@ -19,3 +19,4 @@ preview_title_fg = '#fd971f'
|
|||||||
channel_mode_fg = '#fd971f'
|
channel_mode_fg = '#fd971f'
|
||||||
remote_control_mode_fg = '#a6e22e'
|
remote_control_mode_fg = '#a6e22e'
|
||||||
send_to_channel_mode_fg = '#66d9ef'
|
send_to_channel_mode_fg = '#66d9ef'
|
||||||
|
action_mode_fg = '#f92672'
|
||||||
|
@ -19,3 +19,4 @@ preview_title_fg = '#8fbcbb'
|
|||||||
channel_mode_fg = '#b48ead'
|
channel_mode_fg = '#b48ead'
|
||||||
remote_control_mode_fg = '#a3be8c'
|
remote_control_mode_fg = '#a3be8c'
|
||||||
send_to_channel_mode_fg = '#d08770'
|
send_to_channel_mode_fg = '#d08770'
|
||||||
|
action_mode_fg = '#bf616a'
|
||||||
|
@ -19,3 +19,4 @@ preview_title_fg = '#61afef'
|
|||||||
channel_mode_fg = '#61afef'
|
channel_mode_fg = '#61afef'
|
||||||
remote_control_mode_fg = '#98c379'
|
remote_control_mode_fg = '#98c379'
|
||||||
send_to_channel_mode_fg = '#c678dd'
|
send_to_channel_mode_fg = '#c678dd'
|
||||||
|
action_mode_fg = '#e06c75'
|
||||||
|
@ -19,3 +19,4 @@ preview_title_fg = '#859900'
|
|||||||
channel_mode_fg = '#2aa198'
|
channel_mode_fg = '#2aa198'
|
||||||
remote_control_mode_fg = '#859900'
|
remote_control_mode_fg = '#859900'
|
||||||
send_to_channel_mode_fg = '#dc322f'
|
send_to_channel_mode_fg = '#dc322f'
|
||||||
|
action_mode_fg = '#cb4b16'
|
||||||
|
@ -19,3 +19,4 @@ preview_title_fg = '#859900'
|
|||||||
channel_mode_fg = '#2aa198'
|
channel_mode_fg = '#2aa198'
|
||||||
remote_control_mode_fg = '#859900'
|
remote_control_mode_fg = '#859900'
|
||||||
send_to_channel_mode_fg = '#dc322f'
|
send_to_channel_mode_fg = '#dc322f'
|
||||||
|
action_mode_fg = '#cb4b16'
|
||||||
|
@ -20,3 +20,4 @@ preview_title_fg = '#d2a374'
|
|||||||
channel_mode_fg = '#8faf77'
|
channel_mode_fg = '#8faf77'
|
||||||
remote_control_mode_fg = '#d2a374'
|
remote_control_mode_fg = '#d2a374'
|
||||||
send_to_channel_mode_fg = '#d2788c'
|
send_to_channel_mode_fg = '#d2788c'
|
||||||
|
action_mode_fg = '#d2788c'
|
||||||
|
@ -19,4 +19,4 @@ preview_title_fg = '#bb9af7'
|
|||||||
channel_mode_fg = '#faba4a'
|
channel_mode_fg = '#faba4a'
|
||||||
remote_control_mode_fg = '#9ece6a'
|
remote_control_mode_fg = '#9ece6a'
|
||||||
send_to_channel_mode_fg = '#a4daff'
|
send_to_channel_mode_fg = '#a4daff'
|
||||||
|
action_mode_fg = '#f7768e'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user