A "copy to clipboard" infoview widget #
copyToClipboard creates a MessageData widget that copies a string to the
clipboard when clicked. This may be rendered as some combination of a clickable "copy" codicon and
clickable text. See copyToClipboard and CopyDisplay for details.
Note: we use CopyDisplay instead of e.g. an Option String for text and a top-level
hasIcon := Bool for readability and to avoid situations where the user may remove both the icon
and the text accidentally.
Equations
How copyToClipboard is displayed in the infoview. May be:
.iconOnlyto just display the "copy" codicon.text s (hasIcon := true)to displays : String(with or without a preceding codicon).copiedText (hasIcon := true)to display the copied text (with or without a preceding codicon)
Everything displayed is clickable.
- text
(s : String)
(hasIcon : Bool := true)
: CopyDisplay
Displays some string with or without a preceding codicon.
Note that this only needs to be used if
hasIcon := false. Otherwise, you may take advantage of the coercion fromStringtoCopyDisplay. - iconOnly : CopyDisplay
Displays just a "copy" codicon. This turns into a check when clicked.
- copiedText
(hasIcon : Bool := true)
: CopyDisplay
Displays whatever text is to be copied, with or without a preceding codicon.
Instances For
Equations
- ImportGraph.Widget.instCoeStringCopyDisplay = { coe := fun (s : String) => ImportGraph.Widget.CopyDisplay.text s }
Build a MessageData widget that, when clicked, copies copyText to the clipboard.
By default, this is simply a clickable "copy" codicon, but text may be provided through the
display argument. Specifically:
display := .iconOnly(the default) renders just a clickable "copy" codicon.display := .text s (hasIcon := true)or equivalentlydisplay := (s : String)(in thehasIcon := truecase) displayss : String(with or without a preceding codicon)display := .copiedText (hasIcon := true)displays the copied text (with or without a preceding codicon)
Use as e.g. let msg ← copyToClipboard "text to be copied" (display := "(click to copy!)").
Equations
- One or more equations did not get rendered due to their size.