Skip to content

Commit ab0e333

Browse files
author
jgray-19
committed
Add a flag to force the plots to close on exit
1 parent 7ef048b commit ab0e333

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/madl_plot.mad

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,15 +313,26 @@ local function gnuplot_mv (fname, uname)
313313
end
314314
end
315315

316+
local not_paused = true
317+
local function kill_plots(self)
318+
if not_paused then -- Pause only once, independent of the number of streams
319+
pause("Closing plots, ")
320+
not_paused = false
321+
end
322+
gplot:set_sid(self.sid)
323+
gplot:printf("set term %s close", self.term)
324+
end
325+
316326
local function teardown_cmd (self, file, fname)
317-
local scrdump, output in self
327+
local scrdump, output, close_plots in self
318328
file:close()
319329
if output ~= false then
320330
gplot:printf("load('%s')", fname)
321331
if is_string(scrdump)
322332
then gnuplot_mv(fname, scrdump)
323333
else gnuplot_rm(fname)
324334
end
335+
if close_plots then atexit(\-> kill_plots(self)) end
325336
else
326337
if is_string(scrdump) then
327338
os.rename(fname, scrdump)
@@ -1005,6 +1016,7 @@ local plot = command "plot" {
10051016

10061017
-- output
10071018
output = nil, -- ("filename") -> pdf | number -> wid
1019+
close_plots = true, -- boolean, close all plots on exit of MAD-NG or not
10081020
scrdump = nil, -- ("filename")
10091021

10101022
-- title

0 commit comments

Comments
 (0)