1
>
/*---------------------------------------------------------------------------------------------
viewLineRenderer.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 * as nls from '../../../nls.js';
7
>
import { CharCode } from '../../../base/common/charCode.js';
8
>
import * as strings from '../../../base/common/strings.js';
9
>
import { IViewLineTokens } from '../tokens/lineTokens.js';
10
>
import { StringBuilder } from '../core/stringBuilder.js';
11
>
import { LineDecoration, LineDecorationsNormalizer } from './lineDecorations.js';
12
>
import { LinePart, LinePartMetadata } from './linePart.js';
13
>
import { OffsetRange } from '../core/ranges/offsetRange.js';
14
>
import { InlineDecorationType } from '../viewModel/inlineDecorations.js';
15
>
import { TextDirection } from '../model.js';
16
>
17
>
export const enum RenderWhitespace {
18
>
None = 0,
19
>
Boundary = 1,
20
>
Selection = 2,
21
>
Trailing = 3,
22
>
All = 4
23
>
}
24
>
25
>
export interface IRenderLineInputOptions {
26
>
useMonospaceOptimizations: boolean;
27
>
canUseHalfwidthRightwardsArrow: boolean;
28
>
lineContent: string;
29
>
continuesWithWrappedLine: boolean;
30
>
isBasicASCII: boolean;
31
>
containsRTL: boolean;
32
>
fauxIndentLength: number;
33
>
lineTokens: IViewLineTokens;
34
>
lineDecorations: LineDecoration[];
35
>
tabSize: number;
36
>
startVisibleColumn: number;
37
>
spaceWidth: number;
38
>
middotWidth: number;
39
>
wsmiddotWidth: number;
40
>
stopRenderingLineAfter: number;
41
>
renderWhitespace: 'none' | 'boundary' | 'selection' | 'trailing' | 'all';
42
>
renderControlCharacters: boolean;
43
>
fontLigatures: boolean;
44
>
selectionsOnLine: OffsetRange[] | null;
45
>
textDirection: TextDirection | null;
46
>
verticalScrollbarSize: number;
47
>
renderNewLineWhenEmpty: boolean;
48
>
}
49
>
50
>
export class RenderLineInput {
51
>
52
>
public readonly useMonospaceOptimizations: boolean;
53
>
public readonly canUseHalfwidthRightwardsArrow: boolean;
54
>
public readonly lineContent: string;
55
>
public readonly continuesWithWrappedLine: boolean;
56
>
public readonly isBasicASCII: boolean;
57
>
public readonly containsRTL: boolean;
58
>
public readonly fauxIndentLength: number;
59
>
public readonly lineTokens: IViewLineTokens;
60
>
public readonly lineDecorations: LineDecoration[];
61
>
public readonly tabSize: number;
62
>
public readonly startVisibleColumn: number;
63
>
public readonly spaceWidth: number;
64
>
public readonly renderSpaceWidth: number;
65
>
public readonly renderSpaceCharCode: number;
66
>
public readonly stopRenderingLineAfter: number;
67
>
public readonly renderWhitespace: RenderWhitespace;
68
>
public readonly renderControlCharacters: boolean;
69
>
public readonly fontLigatures: boolean;
70
>
public readonly textDirection: TextDirection | null;
71
>
public readonly verticalScrollbarSize: number;
72
>
73
>
/**
74
>
* Defined only when renderWhitespace is 'selection'. Selections are non-overlapping,
75
>
* and ordered by position within the line.
76
>
*/
77
>
public readonly selectionsOnLine: OffsetRange[] | null;
78
>
/**
79
>
* When rendering an empty line, whether to render a new line instead
80
>
*/
81
>
public readonly renderNewLineWhenEmpty: boolean;
82
>
83
>
public get isLTR(): boolean {
84
return !this.containsRTL && this.textDirection !== TextDirection.RTL;
85
}
87
>
constructor(
88
>
useMonospaceOptimizations: boolean,
89
>
canUseHalfwidthRightwardsArrow: boolean,
90
>
lineContent: string,
91
>
continuesWithWrappedLine: boolean,
92
>
isBasicASCII: boolean,
93
>
containsRTL: boolean,
94
>
fauxIndentLength: number,
95
>
lineTokens: IViewLineTokens,
96
>
lineDecorations: LineDecoration[],
97
>
tabSize: number,
98
>
startVisibleColumn: number,
99
>
spaceWidth: number,
100
>
middotWidth: number,
101
>
wsmiddotWidth: number,
102
>
stopRenderingLineAfter: number,
103
>
renderWhitespace: 'none' | 'boundary' | 'selection' | 'trailing' | 'all',
104
>
renderControlCharacters: boolean,
105
>
fontLigatures: boolean,
106
>
selectionsOnLine: OffsetRange[] | null,
107
>
textDirection: TextDirection | null,
108
>
verticalScrollbarSize: number,
109
>
renderNewLineWhenEmpty: boolean = false,
110
>
) {
111
>
this.useMonospaceOptimizations = useMonospaceOptimizations;
112
>
this.canUseHalfwidthRightwardsArrow = canUseHalfwidthRightwardsArrow;
113
>
this.lineContent = lineContent;
114
>
this.continuesWithWrappedLine = continuesWithWrappedLine;
115
>
this.isBasicASCII = isBasicASCII;
116
>
this.containsRTL = containsRTL;
117
>
this.fauxIndentLength = fauxIndentLength;
118
>
this.lineTokens = lineTokens;
119
>
this.lineDecorations = lineDecorations.sort(LineDecoration.compare);
120
>
this.tabSize = tabSize;
121
>
this.startVisibleColumn = startVisibleColumn;
122
>
this.spaceWidth = spaceWidth;
123
>
this.stopRenderingLineAfter = stopRenderingLineAfter;
124
>
this.renderWhitespace = (
125
>
renderWhitespace === 'all'
126
? RenderWhitespace.All
127
: renderWhitespace === 'boundary'