Skip to content
This repository was archived by the owner on Oct 22, 2021. It is now read-only.

Commit 1092c8f

Browse files
committed
✨ Natural copy/pasting using CTRL+C/V
#37
1 parent 2d2ac17 commit 1092c8f

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/classes/keyboard.class.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ class Keyboard {
194194
}
195195
} else if (cmd === "\n") {
196196
term.writelr("");
197+
} else if (cmd === ctrlseq[19] && window.term.term.hasSelection()) {
198+
window.term.copy();
197199
} else {
198200
term.write(cmd);
199201
}

src/classes/terminal.class.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ class Terminal {
165165
this.writelr = cmd => {
166166
this.socket.send(cmd+"\r");
167167
};
168+
169+
this.copy = () => {
170+
if (!this.term.hasSelection()) return false;
171+
document.execCommand("copy");
172+
this.term.clearSelection();
173+
};
168174
} else if (opts.role === "server") {
169175

170176
this.Pty = require("node-pty");

0 commit comments

Comments
 (0)