mirror of
https://github.com/Eugeny/tabby.git
synced 2024-12-27 06:49:39 +08:00
fixed visual layout of readline prompts
This commit is contained in:
parent
3be98e6244
commit
8f55333d23
@ -33,19 +33,9 @@ export class TerminalStreamProcessor {
|
|||||||
constructor (private options: StreamProcessingOptions) {
|
constructor (private options: StreamProcessingOptions) {
|
||||||
this.inputReadlineInStream = new PassThrough()
|
this.inputReadlineInStream = new PassThrough()
|
||||||
this.inputReadlineOutStream = new PassThrough()
|
this.inputReadlineOutStream = new PassThrough()
|
||||||
this.inputReadline = createReadline({
|
|
||||||
input: this.inputReadlineInStream,
|
|
||||||
output: this.inputReadlineOutStream,
|
|
||||||
terminal: true,
|
|
||||||
prompt: this.options.inputMode === 'readline-hex' ? 'hex> ' : '> ',
|
|
||||||
} as any)
|
|
||||||
this.inputReadlineOutStream.on('data', data => {
|
this.inputReadlineOutStream.on('data', data => {
|
||||||
this.outputToTerminal.next(Buffer.from(data))
|
this.outputToTerminal.next(Buffer.from(data))
|
||||||
})
|
})
|
||||||
this.inputReadline.on('line', line => {
|
|
||||||
this.onTerminalInput(Buffer.from(line + '\n'))
|
|
||||||
this.resetInputPrompt()
|
|
||||||
})
|
|
||||||
this.outputToTerminal$.pipe(debounce(() => interval(500))).subscribe(() => {
|
this.outputToTerminal$.pipe(debounce(() => interval(500))).subscribe(() => {
|
||||||
if (this.started) {
|
if (this.started) {
|
||||||
this.onOutputSettled()
|
this.onOutputSettled()
|
||||||
@ -54,14 +44,24 @@ export class TerminalStreamProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
start (): void {
|
start (): void {
|
||||||
|
this.inputReadline = createReadline({
|
||||||
|
input: this.inputReadlineInStream,
|
||||||
|
output: this.inputReadlineOutStream,
|
||||||
|
terminal: true,
|
||||||
|
prompt: this.options.inputMode === 'readline-hex' ? 'hex> ' : '> ',
|
||||||
|
} as any)
|
||||||
|
this.inputReadline.on('line', line => {
|
||||||
|
this.onTerminalInput(Buffer.from(line + '\n'))
|
||||||
|
this.resetInputPrompt()
|
||||||
|
})
|
||||||
this.started = true
|
this.started = true
|
||||||
this.onOutputSettled()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
feedFromSession (data: Buffer): void {
|
feedFromSession (data: Buffer): void {
|
||||||
if (this.options.inputMode?.startsWith('readline')) {
|
if (this.options.inputMode?.startsWith('readline')) {
|
||||||
if (this.inputPromptVisible) {
|
if (this.inputPromptVisible) {
|
||||||
clearLine(this.inputReadlineOutStream, 0)
|
clearLine(this.inputReadlineOutStream, 0)
|
||||||
|
this.outputToTerminal.next(Buffer.from('\r'))
|
||||||
this.inputPromptVisible = false
|
this.inputPromptVisible = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user