本文整理匯總了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);
}