Support alt+Enter key signal by default
This commit is contained in:
@@ -1788,6 +1788,9 @@ export class InputHandler extends Disposable implements IInputHandler {
|
|||||||
case 25: // show cursor
|
case 25: // show cursor
|
||||||
this._coreService.isCursorHidden = false;
|
this._coreService.isCursorHidden = false;
|
||||||
break;
|
break;
|
||||||
|
case 1039:
|
||||||
|
this._coreService.decPrivateModes.altEnterMode = true;
|
||||||
|
break;
|
||||||
case 1048: // alt screen cursor
|
case 1048: // alt screen cursor
|
||||||
this.saveCursor();
|
this.saveCursor();
|
||||||
break;
|
break;
|
||||||
@@ -2003,6 +2006,9 @@ export class InputHandler extends Disposable implements IInputHandler {
|
|||||||
case 25: // hide cursor
|
case 25: // hide cursor
|
||||||
this._coreService.isCursorHidden = true;
|
this._coreService.isCursorHidden = true;
|
||||||
break;
|
break;
|
||||||
|
case 1039:
|
||||||
|
this._coreService.decPrivateModes.altEnterMode = false;
|
||||||
|
break;
|
||||||
case 1048: // alt screen cursor
|
case 1048: // alt screen cursor
|
||||||
this.restoreCursor();
|
this.restoreCursor();
|
||||||
break;
|
break;
|
||||||
|
|||||||
+1
-1
@@ -1222,7 +1222,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = evaluateKeyboardEvent(event, this._coreService.decPrivateModes.applicationCursorKeys, this.browser.isMac, this.options.macOptionIsMeta);
|
const result = evaluateKeyboardEvent(event, this._coreService.decPrivateModes.altEnterMode, this._coreService.decPrivateModes.applicationCursorKeys, this.browser.isMac, this.options.macOptionIsMeta);
|
||||||
|
|
||||||
this.updateCursorStyle(event);
|
this.updateCursorStyle(event);
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ export class MockCoreService implements ICoreService {
|
|||||||
isCursorHidden: boolean = false;
|
isCursorHidden: boolean = false;
|
||||||
isFocused: boolean = false;
|
isFocused: boolean = false;
|
||||||
decPrivateModes: IDecPrivateModes = {
|
decPrivateModes: IDecPrivateModes = {
|
||||||
|
altEnterMode: true,
|
||||||
applicationCursorKeys: false,
|
applicationCursorKeys: false,
|
||||||
applicationKeypad: false,
|
applicationKeypad: false,
|
||||||
origin: false,
|
origin: false,
|
||||||
|
|||||||
Vendored
+1
@@ -152,6 +152,7 @@ export interface IMarker extends IDisposable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface IDecPrivateModes {
|
export interface IDecPrivateModes {
|
||||||
|
altEnterMode: boolean;
|
||||||
applicationCursorKeys: boolean;
|
applicationCursorKeys: boolean;
|
||||||
applicationKeypad: boolean;
|
applicationKeypad: boolean;
|
||||||
origin: boolean;
|
origin: boolean;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ function testEvaluateKeyboardEvent(partialEvent: {
|
|||||||
key?: string;
|
key?: string;
|
||||||
type?: string;
|
type?: string;
|
||||||
}, partialOptions: {
|
}, partialOptions: {
|
||||||
|
altEnterMode?: boolean;
|
||||||
applicationCursorMode?: boolean;
|
applicationCursorMode?: boolean;
|
||||||
isMac?: boolean;
|
isMac?: boolean;
|
||||||
macOptionIsMeta?: boolean;
|
macOptionIsMeta?: boolean;
|
||||||
@@ -30,11 +31,12 @@ function testEvaluateKeyboardEvent(partialEvent: {
|
|||||||
type: partialEvent.type || ''
|
type: partialEvent.type || ''
|
||||||
};
|
};
|
||||||
const options = {
|
const options = {
|
||||||
|
altEnterMode: partialOptions.altEnterMode || true,
|
||||||
applicationCursorMode: partialOptions.applicationCursorMode || false,
|
applicationCursorMode: partialOptions.applicationCursorMode || false,
|
||||||
isMac: partialOptions.isMac || false,
|
isMac: partialOptions.isMac || false,
|
||||||
macOptionIsMeta: partialOptions.macOptionIsMeta || false
|
macOptionIsMeta: partialOptions.macOptionIsMeta || false
|
||||||
};
|
};
|
||||||
return evaluateKeyboardEvent(event, options.applicationCursorMode, options.isMac, options.macOptionIsMeta);
|
return evaluateKeyboardEvent(event, options.altEnterMode, options.applicationCursorMode, options.isMac, options.macOptionIsMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('Keyboard', () => {
|
describe('Keyboard', () => {
|
||||||
@@ -86,6 +88,9 @@ describe('Keyboard', () => {
|
|||||||
it('should return \\x1b[3;3~ for alt+delete', () => {
|
it('should return \\x1b[3;3~ for alt+delete', () => {
|
||||||
assert.equal(testEvaluateKeyboardEvent({ altKey: true, keyCode: 46 }).key, '\x1b[3;3~');
|
assert.equal(testEvaluateKeyboardEvent({ altKey: true, keyCode: 46 }).key, '\x1b[3;3~');
|
||||||
});
|
});
|
||||||
|
it('should return \\x1b\\r for alt+enter', () => {
|
||||||
|
assert.equal(testEvaluateKeyboardEvent({ altKey: true, keyCode: 13 }).key, '\x1b\r');
|
||||||
|
});
|
||||||
it('should return \\x1b[5D for ctrl+left', () => {
|
it('should return \\x1b[5D for ctrl+left', () => {
|
||||||
assert.equal(testEvaluateKeyboardEvent({ ctrlKey: true, keyCode: 37 }).key, '\x1b[1;5D'); // CSI 5 D
|
assert.equal(testEvaluateKeyboardEvent({ ctrlKey: true, keyCode: 37 }).key, '\x1b[1;5D'); // CSI 5 D
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ const KEYCODE_KEY_MAPPINGS: { [key: number]: [string, string]} = {
|
|||||||
|
|
||||||
export function evaluateKeyboardEvent(
|
export function evaluateKeyboardEvent(
|
||||||
ev: IKeyboardEvent,
|
ev: IKeyboardEvent,
|
||||||
|
altEnterMode: boolean,
|
||||||
applicationCursorMode: boolean,
|
applicationCursorMode: boolean,
|
||||||
isMac: boolean,
|
isMac: boolean,
|
||||||
macOptionIsMeta: boolean
|
macOptionIsMeta: boolean
|
||||||
@@ -103,7 +104,12 @@ export function evaluateKeyboardEvent(
|
|||||||
break;
|
break;
|
||||||
case 13:
|
case 13:
|
||||||
// return/enter
|
// return/enter
|
||||||
result.key = C0.CR;
|
if (altEnterMode && modifiers === 2) {
|
||||||
|
result.key = C0.ESC + C0.CR;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result.key = C0.CR;
|
||||||
|
}
|
||||||
result.cancel = true;
|
result.cancel = true;
|
||||||
break;
|
break;
|
||||||
case 27:
|
case 27:
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { IDecPrivateModes, ICharset } from 'common/Types';
|
|||||||
import { clone } from 'common/Clone';
|
import { clone } from 'common/Clone';
|
||||||
|
|
||||||
const DEFAULT_DEC_PRIVATE_MODES: IDecPrivateModes = Object.freeze({
|
const DEFAULT_DEC_PRIVATE_MODES: IDecPrivateModes = Object.freeze({
|
||||||
|
altEnterMode: true,
|
||||||
applicationCursorKeys: false,
|
applicationCursorKeys: false,
|
||||||
applicationKeypad: false,
|
applicationKeypad: false,
|
||||||
origin: false,
|
origin: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user