-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed #5862 - configurable Backspace behaviour
- Loading branch information
Showing
15 changed files
with
109 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
tabby-terminal/src/components/inputProcessingSettings.component.pug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.form-line | ||
.header | ||
.title(translate) Backspace key mode | ||
|
||
select.form-control([(ngModel)]='options.backspace') | ||
option( | ||
*ngFor='let mode of backspaceModes', | ||
[value]='mode.key', | ||
) {{mode.name|translate}} |
40 changes: 40 additions & 0 deletions
40
tabby-terminal/src/components/inputProcessingSettings.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker' | ||
import { Component, Input } from '@angular/core' | ||
import { InputProcessingOptions } from '../middleware/inputProcessing' | ||
|
||
/** @hidden */ | ||
@Component({ | ||
selector: 'input-processing-settings', | ||
templateUrl: './inputProcessingSettings.component.pug', | ||
}) | ||
export class InputProcessingSettingsComponent { | ||
@Input() options: InputProcessingOptions | ||
|
||
backspaceModes = [ | ||
{ | ||
key: 'backspace', | ||
name: _('Pass-through'), | ||
}, | ||
{ | ||
key: 'ctrl-h', | ||
name: 'Ctrl-H', | ||
}, | ||
{ | ||
key: 'ctrl-?', | ||
name: 'Ctrl-?', | ||
}, | ||
{ | ||
key: 'delete', | ||
name: 'Delete (CSI 3~)', | ||
}, | ||
] | ||
|
||
getBackspaceModeName (key) { | ||
return this.backspaceModes.find(x => x.key === key)?.name | ||
} | ||
|
||
setBackspaceMode (mode) { | ||
this.options.backspace = mode | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { SessionMiddleware } from '../api/middleware' | ||
|
||
export interface InputProcessingOptions { | ||
backspace: 'ctrl-h'|'ctrl-?'|'delete'|'backspace' | ||
} | ||
|
||
export class InputProcessor extends SessionMiddleware { | ||
constructor ( | ||
private options: InputProcessingOptions, | ||
) { | ||
super() | ||
} | ||
|
||
feedFromTerminal (data: Buffer): void { | ||
if (data.length === 1 && data[0] === 0x7f) { | ||
if (this.options.backspace === 'ctrl-h') { | ||
data = Buffer.from('\x08') | ||
} else if (this.options.backspace === 'ctrl-?') { | ||
data = Buffer.from('\x7f') | ||
} else if (this.options.backspace === 'delete') { | ||
data = Buffer.from('\x1b[3~') | ||
} else { | ||
data = Buffer.from('\x7f') | ||
} | ||
} | ||
this.outputToSession.next(data) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters