import { ITerminal } from './Interfaces';
+/**
+ * Represents a selection within the buffer. This model only cares about column
+ * and row coordinates, not wide characters.
+ */
export class SelectionModel {
/**
* Whether select all is currently active.
return this.selectionStart;
}
- return this._areSelectionValuesReversed() ? this.selectionEnd : this.selectionStart;
+ return this.areSelectionValuesReversed() ? this.selectionEnd : this.selectionStart;
}
/**
*/
public get finalSelectionEnd(): [number, number] {
if (this.isSelectAllActive) {
- return [this._terminal.cols - 1, this._terminal.ybase + this._terminal.rows - 1];
+ return [this._terminal.cols, this._terminal.ybase + this._terminal.rows - 1];
}
if (!this.selectionStart) {
}
// Use the selection start if the end doesn't exist or they're reversed
- if (!this.selectionEnd || this._areSelectionValuesReversed()) {
- if (this.selectionStartLength === 0) {
- return null;
- }
+ if (!this.selectionEnd || this.areSelectionValuesReversed()) {
return [this.selectionStart[0] + this.selectionStartLength, this.selectionStart[1]];
}
/**
* Returns whether the selection start and end are reversed.
*/
- protected _areSelectionValuesReversed(): boolean {
+ public areSelectionValuesReversed(): boolean {
const start = this.selectionStart;
const end = this.selectionEnd;
return start[1] > end[1] || (start[1] === end[1] && start[0] > end[0]);