package miaou-core
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=60a3b9f181f24572a06a9492532bfdda
sha512=fcc35a275066be2900e6201782faf47503076fa4640f08cf78067835a6f447b74613009e55b2ac799adb7ca46f1bffa261fc5971753f2cc3c6bef327511c7ef6
doc/miaou-core.interfaces/Miaou_interfaces/Clipboard/index.html
Module Miaou_interfaces.ClipboardSource
Clipboard capability — copy text to the system clipboard via OSC 52.
OSC 52 is a terminal escape sequence that allows terminal applications to set the system clipboard contents. It is supported by most modern terminals including:
- iTerm2
- Alacritty
- kitty
- WezTerm
- tmux (with
set-clipboard on) - Windows Terminal
Usage in pages / widgets:
let clipboard = Clipboard.require () in
clipboard.copy "Hello, world!"Usage in drivers:
Clipboard.register ~write:(fun s -> output_string stdout s; flush stdout)Note: Reading from clipboard (paste) is not supported because it requires asynchronous terminal responses. Use the terminal's native paste (Ctrl+Shift+V or Cmd+V) which sends text as regular key input.
type t = {copy : string -> unit;(*Copy the given text to the system clipboard using OSC 52. If a toast callback was registered, shows a brief notification.
*)copy_available : unit -> bool;(*Returns
*)trueif OSC 52 clipboard support is enabled. May returnfalseif the driver doesn't support it or if clipboard was explicitly disabled.
}The clipboard interface exposed to pages and widgets.
Capability access
Driver-side API
val register :
write:(string -> unit) ->
?on_copy:(string -> unit) ->
?enabled:bool ->
unit ->
unitRegister the clipboard capability.
Encode text as an OSC 52 escape sequence. Exported for testing. The sequence format is: ESC 52 ; c ; <base64-encoded-text> BEL] BEL (0x07) is used as terminator for wider terminal compatibility.