SyntaxEditor makes use of the Windows clipboard as a temporary repository for data for cut/copy/paste operations.
Tip
Clipboard and Drag and Drop operations share many of the same concepts. Refer to the Drag and Drop topic for details specific to working with drag-and-drop.
Cutting and Copying Text
The IEditor
If the selection length is zero, or in other words, no text is selected, a feature of SyntaxEditor is to place the entire line of text on the clipboard of which the caret is currently on. You can control whether blank lines will overwrite the clipboard by using the Can
There are Cut
This code demonstrates how to copy the currently selected text to the clipboard:
Cutting and Copying with HTML and RTF Export
The text that is copied can also be copied to the clipboard with HTML and RTF exported highlighting. Then, if you paste the text in an application such as Word, the text will appear highlighted.
The Syntax
The Syntax
Pasting Text
The IEditor
If text was copied from a SyntaxEditor when the selection length was zero (see above) the entire line of text that was copied will be inserted above the line in which the caret is currently located. In this situation, the caret is not moved.
This code demonstrates how to paste text from the clipboard:
Customizing Text to be Cut or Copied
Sometimes it is useful to be able to customize the text, or objects, to be cut or copied. The Syntax
In its event arguments, it passes the IDataDataFormats.UnicodeText
and DataFormats.Text
entries based on the current selection in the editor. The IData
Note
The IDataIDataObject
. IDataIDataObject
does and provides a consistent API across our supported platforms.
Customizing Text to be Pasted
Just like the Syntax
- Paste operations
- Paste completion
- CanPaste checks
- Drag enter
- Drag over
- Drag/drop
This event passes the IDataIDataObject
(see note above) and provides access to any clipboard data (such as non-text formats) that was used to trigger the event.
The Pastenull
to insert nothing.
Tip
For Cannull
value to indicate that an object can be pasted. The actual value only has to be assigned for the Paste actions.
Tracking Clipboard Change Events
Since the Syntax