1
1
mirror of https://github.com/Eugeny/tabby.git synced 2024-12-23 10:32:29 +03:00

added support for long-clicking for context menu when right click is set to paste (#4858)

This commit is contained in:
Eugene Pankov 2021-11-14 10:59:08 +01:00
parent a1dbcdbae3
commit 39389f77d0
No known key found for this signature in database
GPG Key ID: 5896FCBBDD1CF4F4
2 changed files with 25 additions and 4 deletions

View File

@ -565,13 +565,27 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
this.termContainerSubscriptions.cancelAll()
}
protected async handleRightClick (event: MouseEvent): Promise<void> {
private rightMouseDownTime = 0
protected async handleRightMouseDown (event: MouseEvent): Promise<void> {
event.preventDefault()
event.stopPropagation()
this.rightMouseDownTime = Date.now()
if (this.config.store.terminal.rightClick === 'menu') {
this.platform.popupContextMenu(await this.buildContextMenu(), event)
} else if (this.config.store.terminal.rightClick === 'paste') {
this.paste()
}
}
protected async handleRightMouseUp (event: MouseEvent): Promise<void> {
event.preventDefault()
event.stopPropagation()
if (this.config.store.terminal.rightClick === 'paste') {
const duration = Date.now() - this.rightMouseDownTime
if (duration < 250) {
this.paste()
} else {
this.platform.popupContextMenu(await this.buildContextMenu(), event)
}
}
}
@ -611,7 +625,13 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
return
}
if (event.which === 3 || event.which === 1 && event.ctrlKey) {
this.handleRightClick(event)
this.handleRightMouseDown(event)
return
}
}
if (event.type === 'mouseup') {
if (event.which === 3 || event.which === 1 && event.ctrlKey) {
this.handleRightMouseUp(event)
return
}
}

View File

@ -49,6 +49,7 @@ h3.mb-3 Terminal
.form-line
.header
.title Right click
.description(*ngIf='config.store.terminal.rightClick == "paste"') Long-click for context menu
.btn-group(
[(ngModel)]='config.store.terminal.rightClick',
(ngModelChange)='config.save()',