本文整理匯總了TypeScript中vs/editor/common/controller/cursorCommon.ICursorSimpleModel.getLineMaxColumn方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript ICursorSimpleModel.getLineMaxColumn方法的具體用法?TypeScript ICursorSimpleModel.getLineMaxColumn怎麽用?TypeScript ICursorSimpleModel.getLineMaxColumn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vs/editor/common/controller/cursorCommon.ICursorSimpleModel
的用法示例。
在下文中一共展示了ICursorSimpleModel.getLineMaxColumn方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: moveWordRight
public static moveWordRight(config: CursorConfiguration, model: ICursorSimpleModel, cursor: SingleCursorState, inSelectionMode: boolean, wordNavigationType: WordNavigationType): SingleMoveOperationResult {
let position = cursor.position;
let lineNumber = position.lineNumber;
let column = position.column;
if (column === model.getLineMaxColumn(lineNumber)) {
if (lineNumber < model.getLineCount()) {
lineNumber = lineNumber + 1;
column = 1;
}
}
let nextWordOnLine = WordOperations.findNextWordOnLine(config, model, new Position(lineNumber, column));
if (wordNavigationType === WordNavigationType.WordEnd) {
if (nextWordOnLine) {
column = nextWordOnLine.end + 1;
} else {
column = model.getLineMaxColumn(lineNumber);
}
} else {
if (nextWordOnLine && column >= nextWordOnLine.start + 1) {
nextWordOnLine = WordOperations.findNextWordOnLine(config, model, new Position(lineNumber, nextWordOnLine.end + 1));
}
if (nextWordOnLine) {
column = nextWordOnLine.start + 1;
} else {
column = model.getLineMaxColumn(lineNumber);
}
}
return SingleMoveOperationResult.fromMove(cursor, inSelectionMode, lineNumber, column, 0, true, CursorChangeReason.Explicit);
}
示例2: moveWordRight
public static moveWordRight(wordSeparators: WordCharacterClassifier, model: ICursorSimpleModel, position: Position, wordNavigationType: WordNavigationType): Position {
let lineNumber = position.lineNumber;
let column = position.column;
if (column === model.getLineMaxColumn(lineNumber)) {
if (lineNumber < model.getLineCount()) {
lineNumber = lineNumber + 1;
column = 1;
}
}
let nextWordOnLine = WordOperations._findNextWordOnLine(wordSeparators, model, new Position(lineNumber, column));
if (wordNavigationType === WordNavigationType.WordEnd) {
if (nextWordOnLine) {
column = nextWordOnLine.end + 1;
} else {
column = model.getLineMaxColumn(lineNumber);
}
} else {
if (nextWordOnLine && column >= nextWordOnLine.start + 1) {
nextWordOnLine = WordOperations._findNextWordOnLine(wordSeparators, model, new Position(lineNumber, nextWordOnLine.end + 1));
}
if (nextWordOnLine) {
column = nextWordOnLine.start + 1;
} else {
column = model.getLineMaxColumn(lineNumber);
}
}
return new Position(lineNumber, column);
}
示例3: down
public static down(config: CursorConfiguration, model: ICursorSimpleModel, lineNumber: number, column: number, leftoverVisibleColumns: number, count: number, allowMoveOnLastLine: boolean): CursorPosition {
const currentVisibleColumn = CursorColumns.visibleColumnFromColumn(model.getLineContent(lineNumber), column, config.tabSize) + leftoverVisibleColumns;
lineNumber = lineNumber + count;
let lineCount = model.getLineCount();
if (lineNumber > lineCount) {
lineNumber = lineCount;
if (allowMoveOnLastLine) {
column = model.getLineMaxColumn(lineNumber);
} else {
column = Math.min(model.getLineMaxColumn(lineNumber), column);
if (CursorColumns.isInsideSurrogatePair(model, lineNumber, column)) {
column = column - 1;
}
}
} else {
column = CursorColumns.columnFromVisibleColumn2(config, model, lineNumber, currentVisibleColumn);
if (CursorColumns.isInsideSurrogatePair(model, lineNumber, column)) {
column = column - 1;
}
}
leftoverVisibleColumns = currentVisibleColumn - CursorColumns.visibleColumnFromColumn(model.getLineContent(lineNumber), column, config.tabSize);
return new CursorPosition(lineNumber, column, leftoverVisibleColumns);
}
示例4: cut
public static cut(config: CursorConfiguration, model: ICursorSimpleModel, cursor: SingleCursorState, enableEmptySelectionClipboard: boolean): EditOperationResult {
let selection = cursor.selection;
if (selection.isEmpty()) {
if (enableEmptySelectionClipboard) {
// This is a full line cut
let position = cursor.position;
let startLineNumber: number,
startColumn: number,
endLineNumber: number,
endColumn: number;
if (position.lineNumber < model.getLineCount()) {
// Cutting a line in the middle of the model
startLineNumber = position.lineNumber;
startColumn = 1;
endLineNumber = position.lineNumber + 1;
endColumn = 1;
} else if (position.lineNumber > 1) {
// Cutting the last line & there are more than 1 lines in the model
startLineNumber = position.lineNumber - 1;
startColumn = model.getLineMaxColumn(position.lineNumber - 1);
endLineNumber = position.lineNumber;
endColumn = model.getLineMaxColumn(position.lineNumber);
} else {
// Cutting the single line that the model contains
startLineNumber = position.lineNumber;
startColumn = 1;
endLineNumber = position.lineNumber;
endColumn = model.getLineMaxColumn(position.lineNumber);
}
let deleteSelection = new Range(
startLineNumber,
startColumn,
endLineNumber,
endColumn
);
if (!deleteSelection.isEmpty()) {
return new EditOperationResult(new ReplaceCommand(deleteSelection, ''), {
shouldPushStackElementBefore: true,
shouldPushStackElementAfter: true
});
} else {
return null;
}
} else {
// Cannot cut empty selection
return null;
}
} else {
// Delete left or right, they will both result in the selection being deleted
return this.deleteRight(config, model, cursor);
}
}
示例5: deleteWordLeft
public static deleteWordLeft(wordSeparators: WordCharacterClassifier, model: ICursorSimpleModel, selection: Selection, whitespaceHeuristics: boolean, wordNavigationType: WordNavigationType): Range {
if (!selection.isEmpty()) {
return selection;
}
const position = new Position(selection.positionLineNumber, selection.positionColumn);
let lineNumber = position.lineNumber;
let column = position.column;
if (lineNumber === 1 && column === 1) {
// Ignore deleting at beginning of file
return null;
}
if (whitespaceHeuristics) {
let r = this._deleteWordLeftWhitespace(model, position);
if (r) {
return r;
}
}
let prevWordOnLine = WordOperations._findPreviousWordOnLine(wordSeparators, model, position);
if (wordNavigationType === WordNavigationType.WordStart) {
if (prevWordOnLine) {
column = prevWordOnLine.start + 1;
} else {
if (column > 1) {
column = 1;
} else {
lineNumber--;
column = model.getLineMaxColumn(lineNumber);
}
}
} else {
if (prevWordOnLine && column <= prevWordOnLine.end + 1) {
prevWordOnLine = WordOperations._findPreviousWordOnLine(wordSeparators, model, new Position(lineNumber, prevWordOnLine.start + 1));
}
if (prevWordOnLine) {
column = prevWordOnLine.end + 1;
} else {
if (column > 1) {
column = 1;
} else {
lineNumber--;
column = model.getLineMaxColumn(lineNumber);
}
}
}
return new Range(lineNumber, column, position.lineNumber, position.column);
}
示例6: moveToEndOfLine
public static moveToEndOfLine(config: CursorConfiguration, model: ICursorSimpleModel, cursor: SingleCursorState, inSelectionMode: boolean): SingleMoveOperationResult {
let lineNumber = cursor.selection.endLineNumber;
let maxColumn = model.getLineMaxColumn(lineNumber);
return SingleMoveOperationResult.fromMove(cursor, inSelectionMode, lineNumber, maxColumn, 0, true, CursorChangeReason.Explicit);
}
示例7: deleteAllRight
public static deleteAllRight(config: CursorConfiguration, model: ICursorSimpleModel, cursor: SingleCursorState): EditOperationResult {
let selection = cursor.selection;
if (selection.isEmpty()) {
let position = cursor.position;
let lineNumber = position.lineNumber;
let column = position.column;
let maxColumn = model.getLineMaxColumn(lineNumber);
if (column === maxColumn) {
// Ignore deleting at end of file
return null;
}
let deleteSelection = new Range(lineNumber, column, lineNumber, maxColumn);
if (!deleteSelection.isEmpty()) {
return new EditOperationResult(new ReplaceCommand(deleteSelection, ''), {
shouldPushStackElementBefore: false,
shouldPushStackElementAfter: false
});
}
}
return this.deleteRight(config, model, cursor);
}
示例8: moveWordLeft
public static moveWordLeft(config: CursorConfiguration, model: ICursorSimpleModel, cursor: SingleCursorState, inSelectionMode: boolean, wordNavigationType: WordNavigationType): SingleMoveOperationResult {
let position = cursor.position;
let lineNumber = position.lineNumber;
let column = position.column;
if (column === 1) {
if (lineNumber > 1) {
lineNumber = lineNumber - 1;
column = model.getLineMaxColumn(lineNumber);
}
}
let prevWordOnLine = WordOperations.findPreviousWordOnLine(config, model, new Position(lineNumber, column));
if (wordNavigationType === WordNavigationType.WordStart) {
if (prevWordOnLine) {
column = prevWordOnLine.start + 1;
} else {
column = 1;
}
} else {
if (prevWordOnLine && column <= prevWordOnLine.end + 1) {
prevWordOnLine = WordOperations.findPreviousWordOnLine(config, model, new Position(lineNumber, prevWordOnLine.start + 1));
}
if (prevWordOnLine) {
column = prevWordOnLine.end + 1;
} else {
column = 1;
}
}
return SingleMoveOperationResult.fromMove(cursor, inSelectionMode, lineNumber, column, 0, true, CursorChangeReason.Explicit);
}
示例9: deleteWordPartRight
public static deleteWordPartRight(wordSeparators: WordCharacterClassifier, model: ICursorSimpleModel, selection: Selection, whitespaceHeuristics: boolean, wordNavigationType: WordNavigationType): Range {
if (!selection.isEmpty()) {
return selection;
}
const position = new Position(selection.positionLineNumber, selection.positionColumn);
const lineNumber = position.lineNumber;
const column = position.column;
const lineCount = model.getLineCount();
const maxColumn = model.getLineMaxColumn(lineNumber);
if (lineNumber === lineCount && column === maxColumn) {
// Ignore deleting at end of file
return null;
}
if (whitespaceHeuristics) {
let r = WordOperations._deleteWordRightWhitespace(model, position);
if (r) {
return r;
}
}
const wordRange = WordOperations.deleteWordRight(wordSeparators, model, selection, whitespaceHeuristics, wordNavigationType);
const nextWordPartBegin = _nextWordPartBegin(model.getLineContent(position.lineNumber), position.column);
const wordPartRange = new Range(lineNumber, column, lineNumber, nextWordPartBegin);
if (wordRange.getEndPosition().isBeforeOrEqual(wordPartRange.getEndPosition())) {
return wordRange;
}
return wordPartRange;
}
示例10: moveWordLeft
public static moveWordLeft(wordSeparators: WordCharacterClassifier, model: ICursorSimpleModel, position: Position, wordNavigationType: WordNavigationType): Position {
let lineNumber = position.lineNumber;
let column = position.column;
if (column === 1) {
if (lineNumber > 1) {
lineNumber = lineNumber - 1;
column = model.getLineMaxColumn(lineNumber);
}
}
let prevWordOnLine = WordOperations._findPreviousWordOnLine(wordSeparators, model, new Position(lineNumber, column));
if (wordNavigationType === WordNavigationType.WordStart) {
if (prevWordOnLine) {
column = prevWordOnLine.start + 1;
} else {
column = 1;
}
} else {
if (prevWordOnLine && column <= prevWordOnLine.end + 1) {
prevWordOnLine = WordOperations._findPreviousWordOnLine(wordSeparators, model, new Position(lineNumber, prevWordOnLine.start + 1));
}
if (prevWordOnLine) {
column = prevWordOnLine.end + 1;
} else {
column = 1;
}
}
return new Position(lineNumber, column);
}