Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/editor/browser/viewParts/minimap/minimapCharSheet.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
export const enum Constants {
7
START_CH_CODE = 32, // Space
8
END_CH_CODE = 126, // Tilde (~)
9
UNKNOWN_CODE = 65533, // UTF placeholder code
10
CHAR_COUNT = END_CH_CODE - START_CH_CODE + 2,
11
12
SAMPLED_CHAR_HEIGHT = 16,
13
SAMPLED_CHAR_WIDTH = 10,
14
15
BASE_CHAR_HEIGHT = 2,
16
BASE_CHAR_WIDTH = 1,
17
18
RGBA_CHANNELS_CNT = 4,
19
RGBA_SAMPLED_ROW_WIDTH = RGBA_CHANNELS_CNT * CHAR_COUNT * SAMPLED_CHAR_WIDTH
20
}
21
22
export const allCharCodes: ReadonlyArray<number> = (() => {
23
const v: number[] = [];
24
for (let i = Constants.START_CH_CODE; i <= Constants.END_CH_CODE; i++) {
25
v.push(i);
26
}
27
28
v.push(Constants.UNKNOWN_CODE);
29
return v;
30
})();
31
32
export const getCharIndex = (chCode: number, fontScale: number) => {
33
chCode -= Constants.START_CH_CODE;
34
if (chCode < 0 || chCode > Constants.CHAR_COUNT) {
35
if (fontScale <= 2) {
36
// for smaller scales, we can get away with using any ASCII character...
37
return (chCode + Constants.CHAR_COUNT) % Constants.CHAR_COUNT;
38
}
39
return Constants.CHAR_COUNT - 1; // unknown symbol
40
}
41
42
return chCode;
43
};
44
45