Command "setplot new" may set name and description of the new plot.

This commit is contained in:
Giles Atkinson 2026-05-07 18:05:43 +01:00
parent bfb5381bfc
commit c06a3b4484
2 changed files with 25 additions and 2 deletions

View File

@ -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,
@ -736,7 +736,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,

View File

@ -1179,6 +1179,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'
@ -1196,6 +1207,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;
}