package miaou-core

  1. Overview
  2. Docs
Miaou core/widgets (no drivers, no SDL)

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v0.5.2.tar.gz
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.

Sourcetype t = {
  1. copy : string -> unit;
    (*

    Copy the given text to the system clipboard using OSC 52. If a toast callback was registered, shows a brief notification.

    *)
  2. copy_available : unit -> bool;
    (*

    Returns true if OSC 52 clipboard support is enabled. May return false if the driver doesn't support it or if clipboard was explicitly disabled.

    *)
}

The clipboard interface exposed to pages and widgets.

Capability access

Sourceval set : t -> unit
Sourceval get : unit -> t option
Sourceval require : unit -> t

Driver-side API

Sourceval register : write:(string -> unit) -> ?on_copy:(string -> unit) -> ?enabled:bool -> unit -> unit

Register the clipboard capability.

  • parameter write

    Function to write raw output to the terminal

  • parameter on_copy

    Optional callback invoked after each copy with the copied text. Use this to show a toast notification, e.g.: ~on_copy:(fun _text -> Toast_widget.enqueue toasts Success "Copied!")

  • parameter enabled

    Whether clipboard support is enabled (default: true)

Sourceval osc52_encode : string -> string

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.