Path: blob/main/src/vs/editor/browser/viewParts/minimap/minimapCharSheet.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45export const enum Constants {6START_CH_CODE = 32, // Space7END_CH_CODE = 126, // Tilde (~)8UNKNOWN_CODE = 65533, // UTF placeholder code9CHAR_COUNT = END_CH_CODE - START_CH_CODE + 2,1011SAMPLED_CHAR_HEIGHT = 16,12SAMPLED_CHAR_WIDTH = 10,1314BASE_CHAR_HEIGHT = 2,15BASE_CHAR_WIDTH = 1,1617RGBA_CHANNELS_CNT = 4,18RGBA_SAMPLED_ROW_WIDTH = RGBA_CHANNELS_CNT * CHAR_COUNT * SAMPLED_CHAR_WIDTH19}2021export const allCharCodes: ReadonlyArray<number> = (() => {22const v: number[] = [];23for (let i = Constants.START_CH_CODE; i <= Constants.END_CH_CODE; i++) {24v.push(i);25}2627v.push(Constants.UNKNOWN_CODE);28return v;29})();3031export const getCharIndex = (chCode: number, fontScale: number) => {32chCode -= Constants.START_CH_CODE;33if (chCode < 0 || chCode > Constants.CHAR_COUNT) {34if (fontScale <= 2) {35// for smaller scales, we can get away with using any ASCII character...36return (chCode + Constants.CHAR_COUNT) % Constants.CHAR_COUNT;37}38return Constants.CHAR_COUNT - 1; // unknown symbol39}4041return chCode;42};434445