本文整理汇总了TypeScript中vs/editor/common/view/renderingContext.RenderingContext.getDecorationsInViewport方法的典型用法代码示例。如果您正苦于以下问题:TypeScript RenderingContext.getDecorationsInViewport方法的具体用法?TypeScript RenderingContext.getDecorationsInViewport怎么用?TypeScript RenderingContext.getDecorationsInViewport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/editor/common/view/renderingContext.RenderingContext
的用法示例。
在下文中一共展示了RenderingContext.getDecorationsInViewport方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _getDecorations
protected _getDecorations(ctx: RenderingContext): DecorationToRender[] {
let decorations = ctx.getDecorationsInViewport();
let r: DecorationToRender[] = [], rLen = 0;
for (let i = 0, len = decorations.length; i < len; i++) {
let d = decorations[i];
let linesDecorationsClassName = d.options.linesDecorationsClassName;
if (linesDecorationsClassName) {
r[rLen++] = new DecorationToRender(d.range.startLineNumber, d.range.endLineNumber, linesDecorationsClassName);
}
}
return r;
}
示例2: _getDecorations
protected _getDecorations(ctx: RenderingContext): DecorationToRender[] {
let decorations = ctx.getDecorationsInViewport();
let r: DecorationToRender[] = [];
for (let i = 0, len = decorations.length; i < len; i++) {
let d = decorations[i];
let marginClassName = d.source.options.marginClassName;
if (marginClassName) {
r.push(new DecorationToRender(d.range.startLineNumber, d.range.endLineNumber, marginClassName));
}
}
return r;
}
示例3: prepareRender
public prepareRender(ctx: RenderingContext): void {
let _decorations = ctx.getDecorationsInViewport();
// Keep only decorations with `className`
let decorations: ViewModelDecoration[] = [], decorationsLen = 0;
for (let i = 0, len = _decorations.length; i < len; i++) {
let d = _decorations[i];
if (d.options.className) {
decorations[decorationsLen++] = d;
}
}
// Sort decorations for consistent render output
decorations = decorations.sort((a, b) => {
if (a.options.zIndex! < b.options.zIndex!) {
return -1;
}
if (a.options.zIndex! > b.options.zIndex!) {
return 1;
}
const aClassName = a.options.className!;
const bClassName = b.options.className!;
if (aClassName < bClassName) {
return -1;
}
if (aClassName > bClassName) {
return 1;
}
return Range.compareRangesUsingStarts(a.range, b.range);
});
let visibleStartLineNumber = ctx.visibleRange.startLineNumber;
let visibleEndLineNumber = ctx.visibleRange.endLineNumber;
let output: string[] = [];
for (let lineNumber = visibleStartLineNumber; lineNumber <= visibleEndLineNumber; lineNumber++) {
let lineIndex = lineNumber - visibleStartLineNumber;
output[lineIndex] = '';
}
// Render first whole line decorations and then regular decorations
this._renderWholeLineDecorations(ctx, decorations, output);
this._renderNormalDecorations(ctx, decorations, output);
this._renderResult = output;
}