本文整理汇总了TypeScript中vs/editor/common/viewModel/prefixSumComputer.PrefixSumComputer类的典型用法代码示例。如果您正苦于以下问题:TypeScript PrefixSumComputer类的具体用法?TypeScript PrefixSumComputer怎么用?TypeScript PrefixSumComputer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PrefixSumComputer类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getRangeAt
public getRangeAt(offset: number, length: number): Range {
const startResult = this._lineStarts.getIndexOf(offset);
const startLineLength = this._lines[startResult.index].length;
const startColumn = Math.min(startResult.remainder + 1, startLineLength + 1);
const endResult = this._lineStarts.getIndexOf(offset + length);
const endLineLength = this._lines[endResult.index].length;
const endColumn = Math.min(endResult.remainder + 1, endLineLength + 1);
return new Range(startResult.index + 1, startColumn, endResult.index + 1, endColumn);
}
示例2: _acceptDeleteRange
private _acceptDeleteRange(range: IRange): void {
if (range.startLineNumber === range.endLineNumber) {
if (range.startColumn === range.endColumn) {
// Nothing to delete
return;
}
// Delete text on the affected line
this._setLineText(range.startLineNumber - 1,
this._lines[range.startLineNumber - 1].substring(0, range.startColumn - 1)
+ this._lines[range.startLineNumber - 1].substring(range.endColumn - 1)
);
return;
}
// Take remaining text on last line and append it to remaining text on first line
this._setLineText(range.startLineNumber - 1,
this._lines[range.startLineNumber - 1].substring(0, range.startColumn - 1)
+ this._lines[range.endLineNumber - 1].substring(range.endColumn - 1)
);
// Delete middle lines
this._lines.splice(range.startLineNumber, range.endLineNumber - range.startLineNumber);
if (this._lineStarts) {
// update prefix sum
this._lineStarts.removeValues(range.startLineNumber, range.endLineNumber - range.startLineNumber);
}
}
示例3: convertInputPositionToOutputPosition
public convertInputPositionToOutputPosition(inputLineNumber: number, inputColumn: number): editorCommon.IEditorPosition {
this._ensureValidState();
if (inputLineNumber > this.lines.length) {
inputLineNumber = this.lines.length;
}
let lineIndex = inputLineNumber - 1, lineIndexChanged = false;
while (lineIndex > 0 && !this.lines[lineIndex].isVisible()) {
lineIndex--;
lineIndexChanged = true;
}
if (lineIndex === 0 && !this.lines[lineIndex].isVisible()) {
// Could not reach a real line
return new Position(1, 1);
}
var deltaLineNumber = 1 + (lineIndex === 0 ? 0 : this.prefixSumComputer.getAccumulatedValue(lineIndex - 1));
var r:editorCommon.IEditorPosition;
if (lineIndexChanged) {
r = this.lines[lineIndex].getOutputPositionOfInputPosition(deltaLineNumber, this.model.getLineMaxColumn(lineIndex + 1));
} else {
r = this.lines[inputLineNumber - 1].getOutputPositionOfInputPosition(deltaLineNumber, inputColumn);
}
// console.log('in -> out ' + inputLineNumber + ',' + inputColumn + ' ===> ' + r.lineNumber + ',' + r.column);
return r;
}
示例4: convertInputPositionToOutputPosition
public convertInputPositionToOutputPosition(_inputLineNumber: number, _inputColumn: number): Position {
this._ensureValidState();
let validPosition = this.model.validatePosition(new Position(_inputLineNumber, _inputColumn));
let inputLineNumber = validPosition.lineNumber;
let inputColumn = validPosition.column;
let lineIndex = inputLineNumber - 1, lineIndexChanged = false;
while (lineIndex > 0 && !this.lines[lineIndex].isVisible()) {
lineIndex--;
lineIndexChanged = true;
}
if (lineIndex === 0 && !this.lines[lineIndex].isVisible()) {
// Could not reach a real line
// console.log('in -> out ' + inputLineNumber + ',' + inputColumn + ' ===> ' + 1 + ',' + 1);
return new Position(1, 1);
}
let deltaLineNumber = 1 + (lineIndex === 0 ? 0 : this.prefixSumComputer.getAccumulatedValue(lineIndex - 1));
let r:Position;
if (lineIndexChanged) {
r = this.lines[lineIndex].getOutputPositionOfInputPosition(deltaLineNumber, this.model.getLineMaxColumn(lineIndex + 1));
} else {
r = this.lines[inputLineNumber - 1].getOutputPositionOfInputPosition(deltaLineNumber, inputColumn);
}
// console.log('in -> out ' + inputLineNumber + ',' + inputColumn + ' ===> ' + r.lineNumber + ',' + r);
return r;
}
示例5: getInputOffsetOfOutputPosition
public getInputOffsetOfOutputPosition(outputLineIndex: number, outputOffset: number): number {
if (outputLineIndex === 0) {
return outputOffset;
} else {
return this._prefixSums.getAccumulatedValue(outputLineIndex - 1) + outputOffset;
}
}
示例6: _setLineText
/**
* All changes to a line's text go through this method
*/
private _setLineText(lineIndex:number, newValue:string): void {
this._lines[lineIndex] = newValue;
if (this._lineStarts) {
// update prefix sum
this._lineStarts.changeValue(lineIndex, this._lines[lineIndex].length + this._eol.length);
}
}
示例7: getOutputLineMaxColumn
public getOutputLineMaxColumn(outputLineNumber: number): number {
this._ensureValidState();
this.prefixSumComputer.getIndexOf(outputLineNumber - 1, this.tmpIndexOfResult);
var lineIndex = this.tmpIndexOfResult.index;
var remainder = this.tmpIndexOfResult.remainder;
return this.lines[lineIndex].getOutputLineMaxColumn(this.model, lineIndex + 1, remainder);
}
示例8: getOutputLineTokens
public getOutputLineTokens(outputLineNumber: number, inaccurateTokensAcceptable: boolean): editorCommon.IViewLineTokens {
this._ensureValidState();
this.prefixSumComputer.getIndexOf(outputLineNumber - 1, this.tmpIndexOfResult);
var lineIndex = this.tmpIndexOfResult.index;
var remainder = this.tmpIndexOfResult.remainder;
return this.lines[lineIndex].getOutputLineTokens(this.model, lineIndex + 1, remainder, inaccurateTokensAcceptable);
}
示例9: getOutputLineTokens
public getOutputLineTokens(outputLineNumber: number): editorCommon.ViewLineTokens {
this._ensureValidState();
outputLineNumber = this._toValidOutputLineNumber(outputLineNumber);
let r = this.prefixSumComputer.getIndexOf(outputLineNumber - 1);
let lineIndex = r.index;
let remainder = r.remainder;
return this.lines[lineIndex].getOutputLineTokens(this.model, lineIndex + 1, remainder);
}
示例10: getOutputLineMaxColumn
public getOutputLineMaxColumn(outputLineNumber: number): number {
this._ensureValidState();
outputLineNumber = this._toValidOutputLineNumber(outputLineNumber);
let r = this.prefixSumComputer.getIndexOf(outputLineNumber - 1);
let lineIndex = r.index;
let remainder = r.remainder;
return this.lines[lineIndex].getOutputLineMaxColumn(this.model, lineIndex + 1, remainder);
}