New unicode-graphemes addon.

Handle grapheme cluster lookup as well as wcwidth.
This is based on Unicode 15, and could replace the unicode11 addon.
This commit is contained in:
Per Bothner
2023-05-16 18:31:31 -07:00
parent 7a7f4f0add
commit 2f7fe1189c
28 changed files with 1055 additions and 49 deletions
+12 -2
View File
@@ -294,6 +294,11 @@ export interface IOscLinkService {
getLinkData(linkId: number): IOscLinkData | undefined;
}
/** Width and Grapheme_Cluster_Break properties of a character. */
export type UnicodeCharProperties = number;
export const UnicodeInitialProperties: UnicodeCharProperties = 0; // UNEEDED?
export type UnicodeCharWidth = 0 | 1 | 2;
export const IUnicodeService = createDecorator<IUnicodeService>('UnicodeService');
export interface IUnicodeService {
serviceBrand: undefined;
@@ -309,13 +314,18 @@ export interface IUnicodeService {
/**
* Unicode version dependent
*/
wcwidth(codepoint: number): number;
wcwidth(codepoint: number): UnicodeCharWidth;
getStringCellWidth(s: string): number;
/** Return character width, character type (for grapheme clustering).
* If preceding!=0, it is return code from previous character;
* in that case result specifies if characters should be joined. */
charProperties(codepoint: number, preceding: UnicodeCharProperties): UnicodeCharProperties;
}
export interface IUnicodeVersionProvider {
readonly version: string;
wcwidth(ucs: number): 0 | 1 | 2;
wcwidth(ucs: number): UnicodeCharWidth;
charProperties(codepoint: number, preceding: UnicodeCharProperties): UnicodeCharProperties;
}
export const IDecorationService = createDecorator<IDecorationService>('DecorationService');