本文整理汇总了TypeScript中vs/editor/common/controller/cursorCommon.CursorColumns.visibleColumnFromColumn2方法的典型用法代码示例。如果您正苦于以下问题:TypeScript CursorColumns.visibleColumnFromColumn2方法的具体用法?TypeScript CursorColumns.visibleColumnFromColumn2怎么用?TypeScript CursorColumns.visibleColumnFromColumn2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/editor/common/controller/cursorCommon.CursorColumns
的用法示例。
在下文中一共展示了CursorColumns.visibleColumnFromColumn2方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _columnSelect
private static _columnSelect(config: CursorConfiguration, model: ICursorSimpleModel, fromLineNumber: number, fromVisibleColumn: number, toLineNumber: number, toVisibleColumn: number): IColumnSelectResult {
let lineCount = Math.abs(toLineNumber - fromLineNumber) + 1;
let reversed = (fromLineNumber > toLineNumber);
let isRTL = (fromVisibleColumn > toVisibleColumn);
let isLTR = (fromVisibleColumn < toVisibleColumn);
let result: SingleCursorState[] = [];
// console.log(`fromVisibleColumn: ${fromVisibleColumn}, toVisibleColumn: ${toVisibleColumn}`);
for (let i = 0; i < lineCount; i++) {
let lineNumber = fromLineNumber + (reversed ? -i : i);
let startColumn = CursorColumns.columnFromVisibleColumn2(config, model, lineNumber, fromVisibleColumn);
let endColumn = CursorColumns.columnFromVisibleColumn2(config, model, lineNumber, toVisibleColumn);
let visibleStartColumn = CursorColumns.visibleColumnFromColumn2(config, model, new Position(lineNumber, startColumn));
let visibleEndColumn = CursorColumns.visibleColumnFromColumn2(config, model, new Position(lineNumber, endColumn));
// console.log(`lineNumber: ${lineNumber}: visibleStartColumn: ${visibleStartColumn}, visibleEndColumn: ${visibleEndColumn}`);
if (isLTR) {
if (visibleStartColumn > toVisibleColumn) {
continue;
}
if (visibleEndColumn < fromVisibleColumn) {
continue;
}
}
if (isRTL) {
if (visibleEndColumn > fromVisibleColumn) {
continue;
}
if (visibleStartColumn < toVisibleColumn) {
continue;
}
}
result.push(new SingleCursorState(
new Range(lineNumber, startColumn, lineNumber, startColumn), 0,
new Position(lineNumber, endColumn), 0
));
}
return {
viewStates: result,
reversed: reversed,
toLineNumber: toLineNumber,
toVisualColumn: toVisibleColumn
};
}
示例2: deleteLeft
public static deleteLeft(prevEditOperationType: EditOperationType, config: CursorConfiguration, model: ICursorSimpleModel, selections: Selection[]): [boolean, ICommand[]] {
if (this._isAutoClosingPairDelete(config, model, selections)) {
return this._runAutoClosingPairDelete(config, model, selections);
}
let commands: ICommand[] = [];
let shouldPushStackElementBefore = (prevEditOperationType !== EditOperationType.DeletingLeft);
for (let i = 0, len = selections.length; i < len; i++) {
const selection = selections[i];
let deleteSelection: Range = selection;
if (deleteSelection.isEmpty()) {
let position = selection.getPosition();
if (config.useTabStops && position.column > 1) {
let lineContent = model.getLineContent(position.lineNumber);
let firstNonWhitespaceIndex = strings.firstNonWhitespaceIndex(lineContent);
let lastIndentationColumn = (
firstNonWhitespaceIndex === -1
? /* entire string is whitespace */lineContent.length + 1
: firstNonWhitespaceIndex + 1
);
if (position.column <= lastIndentationColumn) {
let fromVisibleColumn = CursorColumns.visibleColumnFromColumn2(config, model, position);
let toVisibleColumn = CursorColumns.prevTabStop(fromVisibleColumn, config.tabSize);
let toColumn = CursorColumns.columnFromVisibleColumn2(config, model, position.lineNumber, toVisibleColumn);
deleteSelection = new Range(position.lineNumber, toColumn, position.lineNumber, position.column);
} else {
deleteSelection = new Range(position.lineNumber, position.column - 1, position.lineNumber, position.column);
}
} else {
let leftOfPosition = MoveOperations.left(config, model, position.lineNumber, position.column);
deleteSelection = new Range(
leftOfPosition.lineNumber,
leftOfPosition.column,
position.lineNumber,
position.column
);
}
}
if (deleteSelection.isEmpty()) {
// Probably at beginning of file => ignore
commands[i] = null;
continue;
}
if (deleteSelection.startLineNumber !== deleteSelection.endLineNumber) {
shouldPushStackElementBefore = true;
}
commands[i] = new ReplaceCommand(deleteSelection, '');
}
return [shouldPushStackElementBefore, commands];
}
示例3: deleteLeft
public static deleteLeft(config: CursorConfiguration, model: ICursorSimpleModel, cursor: SingleCursorState): EditOperationResult {
let r = this.autoClosingPairDelete(config, model, cursor);
if (r) {
// This was a case for an auto-closing pair delete
return r;
}
let deleteSelection: Range = cursor.selection;
if (deleteSelection.isEmpty()) {
let position = cursor.position;
if (config.useTabStops && position.column > 1) {
let lineContent = model.getLineContent(position.lineNumber);
let firstNonWhitespaceIndex = strings.firstNonWhitespaceIndex(lineContent);
let lastIndentationColumn = (
firstNonWhitespaceIndex === -1
? /* entire string is whitespace */lineContent.length + 1
: firstNonWhitespaceIndex + 1
);
if (position.column <= lastIndentationColumn) {
let fromVisibleColumn = CursorColumns.visibleColumnFromColumn2(config, model, position);
let toVisibleColumn = CursorColumns.prevTabStop(fromVisibleColumn, config.tabSize);
let toColumn = CursorColumns.columnFromVisibleColumn2(config, model, position.lineNumber, toVisibleColumn);
deleteSelection = new Range(position.lineNumber, toColumn, position.lineNumber, position.column);
} else {
deleteSelection = new Range(position.lineNumber, position.column - 1, position.lineNumber, position.column);
}
} else {
let leftOfPosition = MoveOperations.left(config, model, position.lineNumber, position.column);
deleteSelection = new Range(
leftOfPosition.lineNumber,
leftOfPosition.column,
position.lineNumber,
position.column
);
}
}
if (deleteSelection.isEmpty()) {
// Probably at beginning of file => ignore
return null;
}
let shouldPushStackElementBefore = false;
if (deleteSelection.startLineNumber !== deleteSelection.endLineNumber) {
shouldPushStackElementBefore = true;
}
return new EditOperationResult(new ReplaceCommand(deleteSelection, ''), {
shouldPushStackElementBefore: shouldPushStackElementBefore,
shouldPushStackElementAfter: false
});
}
示例4: columnSelectRight
public static columnSelectRight(config: CursorConfiguration, model: ICursorSimpleModel, cursor: SingleCursorState, toViewLineNumber: number, toViewVisualColumn: number): IColumnSelectResult {
let maxVisualViewColumn = 0;
let minViewLineNumber = Math.min(cursor.position.lineNumber, toViewLineNumber);
let maxViewLineNumber = Math.max(cursor.position.lineNumber, toViewLineNumber);
for (let lineNumber = minViewLineNumber; lineNumber <= maxViewLineNumber; lineNumber++) {
let lineMaxViewColumn = model.getLineMaxColumn(lineNumber);
let lineMaxVisualViewColumn = CursorColumns.visibleColumnFromColumn2(config, model, new Position(lineNumber, lineMaxViewColumn));
maxVisualViewColumn = Math.max(maxVisualViewColumn, lineMaxVisualViewColumn);
}
if (toViewVisualColumn < maxVisualViewColumn) {
toViewVisualColumn++;
}
return this.columnSelect(config, model, cursor.selection.getStartPosition(), toViewLineNumber, toViewVisualColumn);
}
示例5: _replaceJumpToNextIndent
private static _replaceJumpToNextIndent(config: CursorConfiguration, model: ICursorSimpleModel, selection: Selection, insertsAutoWhitespace: boolean): ReplaceCommand {
let typeText = '';
let position = selection.getStartPosition();
if (config.insertSpaces) {
let visibleColumnFromColumn = CursorColumns.visibleColumnFromColumn2(config, model, position);
let tabSize = config.tabSize;
let spacesCnt = tabSize - (visibleColumnFromColumn % tabSize);
for (let i = 0; i < spacesCnt; i++) {
typeText += ' ';
}
} else {
typeText = '\t';
}
return new ReplaceCommand(selection, typeText, insertsAutoWhitespace);
}
示例6: _enter
private static _enter(config: CursorConfiguration, model: ITextModel, keepPosition: boolean, range: Range): ICommand {
if (!model.isCheapToTokenize(range.getStartPosition().lineNumber)) {
let lineText = model.getLineContent(range.startLineNumber);
let indentation = strings.getLeadingWhitespace(lineText).substring(0, range.startColumn - 1);
return TypeOperations._typeCommand(range, '\n' + config.normalizeIndentation(indentation), keepPosition);
}
let r = LanguageConfigurationRegistry.getEnterAction(model, range);
if (r) {
let enterAction = r.enterAction;
let indentation = r.indentation;
if (enterAction.indentAction === IndentAction.None) {
// Nothing special
return TypeOperations._typeCommand(range, '\n' + config.normalizeIndentation(indentation + enterAction.appendText), keepPosition);
} else if (enterAction.indentAction === IndentAction.Indent) {
// Indent once
return TypeOperations._typeCommand(range, '\n' + config.normalizeIndentation(indentation + enterAction.appendText), keepPosition);
} else if (enterAction.indentAction === IndentAction.IndentOutdent) {
// Ultra special
let normalIndent = config.normalizeIndentation(indentation);
let increasedIndent = config.normalizeIndentation(indentation + enterAction.appendText);
let typeText = '\n' + increasedIndent + '\n' + normalIndent;
if (keepPosition) {
return new ReplaceCommandWithoutChangingPosition(range, typeText, true);
} else {
return new ReplaceCommandWithOffsetCursorState(range, typeText, -1, increasedIndent.length - normalIndent.length, true);
}
} else if (enterAction.indentAction === IndentAction.Outdent) {
let actualIndentation = TypeOperations.unshiftIndent(config, indentation);
return TypeOperations._typeCommand(range, '\n' + config.normalizeIndentation(actualIndentation + enterAction.appendText), keepPosition);
}
}
// no enter rules applied, we should check indentation rules then.
if (!config.autoIndent) {
// Nothing special
let lineText = model.getLineContent(range.startLineNumber);
let indentation = strings.getLeadingWhitespace(lineText).substring(0, range.startColumn - 1);
return TypeOperations._typeCommand(range, '\n' + config.normalizeIndentation(indentation), keepPosition);
}
let ir = LanguageConfigurationRegistry.getIndentForEnter(model, range, {
unshiftIndent: (indent) => {
return TypeOperations.unshiftIndent(config, indent);
},
shiftIndent: (indent) => {
return TypeOperations.shiftIndent(config, indent);
},
normalizeIndentation: (indent) => {
return config.normalizeIndentation(indent);
}
}, config.autoIndent);
let lineText = model.getLineContent(range.startLineNumber);
let indentation = strings.getLeadingWhitespace(lineText).substring(0, range.startColumn - 1);
if (ir) {
let oldEndViewColumn = CursorColumns.visibleColumnFromColumn2(config, model, range.getEndPosition());
let oldEndColumn = range.endColumn;
let beforeText = '\n';
if (indentation !== config.normalizeIndentation(ir.beforeEnter)) {
beforeText = config.normalizeIndentation(ir.beforeEnter) + lineText.substring(indentation.length, range.startColumn - 1) + '\n';
range = new Range(range.startLineNumber, 1, range.endLineNumber, range.endColumn);
}
let newLineContent = model.getLineContent(range.endLineNumber);
let firstNonWhitespace = strings.firstNonWhitespaceIndex(newLineContent);
if (firstNonWhitespace >= 0) {
range = range.setEndPosition(range.endLineNumber, Math.max(range.endColumn, firstNonWhitespace + 1));
} else {
range = range.setEndPosition(range.endLineNumber, model.getLineMaxColumn(range.endLineNumber));
}
if (keepPosition) {
return new ReplaceCommandWithoutChangingPosition(range, beforeText + config.normalizeIndentation(ir.afterEnter), true);
} else {
let offset = 0;
if (oldEndColumn <= firstNonWhitespace + 1) {
if (!config.insertSpaces) {
oldEndViewColumn = Math.ceil(oldEndViewColumn / config.tabSize);
}
offset = Math.min(oldEndViewColumn + 1 - config.normalizeIndentation(ir.afterEnter).length - 1, 0);
}
return new ReplaceCommandWithOffsetCursorState(range, beforeText + config.normalizeIndentation(ir.afterEnter), 0, offset, true);
}
} else {
return TypeOperations._typeCommand(range, '\n' + config.normalizeIndentation(indentation), keepPosition);
}
}
示例7: deleteLeft
public static deleteLeft(config: CursorConfiguration, model: ICursorSimpleModel, cursors: SingleCursorState[]): EditOperationResult {
if (this._isAutoClosingPairDelete(config, model, cursors)) {
return this._runAutoClosingPairDelete(config, model, cursors);
}
let commands: CommandResult[] = [];
let shouldPushStackElementBefore = false;
for (let i = 0, len = cursors.length; i < len; i++) {
const cursor = cursors[i];
let deleteSelection: Range = cursor.selection;
if (deleteSelection.isEmpty()) {
let position = cursor.position;
if (config.useTabStops && position.column > 1) {
let lineContent = model.getLineContent(position.lineNumber);
let firstNonWhitespaceIndex = strings.firstNonWhitespaceIndex(lineContent);
let lastIndentationColumn = (
firstNonWhitespaceIndex === -1
? /* entire string is whitespace */lineContent.length + 1
: firstNonWhitespaceIndex + 1
);
if (position.column <= lastIndentationColumn) {
let fromVisibleColumn = CursorColumns.visibleColumnFromColumn2(config, model, position);
let toVisibleColumn = CursorColumns.prevTabStop(fromVisibleColumn, config.tabSize);
let toColumn = CursorColumns.columnFromVisibleColumn2(config, model, position.lineNumber, toVisibleColumn);
deleteSelection = new Range(position.lineNumber, toColumn, position.lineNumber, position.column);
} else {
deleteSelection = new Range(position.lineNumber, position.column - 1, position.lineNumber, position.column);
}
} else {
let leftOfPosition = MoveOperations.left(config, model, position.lineNumber, position.column);
deleteSelection = new Range(
leftOfPosition.lineNumber,
leftOfPosition.column,
position.lineNumber,
position.column
);
}
}
if (deleteSelection.isEmpty()) {
// Probably at beginning of file => ignore
commands[i] = null;
continue;
}
if (deleteSelection.startLineNumber !== deleteSelection.endLineNumber) {
shouldPushStackElementBefore = true;
}
commands[i] = new CommandResult(new ReplaceCommand(deleteSelection, ''), false);
}
return new EditOperationResult(commands, {
shouldPushStackElementBefore: shouldPushStackElementBefore,
shouldPushStackElementAfter: false
});
}
示例8: columnSelect
public static columnSelect(config: CursorConfiguration, model: ICursorSimpleModel, fromViewPosition: Position, toViewLineNumber: number, toViewVisualColumn: number): IColumnSelectResult {
let fromViewVisibleColumn = CursorColumns.visibleColumnFromColumn2(config, model, fromViewPosition);
return ColumnSelection._columnSelect(config, model, fromViewPosition.lineNumber, fromViewVisibleColumn, toViewLineNumber, toViewVisualColumn);
}