diff --git a/television/cli/args.rs b/television/cli/args.rs index 25318e2..9cea433 100644 --- a/television/cli/args.rs +++ b/television/cli/args.rs @@ -74,6 +74,14 @@ pub struct Cli { #[arg(short, long, value_name = "STRING", verbatim_doc_comment)] pub input: Option, + /// Input fields header title + /// + /// This can be used to give the input field a custom title e.g. the current + /// working directory. + /// The default value for the input header is the current channel. + #[arg(long, value_name = "STRING", verbatim_doc_comment)] + pub custom_header: Option, + /// The working directory to start the application in. /// /// This can be used to specify a different working directory for the diff --git a/television/cli/mod.rs b/television/cli/mod.rs index 3b97580..204ffd0 100644 --- a/television/cli/mod.rs +++ b/television/cli/mod.rs @@ -26,6 +26,7 @@ pub struct PostProcessedCli { pub tick_rate: Option, pub frame_rate: Option, pub input: Option, + pub custom_header: Option, pub command: Option, pub working_directory: Option, pub autocomplete_prompt: Option, @@ -44,6 +45,7 @@ impl Default for PostProcessedCli { tick_rate: None, frame_rate: None, input: None, + custom_header: None, command: None, working_directory: None, autocomplete_prompt: None, @@ -111,6 +113,7 @@ impl From for PostProcessedCli { tick_rate: cli.tick_rate, frame_rate: cli.frame_rate, input: cli.input, + custom_header: cli.custom_header, command: cli.command, working_directory, autocomplete_prompt: cli.autocomplete_prompt, diff --git a/television/config/ui.rs b/television/config/ui.rs index d0b9324..72c82ad 100644 --- a/television/config/ui.rs +++ b/television/config/ui.rs @@ -17,6 +17,7 @@ pub struct UiConfig { pub input_bar_position: InputPosition, pub preview_title_position: Option, pub theme: String, + pub custom_header: Option, } impl Default for UiConfig { @@ -29,6 +30,7 @@ impl Default for UiConfig { input_bar_position: InputPosition::Top, preview_title_position: None, theme: String::from(DEFAULT_THEME), + custom_header: None, } } } diff --git a/television/draw.rs b/television/draw.rs index 3063f2b..91a8ed9 100644 --- a/television/draw.rs +++ b/television/draw.rs @@ -239,6 +239,7 @@ pub fn draw(ctx: &Ctx, f: &mut Frame<'_>, area: Rect) -> Result { &ctx.tv_state.channel_state.current_channel_name, &ctx.tv_state.spinner, &ctx.colorscheme, + &ctx.config.ui.custom_header, )?; if layout.preview_window.is_some() { diff --git a/television/main.rs b/television/main.rs index 09802ee..d7ba3c6 100644 --- a/television/main.rs +++ b/television/main.rs @@ -101,6 +101,9 @@ fn apply_cli_overrides(args: &PostProcessedCli, config: &mut Config) { config.keybindings = merge_keybindings(config.keybindings.clone(), keybindings); } + if let Some(header) = &args.custom_header { + config.ui.custom_header = Some(header.to_string()); + } } pub fn set_current_dir(path: &String) -> Result<()> { diff --git a/television/screen/input.rs b/television/screen/input.rs index 5896a6a..9735146 100644 --- a/television/screen/input.rs +++ b/television/screen/input.rs @@ -24,13 +24,15 @@ pub fn draw_input_box( channel_name: &str, spinner: &Spinner, colorscheme: &Colorscheme, + custom_header: &Option, ) -> Result<()> { + let header = custom_header.as_deref().unwrap_or(channel_name); let input_block = Block::default() .borders(Borders::ALL) .border_type(BorderType::Rounded) .border_style(Style::default().fg(colorscheme.general.border_fg)) .title_top( - Line::from(String::from(" ") + channel_name + " ") + Line::from(String::from(" ") + header + " ") .style(Style::default().fg(colorscheme.mode.channel).bold()) .centered(), )