From 32aadbbd6eef113362db7f43c7b2005e77dcd776 Mon Sep 17 00:00:00 2001 From: na-trium-144 <100704180+na-trium-144@users.noreply.github.com> Date: Tue, 9 Sep 2025 18:05:32 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=BF=E3=83=BC=E3=83=9F=E3=83=8A=E3=83=AB?= =?UTF-8?q?=E3=81=A7ctrl+c=E3=81=A7=E3=82=B3=E3=83=94=E3=83=BC=E3=81=A7?= =?UTF-8?q?=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/terminal/terminal.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/terminal/terminal.tsx b/app/terminal/terminal.tsx index dd2f111..eb9111b 100644 --- a/app/terminal/terminal.tsx +++ b/app/terminal/terminal.tsx @@ -121,6 +121,22 @@ export function useTerminal(props: TerminalProps) { term.open(terminalRef.current); + // https://github.com/xtermjs/xterm.js/issues/2478 + // my.code();ではCtrl+Cでのkeyboardinterruptは要らないので、コピーペーストに置き換えてしまう + term.attachCustomKeyEventHandler((arg) => { + if (arg.ctrlKey && (arg.key === "c" || arg.key === "x") && arg.type === "keydown") { + const selection = term.getSelection(); + if (selection) { + navigator.clipboard.writeText(selection); + return false; + } + } + if (arg.ctrlKey && arg.key === "v" && arg.type === "keydown") { + return false; + } + return true; + }); + setTermReady(true); onReadyRef.current?.(); }