open SFTP panel in the CWD

This commit is contained in:
Eugene Pankov
2021-07-24 09:44:47 +02:00
parent 7fa29b4b37
commit a2e0db2a16
14 changed files with 94 additions and 47 deletions

View File

@@ -268,16 +268,17 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
break
}
})
this.bellPlayer = document.createElement('audio')
this.bellPlayer.src = require('../bell.ogg').default
this.contextMenuProviders.sort((a, b) => a.weight - b.weight)
this.pinToolbar = this.enableToolbar && (window.localStorage.pinTerminalToolbar ?? 'true') === 'true'
}
/** @hidden */
ngOnInit (): void {
this.pinToolbar = this.enableToolbar && (window.localStorage.pinTerminalToolbar ?? 'true') === 'true'
this.focused$.subscribe(() => {
this.configure()
this.frontend?.focus()

View File

@@ -0,0 +1,37 @@
import * as os from 'os'
import { Subject, Observable } from 'rxjs'
const OSC1337Prefix = Buffer.from('\x1b]1337;')
const OSC1337Suffix = Buffer.from('\x07')
export class OSC1337Processor {
get cwdReported$ (): Observable<string> { return this.cwdReported }
private cwdReported = new Subject<string>()
process (data: Buffer): Buffer {
if (data.includes(OSC1337Prefix)) {
const preData = data.subarray(0, data.indexOf(OSC1337Prefix))
const params = data.subarray(data.indexOf(OSC1337Prefix) + OSC1337Prefix.length)
const postData = params.subarray(params.indexOf(OSC1337Suffix) + OSC1337Suffix.length)
const paramString = params.subarray(0, params.indexOf(OSC1337Suffix)).toString()
if (paramString.startsWith('CurrentDir=')) {
let reportedCWD = paramString.split('=')[1]
if (reportedCWD.startsWith('~')) {
reportedCWD = os.homedir() + reportedCWD.substring(1)
}
this.cwdReported.next(reportedCWD)
} else {
console.debug('Unsupported OSC 1337 parameter:', paramString)
}
data = Buffer.concat([preData, postData])
}
return data
}
close (): void {
this.cwdReported.complete()
}
}