paste as a configurable hotkey (fixes #260)

This commit is contained in:
Eugene Pankov 2018-03-30 23:33:46 +02:00
parent b5f96a59f8
commit f947fe3f0f
3 changed files with 22 additions and 4 deletions

View File

@ -93,6 +93,9 @@ export class TerminalTabComponent extends BaseTabComponent {
case 'copy': case 'copy':
this.hterm.copySelectionToClipboard() this.hterm.copySelectionToClipboard()
break break
case 'paste':
this.paste()
break
case 'clear': case 'clear':
this.clear() this.clear()
break break
@ -231,10 +234,7 @@ export class TerminalTabComponent extends BaseTabComponent {
hterm.primaryScreen_.terminal = hterm hterm.primaryScreen_.terminal = hterm
hterm.alternateScreen_.terminal = hterm hterm.alternateScreen_.terminal = hterm
const _onPaste = hterm.scrollPort_.onPaste_.bind(hterm.scrollPort_)
hterm.scrollPort_.onPaste_ = (event) => { hterm.scrollPort_.onPaste_ = (event) => {
hterm.scrollPort_.pasteTarget_.value = event.clipboardData.getData('text/plain').trim()
_onPaste()
event.preventDefault() event.preventDefault()
} }
@ -336,7 +336,12 @@ export class TerminalTabComponent extends BaseTabComponent {
} }
paste () { paste () {
this.sendInput(this.electron.clipboard.readText()) let data = this.electron.clipboard.readText()
data = this.hterm.keyboard.encode(data)
if (this.hterm.options_.bracketedPaste) {
data = '\x1b[200~' + data + '\x1b[201~'
}
this.sendInput(data)
} }
clear () { clear () {

View File

@ -56,6 +56,9 @@ export class TerminalConfigProvider extends ConfigProvider {
'copy': [ 'copy': [
'⌘-C', '⌘-C',
], ],
'paste': [
'⌘-V',
],
'clear': [ 'clear': [
'⌘-K', '⌘-K',
], ],
@ -96,6 +99,9 @@ export class TerminalConfigProvider extends ConfigProvider {
'copy': [ 'copy': [
'Ctrl-Shift-C', 'Ctrl-Shift-C',
], ],
'paste': [
'Ctrl-Shift-V',
],
'clear': [ 'clear': [
'Ctrl-L', 'Ctrl-L',
], ],
@ -133,6 +139,9 @@ export class TerminalConfigProvider extends ConfigProvider {
'copy': [ 'copy': [
'Ctrl-Shift-C', 'Ctrl-Shift-C',
], ],
'paste': [
'Ctrl-Shift-V',
],
'clear': [ 'clear': [
'Ctrl-L', 'Ctrl-L',
], ],

View File

@ -8,6 +8,10 @@ export class TerminalHotkeyProvider extends HotkeyProvider {
id: 'copy', id: 'copy',
name: 'Copy to clipboard', name: 'Copy to clipboard',
}, },
{
id: 'paste',
name: 'Paste from clipboard',
},
{ {
id: 'home', id: 'home',
name: 'Beginning of the line', name: 'Beginning of the line',