Merge branch 'master' into feature/lint-by-putout
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
import { IBufferService, IOptionsService } from 'common/services/Services';
|
||||
import { BufferSet } from 'common/buffer/BufferSet';
|
||||
import { IBufferSet, IBuffer } from 'common/buffer/Types';
|
||||
import { EventEmitter, IEvent } from 'common/EventEmitter';
|
||||
import { EventEmitter, IEventEmitter, IEvent, initEvent } from 'common/EventEmitter';
|
||||
import { Disposable } from 'common/Lifecycle';
|
||||
import { IAttributeData, IBufferLine, ScrollSource } from 'common/Types';
|
||||
|
||||
@@ -22,10 +22,8 @@ export class BufferService extends Disposable implements IBufferService {
|
||||
/** Whether the user is scrolling (locks the scroll position) */
|
||||
public isUserScrolling: boolean = false;
|
||||
|
||||
private _onResize = new EventEmitter<{ cols: number, rows: number }>();
|
||||
public get onResize(): IEvent<{ cols: number, rows: number }> { return this._onResize.event; }
|
||||
private _onScroll = new EventEmitter<number>();
|
||||
public get onScroll(): IEvent<number> { return this._onScroll.event; }
|
||||
public readonly onResize = initEvent<{ cols: number, rows: number }>();
|
||||
public readonly onScroll = initEvent<number>();
|
||||
|
||||
public get buffer(): IBuffer { return this.buffers.active; }
|
||||
|
||||
@@ -49,7 +47,7 @@ export class BufferService extends Disposable implements IBufferService {
|
||||
this.rows = rows;
|
||||
this.buffers.resize(cols, rows);
|
||||
this.buffers.setupTabStops(this.cols);
|
||||
this._onResize.fire({ cols, rows });
|
||||
this.onResize.fire({ cols, rows });
|
||||
}
|
||||
|
||||
public reset(): void {
|
||||
@@ -118,7 +116,7 @@ export class BufferService extends Disposable implements IBufferService {
|
||||
buffer.ydisp = buffer.ybase;
|
||||
}
|
||||
|
||||
this._onScroll.fire(buffer.ydisp);
|
||||
this.onScroll.fire(buffer.ydisp);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,7 +146,7 @@ export class BufferService extends Disposable implements IBufferService {
|
||||
}
|
||||
|
||||
if (!suppressScrollEvent) {
|
||||
this._onScroll.fire(buffer.ydisp);
|
||||
this.onScroll.fire(buffer.ydisp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* @license MIT
|
||||
*/
|
||||
import { IBufferService, ICoreService, ICoreMouseService } from 'common/services/Services';
|
||||
import { EventEmitter, IEvent } from 'common/EventEmitter';
|
||||
import { EventEmitter, IEvent, initEvent } from 'common/EventEmitter';
|
||||
import { ICoreMouseProtocol, ICoreMouseEvent, CoreMouseEncoding, CoreMouseEventType, CoreMouseButton, CoreMouseAction } from 'common/Types';
|
||||
|
||||
/**
|
||||
@@ -170,9 +170,10 @@ export class CoreMouseService implements ICoreMouseService {
|
||||
private _encodings: { [name: string]: CoreMouseEncoding } = {};
|
||||
private _activeProtocol: string = '';
|
||||
private _activeEncoding: string = '';
|
||||
private _onProtocolChange = new EventEmitter<CoreMouseEventType>();
|
||||
private _lastEvent: ICoreMouseEvent | null = null;
|
||||
|
||||
public readonly onProtocolChange = initEvent<CoreMouseEventType>();
|
||||
|
||||
constructor(
|
||||
@IBufferService private readonly _bufferService: IBufferService,
|
||||
@ICoreService private readonly _coreService: ICoreService
|
||||
@@ -205,7 +206,7 @@ export class CoreMouseService implements ICoreMouseService {
|
||||
throw new Error(`unknown protocol "${name}"`);
|
||||
}
|
||||
this._activeProtocol = name;
|
||||
this._onProtocolChange.fire(this._protocols[name].events);
|
||||
this.onProtocolChange.fire(this._protocols[name].events);
|
||||
}
|
||||
|
||||
public get activeEncoding(): string {
|
||||
@@ -225,13 +226,6 @@ export class CoreMouseService implements ICoreMouseService {
|
||||
this._lastEvent = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event to announce changes in mouse tracking.
|
||||
*/
|
||||
public get onProtocolChange(): IEvent<CoreMouseEventType> {
|
||||
return this._onProtocolChange.event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers a mouse event to be sent.
|
||||
*
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import { ICoreService, ILogService, IOptionsService, IBufferService } from 'common/services/Services';
|
||||
import { EventEmitter, IEvent } from 'common/EventEmitter';
|
||||
import { EventEmitter, IEvent, initEvent } from 'common/EventEmitter';
|
||||
import { IDecPrivateModes, IModes } from 'common/Types';
|
||||
import { clone } from 'common/Clone';
|
||||
import { Disposable } from 'common/Lifecycle';
|
||||
@@ -34,12 +34,9 @@ export class CoreService extends Disposable implements ICoreService {
|
||||
// Circular dependency, this must be unset or memory will leak after Terminal.dispose
|
||||
private _scrollToBottom: (() => void) | undefined;
|
||||
|
||||
private _onData = this.register(new EventEmitter<string>());
|
||||
public get onData(): IEvent<string> { return this._onData.event; }
|
||||
private _onUserInput = this.register(new EventEmitter<void>());
|
||||
public get onUserInput(): IEvent<void> { return this._onUserInput.event; }
|
||||
private _onBinary = this.register(new EventEmitter<string>());
|
||||
public get onBinary(): IEvent<string> { return this._onBinary.event; }
|
||||
public readonly onData = this.register(initEvent<string>());
|
||||
public readonly onUserInput = this.register(initEvent<void>());
|
||||
public readonly onBinary = this.register(initEvent<string>());
|
||||
|
||||
constructor(
|
||||
// TODO: Move this into a service
|
||||
@@ -74,12 +71,12 @@ export class CoreService extends Disposable implements ICoreService {
|
||||
|
||||
// Fire onUserInput so listeners can react as well (eg. clear selection)
|
||||
if (wasUserInput) {
|
||||
this._onUserInput.fire();
|
||||
this.onUserInput.fire();
|
||||
}
|
||||
|
||||
// Fire onData API
|
||||
this._logService.debug(`sending data "${data}"`, () => data.split('').map(e => e.charCodeAt(0)));
|
||||
this._onData.fire(data);
|
||||
this.onData.fire(data);
|
||||
}
|
||||
|
||||
public triggerBinaryEvent(data: string): void {
|
||||
@@ -87,6 +84,6 @@ export class CoreService extends Disposable implements ICoreService {
|
||||
return;
|
||||
}
|
||||
this._logService.debug(`sending binary "${data}"`, () => data.split('').map(e => e.charCodeAt(0)));
|
||||
this._onBinary.fire(data);
|
||||
this.onBinary.fire(data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,18 +4,16 @@
|
||||
*/
|
||||
|
||||
import { css } from 'common/Color';
|
||||
import { EventEmitter } from 'common/EventEmitter';
|
||||
import { EventEmitter, initEvent } from 'common/EventEmitter';
|
||||
import { Disposable } from 'common/Lifecycle';
|
||||
import { IDecorationService, IInternalDecoration } from 'common/services/Services';
|
||||
import { SortedList } from 'common/SortedList';
|
||||
import { IColor } from 'common/Types';
|
||||
import { IDecorationOptions, IDecoration, IMarker, IEvent } from 'xterm';
|
||||
|
||||
/** Work variables to avoid garbage collection. */
|
||||
const w = {
|
||||
xmin: 0,
|
||||
xmax: 0
|
||||
};
|
||||
// Work variables to avoid garbage collection
|
||||
let $xmin = 0;
|
||||
let $xmax = 0;
|
||||
|
||||
export class DecorationService extends Disposable implements IDecorationService {
|
||||
public serviceBrand: any;
|
||||
@@ -27,10 +25,8 @@ export class DecorationService extends Disposable implements IDecorationService
|
||||
*/
|
||||
private readonly _decorations: SortedList<IInternalDecoration> = new SortedList(e => e?.marker.line);
|
||||
|
||||
private _onDecorationRegistered = this.register(new EventEmitter<IInternalDecoration>());
|
||||
public get onDecorationRegistered(): IEvent<IInternalDecoration> { return this._onDecorationRegistered.event; }
|
||||
private _onDecorationRemoved = this.register(new EventEmitter<IInternalDecoration>());
|
||||
public get onDecorationRemoved(): IEvent<IInternalDecoration> { return this._onDecorationRemoved.event; }
|
||||
public readonly onDecorationRegistered = this.register(initEvent<IInternalDecoration>());
|
||||
public readonly onDecorationRemoved = this.register(initEvent<IInternalDecoration>());
|
||||
|
||||
public get decorations(): IterableIterator<IInternalDecoration> { return this._decorations.values(); }
|
||||
|
||||
@@ -44,13 +40,13 @@ export class DecorationService extends Disposable implements IDecorationService
|
||||
decoration.onDispose(() => {
|
||||
if (decoration) {
|
||||
if (this._decorations.delete(decoration)) {
|
||||
this._onDecorationRemoved.fire(decoration);
|
||||
this.onDecorationRemoved.fire(decoration);
|
||||
}
|
||||
markerDispose.dispose();
|
||||
}
|
||||
});
|
||||
this._decorations.insert(decoration);
|
||||
this._onDecorationRegistered.fire(decoration);
|
||||
this.onDecorationRegistered.fire(decoration);
|
||||
}
|
||||
return decoration;
|
||||
}
|
||||
@@ -76,9 +72,9 @@ export class DecorationService extends Disposable implements IDecorationService
|
||||
|
||||
public forEachDecorationAtCell(x: number, line: number, layer: 'bottom' | 'top' | undefined, callback: (decoration: IInternalDecoration) => void): void {
|
||||
this._decorations.forEachByKey(line, d => {
|
||||
w.xmin = d.options.x ?? 0;
|
||||
w.xmax = w.xmin + (d.options.width ?? 1);
|
||||
if (x >= w.xmin && x < w.xmax && (!layer || (d.options.layer ?? 'bottom') === layer)) {
|
||||
$xmin = d.options.x ?? 0;
|
||||
$xmax = $xmin + (d.options.width ?? 1);
|
||||
if (x >= $xmin && x < $xmax && (!layer || (d.options.layer ?? 'bottom') === layer)) {
|
||||
callback(d);
|
||||
}
|
||||
});
|
||||
@@ -86,7 +82,7 @@ export class DecorationService extends Disposable implements IDecorationService
|
||||
|
||||
public dispose(): void {
|
||||
for (const d of this._decorations.values()) {
|
||||
this._onDecorationRemoved.fire(d);
|
||||
this.onDecorationRemoved.fire(d);
|
||||
}
|
||||
this.reset();
|
||||
}
|
||||
@@ -97,10 +93,8 @@ class Decoration extends Disposable implements IInternalDecoration {
|
||||
public element: HTMLElement | undefined;
|
||||
public isDisposed: boolean = false;
|
||||
|
||||
public readonly onRenderEmitter = this.register(new EventEmitter<HTMLElement>());
|
||||
public readonly onRender = this.onRenderEmitter.event;
|
||||
private _onDispose = this.register(new EventEmitter<void>());
|
||||
public readonly onDispose = this._onDispose.event;
|
||||
public readonly onRender = this.register(initEvent<HTMLElement>());
|
||||
public readonly onDispose = this.register(initEvent<void>());
|
||||
|
||||
private _cachedBg: IColor | undefined | null = null;
|
||||
public get backgroundColorRGB(): IColor | undefined {
|
||||
@@ -141,7 +135,7 @@ class Decoration extends Disposable implements IInternalDecoration {
|
||||
return;
|
||||
}
|
||||
this._isDisposed = true;
|
||||
this._onDispose.fire();
|
||||
this.onDispose.fire();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2019 The xterm.js authors. All rights reserved.
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { IBufferService, IDirtyRowService } from 'common/services/Services';
|
||||
|
||||
export class DirtyRowService implements IDirtyRowService {
|
||||
public serviceBrand: any;
|
||||
|
||||
private _start!: number;
|
||||
private _end!: number;
|
||||
|
||||
public get start(): number { return this._start; }
|
||||
public get end(): number { return this._end; }
|
||||
|
||||
constructor(
|
||||
@IBufferService private readonly _bufferService: IBufferService
|
||||
) {
|
||||
this.clearRange();
|
||||
}
|
||||
|
||||
public clearRange(): void {
|
||||
this._start = this._bufferService.buffer.y;
|
||||
this._end = this._bufferService.buffer.y;
|
||||
}
|
||||
|
||||
public markDirty(y: number): void {
|
||||
if (y < this._start) {
|
||||
this._start = y;
|
||||
} else if (y > this._end) {
|
||||
this._end = y;
|
||||
}
|
||||
}
|
||||
|
||||
public markRangeDirty(y1: number, y2: number): void {
|
||||
if (y1 > y2) {
|
||||
const temp = y1;
|
||||
y1 = y2;
|
||||
y2 = temp;
|
||||
}
|
||||
if (y1 < this._start) {
|
||||
this._start = y1;
|
||||
}
|
||||
if (y2 > this._end) {
|
||||
this._end = y2;
|
||||
}
|
||||
}
|
||||
|
||||
public markAllDirty(): void {
|
||||
this.markRangeDirty(0, this._bufferService.rows - 1);
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,9 @@
|
||||
*/
|
||||
|
||||
import { IOptionsService, ITerminalOptions, FontWeight } from 'common/services/Services';
|
||||
import { EventEmitter, IEvent } from 'common/EventEmitter';
|
||||
import { isMac } from 'common/Platform';
|
||||
import { CursorStyle } from 'common/Types';
|
||||
import { initEvent } from 'common/EventEmitter';
|
||||
|
||||
export const DEFAULT_OPTIONS: Readonly<Required<ITerminalOptions>> = {
|
||||
cols: 80,
|
||||
@@ -57,8 +57,7 @@ export class OptionsService implements IOptionsService {
|
||||
public readonly rawOptions: Required<ITerminalOptions>;
|
||||
public options: Required<ITerminalOptions>;
|
||||
|
||||
private _onOptionChange = new EventEmitter<string>();
|
||||
public get onOptionChange(): IEvent<string> { return this._onOptionChange.event; }
|
||||
public readonly onOptionChange = initEvent<string>();
|
||||
|
||||
constructor(options: Partial<ITerminalOptions>) {
|
||||
// set the default value of each option
|
||||
@@ -97,7 +96,7 @@ export class OptionsService implements IOptionsService {
|
||||
// Don't fire an option change event if they didn't change
|
||||
if (this.rawOptions[propName] !== value) {
|
||||
this.rawOptions[propName] = value;
|
||||
this._onOptionChange.fire(propName);
|
||||
this.onOptionChange.fire(propName);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { IEvent, IEventEmitter } from 'common/EventEmitter';
|
||||
import { IEvent, IEventEmitter, IEventWithEmitter } from 'common/EventEmitter';
|
||||
import { IBuffer, IBufferSet } from 'common/buffer/Types';
|
||||
import { IDecPrivateModes, ICoreMouseEvent, CoreMouseEncoding, ICoreMouseProtocol, CoreMouseEventType, ICharset, IWindowOptions, IModes, IAttributeData, ScrollSource, IDisposable, IColor, CursorStyle, IOscLinkData } from 'common/Types';
|
||||
import { createDecorator } from 'common/services/ServiceRegistry';
|
||||
@@ -122,19 +122,6 @@ export interface ICharsetService {
|
||||
setgCharset(g: number, charset: ICharset | undefined): void;
|
||||
}
|
||||
|
||||
export const IDirtyRowService = createDecorator<IDirtyRowService>('DirtyRowService');
|
||||
export interface IDirtyRowService {
|
||||
serviceBrand: undefined;
|
||||
|
||||
readonly start: number;
|
||||
readonly end: number;
|
||||
|
||||
clearRange(): void;
|
||||
markDirty(y: number): void;
|
||||
markRangeDirty(y1: number, y2: number): void;
|
||||
markAllDirty(): void;
|
||||
}
|
||||
|
||||
export interface IServiceIdentifier<T> {
|
||||
(...args: any[]): void;
|
||||
type: T;
|
||||
@@ -331,5 +318,5 @@ export interface IInternalDecoration extends IDecoration {
|
||||
readonly options: IDecorationOptions;
|
||||
readonly backgroundColorRGB: IColor | undefined;
|
||||
readonly foregroundColorRGB: IColor | undefined;
|
||||
readonly onRenderEmitter: IEventEmitter<HTMLElement>;
|
||||
readonly onRender: IEventWithEmitter<HTMLElement>;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* @license MIT
|
||||
*/
|
||||
import { IUnicodeService, IUnicodeVersionProvider } from 'common/services/Services';
|
||||
import { EventEmitter, IEvent } from 'common/EventEmitter';
|
||||
import { EventEmitter, IEvent, initEvent } from 'common/EventEmitter';
|
||||
import { UnicodeV6 } from 'common/input/UnicodeV6';
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ export class UnicodeService implements IUnicodeService {
|
||||
private _providers: {[key: string]: IUnicodeVersionProvider} = Object.create(null);
|
||||
private _active: string = '';
|
||||
private _activeProvider: IUnicodeVersionProvider;
|
||||
private _onChange = new EventEmitter<string>();
|
||||
public get onChange(): IEvent<string> { return this._onChange.event; }
|
||||
|
||||
public readonly onChange = initEvent<string>();
|
||||
|
||||
constructor() {
|
||||
const defaultProvider = new UnicodeV6();
|
||||
@@ -37,7 +37,7 @@ export class UnicodeService implements IUnicodeService {
|
||||
}
|
||||
this._active = version;
|
||||
this._activeProvider = this._providers[version];
|
||||
this._onChange.fire(version);
|
||||
this.onChange.fire(version);
|
||||
}
|
||||
|
||||
public register(provider: IUnicodeVersionProvider): void {
|
||||
|
||||
Reference in New Issue
Block a user