Skip to content

Commit

Permalink
fixed visual layout of readline prompts
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugeny committed Jul 12, 2021
1 parent 3be98e6 commit 8f55333
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions tabby-terminal/src/api/streamProcessing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
}
}
Expand Down

0 comments on commit 8f55333

Please sign in to comment.