explicit member visibility

This commit is contained in:
Jörg Breitbart
2018-08-27 17:01:30 +02:00
parent 6576d513b0
commit f964a34b34
+21 -11
View File
@@ -28,7 +28,8 @@ export class TerminalLine {
} }
private _data: CharData[]; private _data: CharData[];
public isWrapped = false; public isWrapped = false;
length: number; public length: number;
constructor(cols?: number, ch?: CharData, isWrapped?: boolean) { constructor(cols?: number, ch?: CharData, isWrapped?: boolean) {
this._data = []; this._data = [];
this.length = this._data.length; this.length = this._data.length;
@@ -38,56 +39,65 @@ export class TerminalLine {
} }
if (isWrapped) this.isWrapped = true; if (isWrapped) this.isWrapped = true;
} }
get(index: number): CharData {
public get(index: number): CharData {
return this._data[index]; return this._data[index];
} }
set(index: number, data: CharData): void {
public set(index: number, data: CharData): void {
this._data[index] = data; this._data[index] = data;
// TODO: unref old, ref new // TODO: unref old, ref new
} }
// to be removed for typed array // to be removed for typed array
pop(): CharData | undefined { public pop(): CharData | undefined {
// TODO: unref here, change CharData to [typeof Attributes, ...] // TODO: unref here, change CharData to [typeof Attributes, ...]
const data = this._data.pop(); const data = this._data.pop();
this.length = this._data.length; this.length = this._data.length;
return data; return data;
} }
// to be removed for typed array // to be removed for typed array
push(data: CharData): void { public push(data: CharData): void {
this._data.push(data); this._data.push(data);
this.length = this._data.length; this.length = this._data.length;
// TODO: ref here // TODO: ref here
} }
// to be removed for typed array // to be removed for typed array
splice(start: number, deleteCount: number, ...items: CharData[]): CharData[] { public splice(start: number, deleteCount: number, ...items: CharData[]): CharData[] {
const removed = this._data.splice(start, deleteCount, ...items); const removed = this._data.splice(start, deleteCount, ...items);
this.length = this._data.length; this.length = this._data.length;
// TODO: ref new, unref old // TODO: ref new, unref old
return removed; return removed;
} }
/** to be called when a line gets removed */ /** to be called when a line gets removed */
release(): void { public release(): void {
// TODO: unref here // TODO: unref here
} }
toArray(): CharData[] { public toArray(): CharData[] {
return this._data; return this._data;
} }
/** insert n cells ch at pos, right cells are lost (stable length) */ /** insert n cells ch at pos, right cells are lost (stable length) */
insertCells(pos: number, n: number, ch: CharData): void { public insertCells(pos: number, n: number, ch: CharData): void {
while (n--) { while (n--) {
this.splice(pos, 0, ch); this.splice(pos, 0, ch);
this.pop(); this.pop();
} }
} }
/** delete n cells at pos, right side is filled with fill (stable length) */ /** delete n cells at pos, right side is filled with fill (stable length) */
deleteCells(pos: number, n: number, fill: CharData): void { public deleteCells(pos: number, n: number, fill: CharData): void {
while (n--) { while (n--) {
this.splice(pos, 1); this.splice(pos, 1);
this.push(fill); this.push(fill);
} }
} }
/** replace cells from pos to pos + n - 1 with fill */ /** replace cells from pos to pos + n - 1 with fill */
replaceCells(start: number, end: number, fill: CharData): void { public replaceCells(start: number, end: number, fill: CharData): void {
while (start < end && start < this.length) this.set(start++, fill); // Note: fill is not cloned while (start < end && start < this.length) this.set(start++, fill); // Note: fill is not cloned
} }
} }