Clipboard and undo

EsClipboardAddText

EsError EsClipboardAddText(EsClipboard clipboard, STRING text = BLANK_STRING);

Copies the text into the clipboard as ES_CLIPBOARD_FORMAT_TEXT. Returns ES_ERROR_INSUFFICIENT_RESOURCES if the clipboard cannot be opened.

EsClipboardAddImage

EsError EsClipboardAddImage(EsClipboard clipboard, const void *png, size_t pngBytes);

Copies one complete PNG byte stream into the clipboard as ES_CLIPBOARD_FORMAT_IMAGE. The data is stored unchanged. Returns the file store error, or ES_ERROR_INSUFFICIENT_RESOURCES if the clipboard cannot be opened.

EsClipboardHasFormat

bool EsClipboardHasFormat(EsClipboard clipboard, EsClipboardFormat format);

Returns true if the clipboard contains data in the given format. ES_CLIPBOARD_FORMAT_TEXT also matches ES_CLIPBOARD_FORMAT_PATH_LIST.

EsClipboardHasData

bool EsClipboardHasData(EsClipboard clipboard);

Returns true if the clipboard contains any data.

EsClipboardReadText

char *EsClipboardReadText(EsClipboard clipboard, size_t *bytes, EsClipboardDataFlags *flags = ES_NULL);

Free with EsHeapFree.

EsClipboardReadImage

void *EsClipboardReadImage(EsClipboard clipboard, size_t *bytes);

Returns a heap-allocated copy of the PNG byte stream when the clipboard contains ES_CLIPBOARD_FORMAT_IMAGE. Returns NULL and sets bytes to zero for a different format or a read failure. Free the result with EsHeapFree.

EsClipboardOpen

EsFileStore *EsClipboardOpen(EsClipboard clipboard);

Open the clipboard for writing.

EsClipboardCloseAndAdd

EsError EsClipboardCloseAndAdd(EsClipboard clipboard, EsClipboardFormat format, EsFileStore *fileStore, EsClipboardDataFlags flags = ES_FLAGS_DEFAULT);

Closes the file store opened with EsClipboardOpen and adds its contents to the clipboard in the given format. Returns the file store's error.

EsUndoClear

void EsUndoClear(EsUndoManager *manager);

Cancels every item on the current undo or redo stack. Each item callback receives ES_MSG_UNDO_CANCEL. This must be done with the message mutex acquired.

EsUndoContinueGroup

void EsUndoContinueGroup(EsUndoManager *manager);

Marks the top item so that the next EsUndoPush continues the same group. The manager must be in the normal state.

EsUndoEndGroup

void EsUndoEndGroup(EsUndoManager *manager);

Marks the top item as the end of a group. EsUndoInvokeGroup undoes or redoes the group as a whole.

EsUndoInvokeGroup

void EsUndoInvokeGroup(EsUndoManager *manager, bool redo);

Undoes or redoes the group at the top of the undo or redo stack. Each item callback receives ES_MSG_UNDO_INVOKE. This must be done with the message mutex acquired.

EsUndoPeek

bool EsUndoPeek(EsUndoManager *manager, EsUndoCallback *callback, const void **item);

Returns the callback and item at the top of the undo or redo stack. Returns false if the stack is empty.

EsUndoPop

void EsUndoPop(EsUndoManager *manager);

Cancels the top item on the current stack and removes it. Its callback receives ES_MSG_UNDO_CANCEL.

EsUndoPush

void EsUndoPush(EsUndoManager *manager, EsUndoCallback callback, const void *item, size_t itemBytes, bool setAsActiveUndoManager = true);

Copies the item bytes and pushes them onto the undo stack with the given callback. It clears the redo stack. This must be done with the message mutex acquired.

EsUndoInUndo

bool EsUndoInUndo(EsUndoManager *manager);

Returns true if the manager is currently undoing or redoing.

EsUndoIsEmpty

bool EsUndoIsEmpty(EsUndoManager *manager, bool redo);

Returns true if the undo or redo stack is empty. The manager must be in the normal state.

EsUndoGetInstance

ES_INSTANCE_TYPE *EsUndoGetInstance(EsUndoManager *manager);

Returns the instance that owns the manager.