Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/editor/browser/viewParts/viewLines/viewLineOptions.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
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 type { ColorScheme } from '../../../../platform/theme/common/theme.js';
7
import type { IEditorConfiguration } from '../../../common/config/editorConfiguration.js';
8
import { EditorOption } from '../../../common/config/editorOptions.js';
9
10
export class ViewLineOptions {
11
public readonly themeType: ColorScheme;
12
public readonly renderWhitespace: 'none' | 'boundary' | 'selection' | 'trailing' | 'all';
13
public readonly experimentalWhitespaceRendering: 'svg' | 'font' | 'off';
14
public readonly renderControlCharacters: boolean;
15
public readonly spaceWidth: number;
16
public readonly middotWidth: number;
17
public readonly wsmiddotWidth: number;
18
public readonly useMonospaceOptimizations: boolean;
19
public readonly canUseHalfwidthRightwardsArrow: boolean;
20
public readonly lineHeight: number;
21
public readonly stopRenderingLineAfter: number;
22
public readonly fontLigatures: string;
23
public readonly verticalScrollbarSize: number;
24
public readonly useGpu: boolean;
25
26
constructor(config: IEditorConfiguration, themeType: ColorScheme) {
27
this.themeType = themeType;
28
const options = config.options;
29
const fontInfo = options.get(EditorOption.fontInfo);
30
this.renderWhitespace = options.get(EditorOption.renderWhitespace);
31
this.experimentalWhitespaceRendering = options.get(EditorOption.experimentalWhitespaceRendering);
32
this.renderControlCharacters = options.get(EditorOption.renderControlCharacters);
33
this.spaceWidth = fontInfo.spaceWidth;
34
this.middotWidth = fontInfo.middotWidth;
35
this.wsmiddotWidth = fontInfo.wsmiddotWidth;
36
this.useMonospaceOptimizations = (
37
fontInfo.isMonospace
38
&& !options.get(EditorOption.disableMonospaceOptimizations)
39
);
40
this.canUseHalfwidthRightwardsArrow = fontInfo.canUseHalfwidthRightwardsArrow;
41
this.lineHeight = options.get(EditorOption.lineHeight);
42
this.stopRenderingLineAfter = options.get(EditorOption.stopRenderingLineAfter);
43
this.fontLigatures = options.get(EditorOption.fontLigatures);
44
this.verticalScrollbarSize = options.get(EditorOption.scrollbar).verticalScrollbarSize;
45
this.useGpu = options.get(EditorOption.experimentalGpuAcceleration) === 'on';
46
}
47
48
public equals(other: ViewLineOptions): boolean {
49
return (
50
this.themeType === other.themeType
51
&& this.renderWhitespace === other.renderWhitespace
52
&& this.experimentalWhitespaceRendering === other.experimentalWhitespaceRendering
53
&& this.renderControlCharacters === other.renderControlCharacters
54
&& this.spaceWidth === other.spaceWidth
55
&& this.middotWidth === other.middotWidth
56
&& this.wsmiddotWidth === other.wsmiddotWidth
57
&& this.useMonospaceOptimizations === other.useMonospaceOptimizations
58
&& this.canUseHalfwidthRightwardsArrow === other.canUseHalfwidthRightwardsArrow
59
&& this.lineHeight === other.lineHeight
60
&& this.stopRenderingLineAfter === other.stopRenderingLineAfter
61
&& this.fontLigatures === other.fontLigatures
62
&& this.verticalScrollbarSize === other.verticalScrollbarSize
63
&& this.useGpu === other.useGpu
64
);
65
}
66
}
67
68