From ca10ef5cad15dd8950433ee7df48faf902be6fbd Mon Sep 17 00:00:00 2001 From: Simon Lamon Date: Sun, 31 Jul 2022 08:55:44 +0000 Subject: [PATCH 01/10] Fix demo --- demo/client.ts | 102 +++++++++++++++++++++++++++---------------------- 1 file changed, 57 insertions(+), 45 deletions(-) diff --git a/demo/client.ts b/demo/client.ts index 1c01a38a..d4fbaa5a 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -60,29 +60,29 @@ interface IDemoAddon { name: T; canChange: boolean; ctor: - T extends 'attach' ? typeof AttachAddon : - T extends 'canvas' ? typeof CanvasAddon : - T extends 'fit' ? typeof FitAddon : - T extends 'search' ? typeof SearchAddon : - T extends 'serialize' ? typeof SerializeAddon : - T extends 'web-links' ? typeof WebLinksAddon : - T extends 'unicode11' ? typeof Unicode11Addon : - T extends 'ligatures' ? typeof LigaturesAddon : - typeof WebglAddon; - instance?: - T extends 'attach' ? AttachAddon : - T extends 'canvas' ? CanvasAddon : - T extends 'fit' ? FitAddon : - T extends 'search' ? SearchAddon : - T extends 'serialize' ? SerializeAddon : - T extends 'web-links' ? WebLinksAddon : - T extends 'webgl' ? WebglAddon : - T extends 'unicode11' ? typeof Unicode11Addon : - T extends 'ligatures' ? typeof LigaturesAddon : - never; + T extends 'attach' ? typeof AttachAddon : + T extends 'canvas' ? typeof CanvasAddon : + T extends 'fit' ? typeof FitAddon : + T extends 'search' ? typeof SearchAddon : + T extends 'serialize' ? typeof SerializeAddon : + T extends 'web-links' ? typeof WebLinksAddon : + T extends 'unicode11' ? typeof Unicode11Addon : + T extends 'ligatures' ? typeof LigaturesAddon : + typeof WebglAddon; + instance?: + T extends 'attach' ? AttachAddon : + T extends 'canvas' ? CanvasAddon : + T extends 'fit' ? FitAddon : + T extends 'search' ? SearchAddon : + T extends 'serialize' ? SerializeAddon : + T extends 'web-links' ? WebLinksAddon : + T extends 'webgl' ? WebglAddon : + T extends 'unicode11' ? typeof Unicode11Addon : + T extends 'ligatures' ? typeof LigaturesAddon : + never; } -const addons: { [T in AddonType]: IDemoAddon} = { +const addons: { [T in AddonType]: IDemoAddon } = { attach: { name: 'attach', ctor: AttachAddon, canChange: false }, canvas: { name: 'canvas', ctor: CanvasAddon, canChange: true }, fit: { name: 'fit', ctor: FitAddon, canChange: false }, @@ -230,17 +230,22 @@ function createTerminal(): void { const rows = size.rows; const url = '/terminals/' + pid + '/size?cols=' + cols + '&rows=' + rows; - fetch(url, {method: 'POST'}); + fetch(url, { method: 'POST' }); }); protocol = (location.protocol === 'https:') ? 'wss://' : 'ws://'; socketURL = protocol + location.hostname + ((location.port) ? (':' + location.port) : '') + '/terminals/'; term.open(terminalContainer); addons.fit.instance!.fit(); - typedTerm.loadAddon(addons.webgl.instance); - setTimeout(() => { - document.body.appendChild(addons.webgl.instance.textureAtlas); - }, 0); + try { + typedTerm.loadAddon(addons.webgl.instance); + setTimeout(() => { + document.body.appendChild(addons.webgl.instance.textureAtlas); + }, 0); + } + catch { + addons.webgl.instance = undefined; + } term.focus(); addDomListener(paddingElement, 'change', setPadding); @@ -269,7 +274,7 @@ function createTerminal(): void { // Set terminal size again to set the specific dimensions on the demo updateTerminalSize(); - fetch('/terminals?cols=' + term.cols + '&rows=' + term.rows, {method: 'POST'}).then((res) => { + fetch('/terminals?cols=' + term.cols + '&rows=' + term.rows, { method: 'POST' }).then((res) => { res.text().then((processId) => { pid = processId; socketURL += processId; @@ -314,7 +319,7 @@ function runFakeTerminal(): void { if (ev.keyCode === 13) { term.prompt(); } else if (ev.keyCode === 8) { - // Do not delete the prompt + // Do not delete the prompt if (term._core.buffer.x > 2) { term.write('\b \b'); } @@ -502,15 +507,22 @@ function initAddons(term: TerminalType): void { addDomListener(checkbox, 'change', () => { if (checkbox.checked) { addon.instance = new addon.ctor(); - term.loadAddon(addon.instance); - if (name === 'webgl') { - setTimeout(() => { - document.body.appendChild((addon.instance as WebglAddon).textureAtlas); - }, 0); - } else if (name === 'unicode11') { - term.unicode.activeVersion = '11'; - } else if (name === 'search') { - addon.instance.onDidChangeResults(e => updateFindResults(e)); + try { + term.loadAddon(addon.instance); + if (name === 'webgl') { + setTimeout(() => { + document.body.appendChild((addon.instance as WebglAddon).textureAtlas); + }, 0); + } else if (name === 'unicode11') { + term.unicode.activeVersion = '11'; + } else if (name === 'search') { + addon.instance.onDidChangeResults(e => updateFindResults(e)); + } + } + catch { + addon.instance = undefined; + checkbox.checked = false; + checkbox.disabled = true; } } else { if (name === 'webgl') { @@ -806,13 +818,13 @@ function addDecoration() { function addOverviewRuler() { term.options['overviewRulerWidth'] = 15; - term.registerDecoration({marker: term.registerMarker(1), overviewRulerOptions: { color: '#ef2929' }}); - term.registerDecoration({marker: term.registerMarker(3), overviewRulerOptions: { color: '#8ae234' }}); - term.registerDecoration({marker: term.registerMarker(5), overviewRulerOptions: { color: '#729fcf' }}); - term.registerDecoration({marker: term.registerMarker(7), overviewRulerOptions: { color: '#ef2929', position: 'left' }}); - term.registerDecoration({marker: term.registerMarker(7), overviewRulerOptions: { color: '#8ae234', position: 'center' }}); - term.registerDecoration({marker: term.registerMarker(7), overviewRulerOptions: { color: '#729fcf', position: 'right' }}); - term.registerDecoration({marker: term.registerMarker(10), overviewRulerOptions: { color: '#8ae234', position: 'center' }}); - term.registerDecoration({marker: term.registerMarker(10), overviewRulerOptions: { color: '#ffffff80', position: 'full' }}); + term.registerDecoration({ marker: term.registerMarker(1), overviewRulerOptions: { color: '#ef2929' } }); + term.registerDecoration({ marker: term.registerMarker(3), overviewRulerOptions: { color: '#8ae234' } }); + term.registerDecoration({ marker: term.registerMarker(5), overviewRulerOptions: { color: '#729fcf' } }); + term.registerDecoration({ marker: term.registerMarker(7), overviewRulerOptions: { color: '#ef2929', position: 'left' } }); + term.registerDecoration({ marker: term.registerMarker(7), overviewRulerOptions: { color: '#8ae234', position: 'center' } }); + term.registerDecoration({ marker: term.registerMarker(7), overviewRulerOptions: { color: '#729fcf', position: 'right' } }); + term.registerDecoration({ marker: term.registerMarker(10), overviewRulerOptions: { color: '#8ae234', position: 'center' } }); + term.registerDecoration({ marker: term.registerMarker(10), overviewRulerOptions: { color: '#ffffff80', position: 'full' } }); } From d0571d86346a794729f10c89a24a58eed994581b Mon Sep 17 00:00:00 2001 From: Simon Lamon Date: Sun, 31 Jul 2022 08:59:25 +0000 Subject: [PATCH 02/10] Fix formatting --- demo/client.ts | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/demo/client.ts b/demo/client.ts index d4fbaa5a..b7b0058d 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -60,26 +60,26 @@ interface IDemoAddon { name: T; canChange: boolean; ctor: - T extends 'attach' ? typeof AttachAddon : - T extends 'canvas' ? typeof CanvasAddon : - T extends 'fit' ? typeof FitAddon : - T extends 'search' ? typeof SearchAddon : - T extends 'serialize' ? typeof SerializeAddon : - T extends 'web-links' ? typeof WebLinksAddon : - T extends 'unicode11' ? typeof Unicode11Addon : - T extends 'ligatures' ? typeof LigaturesAddon : - typeof WebglAddon; - instance?: - T extends 'attach' ? AttachAddon : - T extends 'canvas' ? CanvasAddon : - T extends 'fit' ? FitAddon : - T extends 'search' ? SearchAddon : - T extends 'serialize' ? SerializeAddon : - T extends 'web-links' ? WebLinksAddon : - T extends 'webgl' ? WebglAddon : - T extends 'unicode11' ? typeof Unicode11Addon : - T extends 'ligatures' ? typeof LigaturesAddon : - never; + T extends 'attach' ? typeof AttachAddon : + T extends 'canvas' ? typeof CanvasAddon : + T extends 'fit' ? typeof FitAddon : + T extends 'search' ? typeof SearchAddon : + T extends 'serialize' ? typeof SerializeAddon : + T extends 'web-links' ? typeof WebLinksAddon : + T extends 'unicode11' ? typeof Unicode11Addon : + T extends 'ligatures' ? typeof LigaturesAddon : + typeof WebglAddon; + instance?: + T extends 'attach' ? AttachAddon : + T extends 'canvas' ? CanvasAddon : + T extends 'fit' ? FitAddon : + T extends 'search' ? SearchAddon : + T extends 'serialize' ? SerializeAddon : + T extends 'web-links' ? WebLinksAddon : + T extends 'webgl' ? WebglAddon : + T extends 'unicode11' ? typeof Unicode11Addon : + T extends 'ligatures' ? typeof LigaturesAddon : + never; } const addons: { [T in AddonType]: IDemoAddon } = { From f3cd6134f1e8f5cf43f490155589beb468bab36e Mon Sep 17 00:00:00 2001 From: deepanshu <62979448+deepanshu44@users.noreply.github.com> Date: Mon, 1 Aug 2022 11:29:12 +0530 Subject: [PATCH 03/10] print colors --- demo/client.ts | 287 ++++++++++++++++++++++++++++++++++++++++++++++++ demo/index.html | 1 + 2 files changed, 288 insertions(+) diff --git a/demo/client.ts b/demo/client.ts index c0d3af6d..8f7a8abe 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -188,6 +188,7 @@ if (document.location.pathname === '/test') { document.getElementById('load-test').addEventListener('click', loadTest); document.getElementById('powerline-symbol-test').addEventListener('click', powerlineSymbolTest); document.getElementById('underline-test').addEventListener('click', underlineTest); + document.getElementById('ansi-colors').addEventListener('click', ansiColorsTest); document.getElementById('add-decoration').addEventListener('click', addDecoration); document.getElementById('add-overview-ruler').addEventListener('click', addOverviewRuler); } @@ -789,6 +790,292 @@ function underlineTest() { term.write('\x1b[0m\n\r'); } +function ansiColorsTest() { + term.write('\n\r'); + term.write( +`\x1b[48;5;1m \x1b[0m`+ +`\x1b[48;5;2m \x1b[0m`+ +`\x1b[48;5;3m \x1b[0m`+ +`\x1b[48;5;4m \x1b[0m`+ +`\x1b[48;5;5m \x1b[0m`+ +`\x1b[48;5;6m \x1b[0m`+ +`\x1b[48;5;7m \x1b[0m`+ +`\x1b[48;5;8m \x1b[0m`+ +`\x1b[48;5;9m \x1b[0m`+ +`\x1b[48;5;10m \x1b[0m`); +term.write( +`\x1b[48;5;11m \x1b[0m`+ +`\x1b[48;5;12m \x1b[0m`+ +`\x1b[48;5;13m \x1b[0m`+ +`\x1b[48;5;14m \x1b[0m`+ +`\x1b[48;5;15m \x1b[0m`+ +`\x1b[48;5;16m \x1b[0m`+ +`\x1b[48;5;17m \x1b[0m`+ +`\x1b[48;5;18m \x1b[0m`+ +`\x1b[48;5;19m \x1b[0m`+ +`\x1b[48;5;20m \x1b[0m`); +term.write( +`\x1b[48;5;21m \x1b[0m`+ +`\x1b[48;5;22m \x1b[0m`+ +`\x1b[48;5;23m \x1b[0m`+ +`\x1b[48;5;24m \x1b[0m`+ +`\x1b[48;5;25m \x1b[0m`+ +`\x1b[48;5;26m \x1b[0m`+ +`\x1b[48;5;27m \x1b[0m`+ +`\x1b[48;5;28m \x1b[0m`+ +`\x1b[48;5;29m \x1b[0m`+ +`\x1b[48;5;30m \x1b[0m`); +term.write( +`\x1b[48;5;31m \x1b[0m`+ +`\x1b[48;5;32m \x1b[0m`+ +`\x1b[48;5;33m \x1b[0m`+ +`\x1b[48;5;34m \x1b[0m`+ +`\x1b[48;5;35m \x1b[0m`+ +`\x1b[48;5;36m \x1b[0m`+ +`\x1b[48;5;37m \x1b[0m`+ +`\x1b[48;5;38m \x1b[0m`+ +`\x1b[48;5;39m \x1b[0m`+ +`\x1b[48;5;40m \x1b[0m`); +term.write( +`\x1b[48;5;41m \x1b[0m`+ +`\x1b[48;5;42m \x1b[0m`+ +`\x1b[48;5;43m \x1b[0m`+ +`\x1b[48;5;44m \x1b[0m`+ +`\x1b[48;5;45m \x1b[0m`+ +`\x1b[48;5;46m \x1b[0m`+ +`\x1b[48;5;47m \x1b[0m`+ +`\x1b[48;5;48m \x1b[0m`+ +`\x1b[48;5;49m \x1b[0m`+ +`\x1b[48;5;50m \x1b[0m`); +term.write( +`\x1b[48;5;51m \x1b[0m`+ +`\x1b[48;5;52m \x1b[0m`+ +`\x1b[48;5;53m \x1b[0m`+ +`\x1b[48;5;54m \x1b[0m`+ +`\x1b[48;5;55m \x1b[0m`+ +`\x1b[48;5;56m \x1b[0m`+ +`\x1b[48;5;57m \x1b[0m`+ +`\x1b[48;5;58m \x1b[0m`+ +`\x1b[48;5;59m \x1b[0m`+ +`\x1b[48;5;60m \x1b[0m`); +term.write( +`\x1b[48;5;61m \x1b[0m`+ +`\x1b[48;5;62m \x1b[0m`+ +`\x1b[48;5;63m \x1b[0m`+ +`\x1b[48;5;64m \x1b[0m`+ +`\x1b[48;5;65m \x1b[0m`+ +`\x1b[48;5;66m \x1b[0m`+ +`\x1b[48;5;67m \x1b[0m`+ +`\x1b[48;5;68m \x1b[0m`+ +`\x1b[48;5;69m \x1b[0m`+ +`\x1b[48;5;70m \x1b[0m`); +term.write( +`\x1b[48;5;71m \x1b[0m`+ +`\x1b[48;5;72m \x1b[0m`+ +`\x1b[48;5;73m \x1b[0m`+ +`\x1b[48;5;74m \x1b[0m`+ +`\x1b[48;5;75m \x1b[0m`+ +`\x1b[48;5;76m \x1b[0m`+ +`\x1b[48;5;77m \x1b[0m`+ +`\x1b[48;5;78m \x1b[0m`+ +`\x1b[48;5;79m \x1b[0m`+ +`\x1b[48;5;80m \x1b[0m`); +term.write( +`\x1b[48;5;81m \x1b[0m`+ +`\x1b[48;5;82m \x1b[0m`+ +`\x1b[48;5;83m \x1b[0m`+ +`\x1b[48;5;84m \x1b[0m`+ +`\x1b[48;5;85m \x1b[0m`+ +`\x1b[48;5;86m \x1b[0m`+ +`\x1b[48;5;87m \x1b[0m`+ +`\x1b[48;5;88m \x1b[0m`+ +`\x1b[48;5;89m \x1b[0m`+ +`\x1b[48;5;90m \x1b[0m`); +term.write( +`\x1b[48;5;91m \x1b[0m`+ +`\x1b[48;5;92m \x1b[0m`+ +`\x1b[48;5;93m \x1b[0m`+ +`\x1b[48;5;94m \x1b[0m`+ +`\x1b[48;5;95m \x1b[0m`+ +`\x1b[48;5;96m \x1b[0m`+ +`\x1b[48;5;97m \x1b[0m`+ +`\x1b[48;5;98m \x1b[0m`+ +`\x1b[48;5;99m \x1b[0m`+ +`\x1b[48;5;100m \x1b[0m`); +term.write( +`\x1b[48;5;101m \x1b[0m`+ +`\x1b[48;5;102m \x1b[0m`+ +`\x1b[48;5;103m \x1b[0m`+ +`\x1b[48;5;104m \x1b[0m`+ +`\x1b[48;5;105m \x1b[0m`+ +`\x1b[48;5;106m \x1b[0m`+ +`\x1b[48;5;107m \x1b[0m`+ +`\x1b[48;5;108m \x1b[0m`+ +`\x1b[48;5;109m \x1b[0m`+ +`\x1b[48;5;110m \x1b[0m`); +term.write( +`\x1b[48;5;111m \x1b[0m`+ +`\x1b[48;5;112m \x1b[0m`+ +`\x1b[48;5;113m \x1b[0m`+ +`\x1b[48;5;114m \x1b[0m`+ +`\x1b[48;5;115m \x1b[0m`+ +`\x1b[48;5;116m \x1b[0m`+ +`\x1b[48;5;117m \x1b[0m`+ +`\x1b[48;5;118m \x1b[0m`+ +`\x1b[48;5;119m \x1b[0m`+ +`\x1b[48;5;120m \x1b[0m`); +term.write( +`\x1b[48;5;121m \x1b[0m`+ +`\x1b[48;5;122m \x1b[0m`+ +`\x1b[48;5;123m \x1b[0m`+ +`\x1b[48;5;124m \x1b[0m`+ +`\x1b[48;5;125m \x1b[0m`+ +`\x1b[48;5;126m \x1b[0m`+ +`\x1b[48;5;127m \x1b[0m`+ +`\x1b[48;5;128m \x1b[0m`+ +`\x1b[48;5;129m \x1b[0m`+ +`\x1b[48;5;130m \x1b[0m`); +term.write( +`\x1b[48;5;131m \x1b[0m`+ +`\x1b[48;5;132m \x1b[0m`+ +`\x1b[48;5;133m \x1b[0m`+ +`\x1b[48;5;134m \x1b[0m`+ +`\x1b[48;5;135m \x1b[0m`+ +`\x1b[48;5;136m \x1b[0m`+ +`\x1b[48;5;137m \x1b[0m`+ +`\x1b[48;5;138m \x1b[0m`+ +`\x1b[48;5;139m \x1b[0m`+ +`\x1b[48;5;140m \x1b[0m`); +term.write( +`\x1b[48;5;141m \x1b[0m`+ +`\x1b[48;5;142m \x1b[0m`+ +`\x1b[48;5;143m \x1b[0m`+ +`\x1b[48;5;144m \x1b[0m`+ +`\x1b[48;5;145m \x1b[0m`+ +`\x1b[48;5;146m \x1b[0m`+ +`\x1b[48;5;147m \x1b[0m`+ +`\x1b[48;5;148m \x1b[0m`+ +`\x1b[48;5;149m \x1b[0m`+ +`\x1b[48;5;150m \x1b[0m`); +term.write( +`\x1b[48;5;151m \x1b[0m`+ +`\x1b[48;5;152m \x1b[0m`+ +`\x1b[48;5;153m \x1b[0m`+ +`\x1b[48;5;154m \x1b[0m`+ +`\x1b[48;5;155m \x1b[0m`+ +`\x1b[48;5;156m \x1b[0m`+ +`\x1b[48;5;157m \x1b[0m`+ +`\x1b[48;5;158m \x1b[0m`+ +`\x1b[48;5;159m \x1b[0m`+ +`\x1b[48;5;160m \x1b[0m`); +term.write( +`\x1b[48;5;161m \x1b[0m`+ +`\x1b[48;5;162m \x1b[0m`+ +`\x1b[48;5;163m \x1b[0m`+ +`\x1b[48;5;164m \x1b[0m`+ +`\x1b[48;5;165m \x1b[0m`+ +`\x1b[48;5;166m \x1b[0m`+ +`\x1b[48;5;167m \x1b[0m`+ +`\x1b[48;5;168m \x1b[0m`+ +`\x1b[48;5;169m \x1b[0m`+ +`\x1b[48;5;170m \x1b[0m`); +term.write( +`\x1b[48;5;171m \x1b[0m`+ +`\x1b[48;5;172m \x1b[0m`+ +`\x1b[48;5;173m \x1b[0m`+ +`\x1b[48;5;174m \x1b[0m`+ +`\x1b[48;5;175m \x1b[0m`+ +`\x1b[48;5;176m \x1b[0m`+ +`\x1b[48;5;177m \x1b[0m`+ +`\x1b[48;5;178m \x1b[0m`+ +`\x1b[48;5;179m \x1b[0m`+ +`\x1b[48;5;180m \x1b[0m`); +term.write( +`\x1b[48;5;181m \x1b[0m`+ +`\x1b[48;5;182m \x1b[0m`+ +`\x1b[48;5;183m \x1b[0m`+ +`\x1b[48;5;184m \x1b[0m`+ +`\x1b[48;5;185m \x1b[0m`+ +`\x1b[48;5;186m \x1b[0m`+ +`\x1b[48;5;187m \x1b[0m`+ +`\x1b[48;5;188m \x1b[0m`+ +`\x1b[48;5;189m \x1b[0m`+ +`\x1b[48;5;190m \x1b[0m`); +term.write( +`\x1b[48;5;191m \x1b[0m`+ +`\x1b[48;5;192m \x1b[0m`+ +`\x1b[48;5;193m \x1b[0m`+ +`\x1b[48;5;194m \x1b[0m`+ +`\x1b[48;5;195m \x1b[0m`+ +`\x1b[48;5;196m \x1b[0m`+ +`\x1b[48;5;197m \x1b[0m`+ +`\x1b[48;5;198m \x1b[0m`+ +`\x1b[48;5;199m \x1b[0m`+ +`\x1b[48;5;200m \x1b[0m`); +term.write( +`\x1b[48;5;201m \x1b[0m`+ +`\x1b[48;5;202m \x1b[0m`+ +`\x1b[48;5;203m \x1b[0m`+ +`\x1b[48;5;204m \x1b[0m`+ +`\x1b[48;5;205m \x1b[0m`+ +`\x1b[48;5;206m \x1b[0m`+ +`\x1b[48;5;207m \x1b[0m`+ +`\x1b[48;5;208m \x1b[0m`+ +`\x1b[48;5;209m \x1b[0m`+ +`\x1b[48;5;210m \x1b[0m`); +term.write( +`\x1b[48;5;211m \x1b[0m`+ +`\x1b[48;5;212m \x1b[0m`+ +`\x1b[48;5;213m \x1b[0m`+ +`\x1b[48;5;214m \x1b[0m`+ +`\x1b[48;5;215m \x1b[0m`+ +`\x1b[48;5;216m \x1b[0m`+ +`\x1b[48;5;217m \x1b[0m`+ +`\x1b[48;5;218m \x1b[0m`+ +`\x1b[48;5;219m \x1b[0m`+ +`\x1b[48;5;220m \x1b[0m`); +term.write( +`\x1b[48;5;221m \x1b[0m`+ +`\x1b[48;5;222m \x1b[0m`+ +`\x1b[48;5;223m \x1b[0m`+ +`\x1b[48;5;224m \x1b[0m`+ +`\x1b[48;5;225m \x1b[0m`+ +`\x1b[48;5;226m \x1b[0m`+ +`\x1b[48;5;227m \x1b[0m`+ +`\x1b[48;5;228m \x1b[0m`+ +`\x1b[48;5;229m \x1b[0m`+ +`\x1b[48;5;230m \x1b[0m`); +term.write( +`\x1b[48;5;231m \x1b[0m`+ +`\x1b[48;5;232m \x1b[0m`+ +`\x1b[48;5;233m \x1b[0m`+ +`\x1b[48;5;234m \x1b[0m`+ +`\x1b[48;5;235m \x1b[0m`+ +`\x1b[48;5;236m \x1b[0m`+ +`\x1b[48;5;237m \x1b[0m`+ +`\x1b[48;5;238m \x1b[0m`+ +`\x1b[48;5;239m \x1b[0m`+ +`\x1b[48;5;240m \x1b[0m`); +term.write( +`\x1b[48;5;241m \x1b[0m`+ +`\x1b[48;5;242m \x1b[0m`+ +`\x1b[48;5;243m \x1b[0m`+ +`\x1b[48;5;244m \x1b[0m`+ +`\x1b[48;5;245m \x1b[0m`+ +`\x1b[48;5;246m \x1b[0m`+ +`\x1b[48;5;247m \x1b[0m`+ +`\x1b[48;5;248m \x1b[0m`+ +`\x1b[48;5;249m \x1b[0m`+ +`\x1b[48;5;250m \x1b[0m`); +term.write( +`\x1b[48;5;251m \x1b[0m`+ +`\x1b[48;5;252m \x1b[0m`+ +`\x1b[48;5;253m \x1b[0m`+ +`\x1b[48;5;254m \x1b[0m`+ +`\x1b[48;5;255m \x1b[0m`+ +`\x1b[48;5;256m \x1b[0m`) +term.write('\n\r'); +} function addDecoration() { term.options['overviewRulerWidth'] = 15; const marker = term.registerMarker(1); diff --git a/demo/index.html b/demo/index.html index 214dd25f..d3fc6aab 100644 --- a/demo/index.html +++ b/demo/index.html @@ -78,6 +78,7 @@
+
Decorations
From 04eb6a4160c98f0be83db3eb8ea7e8e6817852c8 Mon Sep 17 00:00:00 2001 From: Simon Lamon <32477463+silamon@users.noreply.github.com> Date: Mon, 1 Aug 2022 18:00:23 +0200 Subject: [PATCH 04/10] Fix wrong merge conflict resolution --- demo/client.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/demo/client.ts b/demo/client.ts index 8b9dd55a..5fa35d51 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -509,9 +509,7 @@ function initAddons(term: TerminalType): void { try { term.loadAddon(addon.instance); if (name === 'webgl') { - setTimeout(() => { - document.body.appendChild((addon.instance as WebglAddon).textureAtlas); - }, 0); + (addon.instance as WebglAddon).onChangeTextureAtlas(e => addTextureAtlas(e)); } else if (name === 'unicode11') { term.unicode.activeVersion = '11'; } else if (name === 'search') { From 76d9d5a3240fdc2ef01d47df22be8cb2d007d088 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 3 Aug 2022 09:45:23 -0700 Subject: [PATCH 05/10] Bump all peer deps to v5 Fixes #3997 --- addons/xterm-addon-attach/package.json | 2 +- addons/xterm-addon-canvas/package.json | 2 +- addons/xterm-addon-fit/package.json | 2 +- addons/xterm-addon-ligatures/package.json | 2 +- addons/xterm-addon-search/package.json | 2 +- addons/xterm-addon-serialize/package.json | 2 +- addons/xterm-addon-unicode11/package.json | 2 +- addons/xterm-addon-web-links/package.json | 2 +- addons/xterm-addon-webgl/package.json | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/addons/xterm-addon-attach/package.json b/addons/xterm-addon-attach/package.json index 6782c57c..c6225b46 100644 --- a/addons/xterm-addon-attach/package.json +++ b/addons/xterm-addon-attach/package.json @@ -21,6 +21,6 @@ "prepublishOnly": "npm run package" }, "peerDependencies": { - "xterm": "^4.0.0" + "xterm": "^5.0.0" } } diff --git a/addons/xterm-addon-canvas/package.json b/addons/xterm-addon-canvas/package.json index ba19e674..fdc2d93a 100644 --- a/addons/xterm-addon-canvas/package.json +++ b/addons/xterm-addon-canvas/package.json @@ -22,6 +22,6 @@ "prepublishOnly": "npm run package" }, "peerDependencies": { - "xterm": "^4.0.0" + "xterm": "^5.0.0" } } diff --git a/addons/xterm-addon-fit/package.json b/addons/xterm-addon-fit/package.json index da52d15f..1d2f6dd5 100644 --- a/addons/xterm-addon-fit/package.json +++ b/addons/xterm-addon-fit/package.json @@ -21,6 +21,6 @@ "prepublishOnly": "npm run package" }, "peerDependencies": { - "xterm": "^4.0.0" + "xterm": "^5.0.0" } } diff --git a/addons/xterm-addon-ligatures/package.json b/addons/xterm-addon-ligatures/package.json index 7e5e5e90..525f377c 100644 --- a/addons/xterm-addon-ligatures/package.json +++ b/addons/xterm-addon-ligatures/package.json @@ -42,6 +42,6 @@ "yauzl": "^2.10.0" }, "peerDependencies": { - "xterm": "^4.0.0" + "xterm": "^5.0.0" } } diff --git a/addons/xterm-addon-search/package.json b/addons/xterm-addon-search/package.json index fb76f07b..8a75c812 100644 --- a/addons/xterm-addon-search/package.json +++ b/addons/xterm-addon-search/package.json @@ -21,6 +21,6 @@ "prepublishOnly": "npm run package" }, "peerDependencies": { - "xterm": "^4.0.0" + "xterm": "^5.0.0" } } diff --git a/addons/xterm-addon-serialize/package.json b/addons/xterm-addon-serialize/package.json index bd7605d9..94562688 100644 --- a/addons/xterm-addon-serialize/package.json +++ b/addons/xterm-addon-serialize/package.json @@ -24,6 +24,6 @@ "benchmark-eval": "NODE_PATH=../../out:./out:./out-benchmark/ ../../node_modules/.bin/xterm-benchmark -r 5 -c benchmark/benchmark.json --eval out-benchmark/benchmark/*benchmark.js" }, "peerDependencies": { - "xterm": "^4.0.0" + "xterm": "^5.0.0" } } diff --git a/addons/xterm-addon-unicode11/package.json b/addons/xterm-addon-unicode11/package.json index c4d1f8e3..275cca4a 100644 --- a/addons/xterm-addon-unicode11/package.json +++ b/addons/xterm-addon-unicode11/package.json @@ -21,6 +21,6 @@ "prepublishOnly": "npm run package" }, "peerDependencies": { - "xterm": "^4.0.0" + "xterm": "^5.0.0" } } diff --git a/addons/xterm-addon-web-links/package.json b/addons/xterm-addon-web-links/package.json index 21a3ef4d..2cfbae6c 100644 --- a/addons/xterm-addon-web-links/package.json +++ b/addons/xterm-addon-web-links/package.json @@ -21,6 +21,6 @@ "prepublishOnly": "npm run package" }, "peerDependencies": { - "xterm": "^4.0.0" + "xterm": "^5.0.0" } } diff --git a/addons/xterm-addon-webgl/package.json b/addons/xterm-addon-webgl/package.json index fce8e24b..45b04897 100644 --- a/addons/xterm-addon-webgl/package.json +++ b/addons/xterm-addon-webgl/package.json @@ -22,6 +22,6 @@ "prepublishOnly": "npm run package" }, "peerDependencies": { - "xterm": "^4.0.0" + "xterm": "^5.0.0" } } From bc57ea3a7a1a8d4843607f7ecce973a383237b7b Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 4 Aug 2022 06:06:31 -0700 Subject: [PATCH 06/10] Reduce duplicate, improve layout --- demo/client.ts | 307 ++++-------------------------------------------- demo/index.html | 2 +- 2 files changed, 24 insertions(+), 285 deletions(-) diff --git a/demo/client.ts b/demo/client.ts index 8f7a8abe..7b113218 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -791,291 +791,30 @@ function underlineTest() { } function ansiColorsTest() { - term.write('\n\r'); - term.write( -`\x1b[48;5;1m \x1b[0m`+ -`\x1b[48;5;2m \x1b[0m`+ -`\x1b[48;5;3m \x1b[0m`+ -`\x1b[48;5;4m \x1b[0m`+ -`\x1b[48;5;5m \x1b[0m`+ -`\x1b[48;5;6m \x1b[0m`+ -`\x1b[48;5;7m \x1b[0m`+ -`\x1b[48;5;8m \x1b[0m`+ -`\x1b[48;5;9m \x1b[0m`+ -`\x1b[48;5;10m \x1b[0m`); -term.write( -`\x1b[48;5;11m \x1b[0m`+ -`\x1b[48;5;12m \x1b[0m`+ -`\x1b[48;5;13m \x1b[0m`+ -`\x1b[48;5;14m \x1b[0m`+ -`\x1b[48;5;15m \x1b[0m`+ -`\x1b[48;5;16m \x1b[0m`+ -`\x1b[48;5;17m \x1b[0m`+ -`\x1b[48;5;18m \x1b[0m`+ -`\x1b[48;5;19m \x1b[0m`+ -`\x1b[48;5;20m \x1b[0m`); -term.write( -`\x1b[48;5;21m \x1b[0m`+ -`\x1b[48;5;22m \x1b[0m`+ -`\x1b[48;5;23m \x1b[0m`+ -`\x1b[48;5;24m \x1b[0m`+ -`\x1b[48;5;25m \x1b[0m`+ -`\x1b[48;5;26m \x1b[0m`+ -`\x1b[48;5;27m \x1b[0m`+ -`\x1b[48;5;28m \x1b[0m`+ -`\x1b[48;5;29m \x1b[0m`+ -`\x1b[48;5;30m \x1b[0m`); -term.write( -`\x1b[48;5;31m \x1b[0m`+ -`\x1b[48;5;32m \x1b[0m`+ -`\x1b[48;5;33m \x1b[0m`+ -`\x1b[48;5;34m \x1b[0m`+ -`\x1b[48;5;35m \x1b[0m`+ -`\x1b[48;5;36m \x1b[0m`+ -`\x1b[48;5;37m \x1b[0m`+ -`\x1b[48;5;38m \x1b[0m`+ -`\x1b[48;5;39m \x1b[0m`+ -`\x1b[48;5;40m \x1b[0m`); -term.write( -`\x1b[48;5;41m \x1b[0m`+ -`\x1b[48;5;42m \x1b[0m`+ -`\x1b[48;5;43m \x1b[0m`+ -`\x1b[48;5;44m \x1b[0m`+ -`\x1b[48;5;45m \x1b[0m`+ -`\x1b[48;5;46m \x1b[0m`+ -`\x1b[48;5;47m \x1b[0m`+ -`\x1b[48;5;48m \x1b[0m`+ -`\x1b[48;5;49m \x1b[0m`+ -`\x1b[48;5;50m \x1b[0m`); -term.write( -`\x1b[48;5;51m \x1b[0m`+ -`\x1b[48;5;52m \x1b[0m`+ -`\x1b[48;5;53m \x1b[0m`+ -`\x1b[48;5;54m \x1b[0m`+ -`\x1b[48;5;55m \x1b[0m`+ -`\x1b[48;5;56m \x1b[0m`+ -`\x1b[48;5;57m \x1b[0m`+ -`\x1b[48;5;58m \x1b[0m`+ -`\x1b[48;5;59m \x1b[0m`+ -`\x1b[48;5;60m \x1b[0m`); -term.write( -`\x1b[48;5;61m \x1b[0m`+ -`\x1b[48;5;62m \x1b[0m`+ -`\x1b[48;5;63m \x1b[0m`+ -`\x1b[48;5;64m \x1b[0m`+ -`\x1b[48;5;65m \x1b[0m`+ -`\x1b[48;5;66m \x1b[0m`+ -`\x1b[48;5;67m \x1b[0m`+ -`\x1b[48;5;68m \x1b[0m`+ -`\x1b[48;5;69m \x1b[0m`+ -`\x1b[48;5;70m \x1b[0m`); -term.write( -`\x1b[48;5;71m \x1b[0m`+ -`\x1b[48;5;72m \x1b[0m`+ -`\x1b[48;5;73m \x1b[0m`+ -`\x1b[48;5;74m \x1b[0m`+ -`\x1b[48;5;75m \x1b[0m`+ -`\x1b[48;5;76m \x1b[0m`+ -`\x1b[48;5;77m \x1b[0m`+ -`\x1b[48;5;78m \x1b[0m`+ -`\x1b[48;5;79m \x1b[0m`+ -`\x1b[48;5;80m \x1b[0m`); -term.write( -`\x1b[48;5;81m \x1b[0m`+ -`\x1b[48;5;82m \x1b[0m`+ -`\x1b[48;5;83m \x1b[0m`+ -`\x1b[48;5;84m \x1b[0m`+ -`\x1b[48;5;85m \x1b[0m`+ -`\x1b[48;5;86m \x1b[0m`+ -`\x1b[48;5;87m \x1b[0m`+ -`\x1b[48;5;88m \x1b[0m`+ -`\x1b[48;5;89m \x1b[0m`+ -`\x1b[48;5;90m \x1b[0m`); -term.write( -`\x1b[48;5;91m \x1b[0m`+ -`\x1b[48;5;92m \x1b[0m`+ -`\x1b[48;5;93m \x1b[0m`+ -`\x1b[48;5;94m \x1b[0m`+ -`\x1b[48;5;95m \x1b[0m`+ -`\x1b[48;5;96m \x1b[0m`+ -`\x1b[48;5;97m \x1b[0m`+ -`\x1b[48;5;98m \x1b[0m`+ -`\x1b[48;5;99m \x1b[0m`+ -`\x1b[48;5;100m \x1b[0m`); -term.write( -`\x1b[48;5;101m \x1b[0m`+ -`\x1b[48;5;102m \x1b[0m`+ -`\x1b[48;5;103m \x1b[0m`+ -`\x1b[48;5;104m \x1b[0m`+ -`\x1b[48;5;105m \x1b[0m`+ -`\x1b[48;5;106m \x1b[0m`+ -`\x1b[48;5;107m \x1b[0m`+ -`\x1b[48;5;108m \x1b[0m`+ -`\x1b[48;5;109m \x1b[0m`+ -`\x1b[48;5;110m \x1b[0m`); -term.write( -`\x1b[48;5;111m \x1b[0m`+ -`\x1b[48;5;112m \x1b[0m`+ -`\x1b[48;5;113m \x1b[0m`+ -`\x1b[48;5;114m \x1b[0m`+ -`\x1b[48;5;115m \x1b[0m`+ -`\x1b[48;5;116m \x1b[0m`+ -`\x1b[48;5;117m \x1b[0m`+ -`\x1b[48;5;118m \x1b[0m`+ -`\x1b[48;5;119m \x1b[0m`+ -`\x1b[48;5;120m \x1b[0m`); -term.write( -`\x1b[48;5;121m \x1b[0m`+ -`\x1b[48;5;122m \x1b[0m`+ -`\x1b[48;5;123m \x1b[0m`+ -`\x1b[48;5;124m \x1b[0m`+ -`\x1b[48;5;125m \x1b[0m`+ -`\x1b[48;5;126m \x1b[0m`+ -`\x1b[48;5;127m \x1b[0m`+ -`\x1b[48;5;128m \x1b[0m`+ -`\x1b[48;5;129m \x1b[0m`+ -`\x1b[48;5;130m \x1b[0m`); -term.write( -`\x1b[48;5;131m \x1b[0m`+ -`\x1b[48;5;132m \x1b[0m`+ -`\x1b[48;5;133m \x1b[0m`+ -`\x1b[48;5;134m \x1b[0m`+ -`\x1b[48;5;135m \x1b[0m`+ -`\x1b[48;5;136m \x1b[0m`+ -`\x1b[48;5;137m \x1b[0m`+ -`\x1b[48;5;138m \x1b[0m`+ -`\x1b[48;5;139m \x1b[0m`+ -`\x1b[48;5;140m \x1b[0m`); -term.write( -`\x1b[48;5;141m \x1b[0m`+ -`\x1b[48;5;142m \x1b[0m`+ -`\x1b[48;5;143m \x1b[0m`+ -`\x1b[48;5;144m \x1b[0m`+ -`\x1b[48;5;145m \x1b[0m`+ -`\x1b[48;5;146m \x1b[0m`+ -`\x1b[48;5;147m \x1b[0m`+ -`\x1b[48;5;148m \x1b[0m`+ -`\x1b[48;5;149m \x1b[0m`+ -`\x1b[48;5;150m \x1b[0m`); -term.write( -`\x1b[48;5;151m \x1b[0m`+ -`\x1b[48;5;152m \x1b[0m`+ -`\x1b[48;5;153m \x1b[0m`+ -`\x1b[48;5;154m \x1b[0m`+ -`\x1b[48;5;155m \x1b[0m`+ -`\x1b[48;5;156m \x1b[0m`+ -`\x1b[48;5;157m \x1b[0m`+ -`\x1b[48;5;158m \x1b[0m`+ -`\x1b[48;5;159m \x1b[0m`+ -`\x1b[48;5;160m \x1b[0m`); -term.write( -`\x1b[48;5;161m \x1b[0m`+ -`\x1b[48;5;162m \x1b[0m`+ -`\x1b[48;5;163m \x1b[0m`+ -`\x1b[48;5;164m \x1b[0m`+ -`\x1b[48;5;165m \x1b[0m`+ -`\x1b[48;5;166m \x1b[0m`+ -`\x1b[48;5;167m \x1b[0m`+ -`\x1b[48;5;168m \x1b[0m`+ -`\x1b[48;5;169m \x1b[0m`+ -`\x1b[48;5;170m \x1b[0m`); -term.write( -`\x1b[48;5;171m \x1b[0m`+ -`\x1b[48;5;172m \x1b[0m`+ -`\x1b[48;5;173m \x1b[0m`+ -`\x1b[48;5;174m \x1b[0m`+ -`\x1b[48;5;175m \x1b[0m`+ -`\x1b[48;5;176m \x1b[0m`+ -`\x1b[48;5;177m \x1b[0m`+ -`\x1b[48;5;178m \x1b[0m`+ -`\x1b[48;5;179m \x1b[0m`+ -`\x1b[48;5;180m \x1b[0m`); -term.write( -`\x1b[48;5;181m \x1b[0m`+ -`\x1b[48;5;182m \x1b[0m`+ -`\x1b[48;5;183m \x1b[0m`+ -`\x1b[48;5;184m \x1b[0m`+ -`\x1b[48;5;185m \x1b[0m`+ -`\x1b[48;5;186m \x1b[0m`+ -`\x1b[48;5;187m \x1b[0m`+ -`\x1b[48;5;188m \x1b[0m`+ -`\x1b[48;5;189m \x1b[0m`+ -`\x1b[48;5;190m \x1b[0m`); -term.write( -`\x1b[48;5;191m \x1b[0m`+ -`\x1b[48;5;192m \x1b[0m`+ -`\x1b[48;5;193m \x1b[0m`+ -`\x1b[48;5;194m \x1b[0m`+ -`\x1b[48;5;195m \x1b[0m`+ -`\x1b[48;5;196m \x1b[0m`+ -`\x1b[48;5;197m \x1b[0m`+ -`\x1b[48;5;198m \x1b[0m`+ -`\x1b[48;5;199m \x1b[0m`+ -`\x1b[48;5;200m \x1b[0m`); -term.write( -`\x1b[48;5;201m \x1b[0m`+ -`\x1b[48;5;202m \x1b[0m`+ -`\x1b[48;5;203m \x1b[0m`+ -`\x1b[48;5;204m \x1b[0m`+ -`\x1b[48;5;205m \x1b[0m`+ -`\x1b[48;5;206m \x1b[0m`+ -`\x1b[48;5;207m \x1b[0m`+ -`\x1b[48;5;208m \x1b[0m`+ -`\x1b[48;5;209m \x1b[0m`+ -`\x1b[48;5;210m \x1b[0m`); -term.write( -`\x1b[48;5;211m \x1b[0m`+ -`\x1b[48;5;212m \x1b[0m`+ -`\x1b[48;5;213m \x1b[0m`+ -`\x1b[48;5;214m \x1b[0m`+ -`\x1b[48;5;215m \x1b[0m`+ -`\x1b[48;5;216m \x1b[0m`+ -`\x1b[48;5;217m \x1b[0m`+ -`\x1b[48;5;218m \x1b[0m`+ -`\x1b[48;5;219m \x1b[0m`+ -`\x1b[48;5;220m \x1b[0m`); -term.write( -`\x1b[48;5;221m \x1b[0m`+ -`\x1b[48;5;222m \x1b[0m`+ -`\x1b[48;5;223m \x1b[0m`+ -`\x1b[48;5;224m \x1b[0m`+ -`\x1b[48;5;225m \x1b[0m`+ -`\x1b[48;5;226m \x1b[0m`+ -`\x1b[48;5;227m \x1b[0m`+ -`\x1b[48;5;228m \x1b[0m`+ -`\x1b[48;5;229m \x1b[0m`+ -`\x1b[48;5;230m \x1b[0m`); -term.write( -`\x1b[48;5;231m \x1b[0m`+ -`\x1b[48;5;232m \x1b[0m`+ -`\x1b[48;5;233m \x1b[0m`+ -`\x1b[48;5;234m \x1b[0m`+ -`\x1b[48;5;235m \x1b[0m`+ -`\x1b[48;5;236m \x1b[0m`+ -`\x1b[48;5;237m \x1b[0m`+ -`\x1b[48;5;238m \x1b[0m`+ -`\x1b[48;5;239m \x1b[0m`+ -`\x1b[48;5;240m \x1b[0m`); -term.write( -`\x1b[48;5;241m \x1b[0m`+ -`\x1b[48;5;242m \x1b[0m`+ -`\x1b[48;5;243m \x1b[0m`+ -`\x1b[48;5;244m \x1b[0m`+ -`\x1b[48;5;245m \x1b[0m`+ -`\x1b[48;5;246m \x1b[0m`+ -`\x1b[48;5;247m \x1b[0m`+ -`\x1b[48;5;248m \x1b[0m`+ -`\x1b[48;5;249m \x1b[0m`+ -`\x1b[48;5;250m \x1b[0m`); -term.write( -`\x1b[48;5;251m \x1b[0m`+ -`\x1b[48;5;252m \x1b[0m`+ -`\x1b[48;5;253m \x1b[0m`+ -`\x1b[48;5;254m \x1b[0m`+ -`\x1b[48;5;255m \x1b[0m`+ -`\x1b[48;5;256m \x1b[0m`) -term.write('\n\r'); + term.writeln(`\x1b[0m\n\n\rStandard colors: Bright colors:`); + for (let i = 0; i < 16; i++) { + term.write(`\x1b[48;5;${i}m ${i.toString().padEnd(2, ' ').padStart(3, ' ')} \x1b[0m`); + } + + term.writeln(`\x1b[0m\n\n\rColors 17-231 from 256 palette:`); + for (let i = 0; i < 6; i++) { + const startId = 16 + i * 36; + const endId = 16 + (i + 1) * 36 - 1; + term.write(`${startId.toString().padStart(3, ' ')}-${endId.toString().padStart(3, ' ')} `); + for (let j = 0; j < 36; j++) { + const id = 16 + i * 36 + j; + term.write(`\x1b[48;5;${id}m${(id % 10).toString().padStart(2, ' ')}\x1b[0m`); + } + term.write(`\r\n`); + } + + term.writeln(`\x1b[0m\n\rGreyscale from 256 palette:`); + term.write('232-255 '); + for (let i = 232; i < 256; i++) { + term.write(`\x1b[48;5;${i}m ${(i % 10)} \x1b[0m`); + } } + function addDecoration() { term.options['overviewRulerWidth'] = 15; const marker = term.registerMarker(1); diff --git a/demo/index.html b/demo/index.html index d3fc6aab..836084b3 100644 --- a/demo/index.html +++ b/demo/index.html @@ -78,7 +78,7 @@
-
+
Decorations
From d608912efdd62a317dca9cb915f15880d5d05a7e Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 4 Aug 2022 06:20:42 -0700 Subject: [PATCH 07/10] Remove electron renderer target This causes global to be required which is not available in sandboxed electron renderers See microsoft/vscode#157008 --- addons/xterm-addon-ligatures/webpack.config.js | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/xterm-addon-ligatures/webpack.config.js b/addons/xterm-addon-ligatures/webpack.config.js index ea69841e..e8066771 100644 --- a/addons/xterm-addon-ligatures/webpack.config.js +++ b/addons/xterm-addon-ligatures/webpack.config.js @@ -11,7 +11,6 @@ const mainFile = 'xterm-addon-ligatures.js'; module.exports = { entry: `./out/${addonName}.js`, devtool: 'source-map', - target: 'electron-renderer', module: { rules: [ { From f3f6a91f162c724f70a99b9b93e0873eb09355a0 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 4 Aug 2022 09:57:37 -0700 Subject: [PATCH 08/10] Remove node target from ligatures This complicates bundling for sandboxed electron a lot, ideally we would only rely on browser APIs for font access --- addons/xterm-addon-ligatures/src/font.ts | 15 +++------------ addons/xterm-addon-ligatures/src/index.ts | 2 +- addons/xterm-addon-ligatures/webpack.config.js | 17 +---------------- 3 files changed, 5 insertions(+), 29 deletions(-) diff --git a/addons/xterm-addon-ligatures/src/font.ts b/addons/xterm-addon-ligatures/src/font.ts index 5c5f0a6c..ece22367 100644 --- a/addons/xterm-addon-ligatures/src/font.ts +++ b/addons/xterm-addon-ligatures/src/font.ts @@ -3,8 +3,7 @@ * @license MIT */ -import { FontList } from 'font-finder'; -import { Font, loadBuffer, loadFile } from 'font-ligatures'; +import { Font, loadBuffer } from 'font-ligatures'; import parse from './parse'; @@ -24,7 +23,7 @@ interface IFontAccessNavigator { }; } -let fontsPromise: Promise> | undefined = undefined; +let fontsPromise: Promise> | undefined = undefined; /** * Loads the font ligature wrapper for the specified font family if it could be @@ -81,14 +80,6 @@ export default async function load(fontFamily: string, cacheSize: number): Promi console.error(err.name, err.message); } } - // Node environment or no font access API - else { - try { - fontsPromise = (await import('font-finder')).list(); - } catch (err) { - // No-op - } - } if (!fontsPromise) { fontsPromise = Promise.resolve({}); } @@ -110,7 +101,7 @@ export default async function load(fontFamily: string, cacheSize: number): Promi const buffer = await bytes.arrayBuffer(); return loadBuffer(buffer, { cacheSize }); } - return await loadFile(font.path, { cacheSize }); + return undefined; } } diff --git a/addons/xterm-addon-ligatures/src/index.ts b/addons/xterm-addon-ligatures/src/index.ts index 82589e36..82675626 100644 --- a/addons/xterm-addon-ligatures/src/index.ts +++ b/addons/xterm-addon-ligatures/src/index.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { Terminal } from 'xterm'; +import type { Terminal } from 'xterm'; import { Font } from 'font-ligatures'; import load from './font'; diff --git a/addons/xterm-addon-ligatures/webpack.config.js b/addons/xterm-addon-ligatures/webpack.config.js index e8066771..97da1e17 100644 --- a/addons/xterm-addon-ligatures/webpack.config.js +++ b/addons/xterm-addon-ligatures/webpack.config.js @@ -27,20 +27,5 @@ module.exports = { library: addonName, libraryTarget: 'umd' }, - mode: 'production', - externals: { - 'font-finder': 'font-finder', - 'stream': 'stream', - 'os': 'os', - 'util': 'util' - }, - resolve: { - // The ligature modules contains fallbacks for node environments, we never want to browserify them - fallback: { - stream: false, - util: false, - os: false, - path: false - } - } + mode: 'production' }; From d495fdd9ab6ea8f3371aeab97f784984abc87083 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 4 Aug 2022 10:01:58 -0700 Subject: [PATCH 09/10] Bring back webpack resolve config --- addons/xterm-addon-ligatures/webpack.config.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/addons/xterm-addon-ligatures/webpack.config.js b/addons/xterm-addon-ligatures/webpack.config.js index 97da1e17..5aeebe2e 100644 --- a/addons/xterm-addon-ligatures/webpack.config.js +++ b/addons/xterm-addon-ligatures/webpack.config.js @@ -27,5 +27,21 @@ module.exports = { library: addonName, libraryTarget: 'umd' }, - mode: 'production' + mode: 'production', + externals: { + 'fs': 'fs', + 'path': 'path', + 'stream': 'stream', + 'util': 'util' + }, + resolve: { + // The ligature modules contains fallbacks for node environments, we never want to browserify them + fallback: { + fs: false, + os: false, + path: false, + stream: false, + util: false + } + } }; From f0926e78211eecd4bf287cbdc91c7f3d100abe0c Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Thu, 4 Aug 2022 10:11:11 -0700 Subject: [PATCH 10/10] Remove tests that rely on node We can test this primarily with api tests instead --- .../xterm-addon-ligatures/src/index.test.ts | 70 ------------------- 1 file changed, 70 deletions(-) diff --git a/addons/xterm-addon-ligatures/src/index.test.ts b/addons/xterm-addon-ligatures/src/index.test.ts index 0cfe2462..c7bf09ce 100644 --- a/addons/xterm-addon-ligatures/src/index.test.ts +++ b/addons/xterm-addon-ligatures/src/index.test.ts @@ -69,76 +69,6 @@ describe('xterm-addon-ligatures', () => { assert.deepEqual(term.joiner!(input), []); }); - it('returns the correct set of ranges once the font has loaded', done => { - assert.deepEqual(term.joiner!(input), []); - onRefresh.callsFake(() => { - assert.deepEqual(term.joiner!(input), [[2, 4], [7, 10]]); - done(); - }); - }); - - it('handles quoted font names', done => { - term.options.fontFamily = '"Fira Code", monospace'; - assert.deepEqual(term.joiner!(input), []); - onRefresh.callsFake(() => { - assert.deepEqual(term.joiner!(input), [[2, 4], [7, 10]]); - done(); - }); - }); - - it('falls back to later fonts if earlier ones are not present', done => { - term.options.fontFamily = 'notinstalled, Fira Code, monospace'; - assert.deepEqual(term.joiner!(input), []); - onRefresh.callsFake(() => { - assert.deepEqual(term.joiner!(input), [[2, 4], [7, 10]]); - done(); - }); - }); - - it('uses the current font value', done => { - // The first three calls are all synchronous so that we don't allow time for - // any fonts to load while we're switching things around - term.options.fontFamily = 'Fira Code'; - assert.deepEqual(term.joiner!(input), []); - term.options.fontFamily = 'notinstalled'; - assert.deepEqual(term.joiner!(input), []); - term.options.fontFamily = 'Iosevka'; - assert.deepEqual(term.joiner!(input), []); - onRefresh.callsFake(() => { - assert.deepEqual(term.joiner!(input), [[2, 4]]); - - // And switch it back to Fira Code for good measure - term.options.fontFamily = 'Fira Code'; - - // At this point, we haven't loaded the new font, so the result reverts - // back to empty until that happens - assert.deepEqual(term.joiner!(input), []); - - onRefresh.callsFake(() => { - assert.deepEqual(term.joiner!(input), [[2, 4], [7, 10]]); - done(); - }); - }); - }); - - it('allows multiple terminal instances that use different fonts', done => { - const onRefresh2 = sinon.stub(); - const term2 = new MockTerminal(onRefresh2); - term2.options.fontFamily = 'Iosevka'; - ligatureSupport.enableLigatures(term2 as any); - - assert.deepEqual(term.joiner!(input), []); - onRefresh.callsFake(() => { - assert.deepEqual(term.joiner!(input), [[2, 4], [7, 10]]); - assert.deepEqual(term2.joiner!(input), []); - onRefresh2.callsFake(() => { - assert.deepEqual(term2.joiner!(input), [[2, 4]]); - assert.deepEqual(term.joiner!(input), [[2, 4], [7, 10]]); - done(); - }); - }); - }); - it('fails if it finds but cannot load the font', async () => { term.options.fontFamily = 'Nonexistant Font, monospace'; assert.deepEqual(term.joiner!(input), []);