cleanup gnuplot command

This commit is contained in:
2026-01-22 14:11:02 -07:00
parent 3ff9e8683c
commit 4ae7aec66e
2 changed files with 19 additions and 4 deletions

View File

@@ -51,6 +51,15 @@ Based loosely off sc-im (spreadsheet calculator improvised), which has dumb keyb
| `:q` | Quit program |
| `:q!` | Quit program, even if the file isn't saved |
#### Visual mode commands
These commands operate on selections.
| Commmand | Description |
| - | - |
| `:plot` | Plots the current selection to `plog.png` using gnuplot |
| `:export <filename>` | Exports the current selection to a new file |
## Math / Functions
### Math

View File

@@ -216,10 +216,16 @@ impl Mode {
let s = s.replace("$OUTPUT", "/tmp/output.png");
let _ = fs::write("/tmp/plot.p", s);
let _ = Command::new("gnuplot").arg("/tmp/plot.p").output();
let cmd_res= Command::new("gnuplot").arg("/tmp/plot.p").output();
if let Err(err) = cmd_res {
match err.kind() {
std::io::ErrorKind::NotFound => app.msg = StatusMessage::error("Error - Is gnuplot installed?"),
_ => app.msg = StatusMessage::error(format!("{err}")),
};
} else {
let _ = fs::copy("/tmp/output.png", output_filename);
app.msg = StatusMessage::info("Wrote gnuplot data to /tmp");
app.msg = StatusMessage::info(format!("Created {output_filename}. Artifacts are in /tmp"));
}
app.mode = Mode::Normal
}
_ => {}