mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-20 02:18:01 +00:00
fixed #5862 - configurable Backspace behaviour
This commit is contained in:
@@ -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}}
|
@@ -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
|
||||
}
|
||||
}
|
@@ -18,6 +18,7 @@ import { StreamProcessingSettingsComponent } from './components/streamProcessing
|
||||
import { LoginScriptsSettingsComponent } from './components/loginScriptsSettings.component'
|
||||
import { TerminalToolbarComponent } from './components/terminalToolbar.component'
|
||||
import { ColorSchemeSelectorComponent } from './components/colorSchemeSelector.component'
|
||||
import { InputProcessingSettingsComponent } from './components/inputProcessingSettings.component'
|
||||
|
||||
import { TerminalDecorator } from './api/decorator'
|
||||
import { TerminalContextMenuItemProvider } from './api/contextMenuProvider'
|
||||
@@ -76,6 +77,7 @@ import { DefaultColorSchemes } from './colorSchemes'
|
||||
StreamProcessingSettingsComponent,
|
||||
LoginScriptsSettingsComponent,
|
||||
TerminalToolbarComponent,
|
||||
InputProcessingSettingsComponent,
|
||||
],
|
||||
exports: [
|
||||
ColorPickerComponent,
|
||||
@@ -84,6 +86,7 @@ import { DefaultColorSchemes } from './colorSchemes'
|
||||
StreamProcessingSettingsComponent,
|
||||
LoginScriptsSettingsComponent,
|
||||
TerminalToolbarComponent,
|
||||
InputProcessingSettingsComponent,
|
||||
],
|
||||
})
|
||||
export default class TerminalModule { } // eslint-disable-line @typescript-eslint/no-extraneous-class
|
||||
@@ -97,6 +100,7 @@ export * from './middleware/streamProcessing'
|
||||
export * from './middleware/loginScriptProcessing'
|
||||
export * from './middleware/oscProcessing'
|
||||
export * from './middleware/utf8Splitter'
|
||||
export * from './middleware/inputProcessing'
|
||||
export * from './api/middleware'
|
||||
export * from './session'
|
||||
export { LoginScriptsSettingsComponent, StreamProcessingSettingsComponent }
|
||||
|
28
tabby-terminal/src/middleware/inputProcessing.ts
Normal file
28
tabby-terminal/src/middleware/inputProcessing.ts
Normal file
@@ -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)
|
||||
}
|
||||
}
|
@@ -73,11 +73,6 @@ export class LoginScriptProcessor extends SessionMiddleware {
|
||||
super.feedFromSession(data)
|
||||
}
|
||||
|
||||
close (): void {
|
||||
this.outputToSession.complete()
|
||||
super.close()
|
||||
}
|
||||
|
||||
executeUnconditionalScripts (): void {
|
||||
for (const script of this.remainingScripts) {
|
||||
if (!script.expect) {
|
||||
|
Reference in New Issue
Block a user