cleanup gnuplot command
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 _ = fs::copy("/tmp/output.png", output_filename);
|
||||
|
||||
app.msg = StatusMessage::info("Wrote gnuplot data to /tmp");
|
||||
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(format!("Created {output_filename}. Artifacts are in /tmp"));
|
||||
}
|
||||
app.mode = Mode::Normal
|
||||
}
|
||||
_ => {}
|
||||
|
||||
Reference in New Issue
Block a user