feat(ui): add terminal cursor support (#17711)

This commit is contained in:
Jacob Richman
2026-01-27 16:43:37 -08:00
committed by GitHub
parent fe8de892f7
commit 5e41b7d29e
5 changed files with 263 additions and 6 deletions
+7
View File
@@ -71,6 +71,13 @@ export function cpLen(str: string): number {
return toCodePoints(str).length;
}
/**
* Converts a code point index to a UTF-16 code unit offset.
*/
export function cpIndexToOffset(str: string, cpIndex: number): number {
return cpSlice(str, 0, cpIndex).length;
}
export function cpSlice(str: string, start: number, end?: number): string {
// Slice by codepoint indices and rejoin.
const arr = toCodePoints(str).slice(start, end);