From f887a2390ede0a5f30d61f2bb9d4e1e421109d63 Mon Sep 17 00:00:00 2001 From: Alexandre Pasmantier <47638216+alexpasmantier@users.noreply.github.com> Date: Thu, 1 May 2025 20:46:05 +0200 Subject: [PATCH] feat(cli): add a `--ui-scale` [0,100] cli parameter (#492) --- man/tv.1 | 21 +++++++++++++++++---- television/cli/args.rs | 12 ++++++++++++ television/cli/mod.rs | 3 +++ television/main.rs | 1 + 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/man/tv.1 b/man/tv.1 index bb5b14f..040c8c9 100644 --- a/man/tv.1 +++ b/man/tv.1 @@ -1,10 +1,10 @@ .ie \n(.g .ds Aq \(aq .el .ds Aq ' -.TH television 1 "television 0.11.8" +.TH television 1 "television 0.11.9" .SH NAME television \- A cross\-platform, fast and extensible general purpose fuzzy finder TUI. .SH SYNOPSIS -\fBtelevision\fR [\fB\-p\fR|\fB\-\-preview\fR] [\fB\-\-no\-preview\fR] [\fB\-\-delimiter\fR] [\fB\-t\fR|\fB\-\-tick\-rate\fR] [\fB\-f\fR|\fB\-\-frame\-rate\fR] [\fB\-k\fR|\fB\-\-keybindings\fR] [\fB\-i\fR|\fB\-\-input\fR] [\fB\-\-custom\-header\fR] [\fB\-\-autocomplete\-prompt\fR] [\fB\-\-select\-1\fR] [\fB\-\-no\-remote\fR] [\fB\-\-no\-help\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] [\fICHANNEL\fR] [\fIPATH\fR] [\fIsubcommands\fR] +\fBtelevision\fR [\fB\-p\fR|\fB\-\-preview\fR] [\fB\-\-no\-preview\fR] [\fB\-\-delimiter\fR] [\fB\-t\fR|\fB\-\-tick\-rate\fR] [\fB\-f\fR|\fB\-\-frame\-rate\fR] [\fB\-k\fR|\fB\-\-keybindings\fR] [\fB\-i\fR|\fB\-\-input\fR] [\fB\-\-custom\-header\fR] [\fB\-\-autocomplete\-prompt\fR] [\fB\-\-exact\fR] [\fB\-\-select\-1\fR] [\fB\-\-no\-remote\fR] [\fB\-\-no\-help\fR] [\fB\-\-ui\-scale\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] [\fICHANNEL\fR] [\fIPATH\fR] [\fIsubcommands\fR] .SH DESCRIPTION A cross\-platform, fast and extensible general purpose fuzzy finder TUI. .SH OPTIONS @@ -73,6 +73,13 @@ This can be used to automatically select a channel based on the input prompt by using the `shell_integration` mapping in the configuration file. .TP +\fB\-\-exact\fR +Use substring matching instead of fuzzy matching. + +This will use substring matching instead of fuzzy matching when +searching for entries. This is useful when the user wants to search for +an exact match instead of a fuzzy match e.g. to improve performance. +.TP \fB\-\-select\-1\fR Automatically select and output the first entry if there is only one entry. @@ -102,13 +109,19 @@ when the user wants `tv` to run with a minimal interface (e.g. when using it as a file picker for a script or embedding it in a larger application). .TP +\fB\-\-ui\-scale\fR=\fIINTEGER\fR [default: 100] +Change the display size in relation to the available area. + +This will crop the UI to a centered rectangle of the specified +percentage of the available area (e.g. 0.5 for 50% x 50%). +.TP \fB\-h\fR, \fB\-\-help\fR Print help (see a summary with \*(Aq\-h\*(Aq) .TP \fB\-V\fR, \fB\-\-version\fR Print version .TP -[\fICHANNEL\fR] [default: files] +[\fICHANNEL\fR] Which channel shall we watch? A list of the available channels can be displayed using the @@ -133,6 +146,6 @@ Initializes shell completion ("tv init zsh") television\-help(1) Print this message or the help of the given subcommand(s) .SH VERSION -v0.11.8 +v0.11.9 .SH AUTHORS Alexandre Pasmantier diff --git a/television/cli/args.rs b/television/cli/args.rs index a319b4a..eb44b0d 100644 --- a/television/cli/args.rs +++ b/television/cli/args.rs @@ -134,6 +134,18 @@ pub struct Cli { #[arg(long, default_value = "false", verbatim_doc_comment)] pub no_help: bool, + /// Change the display size in relation to the available area. + /// + /// This will crop the UI to a centered rectangle of the specified + /// percentage of the available area (e.g. 0.5 for 50% x 50%). + #[arg( + long, + value_name = "INTEGER", + default_value = "100", + verbatim_doc_comment + )] + pub ui_scale: u16, + #[command(subcommand)] pub command: Option, } diff --git a/television/cli/mod.rs b/television/cli/mod.rs index d4ee1b2..4d8056b 100644 --- a/television/cli/mod.rs +++ b/television/cli/mod.rs @@ -37,6 +37,7 @@ pub struct PostProcessedCli { pub select_1: bool, pub no_remote: bool, pub no_help: bool, + pub ui_scale: u16, } impl Default for PostProcessedCli { @@ -57,6 +58,7 @@ impl Default for PostProcessedCli { select_1: false, no_remote: false, no_help: false, + ui_scale: 100, } } } @@ -141,6 +143,7 @@ impl From for PostProcessedCli { select_1: cli.select_1, no_remote: cli.no_remote, no_help: cli.no_help, + ui_scale: cli.ui_scale, } } } diff --git a/television/main.rs b/television/main.rs index 1d011ed..a8d09cd 100644 --- a/television/main.rs +++ b/television/main.rs @@ -114,6 +114,7 @@ fn apply_cli_overrides(args: &PostProcessedCli, config: &mut Config) { if let Some(header) = &args.custom_header { config.ui.custom_header = Some(header.to_string()); } + config.ui.ui_scale = args.ui_scale; } pub fn set_current_dir(path: &String) -> Result<()> {