mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Undo CiruclarList id changes, fix null check, lint
This commit is contained in:
+6
-2
@@ -365,11 +365,15 @@ export class Renderer {
|
||||
this._terminal.selectionContainer.appendChild(documentFragment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a selection element at the specified position.
|
||||
* @param row The row of the selection.
|
||||
* @param colStart The start column.
|
||||
* @param colEnd The end columns.
|
||||
*/
|
||||
private _createSelectionElement(row: number, colStart: number, colEnd: number): HTMLElement {
|
||||
const element = document.createElement('div');
|
||||
// TODO: Move into a generated <style> element
|
||||
element.style.height = `${this._terminal.charMeasure.height}px`;
|
||||
|
||||
element.style.top = `${row * this._terminal.charMeasure.height}px`;
|
||||
element.style.left = `${colStart * this._terminal.charMeasure.width}px`;
|
||||
element.style.width = `${this._terminal.charMeasure.width * (colEnd - colStart)}px`;
|
||||
|
||||
@@ -7,7 +7,7 @@ import { ITerminal } from './Interfaces';
|
||||
import { CharMeasure } from './utils/CharMeasure';
|
||||
import { CircularList } from './utils/CircularList';
|
||||
import { SelectionManager } from './SelectionManager';
|
||||
import { SelectionModel } from "./SelectionModel";
|
||||
import { SelectionModel } from './SelectionModel';
|
||||
|
||||
class TestSelectionManager extends SelectionManager {
|
||||
constructor(
|
||||
|
||||
@@ -245,7 +245,6 @@ export class SelectionManager extends EventEmitter {
|
||||
*/
|
||||
private _getMouseBufferCoords(event: MouseEvent): [number, number] {
|
||||
const coords = Mouse.getCoords(event, this._rowContainer, this._charMeasure, this._terminal.cols, this._terminal.rows);
|
||||
console.log(coords);
|
||||
// Convert to 0-based
|
||||
coords[0]--;
|
||||
coords[1]--;
|
||||
@@ -285,7 +284,6 @@ export class SelectionManager extends EventEmitter {
|
||||
}
|
||||
|
||||
this._setMouseClickCount(event);
|
||||
console.log(this._clickCount);
|
||||
|
||||
if (event.shiftKey) {
|
||||
this._onShiftClick(event);
|
||||
@@ -424,9 +422,11 @@ export class SelectionManager extends EventEmitter {
|
||||
// If the character is a wide character include the cell to the right in the
|
||||
// selection. Note that selections at the very end of the line will never
|
||||
// have a character.
|
||||
const char = this._buffer.get(this._model.selectionEnd[1])[this._model.selectionEnd[0]];
|
||||
if (char && char[2] === 0) {
|
||||
this._model.selectionEnd[0]++;
|
||||
if (this._model.selectionEnd[1] < this._buffer.length) {
|
||||
const char = this._buffer.get(this._model.selectionEnd[1])[this._model.selectionEnd[0]];
|
||||
if (char && char[2] === 0) {
|
||||
this._model.selectionEnd[0]++;
|
||||
}
|
||||
}
|
||||
|
||||
// Only draw here if the selection changes.
|
||||
|
||||
@@ -6,22 +6,14 @@
|
||||
*/
|
||||
import { EventEmitter } from '../EventEmitter';
|
||||
|
||||
// TODO: Do we need the ID here?
|
||||
interface ListEntry<T> {
|
||||
id: number;
|
||||
value: T;
|
||||
}
|
||||
|
||||
export class CircularList<T> extends EventEmitter {
|
||||
private _array: ListEntry<T>[];
|
||||
private _array: T[];
|
||||
private _startIndex: number;
|
||||
private _length: number;
|
||||
|
||||
private _nextId = 0;
|
||||
|
||||
constructor(maxLength: number) {
|
||||
super();
|
||||
this._array = new Array<ListEntry<T>>(maxLength);
|
||||
this._array = new Array<T>(maxLength);
|
||||
this._startIndex = 0;
|
||||
this._length = 0;
|
||||
}
|
||||
@@ -33,14 +25,9 @@ export class CircularList<T> extends EventEmitter {
|
||||
public set maxLength(newMaxLength: number) {
|
||||
// Reconstruct array, starting at index 0. Only transfer values from the
|
||||
// indexes 0 to length.
|
||||
let newArray = new Array<ListEntry<T>>(newMaxLength);
|
||||
// Reset ids when maxLength is changed
|
||||
this._nextId = 0;
|
||||
let newArray = new Array<T>(newMaxLength);
|
||||
for (let i = 0; i < Math.min(newMaxLength, this.length); i++) {
|
||||
newArray[i] = {
|
||||
id: this._nextId++,
|
||||
value: this._array[this._getCyclicIndex(i)].value
|
||||
};
|
||||
newArray[i] = this._array[this._getCyclicIndex(i)];
|
||||
}
|
||||
this._array = newArray;
|
||||
this._startIndex = 0;
|
||||
@@ -78,10 +65,6 @@ export class CircularList<T> extends EventEmitter {
|
||||
* @return The value corresponding to the index.
|
||||
*/
|
||||
public get(index: number): T {
|
||||
return this.getEntry(index).value;
|
||||
}
|
||||
|
||||
public getEntry(index: number): ListEntry<T> {
|
||||
return this._array[this._getCyclicIndex(index)];
|
||||
}
|
||||
|
||||
@@ -94,11 +77,7 @@ export class CircularList<T> extends EventEmitter {
|
||||
* @param value The value to set.
|
||||
*/
|
||||
public set(index: number, value: T): void {
|
||||
this._array[this._getCyclicIndex(index)].value = value;
|
||||
}
|
||||
|
||||
private _setEntry(index: number, entry: ListEntry<T>): void {
|
||||
this._array[this._getCyclicIndex(index)] = entry;
|
||||
this._array[this._getCyclicIndex(index)] = value;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,10 +86,7 @@ export class CircularList<T> extends EventEmitter {
|
||||
* @param value The value to push onto the list.
|
||||
*/
|
||||
public push(value: T): void {
|
||||
this._array[this._getCyclicIndex(this._length)] = {
|
||||
id: this._nextId,
|
||||
value
|
||||
};
|
||||
this._array[this._getCyclicIndex(this._length)] = value;
|
||||
if (this._length === this.maxLength) {
|
||||
this._startIndex++;
|
||||
if (this._startIndex === this.maxLength) {
|
||||
@@ -127,7 +103,7 @@ export class CircularList<T> extends EventEmitter {
|
||||
* @return The popped value.
|
||||
*/
|
||||
public pop(): T {
|
||||
return this._array[this._getCyclicIndex(this._length-- - 1)].value;
|
||||
return this._array[this._getCyclicIndex(this._length-- - 1)];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,10 +130,7 @@ export class CircularList<T> extends EventEmitter {
|
||||
this._array[this._getCyclicIndex(i + items.length)] = this._array[this._getCyclicIndex(i)];
|
||||
}
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
this._array[this._getCyclicIndex(start + i)] = {
|
||||
id: this._nextId,
|
||||
value: items[i]
|
||||
};
|
||||
this._array[this._getCyclicIndex(start + i)] = items[i];
|
||||
}
|
||||
|
||||
// Adjust length as needed
|
||||
@@ -198,10 +171,7 @@ export class CircularList<T> extends EventEmitter {
|
||||
|
||||
if (offset > 0) {
|
||||
for (let i = count - 1; i >= 0; i--) {
|
||||
this._setEntry(start + i + offset, {
|
||||
id: this._nextId++,
|
||||
value: this.get(start + i)
|
||||
});
|
||||
this.set(start + i + offset, this.get(start + i));
|
||||
}
|
||||
const expandListBy = (start + count + offset) - this._length;
|
||||
if (expandListBy > 0) {
|
||||
|
||||
Reference in New Issue
Block a user