Added support for pasting text into the terminal

This commit is contained in:
Lukáš Ondrejka 2024-09-27 20:19:20 +02:00
parent 109222f024
commit adda2e15c1

View file

@ -129,6 +129,15 @@ export default {
}
// Fit the terminal width to the div container size after terminal is created.
this.updateTerminalSize();
// Add paste event listener
this.terminal.textarea.addEventListener("paste", (event) => {
const textToPaste = event.clipboardData.getData("text").replace(/\n+$/, "");
this.cursorPosition += textToPaste.length;
this.terminalInputBuffer += textToPaste;
console.debug("Paste text: " + textToPaste);
this.terminal.write(textToPaste);
});
},
unmounted() {