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