mirror of
https://github.com/Eugeny/tabby
synced 2024-11-14 17:07:15 +00:00
fixed visual layout of readline prompts
This commit is contained in:
parent
3be98e6244
commit
8f55333d23
1 changed files with 11 additions and 11 deletions
|
@ -33,19 +33,9 @@ export class TerminalStreamProcessor {
|
|||
constructor (private options: StreamProcessingOptions) {
|
||||
this.inputReadlineInStream = 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.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(() => {
|
||||
if (this.started) {
|
||||
this.onOutputSettled()
|
||||
|
@ -54,14 +44,24 @@ export class TerminalStreamProcessor {
|
|||
}
|
||||
|
||||
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.onOutputSettled()
|
||||
}
|
||||
|
||||
feedFromSession (data: Buffer): void {
|
||||
if (this.options.inputMode?.startsWith('readline')) {
|
||||
if (this.inputPromptVisible) {
|
||||
clearLine(this.inputReadlineOutStream, 0)
|
||||
this.outputToTerminal.next(Buffer.from('\r'))
|
||||
this.inputPromptVisible = false
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue