Selection
Selecting text by character, word or line.
Selection
Cascade supports interactive text selection. When the user clicks within a text renderable, the selection granularity is determined by the click count: a single click selects a character, a double click selects the word under the cursor, and a triple click selects the entire line. Dragging extends the selection across characters or lines.
You can respond to selection events on the renderer. For example, listen for mouse events and call selectWord or selectLine manually based on the click count.
renderer.on("mouse", (event) => {
if (event.clickCount === 2) {
renderer.selectWord(event.x, event.y)
}
if (event.clickCount === 3) {
renderer.selectLine(event.x, event.y)
}
})Selections can be copied to the clipboard via your terminal emulator’s standard shortcuts.
Selection is especially useful for log viewers and diff panes. A common UX improvement is to also provide a “copy selected” action that prints the current selection to the built-in console, which makes it visible even when the host terminal clipboard integration is limited.