defaultPasteAction function

Future<void> defaultPasteAction(
  1. TerminalEngine engine,
  2. TerminalController controller
)

Reads text/plain from the system clipboard and writes it to the engine, applying bracketed-paste encoding when active. Goes through TerminalController.onTerminalInputStart which mirrors alacritty event.rs:on_terminal_input_start — scrollback rewind, gated selection clear AND the follow-up refreshView so any prior selection highlight disappears from the painter before the paste echo arrives.

Implementation

Future<void> defaultPasteAction(
  TerminalEngine engine,
  TerminalController controller,
) async {
  final data = await Clipboard.getData('text/plain');
  final text = data?.text;
  if (text == null || text.isEmpty) return;
  controller.onTerminalInputStart();
  engine.write(pasteBytes(text, modeFlags: engine.grid.modeFlags));
}