本文整理汇总了TypeScript中vs/editor/common/viewModel/viewModel.ICoordinatesConverter.validateViewPosition方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ICoordinatesConverter.validateViewPosition方法的具体用法?TypeScript ICoordinatesConverter.validateViewPosition怎么用?TypeScript ICoordinatesConverter.validateViewPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/editor/common/viewModel/viewModel.ICoordinatesConverter
的用法示例。
在下文中一共展示了ICoordinatesConverter.validateViewPosition方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: setSelection
public setSelection(selection: editorCommon.ISelection, viewSelection: editorCommon.ISelection = null): void {
let position = this.model.validatePosition({
lineNumber: selection.positionLineNumber,
column: selection.positionColumn
});
let selectionStart = this.model.validatePosition({
lineNumber: selection.selectionStartLineNumber,
column: selection.selectionStartColumn
});
let viewPosition: Position;
let viewSelectionStart: Position;
if (viewSelection) {
viewPosition = this.coordinatesConverter.validateViewPosition(new Position(viewSelection.positionLineNumber, viewSelection.positionColumn), position);
viewSelectionStart = this.coordinatesConverter.validateViewPosition(new Position(viewSelection.selectionStartLineNumber, viewSelection.selectionStartColumn), selectionStart);
} else {
viewPosition = this.coordinatesConverter.convertModelPositionToViewPosition(position);
viewSelectionStart = this.coordinatesConverter.convertModelPositionToViewPosition(selectionStart);
}
this._setState(
new SingleCursorState(new Range(selectionStart.lineNumber, selectionStart.column, selectionStart.lineNumber, selectionStart.column), 0, position, 0),
new SingleCursorState(new Range(viewSelectionStart.lineNumber, viewSelectionStart.column, viewSelectionStart.lineNumber, viewSelectionStart.column), 0, viewPosition, 0),
false
);
}
示例2: _setState
private _setState(modelState: SingleCursorState, viewState: SingleCursorState, ensureInEditableRange: boolean): void {
// Validate new model state
let selectionStart = this.model.validateRange(modelState.selectionStart);
let selectionStartLeftoverVisibleColumns = modelState.selectionStart.equalsRange(selectionStart) ? modelState.selectionStartLeftoverVisibleColumns : 0;
let position = this.model.validatePosition(modelState.position);
if (ensureInEditableRange) {
position = this._ensureInEditableRange(position);
}
let leftoverVisibleColumns = modelState.position.equals(position) ? modelState.leftoverVisibleColumns : 0;
modelState = new SingleCursorState(selectionStart, selectionStartLeftoverVisibleColumns, position, leftoverVisibleColumns);
// Validate new view state
let viewSelectionStart = this.coordinatesConverter.validateViewRange(viewState.selectionStart, modelState.selectionStart);
let viewPosition = this.coordinatesConverter.validateViewPosition(viewState.position, modelState.position);
viewState = new SingleCursorState(viewSelectionStart, selectionStartLeftoverVisibleColumns, viewPosition, leftoverVisibleColumns);
if (this.modelState && this.viewState && this.modelState.equals(modelState) && this.viewState.equals(viewState)) {
// No-op, early return
return;
}
this.modelState = modelState;
this.viewState = viewState;
this._selStartMarker = this._ensureMarker(this._selStartMarker, this.modelState.selection.startLineNumber, this.modelState.selection.startColumn, true);
this._selEndMarker = this._ensureMarker(this._selEndMarker, this.modelState.selection.endLineNumber, this.modelState.selection.endColumn, false);
}
示例3: restoreState
public restoreState(state: IOneCursorState): void {
let position = this.model.validatePosition(state.position);
let selectionStart: Range;
if (state.selectionStart) {
selectionStart = this.model.validateRange(state.selectionStart);
} else {
selectionStart = new Range(position.lineNumber, position.column, position.lineNumber, position.column);
}
let viewPosition = this.coordinatesConverter.validateViewPosition(new Position(state.viewPosition.lineNumber, state.viewPosition.column), position);
let viewSelectionStart: Range;
if (state.viewSelectionStart) {
viewSelectionStart = this.coordinatesConverter.validateViewRange(new Range(state.viewSelectionStart.startLineNumber, state.viewSelectionStart.startColumn, state.viewSelectionStart.endLineNumber, state.viewSelectionStart.endColumn), selectionStart);
} else {
viewSelectionStart = this.coordinatesConverter.convertModelRangeToViewRange(selectionStart);
}
this._setState(
new SingleCursorState(selectionStart, state.selectionStartLeftoverVisibleColumns, position, state.leftoverVisibleColumns),
new SingleCursorState(viewSelectionStart, state.selectionStartLeftoverVisibleColumns, viewPosition, state.leftoverVisibleColumns),
false
);
}
示例4: validateViewPosition
public validateViewPosition(viewPosition: Position, modelPosition: Position): Position {
return this._coordinatesConverter.validateViewPosition(viewPosition, modelPosition);
}
示例5: validateViewPosition
public validateViewPosition(viewLineNumber: number, viewColumn: number, modelPosition: Position): Position {
return this.coordinatesConverter.validateViewPosition(new Position(viewLineNumber, viewColumn), modelPosition);
}