From f0734f361c8e01ef8bda51f296253f773af8d2d7 Mon Sep 17 00:00:00 2001 From: Adam Perkowski Date: Wed, 6 Nov 2024 16:49:26 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A6=80=20feat(ux):=20add=20a=20minimum=20?= =?UTF-8?q?size=20bypass=20cli=20flag=20(#920)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🦀 feat(ux): add a minimum size bypass cli flag * oopsie --- man/linutil.1 | 4 ++++ tui/src/main.rs | 5 ++++- tui/src/state.rs | 8 ++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/man/linutil.1 b/man/linutil.1 index d31cf879..a85bee96 100644 --- a/man/linutil.1 +++ b/man/linutil.1 @@ -36,6 +36,10 @@ Defaults to \fIdefault\fR. \fB\-\-override\-validation\fR Show all available entries, disregarding compatibility checks. (\fBUNSAFE\fR) +.TP +\fB\-\-size\-bypass\fR +Bypass the terminal size limit + .TP \fB\-h\fR, \fB\-\-help\fR Print help. diff --git a/tui/src/main.rs b/tui/src/main.rs index 801e3b1d..df20e733 100644 --- a/tui/src/main.rs +++ b/tui/src/main.rs @@ -33,12 +33,15 @@ struct Args { #[arg(long, default_value_t = false)] #[clap(help = "Show all available options, disregarding compatibility checks (UNSAFE)")] override_validation: bool, + #[arg(long, default_value_t = false)] + #[clap(help = "Bypass the terminal size limit")] + size_bypass: bool, } fn main() -> io::Result<()> { let args = Args::parse(); - let mut state = AppState::new(args.theme, args.override_validation); + let mut state = AppState::new(args.theme, args.override_validation, args.size_bypass); stdout().execute(EnterAlternateScreen)?; enable_raw_mode()?; diff --git a/tui/src/state.rs b/tui/src/state.rs index 92160bf7..058dcc20 100644 --- a/tui/src/state.rs +++ b/tui/src/state.rs @@ -62,6 +62,7 @@ pub struct AppState { drawable: bool, #[cfg(feature = "tips")] tip: String, + size_bypass: bool, } pub enum Focus { @@ -86,7 +87,7 @@ enum SelectedItem { } impl AppState { - pub fn new(theme: Theme, override_validation: bool) -> Self { + pub fn new(theme: Theme, override_validation: bool, size_bypass: bool) -> Self { let (temp_dir, tabs) = linutil_core::get_tabs(!override_validation); let root_id = tabs[0].tree.root().id(); @@ -104,6 +105,7 @@ impl AppState { drawable: false, #[cfg(feature = "tips")] tip: get_random_tip(), + size_bypass, }; state.update_items(); @@ -186,7 +188,9 @@ impl AppState { pub fn draw(&mut self, frame: &mut Frame) { let terminal_size = frame.area(); - if terminal_size.width < MIN_WIDTH || terminal_size.height < MIN_HEIGHT { + if !self.size_bypass + && (terminal_size.height < MIN_HEIGHT || terminal_size.width < MIN_WIDTH) + { let warning = Paragraph::new(format!( "Terminal size too small:\nWidth = {} Height = {}\n\nMinimum size:\nWidth = {} Height = {}", terminal_size.width,