From 06afc7c1daf253c1178f8b11d245c9c6a43b3630 Mon Sep 17 00:00:00 2001 From: Giles Atkinson <“gatk555@gmail.com”> Date: Thu, 7 May 2026 18:05:43 +0100 Subject: [PATCH] Command "setplot new" may set name and description of the new plot. --- src/frontend/commands.c | 4 ++-- src/frontend/postcoms.c | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/frontend/commands.c b/src/frontend/commands.c index eb03fb159..c4e592246 100644 --- a/src/frontend/commands.c +++ b/src/frontend/commands.c @@ -188,7 +188,7 @@ struct comm spcp_coms[] = { NULL, "[plotname] ... : Throw away all the data in the plot." } , { "setplot", com_splot, FALSE, TRUE, - { 0400, 0, 0, 0 }, E_DEFHMASK, 0, 1, + { 0400, 0, 0, 0 }, E_DEFHMASK, 0, 4, NULL, "[plotname] : Change the current working plot." } , { "setcirc", com_scirc, TRUE, FALSE, @@ -734,7 +734,7 @@ struct comm nutcp_coms[] = { NULL, "[plotname] ... : Throw away all the data in the plot." } , { "setplot", com_splot, FALSE, TRUE, - { 0400, 0, 0, 0 }, E_DEFHMASK, 0, 1, + { 0400, 0, 0, 0 }, E_DEFHMASK, 0, 4, NULL, "[plotname] : Change the current working plot." } , { "setcirc", com_scirc, TRUE, FALSE, diff --git a/src/frontend/postcoms.c b/src/frontend/postcoms.c index a346d8e8b..248aa5a99 100644 --- a/src/frontend/postcoms.c +++ b/src/frontend/postcoms.c @@ -1177,6 +1177,17 @@ DelPlotWindows(struct plot *pl) #endif } +/* Helper for com_splot(). */ + +static int new_str(wordlist **pwl, char **ps) +{ + *pwl = (*pwl)->wl_next; + if (!*pwl) + return 1; + tfree(*ps); + *ps = copy((*pwl)->wl_word); + return 0; +} /* * command 'setplot' @@ -1194,6 +1205,18 @@ com_splot(wordlist *wl) if (wl) { plot_setcur(wl->wl_word); + + if (cieq(wl->wl_word, "new")) { + /* The user may also supply, name, title and typename strings. + * The typename is the 'true name' used in commands! + */ + + if (new_str(&wl, &plot_cur->pl_typename)) + return; + if (new_str(&wl, &plot_cur->pl_title)) + return; + new_str(&wl, &plot_cur->pl_name); + } return; }