Move applicationCursor into core service
This commit is contained in:
+3
-3
@@ -1299,7 +1299,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
|||||||
} else if (collect === '?') {
|
} else if (collect === '?') {
|
||||||
switch (params[0]) {
|
switch (params[0]) {
|
||||||
case 1:
|
case 1:
|
||||||
this._terminal.applicationCursor = true;
|
this._coreService.decPrivateModes.applicationCursorKeys = true;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
this._terminal.setgCharset(0, DEFAULT_CHARSET);
|
this._terminal.setgCharset(0, DEFAULT_CHARSET);
|
||||||
@@ -1504,7 +1504,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
|||||||
} else if (collect === '?') {
|
} else if (collect === '?') {
|
||||||
switch (params[0]) {
|
switch (params[0]) {
|
||||||
case 1:
|
case 1:
|
||||||
this._terminal.applicationCursor = false;
|
this._coreService.decPrivateModes.applicationCursorKeys = false;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if (this._terminal.cols === 132 && this._terminal.savedCols) {
|
if (this._terminal.cols === 132 && this._terminal.savedCols) {
|
||||||
@@ -1852,7 +1852,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
|||||||
if (this._terminal.viewport) {
|
if (this._terminal.viewport) {
|
||||||
this._terminal.viewport.syncScrollArea();
|
this._terminal.viewport.syncScrollArea();
|
||||||
}
|
}
|
||||||
this._terminal.applicationCursor = false;
|
this._coreService.decPrivateModes.applicationCursorKeys = false;
|
||||||
this._terminal.buffer.scrollTop = 0;
|
this._terminal.buffer.scrollTop = 0;
|
||||||
this._terminal.buffer.scrollBottom = this._terminal.rows - 1;
|
this._terminal.buffer.scrollBottom = this._terminal.rows - 1;
|
||||||
this._terminal.curAttrData = DEFAULT_ATTR_DATA.clone();
|
this._terminal.curAttrData = DEFAULT_ATTR_DATA.clone();
|
||||||
|
|||||||
@@ -665,7 +665,7 @@ export class SelectionManager implements ISelectionManager {
|
|||||||
false
|
false
|
||||||
);
|
);
|
||||||
if (coordinates && coordinates[0] !== undefined && coordinates[1] !== undefined) {
|
if (coordinates && coordinates[0] !== undefined && coordinates[1] !== undefined) {
|
||||||
const sequence = moveToCellSequence(coordinates[0] - 1, coordinates[1] - 1, this._bufferService, this._terminal.applicationCursor);
|
const sequence = moveToCellSequence(coordinates[0] - 1, coordinates[1] - 1, this._bufferService, this._coreService.decPrivateModes.applicationCursorKeys);
|
||||||
this._coreService.triggerDataEvent(sequence, true);
|
this._coreService.triggerDataEvent(sequence, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-4
@@ -118,7 +118,6 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
|
|||||||
|
|
||||||
// modes
|
// modes
|
||||||
public applicationKeypad: boolean;
|
public applicationKeypad: boolean;
|
||||||
public applicationCursor: boolean;
|
|
||||||
public originMode: boolean;
|
public originMode: boolean;
|
||||||
public insertMode: boolean;
|
public insertMode: boolean;
|
||||||
public wraparoundMode: boolean; // defaults: xterm - true, vt100 - false
|
public wraparoundMode: boolean; // defaults: xterm - true, vt100 - false
|
||||||
@@ -269,7 +268,6 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
|
|||||||
|
|
||||||
// modes
|
// modes
|
||||||
this.applicationKeypad = false;
|
this.applicationKeypad = false;
|
||||||
this.applicationCursor = false;
|
|
||||||
this.originMode = false;
|
this.originMode = false;
|
||||||
this.insertMode = false;
|
this.insertMode = false;
|
||||||
this.wraparoundMode = true; // defaults: xterm - true, vt100 - false
|
this.wraparoundMode = true; // defaults: xterm - true, vt100 - false
|
||||||
@@ -1013,7 +1011,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Construct and send sequences
|
// Construct and send sequences
|
||||||
const sequence = C0.ESC + (this.applicationCursor ? 'O' : '[') + ( ev.deltaY < 0 ? 'A' : 'B');
|
const sequence = C0.ESC + (this._coreService.decPrivateModes.applicationCursorKeys ? 'O' : '[') + ( ev.deltaY < 0 ? 'A' : 'B');
|
||||||
let data = '';
|
let data = '';
|
||||||
for (let i = 0; i < Math.abs(amount); i++) {
|
for (let i = 0; i < Math.abs(amount); i++) {
|
||||||
data += sequence;
|
data += sequence;
|
||||||
@@ -1555,7 +1553,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = evaluateKeyboardEvent(event, this.applicationCursor, this.browser.isMac, this.options.macOptionIsMeta);
|
const result = evaluateKeyboardEvent(event, this._coreService.decPrivateModes.applicationCursorKeys, this.browser.isMac, this.options.macOptionIsMeta);
|
||||||
|
|
||||||
this.updateCursorStyle(event);
|
this.updateCursorStyle(event);
|
||||||
|
|
||||||
@@ -1885,6 +1883,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
|
|||||||
|
|
||||||
this._setup();
|
this._setup();
|
||||||
this._bufferService.reset();
|
this._bufferService.reset();
|
||||||
|
this._coreService.reset();
|
||||||
|
|
||||||
// reattach
|
// reattach
|
||||||
this._customKeyEventHandler = customKeyEventHandler;
|
this._customKeyEventHandler = customKeyEventHandler;
|
||||||
|
|||||||
Vendored
-2
@@ -33,7 +33,6 @@ export interface IInputHandlingTerminal {
|
|||||||
glevel: number;
|
glevel: number;
|
||||||
charsets: ICharset[];
|
charsets: ICharset[];
|
||||||
applicationKeypad: boolean;
|
applicationKeypad: boolean;
|
||||||
applicationCursor: boolean;
|
|
||||||
originMode: boolean;
|
originMode: boolean;
|
||||||
insertMode: boolean;
|
insertMode: boolean;
|
||||||
wraparoundMode: boolean;
|
wraparoundMode: boolean;
|
||||||
@@ -206,7 +205,6 @@ export interface ITerminal extends IPublicTerminal, IElementAccessor, IBufferAcc
|
|||||||
isFocused: boolean;
|
isFocused: boolean;
|
||||||
viewport: IViewport;
|
viewport: IViewport;
|
||||||
bracketedPasteMode: boolean;
|
bracketedPasteMode: boolean;
|
||||||
applicationCursor: boolean;
|
|
||||||
optionsService: IOptionsService;
|
optionsService: IOptionsService;
|
||||||
// TODO: We should remove options once components adopt optionsService
|
// TODO: We should remove options once components adopt optionsService
|
||||||
options: ITerminalOptions;
|
options: ITerminalOptions;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { clone } from 'common/Clone';
|
|||||||
import { DEFAULT_OPTIONS } from 'common/services/OptionsService';
|
import { DEFAULT_OPTIONS } from 'common/services/OptionsService';
|
||||||
import { IBufferSet, IBuffer } from 'common/buffer/Types';
|
import { IBufferSet, IBuffer } from 'common/buffer/Types';
|
||||||
import { BufferSet } from 'common/buffer/BufferSet';
|
import { BufferSet } from 'common/buffer/BufferSet';
|
||||||
|
import { IDecPrivateModes } from 'common/Types';
|
||||||
|
|
||||||
export class MockBufferService implements IBufferService {
|
export class MockBufferService implements IBufferService {
|
||||||
public get buffer(): IBuffer { return this.buffers.active; }
|
public get buffer(): IBuffer { return this.buffers.active; }
|
||||||
@@ -28,8 +29,10 @@ export class MockBufferService implements IBufferService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class MockCoreService implements ICoreService {
|
export class MockCoreService implements ICoreService {
|
||||||
|
decPrivateModes: IDecPrivateModes = {} as any;
|
||||||
onData: IEvent<string> = new EventEmitter<string>().event;
|
onData: IEvent<string> = new EventEmitter<string>().event;
|
||||||
onUserInput: IEvent<void> = new EventEmitter<void>().event;
|
onUserInput: IEvent<void> = new EventEmitter<void>().event;
|
||||||
|
reset(): void {}
|
||||||
triggerDataEvent(data: string, wasUserInput?: boolean): void {}
|
triggerDataEvent(data: string, wasUserInput?: boolean): void {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
+4
@@ -149,3 +149,7 @@ export interface IMarker extends IDisposable {
|
|||||||
readonly isDisposed: boolean;
|
readonly isDisposed: boolean;
|
||||||
readonly line: number;
|
readonly line: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IDecPrivateModes {
|
||||||
|
applicationCursorKeys: boolean;
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,8 +5,16 @@
|
|||||||
|
|
||||||
import { ICoreService, IOptionsService, IBufferService } from 'common/services/Services';
|
import { ICoreService, IOptionsService, IBufferService } from 'common/services/Services';
|
||||||
import { EventEmitter, IEvent } from 'common/EventEmitter';
|
import { EventEmitter, IEvent } from 'common/EventEmitter';
|
||||||
|
import { IDecPrivateModes } from 'common/Types';
|
||||||
|
import { clone } from 'common/Clone';
|
||||||
|
|
||||||
|
const DEFAULT_DEC_PRIVATE_MODES: IDecPrivateModes = Object.freeze({
|
||||||
|
applicationCursorKeys: false
|
||||||
|
});
|
||||||
|
|
||||||
export class CoreService implements ICoreService {
|
export class CoreService implements ICoreService {
|
||||||
|
public decPrivateModes: IDecPrivateModes;
|
||||||
|
|
||||||
private _onData = new EventEmitter<string>();
|
private _onData = new EventEmitter<string>();
|
||||||
public get onData(): IEvent<string> { return this._onData.event; }
|
public get onData(): IEvent<string> { return this._onData.event; }
|
||||||
private _onUserInput = new EventEmitter<void>();
|
private _onUserInput = new EventEmitter<void>();
|
||||||
@@ -18,6 +26,11 @@ export class CoreService implements ICoreService {
|
|||||||
private readonly _bufferService: IBufferService,
|
private readonly _bufferService: IBufferService,
|
||||||
private readonly _optionsService: IOptionsService
|
private readonly _optionsService: IOptionsService
|
||||||
) {
|
) {
|
||||||
|
this.decPrivateModes = clone(DEFAULT_DEC_PRIVATE_MODES);
|
||||||
|
}
|
||||||
|
|
||||||
|
public reset(): void {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public triggerDataEvent(data: string, wasUserInput: boolean = false): void {
|
public triggerDataEvent(data: string, wasUserInput: boolean = false): void {
|
||||||
|
|||||||
Vendored
+5
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
import { IEvent } from 'common/EventEmitter';
|
import { IEvent } from 'common/EventEmitter';
|
||||||
import { IBuffer, IBufferSet } from 'common/buffer/Types';
|
import { IBuffer, IBufferSet } from 'common/buffer/Types';
|
||||||
|
import { IDecPrivateModes } from 'common/Types';
|
||||||
|
|
||||||
export interface IBufferService {
|
export interface IBufferService {
|
||||||
readonly cols: number;
|
readonly cols: number;
|
||||||
@@ -19,9 +20,13 @@ export interface IBufferService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ICoreService {
|
export interface ICoreService {
|
||||||
|
readonly decPrivateModes: IDecPrivateModes;
|
||||||
|
|
||||||
readonly onData: IEvent<string>;
|
readonly onData: IEvent<string>;
|
||||||
readonly onUserInput: IEvent<void>;
|
readonly onUserInput: IEvent<void>;
|
||||||
|
|
||||||
|
reset(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Triggers the onData event in the public API.
|
* Triggers the onData event in the public API.
|
||||||
* @param data The data that is being emitted.
|
* @param data The data that is being emitted.
|
||||||
|
|||||||
Reference in New Issue
Block a user