845
/** Iterates over parts of a string with CSI sequences */
846
export function* forAnsiStringParts(str: string) {
848
>
for (const match of str.matchAll(CONTROL_SEQUENCES)) {
849
>
if (last !== match.index) {
850
>
yield { isCode: false, str: str.substring(last, match.index) };
851
>
}
852
>
853
>
yield { isCode: true, str: match[0] };
854
>
last = match.index + match[0].length;
855
>
}
856
>
857
>
if (last !== str.length) {
858
>
yield { isCode: false, str: str.substring(last) };
859
>
}
860
>
}
861
862
/**