diff --git a/src/arguments.rs b/src/arguments.rs index 9c9d211..8a13880 100644 --- a/src/arguments.rs +++ b/src/arguments.rs @@ -2,7 +2,7 @@ use clap::Parser; use crate::config::{ BACKGROUND_COLOR, BACKGROUND_COLOR_ACTIVE, FONT_COLOR, FONT_COLOR_ACTIVE, FONT_POINT_SIZE, - MAX_ITEM_DISPLAY_COUNT, + LINE_SPACING, MAX_ITEM_DISPLAY_COUNT, }; #[derive(Parser, Debug)] @@ -28,4 +28,7 @@ pub struct Arguments { #[arg(long, help = "The menu's font size", default_value_t = FONT_POINT_SIZE)] pub font_size: u16, + + #[arg(long, help = "The spacing between items", default_value_t = LINE_SPACING)] + pub line_spacing: u16, } diff --git a/src/config.rs b/src/config.rs index 83f53dd..519635f 100644 --- a/src/config.rs +++ b/src/config.rs @@ -16,4 +16,5 @@ pub struct RunnerMenuSettings { pub background_color_active: String, pub rows: u16, pub font_size: u16, + pub line_spacing: u16, } diff --git a/src/main.rs b/src/main.rs index 97a4eda..a439d2c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,6 +30,7 @@ fn main() -> Result<(), Box> { background_color_active: args.background_color_active, rows: args.rows, font_size: args.font_size, + line_spacing: args.line_spacing, }, ); diff --git a/src/runner/mod.rs b/src/runner/mod.rs index 8598f55..6fcdd75 100644 --- a/src/runner/mod.rs +++ b/src/runner/mod.rs @@ -12,7 +12,7 @@ use sdl2::{ }; use crate::{ - config::{RunnerMenuSettings, LINE_SPACING, PADDING}, + config::{RunnerMenuSettings, PADDING}, utils::color_from_hex, }; @@ -42,8 +42,9 @@ impl Runner { .load_font(font_path.clone(), settings.font_size) .expect(&format!("Error loading font {}", font_path)); - window_height = - (PADDING + ((font.height() as u16 + LINE_SPACING) * (1 + settings.rows))).into(); + window_height = (PADDING + + ((font.height() as u16 + settings.line_spacing) * (1 + settings.rows))) + .into(); } let video = context.video().expect("Error initializing SDL video"); @@ -218,7 +219,8 @@ impl Runner { let mut display_count: u16 = 0; for i in start..end { - let offset = PADDING + (font.height() as u16 + LINE_SPACING) * (display_count + 1); + let offset = PADDING + + (font.height() as u16 + self.settings.line_spacing) * (display_count + 1); let surface = font .render(&filtered_executables[i as usize])