1
>
/*---------------------------------------------------------------------------------------------
inlineDecorations.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import { IModelDecoration, InjectedTextOptions, ITextModel, PositionAffinity } from '../model.js';
7
>
import { Range } from '../core/range.js';
8
>
import { Position } from '../core/position.js';
9
>
import { ICoordinatesConverter } from '../coordinatesConverter.js';
10
>
import { isModelDecorationVisible, ViewModelDecoration } from './viewModelDecoration.js';
11
>
12
>
export const enum InlineDecorationType {
13
>
Regular = 0,
14
>
Before = 1,
15
>
After = 2,
16
>
RegularAffectingLetterSpacing = 3
17
>
}
18
>
19
>
export class InlineDecoration {
20
>
constructor(
21
public readonly range: Range,
22
public readonly inlineClassName: string,
23
public readonly type: InlineDecorationType
24
) { }
26
>
27
>
/**
28
>
* A collection of decorations in a range of lines.
29
>
*/
30
>
export interface IViewDecorationsCollection {
31
>
/**
32
>
* decorations in the range of lines (ungrouped).
33
>
*/
34
>
readonly decorations: ViewModelDecoration[];
35
>
/**
36
>
* inline decorations (grouped by each line in the range of lines).
37
>
*/
38
>
readonly inlineDecorations: InlineDecoration[][];
39
>
/**
40
>
* Whether the decorations affect the fonts.
41
>
*/
42
>
readonly hasVariableFonts: boolean[];
43
>
}
44
>
45
>
export interface IInlineDecorationsComputer {
46
>
/**
47
>
* Get the inline decorations for a specific model line number, split by view line number
48
>
*/
49
>
getInlineDecorations(modelLineNumber: number): InlineDecoration[][];
50
>
}
51
>
52
>
export interface IInlineModelDecorationsComputerContext {
53
>
/**
54
>
* Get model decorations for a view range
55
>
*/
56
>
getModelDecorations(viewRange: Range, onlyMinimapDecorations: boolean, onlyMarginDecorations: boolean): IModelDecoration[];
57
>
}
58
>
59
>
export class InlineModelDecorationsComputer implements IInlineDecorationsComputer {
60
>
61
>
private _decorationsCache: { [decorationId: string]: ViewModelDecoration };
62
>
63
>
constructor(
64
private readonly context: IInlineModelDecorationsComputerContext,
65
private readonly model: ITextModel,