Merge branch 'master' into remove_ee

This commit is contained in:
Daniel Imms
2019-06-08 21:45:30 -07:00
7 changed files with 42 additions and 18 deletions
+1 -1
View File
@@ -6,7 +6,7 @@
import { ITerminal, ISelectionManager, ISelectionRedrawRequestEvent } from './Types'; import { ITerminal, ISelectionManager, ISelectionRedrawRequestEvent } from './Types';
import { IBuffer } from 'common/buffer/Types'; import { IBuffer } from 'common/buffer/Types';
import { IBufferLine } from 'common/Types'; import { IBufferLine } from 'common/Types';
import { MouseHelper } from './browser/input/MouseHelper'; import { MouseHelper } from 'browser/input/MouseHelper';
import * as Browser from 'common/Platform'; import * as Browser from 'common/Platform';
import { SelectionModel } from './SelectionModel'; import { SelectionModel } from './SelectionModel';
import { AltClickHandler } from './handlers/AltClickHandler'; import { AltClickHandler } from './handlers/AltClickHandler';
+10 -12
View File
@@ -23,8 +23,6 @@
import { IInputHandlingTerminal, IViewport, ICompositionHelper, ITerminalOptions, ITerminal, IBrowser, ILinkifier, ILinkMatcherOptions, CustomKeyEventHandler, LinkMatcherHandler, IMouseZoneManager } from './Types'; import { IInputHandlingTerminal, IViewport, ICompositionHelper, ITerminalOptions, ITerminal, IBrowser, ILinkifier, ILinkMatcherOptions, CustomKeyEventHandler, LinkMatcherHandler, IMouseZoneManager } from './Types';
import { IRenderer, CharacterJoinerHandler } from 'browser/renderer/Types'; import { IRenderer, CharacterJoinerHandler } from 'browser/renderer/Types';
import { BufferSet } from 'common/buffer/BufferSet';
import { Buffer } from 'common/buffer/Buffer';
import { CompositionHelper } from './CompositionHelper'; import { CompositionHelper } from './CompositionHelper';
import { Viewport } from './Viewport'; import { Viewport } from './Viewport';
import { rightClickHandler, moveTextAreaUnderMouseCursor, pasteHandler, copyHandler } from './Clipboard'; import { rightClickHandler, moveTextAreaUnderMouseCursor, pasteHandler, copyHandler } from './Clipboard';
@@ -36,7 +34,7 @@ import { SelectionManager } from './SelectionManager';
import * as Browser from 'common/Platform'; import * as Browser from 'common/Platform';
import { addDisposableDomListener } from 'browser/Lifecycle'; import { addDisposableDomListener } from 'browser/Lifecycle';
import * as Strings from './Strings'; import * as Strings from './Strings';
import { MouseHelper } from './browser/input/MouseHelper'; import { MouseHelper } from 'browser/input/MouseHelper';
import { SoundManager } from './SoundManager'; import { SoundManager } from './SoundManager';
import { MouseZoneManager } from './MouseZoneManager'; import { MouseZoneManager } from './MouseZoneManager';
import { AccessibilityManager } from './AccessibilityManager'; import { AccessibilityManager } from './AccessibilityManager';
@@ -56,6 +54,7 @@ import { ICharSizeService } from 'browser/services/Services';
import { CharSizeService } from 'browser/services/CharSizeService'; import { CharSizeService } from 'browser/services/CharSizeService';
import { BufferService, MINIMUM_COLS, MINIMUM_ROWS } from 'common/services/BufferService'; import { BufferService, MINIMUM_COLS, MINIMUM_ROWS } from 'common/services/BufferService';
import { Disposable } from 'common/Lifecycle'; import { Disposable } from 'common/Lifecycle';
import { IBufferSet, IBuffer } from 'common/buffer/Types';
// Let it work inside Node.js for automated testing purposes. // Let it work inside Node.js for automated testing purposes.
const document = (typeof window !== 'undefined') ? window.document : null; const document = (typeof window !== 'undefined') ? window.document : null;
@@ -174,7 +173,6 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
public soundManager: SoundManager; public soundManager: SoundManager;
public selectionManager: SelectionManager; public selectionManager: SelectionManager;
public linkifier: ILinkifier; public linkifier: ILinkifier;
public buffers: BufferSet;
public viewport: IViewport; public viewport: IViewport;
private _compositionHelper: ICompositionHelper; private _compositionHelper: ICompositionHelper;
private _mouseZoneManager: IMouseZoneManager; private _mouseZoneManager: IMouseZoneManager;
@@ -235,14 +233,11 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
) { ) {
super(); super();
// Initialize common services // Setup and initialize common services
this.optionsService = new OptionsService(options); this.optionsService = new OptionsService(options);
this._bufferService = new BufferService(this.optionsService);
this._setupOptionsListeners(); this._setupOptionsListeners();
// this.options = clone(options);
this._setup(); this._setup();
this._bufferService = new BufferService(this.optionsService);
} }
public dispose(): void { public dispose(): void {
@@ -309,8 +304,6 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
this._mouseZoneManager = this._mouseZoneManager || null; this._mouseZoneManager = this._mouseZoneManager || null;
this.soundManager = this.soundManager || new SoundManager(this); this.soundManager = this.soundManager || new SoundManager(this);
// Create the terminal's buffers and set the current buffer
this.buffers = new BufferSet(this.optionsService, this._bufferService);
if (this.selectionManager) { if (this.selectionManager) {
this.selectionManager.clearSelection(); this.selectionManager.clearSelection();
this.selectionManager.initBuffersListeners(); this.selectionManager.initBuffersListeners();
@@ -324,10 +317,14 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
/** /**
* Convenience property to active buffer. * Convenience property to active buffer.
*/ */
public get buffer(): Buffer { public get buffer(): IBuffer {
return this.buffers.active; return this.buffers.active;
} }
public get buffers(): IBufferSet {
return this._bufferService.buffers;
}
/** /**
* back_color_erase feature for xterm. * back_color_erase feature for xterm.
*/ */
@@ -1884,6 +1881,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
const userScrolling = this._userScrolling; const userScrolling = this._userScrolling;
this._setup(); this._setup();
this._bufferService.reset();
// reattach // reattach
this._customKeyEventHandler = customKeyEventHandler; this._customKeyEventHandler = customKeyEventHandler;
+4
View File
@@ -312,6 +312,10 @@ export class MockInputHandlingTerminal implements IInputHandlingTerminal {
} }
export class MockBuffer implements IBuffer { export class MockBuffer implements IBuffer {
markers: IMarker[];
addMarker(y: number): IMarker {
throw new Error('Method not implemented.');
}
isCursorInViewport: boolean; isCursorInViewport: boolean;
lines: ICircularList<IBufferLine>; lines: ICircularList<IBufferLine>;
ydisp: number; ydisp: number;
+4
View File
@@ -7,8 +7,11 @@ import { IBufferService, IOptionsService, ITerminalOptions, IPartialTerminalOpti
import { IEvent, EventEmitter } from 'common/EventEmitter'; import { IEvent, EventEmitter } from 'common/EventEmitter';
import { clone } from 'common/Clone'; 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';
export class MockBufferService implements IBufferService { export class MockBufferService implements IBufferService {
public buffer: IBuffer = {} as any;
public buffers: IBufferSet = {} as any;
constructor( constructor(
public cols: number, public cols: number,
public rows: number public rows: number
@@ -17,6 +20,7 @@ export class MockBufferService implements IBufferService {
this.cols = cols; this.cols = cols;
this.rows = rows; this.rows = rows;
} }
reset(): void {}
} }
export class MockOptionsService implements IOptionsService { export class MockOptionsService implements IOptionsService {
+5 -1
View File
@@ -3,7 +3,7 @@
* @license MIT * @license MIT
*/ */
import { IAttributeData, ICircularList, IBufferLine, ICellData } from 'common/Types'; import { IAttributeData, ICircularList, IBufferLine, ICellData, IMarker } from 'common/Types';
import { IEvent } from 'common/EventEmitter'; import { IEvent } from 'common/EventEmitter';
// BufferIndex denotes a position in the buffer: [rowIndex, colIndex] // BufferIndex denotes a position in the buffer: [rowIndex, colIndex]
@@ -33,6 +33,7 @@ export interface IBuffer {
savedX: number; savedX: number;
savedCurAttrData: IAttributeData; savedCurAttrData: IAttributeData;
isCursorInViewport: boolean; isCursorInViewport: boolean;
markers: IMarker[];
translateBufferLineToString(lineIndex: number, trimRight: boolean, startCol?: number, endCol?: number): string; translateBufferLineToString(lineIndex: number, trimRight: boolean, startCol?: number, endCol?: number): string;
getWrappedRangeForLine(y: number): { first: number, last: number }; getWrappedRangeForLine(y: number): { first: number, last: number };
nextStop(x?: number): number; nextStop(x?: number): number;
@@ -42,6 +43,7 @@ export interface IBuffer {
iterator(trimRight: boolean, startIndex?: number, endIndex?: number, startOverscan?: number, endOverscan?: number): IBufferStringIterator; iterator(trimRight: boolean, startIndex?: number, endIndex?: number, startOverscan?: number, endOverscan?: number): IBufferStringIterator;
getNullCell(attr?: IAttributeData): ICellData; getNullCell(attr?: IAttributeData): ICellData;
getWhitespaceCell(attr?: IAttributeData): ICellData; getWhitespaceCell(attr?: IAttributeData): ICellData;
addMarker(y: number): IMarker;
} }
export interface IBufferSet { export interface IBufferSet {
@@ -53,4 +55,6 @@ export interface IBufferSet {
activateNormalBuffer(): void; activateNormalBuffer(): void;
activateAltBuffer(fillAttr?: IAttributeData): void; activateAltBuffer(fillAttr?: IAttributeData): void;
resize(newCols: number, newRows: number): void;
setupTabStops(i?: number): void;
} }
+14 -4
View File
@@ -3,7 +3,9 @@
* @license MIT * @license MIT
*/ */
import { IBufferService, IOptionsService } from './Services'; import { IBufferService, IOptionsService } from 'common/services/Services';
import { BufferSet } from 'common/buffer/BufferSet';
import { IBufferSet, IBuffer } from 'common/buffer/Types';
export const MINIMUM_COLS = 2; // Less than 2 can mess with wide chars export const MINIMUM_COLS = 2; // Less than 2 can mess with wide chars
export const MINIMUM_ROWS = 1; export const MINIMUM_ROWS = 1;
@@ -11,16 +13,24 @@ export const MINIMUM_ROWS = 1;
export class BufferService implements IBufferService { export class BufferService implements IBufferService {
public cols: number; public cols: number;
public rows: number; public rows: number;
public buffers: IBufferSet;
public get buffer(): IBuffer { return this.buffers.active; }
constructor( constructor(
optionsService: IOptionsService private _optionsService: IOptionsService
) { ) {
this.cols = Math.max(optionsService.options.cols, MINIMUM_COLS); this.cols = Math.max(_optionsService.options.cols, MINIMUM_COLS);
this.rows = Math.max(optionsService.options.rows, MINIMUM_ROWS); this.rows = Math.max(_optionsService.options.rows, MINIMUM_ROWS);
this.buffers = new BufferSet(_optionsService, this);
} }
public resize(cols: number, rows: number): void { public resize(cols: number, rows: number): void {
this.cols = cols; this.cols = cols;
this.rows = rows; this.rows = rows;
} }
public reset(): void {
this.buffers = new BufferSet(this._optionsService, this);
}
} }
+4
View File
@@ -4,14 +4,18 @@
*/ */
import { IEvent } from 'common/EventEmitter'; import { IEvent } from 'common/EventEmitter';
import { IBuffer, IBufferSet } from 'common/buffer/Types';
export interface IBufferService { export interface IBufferService {
readonly cols: number; readonly cols: number;
readonly rows: number; readonly rows: number;
readonly buffer: IBuffer;
readonly buffers: IBufferSet;
// TODO: Move resize event here // TODO: Move resize event here
resize(cols: number, rows: number): void; resize(cols: number, rows: number): void;
reset(): void;
} }
export interface IOptionsService { export interface IOptionsService {