本文整理汇总了TypeScript中vs/editor/common/view/renderingContext.IRenderingContext.getDecorationsInViewport方法的典型用法代码示例。如果您正苦于以下问题:TypeScript IRenderingContext.getDecorationsInViewport方法的具体用法?TypeScript IRenderingContext.getDecorationsInViewport怎么用?TypeScript IRenderingContext.getDecorationsInViewport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/editor/common/view/renderingContext.IRenderingContext
的用法示例。
在下文中一共展示了IRenderingContext.getDecorationsInViewport方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _getDecorations
protected _getDecorations(ctx: IRenderingContext): DecorationToRender[] {
let decorations = ctx.getDecorationsInViewport();
let r: DecorationToRender[] = [];
for (let i = 0, len = decorations.length; i < len; i++) {
let d = decorations[i];
if (d.options.glyphMarginClassName) {
r.push(new DecorationToRender(d.range.startLineNumber, d.range.endLineNumber, d.options.glyphMarginClassName));
}
}
return r;
}
示例2: prepareRender
public prepareRender(ctx: IRenderingContext): void {
if (!this.shouldRender()) {
throw new Error('I did not ask to render!');
}
let decorations = ctx.getDecorationsInViewport();
// Keep only decorations with `className`
decorations = decorations.filter(d => !!d.options.className);
// Sort decorations for consistent render output
decorations = decorations.sort((a, b) => {
if (a.options.className < b.options.className) {
return -1;
}
if (a.options.className > b.options.className) {
return 1;
}
if (a.range.startLineNumber === b.range.startLineNumber) {
if (a.range.startColumn === b.range.startColumn) {
if (a.range.endLineNumber === b.range.endLineNumber) {
return a.range.endColumn - b.range.endColumn;
}
return a.range.endLineNumber - b.range.endLineNumber;
}
return a.range.startColumn - b.range.startColumn;
}
return a.range.startLineNumber - b.range.startLineNumber;
});
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;
}
示例3: prepareRender
public prepareRender(ctx: IRenderingContext): void {
if (!this.shouldRender()) {
throw new Error('I did not ask to render!');
}
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.source.options.className) {
decorations[decorationsLen++] = d;
}
}
// Sort decorations for consistent render output
decorations = decorations.sort((a, b) => {
let aClassName = a.source.options.className;
let bClassName = b.source.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;
}