Skip to content

Commit f7daa04

Browse files
author
jie.xiong
committed
Added support for pasting text into the terminal louislam#623
1 parent ae5d2f1 commit f7daa04

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

frontend/src/components/Terminal.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,20 @@ export default {
129129
}
130130
// Fit the terminal width to the div container size after terminal is created.
131131
this.updateTerminalSize();
132+
133+
// Add paste event listener
134+
this.terminal.textarea.addEventListener("paste", (event) => {
135+
const textToPaste = event.clipboardData.getData("text").replace(/\n+$/, "");
136+
this.cursorPosition += textToPaste.length;
137+
this.terminalInputBuffer += textToPaste;
138+
console.debug("Paste text: " + textToPaste);
139+
this.terminal.write(textToPaste);
140+
});
132141
},
133142
134143
unmounted() {
135144
window.removeEventListener("resize", this.onResizeEvent); // Remove the resize event listener from the window object.
145+
window.removeEventListener("paste", this.onResizeEvent); // Remove the paste event listener from the window object.
136146
this.$root.unbindTerminal(this.name);
137147
this.terminal.dispose();
138148
},

0 commit comments

Comments
 (0)