diff --git a/README.md b/README.md index 6dc7dde..0ea2109 100644 --- a/README.md +++ b/README.md @@ -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 ` | Exports the current selection to a new file | + ## Math / Functions ### Math diff --git a/src/app/mode.rs b/src/app/mode.rs index 42ed1fe..8ea6d13 100644 --- a/src/app/mode.rs +++ b/src/app/mode.rs @@ -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 } _ => {}