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 |
|
||||||
| `:q!` | Quit program, even if the file isn't saved |
|
| `: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 / Functions
|
||||||
|
|
||||||
### Math
|
### Math
|
||||||
|
|||||||
@@ -216,10 +216,16 @@ impl Mode {
|
|||||||
let s = s.replace("$OUTPUT", "/tmp/output.png");
|
let s = s.replace("$OUTPUT", "/tmp/output.png");
|
||||||
let _ = fs::write("/tmp/plot.p", s);
|
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();
|
||||||
let _ = fs::copy("/tmp/output.png", output_filename);
|
if let Err(err) = cmd_res {
|
||||||
|
match err.kind() {
|
||||||
app.msg = StatusMessage::info("Wrote gnuplot data to /tmp");
|
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
|
app.mode = Mode::Normal
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|||||||
Reference in New Issue
Block a user