Skip to content

Commit

Permalink
🎉 Add cli argument for changing the inner box margin (#86)
Browse files Browse the repository at this point in the history
* 🎉 Add cli argument for changing the inner box margin
  • Loading branch information
123marvin123 authored May 13, 2021
1 parent d9a527f commit 8c50b04
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
18 changes: 18 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,24 @@ pub struct Opt {
conflicts_with = "no_ascii"
)]
pub small_ascii: bool,

#[structopt(
help = "Sets the border margin on the x axis for the box.",
long = "box-inner-margin-x",
short = "L",
conflicts_with = "no_box",
default_value = "1"
)]
pub box_border_margin_x: u16,

#[structopt(
help = "Sets the border margin on the y axis for the box.",
long = "box-inner-margin-y",
short = "J",
conflicts_with = "no_box",
default_value = "0"
)]
pub box_border_margin_y: u16,
}

#[allow(dead_code)]
Expand Down
18 changes: 8 additions & 10 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,15 @@ fn draw_readout_data(
theme: Box<dyn Theme>,
buf: &mut Buffer,
area: Rect,
show_box: bool,
palette: bool,
config: &Opt
) {
let mut list = ReadoutList::new(data, &theme).palette(palette);
let mut list = ReadoutList::new(data, &theme).palette(config.palette);

if show_box {
if !config.no_box {
list = list
.block_inner_margin(Margin {
horizontal: 1,
vertical: 1,
horizontal: config.box_border_margin_x,
vertical: config.box_border_margin_y,
})
.block(
Block::default()
Expand Down Expand Up @@ -191,11 +190,11 @@ fn main() -> Result<(), io::Error> {

let ascii_area;

if let Some(file_path) = opt.custom_ascii {
if let Some(ref file_path) = opt.custom_ascii {
let file_path = PathBuf::from(file_path);
let ascii_art;
match opt.custom_ascii_color {
Some(color) => {
Some(ref color) => {
ascii_art = ascii::get_ascii_from_file_override_color(
&file_path,
color.get_color().to_owned(),
Expand Down Expand Up @@ -238,8 +237,7 @@ fn main() -> Result<(), io::Error> {
tmp_buffer_area.width - ascii_area.width - 4,
ascii_area.height,
),
!opt.no_box,
opt.palette,
&opt,
);

write_buffer_to_console(&mut backend, &mut tmp_buffer)?;
Expand Down

0 comments on commit 8c50b04

Please sign in to comment.