Skip to content

Commit

Permalink
Merge pull request #78 from grouzen/configure-viewport
Browse files Browse the repository at this point in the history
Add cli arguments to configure the viewport size
  • Loading branch information
jacek-kurlit authored Sep 24, 2024
2 parents 0c47875 + 7b0b059 commit dcf4780
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ pub struct Args {
/// By default pik shows only proceseses owned by current user. This flag allows to show all processes
#[arg(short, long, default_value_t = false)]
pub all_processes: bool,
#[arg(short = 'F', long, default_value_t = false)]
pub fullscreen: bool,
#[arg(short = 'H', long, default_value_t = 20)]
pub height: u16,
}
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ fn main() -> Result<()> {
ignore_threads: !args.include_threads_processes,
include_all_processes: args.all_processes,
},
args.height,
args.fullscreen,
)
}
18 changes: 11 additions & 7 deletions src/tui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,20 @@ impl App {
}
}

pub fn start_app(search_criteria: String, filter_options: FilterOptions) -> Result<()> {
pub fn start_app(
search_criteria: String,
filter_options: FilterOptions,
viewport_height: u16,
viewport_fullscreen: bool,
) -> Result<()> {
// setup terminal
enable_raw_mode()?;
let backend = CrosstermBackend::new(io::stdout());
let mut terminal = Terminal::with_options(
backend,
TerminalOptions {
viewport: Viewport::Inline(20),
},
)?;
let viewport = match (viewport_height, viewport_fullscreen) {
(_, true) => Viewport::Fullscreen,
(h, false) => Viewport::Inline(h),
};
let mut terminal = Terminal::with_options(backend, TerminalOptions { viewport })?;

// create app and run it
let app = App::new(search_criteria, filter_options)?;
Expand Down

0 comments on commit dcf4780

Please sign in to comment.