Skip to content

__nexus_ide_figure_publish__

plot · scripts/plot/util/__nexus_ide_figure_publish__.m

Stream one figure life-cycle message for the IDE (nexus#1491).

  frame = __nexus_ide_figure_publish__ (h, event)
  frame = __nexus_ide_figure_publish__ (h, event, force)

EVENT is "create", "update" or "close".  The return value is the OSC 7770
frame (ESC ] 7770 ; <json> BEL), or "" when NEXUS_IDE is not "1", the
figure is hidden, or there is nothing to send.  FORCE (tests) streams a
hidden figure too.  The graphics toolkit writes the frame to stdout in one
piece; this function does not.

Outbound JSON (extra fields are fine; the host ignores ones it does not
know): t="figure", v=1, id (figure Number), event, name (Name property),
title (the dock-tab text, "Figure N" or "Figure N: Name" when NumberTitle
is on), width, height (the figure Position in pixels), format "png" or
"svg".  "update" adds png or svg (base64) at that pixel size, or path when
the frame would exceed 64 KiB.  SVG is used after an inbound format event
(see __nexus_ide_figure_event__).  The picture is gnuplot's file terminal,
so no native window is opened.

A figure the IDE has not been told about yet is announced with "create"
(no picture) and, when EVENT is "update", a second frame carrying the
picture.  Hidden figures are not announced.  "close" is sent even if the
figure was hidden.  Property changes mark the figure modified and request
drawnow; drawnow calls this with "update".  That is the same moment MATLAB
repaints a docked figure.