Skip to content

core: Rename the Rust clipboard text functions to match TSX - #4252

Open
huacnlee wants to merge 2 commits into
mainfrom
agent/T-13008-naming
Open

huacnlee wants to merge 2 commits into
mainfrom
agent/T-13008-naming

Conversation

@huacnlee

@huacnlee huacnlee commented Dec 3, 2026

Copy link
Copy Markdown
Member

Summary

Part of the naming pass before the 0.9.0 API freeze: Rust names for the clipboard's text functions now follow TSX (Clipboard.writeText / readText / hasText), the same way #3890 aligned NavStack, NavPage and Dialog. Rust already says text for ClipboardItem.text and image for the image functions; only the text trio said string, and the write had no type at all next to set_clipboard_item and set_clipboard_image.

Before After TSX
set_clipboard(text) set_clipboard_text(text) Clipboard.writeText
clipboard_string() clipboard_text() Clipboard.readText
clipboard_has_string() clipboard_has_text() Clipboard.hasText
ModuleContext::set_clipboard ModuleContext::set_clipboard_text Clipboard.writeText
  • No new API: the old names stay as #[deprecated(since = "0.9.0")] wrappers, re-exported from the prelude, so existing apps compile with a warning that names the replacement.
  • Callers in nsh-base (DataTable, Editor, TextView), nsh-testing, examples and the docs (en + zh-CN) use the new names.
  • Unchanged: the TSX surface (so nothing in nsh-compat changes), the internal services::* functions, Headless::set_clipboard (test fixture that sets the clipboard's contents) and the platform crates' own system::set_clipboard.

Release notes

set_clipboard, clipboard_string and clipboard_has_string are renamed set_clipboard_text, clipboard_text and clipboard_has_text, after TSX's Clipboard.writeText, readText and hasText. The old names still work and warn until a later release removes them.

Testing

  • cargo check -p nsh-core -p nsh-base -p nsh-testing -p nsh-engine --all-targets: no warnings
  • cargo test -p nsh-core --lib clipboard: 15 passed
  • cargo test -p nsh-base --test base data_table: 32 passed
  • cargo test -p nsh-testing --lib clipboard: 1 passed
  • macOS / iOS / Android / Windows crates not compiled locally (they call their own system::set_clipboard, untouched); CI covers them

🤖 Noop (rust-maintainer) · Opus 5.5 acting for @huacnlee

🤖 Generated with Claude Code

set_clipboard -> set_clipboard_text, clipboard_string -> clipboard_text,
clipboard_has_string -> clipboard_has_text, after Clipboard.writeText,
readText and hasText. The old names stay as deprecated aliases.

Agent: rust-maintainer
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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