diff --git a/web/src/components/App.jsx b/web/src/components/App.jsx index 1a681c6..5232c0d 100644 --- a/web/src/components/App.jsx +++ b/web/src/components/App.jsx @@ -92,6 +92,8 @@ export default function App() { { keys: `${layout.keys.shift}+${layout.keys.enter}`, desc: t('statusbar.newLine') }, ], shell: [ + { keys: `${layout.keys.ctrl}+${layout.keys.shift}+C`, desc: t('statusbar.copy') }, + { keys: `${layout.keys.ctrl}+${layout.keys.shift}+V`, desc: t('statusbar.paste') }, { keys: layout.keys.enter, desc: t('statusbar.runCommand') }, { keys: `${layout.keys.up}/${layout.keys.down}`, desc: t('statusbar.commandHistory') }, ], diff --git a/web/src/components/Shell.jsx b/web/src/components/Shell.jsx index b14a698..e3b113d 100644 --- a/web/src/components/Shell.jsx +++ b/web/src/components/Shell.jsx @@ -143,6 +143,32 @@ function createTerminal(container, settings = {}) { const webLinksAddon = new WebLinksAddon() term.loadAddon(fitAddon) term.loadAddon(webLinksAddon) + + term.attachCustomKeyEventHandler((e) => { + if (e.type !== 'keydown') return true + const ctrl = e.ctrlKey || e.metaKey + const shift = e.shiftKey + + if (ctrl && shift && e.key === 'C') { + e.preventDefault() + e.stopPropagation() + const selection = term.getSelection() + if (selection) navigator.clipboard.writeText(selection) + return false + } + + if (ctrl && shift && e.key === 'V') { + e.preventDefault() + e.stopPropagation() + navigator.clipboard.readText().then(text => { + if (text) term.paste(text) + }).catch(() => {}) + return false + } + + return true + }) + term.open(container) fitAddon.fit() diff --git a/web/src/i18n/en.js b/web/src/i18n/en.js index 4303d7d..0428a47 100644 --- a/web/src/i18n/en.js +++ b/web/src/i18n/en.js @@ -16,6 +16,8 @@ const en = { switchWindow: 'Switch window', sendMessage: 'Send message', newLine: 'New line', + copy: 'Copy', + paste: 'Paste', runCommand: 'Run command', commandHistory: 'Command history', }, diff --git a/web/src/i18n/fr.js b/web/src/i18n/fr.js index fc580e3..8d38c09 100644 --- a/web/src/i18n/fr.js +++ b/web/src/i18n/fr.js @@ -16,6 +16,8 @@ const fr = { switchWindow: 'Changer de fen\u00eatre', sendMessage: 'Envoyer le message', newLine: 'Nouvelle ligne', + copy: 'Copier', + paste: 'Coller', runCommand: 'Ex\u00e9cuter', commandHistory: 'Historique', },