本文整理匯總了TypeScript中vs/editor/common/editorCommon.IModel.getLineMaxColumn方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript IModel.getLineMaxColumn方法的具體用法?TypeScript IModel.getLineMaxColumn怎麽用?TypeScript IModel.getLineMaxColumn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vs/editor/common/editorCommon.IModel
的用法示例。
在下文中一共展示了IModel.getLineMaxColumn方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: _cursorMoveMessage
private static _cursorMoveMessage(source: string, model: IModel, oldPosition: Position, newPosition: Position): string {
if (source === 'moveWordCommand') {
return model.getValueInRange(new Range(oldPosition.lineNumber, oldPosition.column, newPosition.lineNumber, newPosition.column));
}
const oldLineNumber = oldPosition.lineNumber;
const oldColumn = oldPosition.column;
const newLineNumber = newPosition.lineNumber;
const newColumn = newPosition.column;
// check going down via right arrow
if (newLineNumber === oldLineNumber + 1 && newColumn === 1 && oldColumn === model.getLineMaxColumn(oldLineNumber)) {
return this._cursorCharMessage(model, newPosition);
}
// check going up via up arrow
if (newLineNumber === oldLineNumber - 1 && newColumn === model.getLineMaxColumn(newLineNumber) && oldColumn === 1) {
return this._cursorCharMessage(model, newPosition);
}
const lineCount = model.getLineCount();
if (oldLineNumber !== newLineNumber) {
if (newLineNumber === lineCount) {
// Last line does not have an EOL
return model.getLineContent(newLineNumber);
}
return model.getLineContent(newLineNumber) + model.getEOL();
}
return this._cursorCharMessage(model, newPosition);
}
示例2: getLinesRangeWithOneSurroundingNewline
function getLinesRangeWithOneSurroundingNewline(model: IModel, startLine: number, endLine: number): Range {
let startColumn = 1;
let endColumn = model.getLineMaxColumn(endLine);
if (endLine < model.getLineCount()) {
endLine++;
endColumn = 1;
} else if (startLine > 1) {
startLine--;
startColumn = model.getLineMaxColumn(startLine);
}
return new Range(startLine, startColumn, endLine, endColumn);
}
示例3: applyChangesToModel
export function applyChangesToModel(original: IModel, modified: IModel, changes: IChange[]): string {
sortChanges(changes);
var result = '';
var positionInOriginal = 1;
for (var i = 0; i < changes.length; ++i) {
// We have to update orginalStartLineNumber for insertions, their start line is always one line behind.
var originalStartLineUpdated = isInsertion(changes[i]) ? changes[i].originalStartLineNumber + 1 : changes[i].originalStartLineNumber;
if (positionInOriginal < originalStartLineUpdated) {
result = appendValueFromRange(result, original,
new Range(positionInOriginal, 1, originalStartLineUpdated - 1, original.getLineMaxColumn(originalStartLineUpdated - 1)));
positionInOriginal = originalStartLineUpdated;
}
if (!isDeletion(changes[i])) {
result = appendValueFromRange(result, modified,
new Range(changes[i].modifiedStartLineNumber, 1, changes[i].modifiedEndLineNumber, modified.getLineMaxColumn(changes[i].modifiedEndLineNumber)));
}
// Update position in the original file where we continue to concatanate.
// Only update position if it was not an insertion.
if (!isInsertion(changes[i])) {
positionInOriginal = changes[i].originalEndLineNumber + 1;
}
}
// Append the last chunk after all the changes.
if (positionInOriginal <= original.getLineCount()) {
result = appendValueFromRange(result, original,
new Range(positionInOriginal, 1, original.getLineCount(), original.getLineMaxColumn(original.getLineCount())));
}
return result;
}
示例4: _delete
protected _delete(wordSeparators: WordCharacterClassifier, model: IModel, selection: Selection, whitespaceHeuristics: boolean, wordNavigationType: WordNavigationType): Range {
let r = WordOperations.deleteWordRight(wordSeparators, model, selection, whitespaceHeuristics, wordNavigationType);
if (r) {
return r;
}
const lineCount = model.getLineCount();
const maxColumn = model.getLineMaxColumn(lineCount);
return new Range(lineCount, maxColumn, lineCount, maxColumn);
}
示例5: _cursorCharMessage
private static _cursorCharMessage(model: IModel, position: Position): string {
const lineNumber = position.lineNumber;
const column = position.column;
const maxLineColumn = model.getLineMaxColumn(lineNumber);
if (column === maxLineColumn) {
const lineCount = model.getLineCount();
if (lineNumber === lineCount) {
// At the end of the file
return '';
}
return model.getEOL();
}
return model.getLineContent(lineNumber).charAt(column - 1);
}
示例6: getDeleteOperation
return changes.map((change, i) => {
if (isInsertion(change)) {
// Delete inserted range
return getDeleteOperation(change);
} else if (isDeletion(change)) {
// Get the original lines and insert at the deleted position
const value = original.getValueInRange(getLinesRangeWithOneSurroundingNewline(original, change.originalStartLineNumber, change.originalEndLineNumber));
return EditOperation.insert(new Position(change.modifiedStartLineNumber + 1, 1), value);
} else if (change.isCompletelySelected) {
// If the entire change is selected, then revert the whole thing.
const value = original.getValueInRange(new Range(change.originalStartLineNumber, 1, change.originalEndLineNumber + 1, 1));
return EditOperation.replace(new Range(change.modifiedStartLineNumber, 1, change.modifiedEndLineNumber + 1, 1), value);
} else {
// If only a portion is selected, replace with the matching lines - e.g. if lines 2-4 are selected, replace with lines 2-4 from the original model (if they exist)
const copyOffset = change.modifiedStartLineNumber - change.fullModifiedStartLineNumber;
const numLinesToCopy = change.modifiedEndLineNumber - change.modifiedStartLineNumber;
const copyStartLine = change.originalStartLineNumber + copyOffset;
const copyEndLine = Math.min(copyStartLine + numLinesToCopy, original.getLineCount());
if (copyStartLine > copyEndLine) {
return getDeleteOperation(change);
}
// Compute the range to copy, and intersect with the full original range to validate
const originalRange = new Range(change.originalStartLineNumber, 1, change.originalEndLineNumber, original.getLineMaxColumn(change.originalEndLineNumber));
const rangeToCopy = originalRange.intersectRanges(
new Range(copyStartLine, 1, copyEndLine, original.getLineMaxColumn(copyEndLine)));
// No intersection, so delete the added text
if (!rangeToCopy) {
return getDeleteOperation(change);
}
const value = original.getValueInRange(rangeToCopy);
return EditOperation.replace(new Range(change.modifiedStartLineNumber, 1, change.modifiedEndLineNumber, modified.getLineMaxColumn(change.modifiedEndLineNumber)), value);
}
});