AxlClipboard — Cut / Copy / Paste

UEFI has no system clipboard, so an editor that wants copy/paste — even just within its own process, across buffers — needs one. AxlClipboard is a process-global owned byte buffer with an optional MIME type string: axl_clipboard_set copies bytes in (freeing the previous contents), axl_clipboard_get borrows a pointer to them (valid until the next set / clear), and axl_clipboard_clear empties it. Byte-oriented and content-agnostic — store UTF-8 text, a UTF-16 region, a serialized selection, or an image, and tag it with a MIME type the paste side can check. Single-threaded; not persisted across a reboot.

Header: <axl/axl-clipboard.h>

API Reference

Functions

int axl_clipboard_set(const void *data, size_t len, const char *mime)

Replace the clipboard contents.

axl-clipboard.h:

A process-global cut/copy/paste clipboard.

UEFI has no system clipboard, so an editor that wants copy/paste — even just within its own process, across buffers — needs one. This is a single owned byte buffer with an optional MIME type string: the library owns the bytes (copied in on set, freed on the next set / clear / exit), and a get borrows a pointer to them.

Byte-oriented and content-agnostic: store UTF-8 text, a UTF-16 region, a serialized selection, an image — whatever the editor cut. The MIME type (optional, NULL when unset) lets the consumer tag the payload (“text/plain;charset=utf-8”, “application/x-axl-rows”, …) and refuse an incompatible paste.

Single-threaded (UEFI). Not persisted across a reboot.

Copies len bytes of data into a library-owned buffer (the previous contents are freed) and stores an optional copy of mime. The copy is made before the old contents are freed, so on OOM the previous clipboard is left intact.

data may be NULL only when len is 0 (sets an empty payload).

Parameters:
  • data – bytes to copy in (NULL only if len is 0)

  • len – number of bytes

  • mime – optional MIME type, or NULL

Returns:

AXL_OK on success, AXL_ERR on OOM or invalid args (NULL data with len > 0).

const void *axl_clipboard_get(size_t *out_len, const char **out_mime)

Borrow the current clipboard contents.

The returned pointer is owned by the clipboard and stays valid only until the next axl_clipboard_set / axl_clipboard_clear. Copy out if you need to retain it.

Parameters:
  • out_len – [out] byte count (set to 0 when empty)

  • out_mime – [out, optional] stored MIME type, or NULL

Returns:

pointer to the bytes (NULL if the clipboard is empty); out_len receives the byte count and out_mime (if non-NULL) the stored MIME type (NULL if none was set).

void axl_clipboard_clear(void)

Empty the clipboard, freeing its contents.