From c5b5190199887f313f94c06c4c2aa6fd706c1a16 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Mon, 6 Aug 2018 20:06:48 +0200 Subject: [PATCH] command 'setplot': add predefined 'previous' and 'next' parameters to switch to the previous or next plot. A warning results if this is not possible, then the currnt plot is not changed. --- src/frontend/vectors.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/frontend/vectors.c b/src/frontend/vectors.c index d467f829d..456c5fdec 100644 --- a/src/frontend/vectors.c +++ b/src/frontend/vectors.c @@ -966,6 +966,28 @@ plot_setcur(char *name) plot_cur = pl; return; } + /* plots are listed in pl in reverse order */ + else if (cieq(name, "previous")) { + if (plot_cur->pl_next) + plot_cur = plot_cur->pl_next; + else + fprintf(cp_err, "Warning: Switching to previous plot not possible, stay with current plot (%s)\n", plot_cur->pl_typename); + return; + } + else if (cieq(name, "next")) { + struct plot *prev_pl = NULL; + for (pl = plot_list; pl; pl = pl->pl_next) { + if (pl == plot_cur) + break; + prev_pl = pl; + } + if (!prev_pl) { + fprintf(cp_err, "Warning: Switching to next plot not possible, stay with current plot (%s)\n", plot_cur->pl_typename); + return; + } + plot_cur = prev_pl; + return; + } for (pl = plot_list; pl; pl = pl->pl_next) if (plot_prefix(name, pl->pl_typename)) break;