Skip to content

Add rich clipboard (CF_HTML build/parse/get/set)#354

Merged
JE-Chen merged 1 commit into
devfrom
feat/rich-clipboard-batch
Jun 23, 2026
Merged

Add rich clipboard (CF_HTML build/parse/get/set)#354
JE-Chen merged 1 commit into
devfrom
feat/rich-clipboard-batch

Conversation

@JE-Chen

@JE-Chen JE-Chen commented Jun 23, 2026

Copy link
Copy Markdown
Member

The base clipboard handles plain text + image only; rich paste into Word / Outlook needs CF_HTML, whose byte-offset header (StartHTML/EndHTML/StartFragment/EndFragment) is famously error-prone.

  • build_cf_html(html) → valid CF_HTML UTF-8 bytes whose offsets point exactly at the fragment (fixed-width 10-digit header → single-pass offsets; correct across multi-byte UTF-8). parse_cf_html(blob) recovers the fragment from bytes/str (comment markers, falling back to byte offsets). Both pure-stdlib and fully round-trip tested.
  • set_clipboard_html / get_clipboard_html: Win32 wrappers (RegisterClipboardFormat "HTML Format" + the GlobalAlloc/SetClipboardData pattern from the base clipboard module); raise RuntimeError off Windows, with a plain-text fallback via fragment_plaintext.
  • The error-prone byte-offset math is headless-tested; the Win32 I/O guard is verified on Linux CI. (CF_HDROP file-list deferred — fiddly OLE, not headless-testable.) Wired through all 5 layers + headless test + EN/Zh docs + WHATS_NEW. Qt-free.

@JE-Chen JE-Chen merged commit 1037919 into dev Jun 23, 2026
15 of 16 checks passed
@codacy-production

Copy link
Copy Markdown

Not up to standards ⛔

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@JE-Chen JE-Chen deleted the feat/rich-clipboard-batch branch June 23, 2026 00:51
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant