Move range updating to DirtyRowService
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { IBufferService, ICoreService, ILogService, IOptionsService, ITerminalOptions, IPartialTerminalOptions } from 'common/services/Services';
|
||||
import { IBufferService, ICoreService, ILogService, IOptionsService, ITerminalOptions, IPartialTerminalOptions, IDirtyRowService } from 'common/services/Services';
|
||||
import { IEvent, EventEmitter } from 'common/EventEmitter';
|
||||
import { clone } from 'common/Clone';
|
||||
import { DEFAULT_OPTIONS } from 'common/services/OptionsService';
|
||||
@@ -36,6 +36,15 @@ export class MockCoreService implements ICoreService {
|
||||
triggerDataEvent(data: string, wasUserInput?: boolean): void {}
|
||||
}
|
||||
|
||||
export class MockDirtyRowService implements IDirtyRowService {
|
||||
start: number = 0;
|
||||
end: number = 0;
|
||||
clearRange(): void {}
|
||||
markDirty(y: number): void {}
|
||||
markRangeDirty(y1: number, y2: number): void {}
|
||||
markAllDirty(): void {}
|
||||
}
|
||||
|
||||
export class MockLogService implements ILogService {
|
||||
debug(message: any, ...optionalParams: any[]): void {}
|
||||
info(message: any, ...optionalParams: any[]): void {}
|
||||
|
||||
Vendored
+5
@@ -153,3 +153,8 @@ export interface IMarker extends IDisposable {
|
||||
export interface IDecPrivateModes {
|
||||
applicationCursorKeys: boolean;
|
||||
}
|
||||
|
||||
export interface IRowRange {
|
||||
start: number;
|
||||
end: number;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Copyright (c) 2019 The xterm.js authors. All rights reserved.
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { IBufferService, IDirtyRowService } from 'common/services/Services';
|
||||
|
||||
export class DirtyRowService implements IDirtyRowService {
|
||||
private _start!: number;
|
||||
private _end!: number;
|
||||
|
||||
public get start(): number { return this._start; }
|
||||
public get end(): number { return this._end; }
|
||||
|
||||
constructor(
|
||||
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);
|
||||
}
|
||||
}
|
||||
Vendored
+10
@@ -38,6 +38,16 @@ export interface ICoreService {
|
||||
triggerDataEvent(data: string, wasUserInput?: boolean): void;
|
||||
}
|
||||
|
||||
export interface IDirtyRowService {
|
||||
readonly start: number;
|
||||
readonly end: number;
|
||||
|
||||
clearRange(): void;
|
||||
markDirty(y: number): void;
|
||||
markRangeDirty(y1: number, y2: number): void;
|
||||
markAllDirty(): void;
|
||||
}
|
||||
|
||||
export interface ILogService {
|
||||
debug(message: any, ...optionalParams: any[]): void;
|
||||
info(message: any, ...optionalParams: any[]): void;
|
||||
|
||||
Reference in New Issue
Block a user