mirror of
https://github.com/Eugeny/tabby.git
synced 2025-01-30 14:20:18 +08:00
fixed #6349 - enable xterm flow control
This commit is contained in:
parent
5f4a7c4d39
commit
c1bd2a720d
@ -141,6 +141,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
|
||||
private toolbarRevealTimeout = new ResettableTimeout(() => {
|
||||
this.revealToolbar = false
|
||||
}, 1000)
|
||||
private frontendWriteLock = Promise.resolve()
|
||||
|
||||
get input$ (): Observable<Buffer> {
|
||||
if (!this.frontend) {
|
||||
@ -373,14 +374,14 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
|
||||
})
|
||||
}
|
||||
|
||||
protected onFrontendReady (): void {
|
||||
protected async onFrontendReady (): Promise<void> {
|
||||
this.frontendIsReady = true
|
||||
if (this.savedState) {
|
||||
this.frontend!.restoreState(this.savedState)
|
||||
if (!this.savedStateIsLive) {
|
||||
this.frontend!.write('\r\n\r\n')
|
||||
this.frontend!.write(colors.bgWhite.black(' * ') + colors.bgBlackBright.white(' History restored '))
|
||||
this.frontend!.write('\r\n\r\n')
|
||||
await this.frontend!.write('\r\n\r\n')
|
||||
await this.frontend!.write(colors.bgWhite.black(' * ') + colors.bgBlackBright.white(' History restored '))
|
||||
await this.frontend!.write('\r\n\r\n')
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -411,13 +412,13 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
|
||||
/**
|
||||
* Feeds input into the terminal frontend
|
||||
*/
|
||||
write (data: string): void {
|
||||
this.withSpinnerPaused(() => {
|
||||
this.writeRaw(data)
|
||||
})
|
||||
async write (data: string): Promise<void> {
|
||||
this.frontendWriteLock = this.frontendWriteLock.then(() =>
|
||||
this.withSpinnerPaused(() => this.writeRaw(data)))
|
||||
await this.frontendWriteLock
|
||||
}
|
||||
|
||||
protected writeRaw (data: string): void {
|
||||
protected async writeRaw (data: string): Promise<void> {
|
||||
if (!this.frontend) {
|
||||
throw new Error('Frontend not ready')
|
||||
}
|
||||
@ -434,7 +435,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
|
||||
}
|
||||
}
|
||||
|
||||
this.frontend.write(data)
|
||||
await this.frontend.write(data)
|
||||
}
|
||||
|
||||
async paste (): Promise<void> {
|
||||
@ -780,10 +781,10 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
|
||||
this.spinnerActive = false
|
||||
}
|
||||
|
||||
protected withSpinnerPaused (work: () => void): void {
|
||||
protected async withSpinnerPaused (work: () => any): Promise<void> {
|
||||
const wasActive = this.spinnerActive
|
||||
this.stopSpinner()
|
||||
work()
|
||||
await work()
|
||||
if (wasActive) {
|
||||
this.startSpinner()
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ export class DebugDecorator extends TerminalDecorator {
|
||||
private async doLoadOutput (terminal: BaseTerminalTabComponent) {
|
||||
const data = await this.loadFile()
|
||||
if (data) {
|
||||
terminal.frontend?.write(data)
|
||||
await terminal.frontend?.write(data)
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,7 +131,7 @@ export class DebugDecorator extends TerminalDecorator {
|
||||
if (data.startsWith('`')) {
|
||||
data = data.substring(3, data.length - 3)
|
||||
}
|
||||
terminal.frontend?.write(JSON.parse(data))
|
||||
await terminal.frontend?.write(JSON.parse(data))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ export abstract class Frontend {
|
||||
abstract selectAll (): void
|
||||
abstract clearSelection (): void
|
||||
abstract focus (): void
|
||||
abstract write (data: string): void
|
||||
abstract write (data: string): Promise<void>
|
||||
abstract clear (): void
|
||||
abstract visualBell (): void
|
||||
abstract scrollToBottom (): void
|
||||
|
@ -247,8 +247,8 @@ export class XTermFrontend extends Frontend {
|
||||
setTimeout(() => this.xterm.focus())
|
||||
}
|
||||
|
||||
write (data: string): void {
|
||||
this.xterm.write(data)
|
||||
async write (data: string): Promise<void> {
|
||||
await new Promise<void>(r => this.xterm.write(data, r))
|
||||
}
|
||||
|
||||
clear (): void {
|
||||
|
Loading…
Reference in New Issue
Block a user