Skip to content

Add clipboard_formats: classify + diff the clipboard's available formats#403

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

Add clipboard_formats: classify + diff the clipboard's available formats#403
JE-Chen merged 1 commit into
devfrom
feat/clipboard-formats-batch

Conversation

@JE-Chen

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

Copy link
Copy Markdown
Member

Why

The clipboard usually holds the same content in several formats at once — a Word copy offers CF_UNICODETEXT + HTML Format + Rich Text Format, a file copy offers CF_HDROP, a screenshot offers CF_DIB. Nothing reported which formats are present (so an automation could know what it can paste) or detected when that set changed. clipboard_formats adds:

  • classify_format / classify_formats — map standard CF_* ids and registered format names to friendly categories (text / image / files / html / rtf / csv / audio / …)
  • diff_formats — a pure monitor primitive: {added, removed, changed} between two snapshots
  • list_clipboard_formats / clipboard_formats — enumerate the live clipboard (EnumClipboardFormats) without consuming anything, and classify it

Design

  • The classifier and diff are pure functions (unit-testable on any platform). A registered name takes priority over the id since registered formats have dynamic ids (>= 0xC000). Descriptors accept an id, {id, name}, or (id, name).
  • Distinct from smart_waits.wait_until_clipboard_changes (which monitors content) — this reports the format set.
  • Only the live enumeration is Win32 (raises RuntimeError elsewhere).
  • 5 layers wired: core → facade __all__AC_clipboard_formats (live) + AC_classify_formats / AC_diff_formats (pure) → read-only ac_* MCP tools → Script Builder (Data). Qt-free verified.

Tests

test/unit_test/headless/test_clipboard_formats_batch.py — standard-id and named classification (name priority), summary categories/flags, diff added/removed/no-change, tuple descriptors, the pure executor paths (_classify_formats / _diff_formats), and 5-layer wiring. 25 passed alongside the clipboard siblings. Win32 enumeration not executed in CI.

The clipboard holds the same content in several formats at once, and
nothing reported which formats were present or detected when that set
changed. Add classify_format/classify_formats (map standard CF_* ids +
registered names to friendly categories), diff_formats (pure monitor
primitive returning added/removed/changed), and a Win32
EnumClipboardFormats enumeration. Classifier and diff are pure and
headless-tested; only the live enumeration is Win32.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 42 complexity · 0 duplication

Metric Results
Complexity 42
Duplication 0

View in Codacy

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 merged commit 7960b5c into dev Jun 24, 2026
16 checks passed
@JE-Chen JE-Chen deleted the feat/clipboard-formats-batch branch June 24, 2026 06:01
@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