Copy
and Paste
is so familiar and works so well that I never wondered what is really happening. My simple idea is that when I select something in the notebook and press [ControlKey]C, then my selection is placed on the on the clipboard. Then, when I go to another position in my notebook and press [ControlKey]V, the contents of the clipboard, i.e. what I selected, is placed at that position in the notebook.
What exactly is placed on the clipboard? I know we have a menu for that, Copy As
, but I am considering the straightforward Copy
. Since everything in the notebook is typesetted in boxes, I expect that it will be some or other box structure, similar to cell expressions, or a string.
Evaluate:
DynamicModule[{x}, Dynamic[x]]
The output looks like FE'x$$37
, but in fact is a DynamicModule
. I select the output cell and copy it. Then I paste it into a text editor, e.g. Notepad++
, and I see
\!\(
DynamicBox[ToBoxes[$CellContext`x$$, StandardForm],
ImageSizeCache->{88., {2., 15.}}]\)
That is more or less as expected. Almost identical:
DynamicModule[{x}, x]
It shows x$$
, but just as before, it is a DynamicModule
. When I copy the output cell and paste it into Notepad++
, I see only
x$$
Nevertheless, when I paste it into the notebook, I find a DynamicModule
. Even stronger, when I start a fresh Mathematica session and paste the clipboard into a new notebook, the result is a cell containing the DynamicModule
as above.
So the clipboard contains enough information that Mathematica can construct the DynamicModule
, but Notepad++
(and Ditto
) are unable to show the complete information from the clipboard. Is there a way to see what exactly Mathematica has placed on the clipboard? It is not important at all, I am just curious.
NotebookGet[FrontEnd`ClipboardNotebook[]]
? $\endgroup$ – kglr Jun 19 '18 at 10:201+x^2
, I see a different collection of formats on the clipboard: a Cell expression, MathML and plain text in 3 different character encodings. $\endgroup$ – Szabolcs Jun 19 '18 at 10:27