From 045d1d6554184f60bb87ffae6c6384de77eb4af3 Mon Sep 17 00:00:00 2001 From: Rushmore75 Date: Wed, 28 Jan 2026 16:29:16 -0700 Subject: [PATCH] solve #36 by adding :fill command --- README.md | 1 + src/app/app.rs | 5 ++++- src/app/mode.rs | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 73a225a..09527d4 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,7 @@ These commands operate on selections. | - | - | | `:plot` | Plots the current selection to `plot.png` using gnuplot | | `:export ` | Exports the current selection to a new file | +| `:fill ` | (Aliased as `f`) Fill the selection with ``, special variables `x`,`y`,`xi`, and `yi` are avaliable. Variables `x` and `y` are the global coordinates of the cell, and `xi` and `yi` are the local coordinates of the selection. | ## Math / Functions diff --git a/src/app/app.rs b/src/app/app.rs index 93ab620..670cba7 100644 --- a/src/app/app.rs +++ b/src/app/app.rs @@ -63,7 +63,7 @@ impl Widget for &App { for x in 0..x_max { for y in 0..y_max { let mut display = String::new(); - let mut style = Style::new().fg(Color::White); + let mut style = Style::new(); // Custom width for the header of each row let row_header_width = get_header_size() as u16; @@ -148,6 +148,9 @@ impl Widget for &App { Ok(val) => { display = val.to_string(); style = Style::new() + .fg(Color::White) + // TODO This breaks dumb terminals like the windows + // terminal .underline_color(Color::DarkGray) .add_modifier(Modifier::UNDERLINED); } diff --git a/src/app/mode.rs b/src/app/mode.rs index 60b1dc2..0307761 100644 --- a/src/app/mode.rs +++ b/src/app/mode.rs @@ -175,6 +175,21 @@ impl Mode { }; match args[0] { + "f" | "fill" => { + for (i, x) in (low_x..=hi_x).enumerate() { + for (j, y) in (low_y..=hi_y).enumerate() { + let arg = args.get(1) + .map(|s| s.replace("xi", &i.to_string())) + .map(|s| s.replace("yi", &j.to_string())) + .map(|s| s.replace("x", &x.to_string())) + .map(|s| s.replace("y", &y.to_string())) + ; + app.grid.set_cell_raw((x,y), arg); + } + } + + app.mode = Mode::Normal + } "export" => { if let Some(arg1) = args.get(1) { save_range(&arg1);