本文整理汇总了TypeScript中vs/editor/common/view/renderingContext.IRenderingContext.getViewportVerticalOffsetForLineNumber方法的典型用法代码示例。如果您正苦于以下问题:TypeScript IRenderingContext.getViewportVerticalOffsetForLineNumber方法的具体用法?TypeScript IRenderingContext.getViewportVerticalOffsetForLineNumber怎么用?TypeScript IRenderingContext.getViewportVerticalOffsetForLineNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/editor/common/view/renderingContext.IRenderingContext
的用法示例。
在下文中一共展示了IRenderingContext.getViewportVerticalOffsetForLineNumber方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _prepareRender
private _prepareRender(ctx: IRenderingContext): ViewCursorRenderData {
if (this._cursorStyle === TextEditorCursorStyle.Line || this._cursorStyle === TextEditorCursorStyle.LineThin) {
let visibleRange = ctx.visibleRangeForPosition(this._position);
if (!visibleRange) {
// Outside viewport
return null;
}
let width: number;
if (this._cursorStyle === TextEditorCursorStyle.Line) {
width = this._isSecondary ? 1 : 2;
} else {
width = 1;
}
return new ViewCursorRenderData(visibleRange.top, visibleRange.left, width, '');
}
let visibleRangeForCharacter = ctx.linesVisibleRangesForRange(new Range(this._position.lineNumber, this._position.column, this._position.lineNumber, this._position.column + 1), false);
if (!visibleRangeForCharacter || visibleRangeForCharacter.length === 0 || visibleRangeForCharacter[0].ranges.length === 0) {
// Outside viewport
return null;
}
let range = visibleRangeForCharacter[0].ranges[0];
let top = ctx.getViewportVerticalOffsetForLineNumber(this._position.lineNumber);
let width = range.width < 1 ? this._typicalHalfwidthCharacterWidth : range.width;
let textContent = '';
if (this._cursorStyle === TextEditorCursorStyle.Block) {
let lineContent = this._context.model.getLineContent(this._position.lineNumber);
textContent = lineContent.charAt(this._position.column - 1);
}
return new ViewCursorRenderData(top, range.left, width, textContent);
}