solve #36 by adding :fill command
Some checks failed
Test Rust project / test (ubuntu-latest, stable) (push) Failing after 53s
Some checks failed
Test Rust project / test (ubuntu-latest, stable) (push) Failing after 53s
This commit is contained in:
@@ -68,6 +68,7 @@ These commands operate on selections.
|
|||||||
| - | - |
|
| - | - |
|
||||||
| `:plot` | Plots the current selection to `plot.png` using gnuplot |
|
| `:plot` | Plots the current selection to `plot.png` using gnuplot |
|
||||||
| `:export <filename>` | Exports the current selection to a new file |
|
| `:export <filename>` | Exports the current selection to a new file |
|
||||||
|
| `:fill <value>` | (Aliased as `f`) Fill the selection with `<value>`, 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
|
## Math / Functions
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ impl Widget for &App {
|
|||||||
for x in 0..x_max {
|
for x in 0..x_max {
|
||||||
for y in 0..y_max {
|
for y in 0..y_max {
|
||||||
let mut display = String::new();
|
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
|
// Custom width for the header of each row
|
||||||
let row_header_width = get_header_size() as u16;
|
let row_header_width = get_header_size() as u16;
|
||||||
@@ -148,6 +148,9 @@ impl Widget for &App {
|
|||||||
Ok(val) => {
|
Ok(val) => {
|
||||||
display = val.to_string();
|
display = val.to_string();
|
||||||
style = Style::new()
|
style = Style::new()
|
||||||
|
.fg(Color::White)
|
||||||
|
// TODO This breaks dumb terminals like the windows
|
||||||
|
// terminal
|
||||||
.underline_color(Color::DarkGray)
|
.underline_color(Color::DarkGray)
|
||||||
.add_modifier(Modifier::UNDERLINED);
|
.add_modifier(Modifier::UNDERLINED);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -175,6 +175,21 @@ impl Mode {
|
|||||||
};
|
};
|
||||||
|
|
||||||
match args[0] {
|
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" => {
|
"export" => {
|
||||||
if let Some(arg1) = args.get(1) {
|
if let Some(arg1) = args.get(1) {
|
||||||
save_range(&arg1);
|
save_range(&arg1);
|
||||||
|
|||||||
Reference in New Issue
Block a user