diff --git a/demo/client.ts b/demo/client.ts index 033ea41b..67ad0284 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -220,6 +220,7 @@ if (document.location.pathname === '/test') { document.getElementById('custom-glyph').addEventListener('click', writeCustomGlyphHandler); document.getElementById('load-test').addEventListener('click', loadTest); document.getElementById('print-cjk').addEventListener('click', addCjk); + document.getElementById('print-cjk-sgr').addEventListener('click', addCjkRandomSgr); document.getElementById('powerline-symbol-test').addEventListener('click', powerlineSymbolTest); document.getElementById('underline-test').addEventListener('click', underlineTest); document.getElementById('ansi-colors').addEventListener('click', ansiColorsTest); @@ -989,6 +990,25 @@ function addCjk(): void { } } +/** + * Prints the 20977 characters from the CJK Unified Ideographs unicode block with randomized styles. + */ +function addCjkRandomSgr(): void { + term.write('\n\n\r'); + for (let i = 0x4E00; i < 0x9FCC; i++) { + term.write(`\x1b[${getRandomSgr()}m${String.fromCharCode(i)}\x1b[0m`); + } +} +const randomSgrAttributes = [ + '1', '2', '3', '4', '5', '6', '7', '9', + '21', '22', '23', '24', '25', '26', '27', '28', '29', + '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', + '40', '41', '42', '43', '44', '45', '46', '47', '48', '49' +]; +function getRandomSgr(): string { + return randomSgrAttributes[Math.floor(Math.random() * randomSgrAttributes.length)]; +} + function addDecoration(): void { term.options['overviewRulerWidth'] = 15; const marker = term.registerMarker(1); diff --git a/demo/index.html b/demo/index.html index 26dcc53d..f62d535c 100644 --- a/demo/index.html +++ b/demo/index.html @@ -75,6 +75,7 @@