mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-12 15:40:11 +00:00
31 lines
1.0 KiB
TypeScript
31 lines
1.0 KiB
TypeScript
import { Injectable } from '@angular/core'
|
|
import { TerminalDecorator } from './api'
|
|
import { TerminalTabComponent } from './components/terminalTab.component'
|
|
|
|
@Injectable()
|
|
export class PathDropDecorator extends TerminalDecorator {
|
|
attach (terminal: TerminalTabComponent): void {
|
|
setTimeout(() => {
|
|
terminal.hterm.scrollPort_.document_.addEventListener('dragover', (event) => {
|
|
event.preventDefault()
|
|
})
|
|
terminal.hterm.scrollPort_.document_.addEventListener('drop', (event) => {
|
|
for (let file of event.dataTransfer.files) {
|
|
this.injectPath(terminal, file.path)
|
|
}
|
|
event.preventDefault()
|
|
})
|
|
})
|
|
}
|
|
|
|
injectPath (terminal: TerminalTabComponent, path: string) {
|
|
if (path.indexOf(' ') >= 0) {
|
|
path = `"${path}"`
|
|
}
|
|
terminal.sendInput(path + ' ')
|
|
}
|
|
|
|
// tslint:disable-next-line no-empty
|
|
detach (terminal: TerminalTabComponent): void { }
|
|
}
|