diff options
Diffstat (limited to 'scripts/theme-selector')
| -rw-r--r-- | scripts/theme-selector/generate.py | 63 | ||||
| -rw-r--r-- | scripts/theme-selector/theme-selector.html | 63 |
2 files changed, 112 insertions, 14 deletions
diff --git a/scripts/theme-selector/generate.py b/scripts/theme-selector/generate.py index d6832084..d66ae4fb 100644 --- a/scripts/theme-selector/generate.py +++ b/scripts/theme-selector/generate.py @@ -221,6 +221,10 @@ HTML = """<!doctype html><meta charset=utf-8><title>theme-selector</title> .pane{min-width:0} .pane.grow{flex:1} .pane.saveload{flex:0 0 auto;margin-left:auto} .pane h1{margin-top:0} .filebar.end{justify-content:flex-end} .langbar{margin-bottom:10px;display:flex;gap:8px;align-items:center} + .pkgbar{margin:0 0 10px;display:flex;gap:8px;align-items:center;flex-wrap:wrap} + .pkgbar button{background:#252321;color:#e8bd30;border:1px solid #3a3a3a;border-radius:4px;padding:6px 12px;font:10pt monospace;cursor:pointer} + .hstep{background:#161412;border:1px solid #252321;color:#cdced1;border-radius:4px;padding:3px 4px;font:10pt monospace;width:56px} + #pkgbody td{padding:3px 8px} #codepre{width:100%;box-sizing:border-box} .mock{border:1px solid #252321;border-radius:8px;overflow:hidden;font:15px/1.7 monospace;display:flex;flex-direction:column} .mock .mbuf{flex:1} .mock .ln{display:flex;align-items:stretch;white-space:pre} @@ -289,6 +293,21 @@ HTML = """<!doctype html><meta charset=utf-8><title>theme-selector</title> <div id="mockframe" class="mock"></div> </section> </div> +<h1>package faces</h1> +<div class="pkgbar"> + <label style="color:#b4b1a2">application</label><select id="appsel" class="chip" style="width:auto;font:bold 10pt monospace"></select> + <label style="color:#b4b1a2">filter</label><input id="pkgfilter" type="text" placeholder="face name" oninput="buildPkgTable()" style="background:#161412;border:1px solid #252321;color:#cdced1;border-radius:4px;padding:5px 8px;font:10pt monospace;width:160px"> + <button onclick="resetApp()">↻ reset all</button> +</div> +<div class="cols stretch"> + <section class="pane"> + <table class="leg" id="pkgtable"><thead><tr><th>face</th><th>fg</th><th>bg</th><th>weight</th><th>inherit</th><th>size</th><th>contrast</th><th></th></tr></thead><tbody id="pkgbody"></tbody></table> + </section> + <section class="pane grow" style="display:flex;flex-direction:column"> + <div class="langbar"><label style="color:#b4b1a2">preview (generic — face names in their own colors)</label></div> + <div id="pkgpreview" class="mock" style="overflow:auto"></div> + </section> +</div> <script> const SAMPLES=SAMPLES_J, CATS=CATS_J, UI_FACES=UIFACES_J, APPS=APPS_J; let MAP=MAP_J, PALETTE=PALETTE_J, BOLD=BOLD_J, ITALIC={}, UIMAP=UIMAP_J; @@ -369,7 +388,7 @@ function renderPalette(){ d.ondragleave=()=>d.classList.remove('over'); d.ondrop=(e)=>{e.preventDefault();d.classList.remove('over');if(dragFrom===null||dragFrom===i)return;const m=PALETTE.splice(dragFrom,1)[0];PALETTE.splice(i,0,m);dragFrom=null;selectedIdx=null;renderPalette();buildTable();buildUITable();}; p.appendChild(d);}); - buildUITable(); + buildUITable();if(document.getElementById('pkgbody'))buildPkgTable(); } function notify(msg,err){const m=document.getElementById('palmsg');if(!m)return;m.textContent=msg;m.style.color=err?'#cb6b4d':'#8a9496';m.style.opacity='1';clearTimeout(m._t);m._t=setTimeout(()=>{m.style.opacity='0';},err?4000:2800);} function applyEdit(){if(selectedIdx!==null)updateColor();else addColor();} @@ -384,6 +403,7 @@ function updateColor(){ PALETTE[i]=[newHex,newName]; for(const k in MAP){if(MAP[k]===oldHex)MAP[k]=newHex;} for(const f in UIMAP){if(UIMAP[f].fg===oldHex)UIMAP[f].fg=newHex;if(UIMAP[f].bg===oldHex)UIMAP[f].bg=newHex;} + for(const ap in PKGMAP)for(const fc in PKGMAP[ap]){const o=PKGMAP[ap][fc];if(o.fg===oldHex)o.fg=newHex;if(o.bg===oldHex)o.bg=newHex;} closePicker();renderPalette();buildTable();buildUITable();renderCode();applyGround();notify('updated "'+newName+'"',false); } function normHex(s){s=s.trim();if(/^[0-9a-fA-F]{6}$/.test(s))s='#'+s;return /^#[0-9a-fA-F]{6}$/.test(s)?s.toLowerCase():null;} @@ -432,7 +452,7 @@ function importFile(ev){const f=ev.target.files[0];if(!f)return;const r=new File BOLD={};(d.bold||[]).forEach(k=>BOLD[k]=true);ITALIC={};(d.italic||[]).forEach(k=>ITALIC[k]=true); if(d.ui)Object.assign(UIMAP,d.ui); PKGMAP=seedPkgmap();if(d.packages)mergePackagesInto(PKGMAP,d.packages); - renderPalette();buildTable();buildUITable();renderCode();applyGround();updateTitle();}catch(e){alert('bad theme file: '+e.message);}}; + renderPalette();buildTable();buildUITable();buildPkgTable();buildPkgPreview();renderCode();applyGround();updateTitle();}catch(e){alert('bad theme file: '+e.message);}}; r.readAsText(f);ev.target.value='';} function applyGround(){document.querySelectorAll('pre').forEach(p=>p.style.background=MAP['bg']);document.querySelectorAll('.ex').forEach(e=>e.style.background=MAP['bg']);} function uf(f){return UIMAP[f]||{};} @@ -487,16 +507,45 @@ function buildMockFrame(){ fr.innerHTML=html;fr.style.background=bg;fr.style.color=fg; fr.onclick=(e)=>{const u=e.target.closest('[data-face]');if(u){flashUi(u.dataset.face);return;}const k=e.target.closest('[data-k]');if(k)flashAssign(k.dataset.k);}; } -function uiSelect(face,attr){ +function colorDropdown(value,onpick){ const sel=document.createElement('select');sel.className='chip'; const none=document.createElement('option');none.value='';none.textContent='— none —';none.style.background='#161412';none.style.color='#b4b1a2';sel.appendChild(none); for(const [hex,name] of PALETTE){const o=document.createElement('option');o.value=hex;o.textContent=name+' '+hex;o.style.background=hex;o.style.color=textOn(hex);sel.appendChild(o);} - sel.value=UIMAP[face][attr]||''; + sel.value=value||''; function style(){if(sel.value){sel.style.background=sel.value;sel.style.color=textOn(sel.value);}else{sel.style.background='#161412';sel.style.color='#b4b1a2';}} style(); - sel.onchange=()=>{UIMAP[face][attr]=sel.value||null;style();paintUI(face);buildMockFrame();}; + sel.onchange=()=>{style();onpick(sel.value||null);}; return sel; } +function uiSelect(face,attr){return colorDropdown(UIMAP[face][attr],v=>{UIMAP[face][attr]=v;paintUI(face);buildMockFrame();});} +const BASE_INHERITS=['fixed-pitch','variable-pitch','default','link','bold','italic','shadow']; +function seedFace(d){return {fg:pname(d.fg),bg:pname(d.bg),bold:!!d.bold,italic:!!d.italic,inherit:d.inherit||null,height:d.height||1,source:'default'};} +function curApp(){const s=document.getElementById('appsel');return s&&s.value?s.value:Object.keys(APPS)[0];} +function pkgEffFg(app,face,seen){seen=seen||{};const f=PKGMAP[app]&&PKGMAP[app][face];if(!f||seen[face])return null;seen[face]=1;if(f.fg)return f.fg;if(f.inherit&&PKGMAP[app][f.inherit])return pkgEffFg(app,f.inherit,seen);return null;} +function pkgEffBg(app,face,seen){seen=seen||{};const f=PKGMAP[app]&&PKGMAP[app][face];if(!f||seen[face])return null;seen[face]=1;if(f.bg)return f.bg;if(f.inherit&&PKGMAP[app][f.inherit])return pkgEffBg(app,f.inherit,seen);return null;} +function buildAppSel(){const s=document.getElementById('appsel');if(!s)return;s.innerHTML='';for(const app in APPS){const o=document.createElement('option');o.value=app;o.textContent=APPS[app].label;s.appendChild(o);}s.onchange=pkgChanged;} +function pkgChanged(){buildPkgTable();buildPkgPreview();syncPkgHeight();} +function buildPkgTable(){ + const app=curApp(),tb=document.getElementById('pkgbody');if(!tb)return;tb.innerHTML=''; + const flt=(document.getElementById('pkgfilter').value||'').trim().toLowerCase(); + const inh=[''].concat(BASE_INHERITS).concat(APPS[app].faces.map(r=>r[0])); + for(const [face,label,def] of APPS[app].faces){ + if(flt&&!(face.toLowerCase().includes(flt)||label.toLowerCase().includes(flt)))continue; + const f=PKGMAP[app][face],tr=document.createElement('tr'); + const c0=document.createElement('td');c0.className='cat';c0.textContent=label;c0.title=face; + const cf=document.createElement('td');cf.appendChild(colorDropdown(f.fg,v=>{f.fg=v;f.source='user';pkgChanged();})); + const cb=document.createElement('td');cb.appendChild(colorDropdown(f.bg,v=>{f.bg=v;f.source='user';pkgChanged();})); + const cw=document.createElement('td');[['B','bold'],['I','italic']].forEach(([ch,at])=>{const b=document.createElement('button');b.className='sbtn'+(f[at]?' on':'');b.textContent='a';b.style.fontWeight=at==='bold'?'bold':'normal';b.style.fontStyle=at==='italic'?'italic':'normal';b.onclick=()=>{f[at]=!f[at];f.source='user';pkgChanged();};cw.appendChild(b);}); + const ci=document.createElement('td');const isel=document.createElement('select');isel.className='chip';isel.style.cssText='width:150px;font:10pt monospace';inh.forEach(o=>{const op=document.createElement('option');op.value=o;op.textContent=o||'— none —';isel.appendChild(op);});isel.value=f.inherit||'';isel.onchange=()=>{f.inherit=isel.value||null;f.source='user';pkgChanged();};ci.appendChild(isel); + const ch=document.createElement('td');const hin=document.createElement('input');hin.type='number';hin.min='0.8';hin.max='2.5';hin.step='0.05';hin.value=f.height||1;hin.className='hstep';hin.onchange=()=>{f.height=parseFloat(hin.value)||1;f.source='user';pkgChanged();};ch.appendChild(hin); + const cc=document.createElement('td');cc.style.fontSize='10pt';cc.style.whiteSpace='nowrap';const efg=pkgEffFg(app,face)||MAP['p'],ebg=pkgEffBg(app,face)||MAP['bg'],r=contrast(efg,ebg);cc.innerHTML=`<span style="color:${ratingColor(r)}">${r.toFixed(1)} ${rating(r)}</span>`; + const cr=document.createElement('td');const rb=document.createElement('button');rb.className='sbtn';rb.textContent='↺';rb.title='reset to default';rb.onclick=()=>{PKGMAP[app][face]=seedFace(def);pkgChanged();};cr.appendChild(rb); + tr.append(c0,cf,cb,cw,ci,ch,cc,cr);tb.appendChild(tr); + } +} +function buildPkgPreview(){const app=curApp(),p=document.getElementById('pkgpreview');if(!p)return;let h='<div style="padding:10px 14px;font:15px/1.8 monospace">';for(const [face,label,def] of APPS[app].faces){const f=PKGMAP[app][face],efg=pkgEffFg(app,face)||MAP['p'],ebg=pkgEffBg(app,face);h+=`<div style="color:${efg};${ebg?'background:'+ebg+';':''}font-weight:${f.bold?'bold':'normal'};font-style:${f.italic?'italic':'normal'};font-size:${(f.height||1)}em">${esc(label)}</div>`;}p.innerHTML=h+'</div>';p.style.background=MAP['bg'];} +function resetApp(){const app=curApp();PKGMAP[app]={};for(const [face,label,d] of APPS[app].faces)PKGMAP[app][face]=seedFace(d);pkgChanged();} +function syncPkgHeight(){const t=document.getElementById('pkgtable'),m=document.getElementById('pkgpreview');if(!t||!m)return;const lb=m.previousElementSibling,lbh=lb?lb.getBoundingClientRect().height+10:30;m.style.height=Math.max(t.getBoundingClientRect().height-lbh,220)+'px';} function paintUI(face){const pv=document.getElementById('uiprev-'+face);if(!pv)return;pv.style.color=UIMAP[face].fg||MAP['p'];pv.style.background=UIMAP[face].bg||MAP['bg'];} function buildUITable(){ const tb=document.getElementById('uibody');tb.innerHTML=''; @@ -514,8 +563,8 @@ function srt(c){const tb=document.getElementById('legbody');const r=[...tb.rows] r.sort((a,b)=>{const x=(c===0?a.querySelector('select').value:a.cells[2].innerText).toLowerCase(), y=(c===0?b.querySelector('select').value:b.cells[2].innerText).toLowerCase(); return (x<y?-1:x>y?1:0)*(D[c]?1:-1);});r.forEach(x=>tb.appendChild(x));} -buildLangSel();renderPalette();buildTable();buildUITable();renderCode();applyGround();updateTitle();initPicker();syncMockHeight(); -addEventListener('resize',syncMockHeight); +buildLangSel();buildAppSel();renderPalette();buildTable();buildUITable();renderCode();applyGround();updateTitle();initPicker();buildPkgTable();buildPkgPreview();syncMockHeight();syncPkgHeight(); +addEventListener('resize',()=>{syncMockHeight();syncPkgHeight();}); // Phase-1 self-test (open with #selftest): seed -> export -> import -> compare. function pkgSelftest(){ const seeded=seedPkgmap(); diff --git a/scripts/theme-selector/theme-selector.html b/scripts/theme-selector/theme-selector.html index 310ee85e..0f865f7d 100644 --- a/scripts/theme-selector/theme-selector.html +++ b/scripts/theme-selector/theme-selector.html @@ -45,6 +45,10 @@ .pane{min-width:0} .pane.grow{flex:1} .pane.saveload{flex:0 0 auto;margin-left:auto} .pane h1{margin-top:0} .filebar.end{justify-content:flex-end} .langbar{margin-bottom:10px;display:flex;gap:8px;align-items:center} + .pkgbar{margin:0 0 10px;display:flex;gap:8px;align-items:center;flex-wrap:wrap} + .pkgbar button{background:#252321;color:#e8bd30;border:1px solid #3a3a3a;border-radius:4px;padding:6px 12px;font:10pt monospace;cursor:pointer} + .hstep{background:#161412;border:1px solid #252321;color:#cdced1;border-radius:4px;padding:3px 4px;font:10pt monospace;width:56px} + #pkgbody td{padding:3px 8px} #codepre{width:100%;box-sizing:border-box} .mock{border:1px solid #252321;border-radius:8px;overflow:hidden;font:15px/1.7 monospace;display:flex;flex-direction:column} .mock .mbuf{flex:1} .mock .ln{display:flex;align-items:stretch;white-space:pre} @@ -113,6 +117,21 @@ <div id="mockframe" class="mock"></div> </section> </div> +<h1>package faces</h1> +<div class="pkgbar"> + <label style="color:#b4b1a2">application</label><select id="appsel" class="chip" style="width:auto;font:bold 10pt monospace"></select> + <label style="color:#b4b1a2">filter</label><input id="pkgfilter" type="text" placeholder="face name" oninput="buildPkgTable()" style="background:#161412;border:1px solid #252321;color:#cdced1;border-radius:4px;padding:5px 8px;font:10pt monospace;width:160px"> + <button onclick="resetApp()">↻ reset all</button> +</div> +<div class="cols stretch"> + <section class="pane"> + <table class="leg" id="pkgtable"><thead><tr><th>face</th><th>fg</th><th>bg</th><th>weight</th><th>inherit</th><th>size</th><th>contrast</th><th></th></tr></thead><tbody id="pkgbody"></tbody></table> + </section> + <section class="pane grow" style="display:flex;flex-direction:column"> + <div class="langbar"><label style="color:#b4b1a2">preview (generic — face names in their own colors)</label></div> + <div id="pkgpreview" class="mock" style="overflow:auto"></div> + </section> +</div> <script> const SAMPLES={"Elisp": [[["cmd", ";;"], ["cm", " cache.el"]], [["punc", "("], ["kw", "require"], ["p", " "], ["con", "'cl-lib"], ["punc", ")"]], [], [["punc", "("], ["kw", "defvar"], ["p", " "], ["var", "cache--tbl"], ["p", " "], ["punc", "("], ["fnc", "make-hash-table"], ["p", " "], ["con", ":test"], ["p", " "], ["con", "'equal"], ["punc", "))"]], [["p", " "], ["doc", "\"Memo table.\")"]], [], [["punc", "("], ["kw", "defun"], ["p", " "], ["fnd", "cache-get"], ["p", " "], ["punc", "("], ["var", "key"], ["punc", ")"]], [["p", " "], ["doc", "\"Return cached value for KEY.\""]], [["p", " "], ["punc", "("], ["kw", "or"], ["p", " "], ["punc", "("], ["bi", "gethash"], ["p", " "], ["var", "key"], ["p", " "], ["var", "cache--tbl"], ["punc", ")"]], [["p", " "], ["punc", "("], ["kw", "let"], ["p", " "], ["punc", "(("], ["var", "v"], ["p", " "], ["punc", "("], ["fnc", "compute"], ["p", " "], ["var", "key"], ["p", " "], ["num", "42"], ["punc", "))) "]], [["p", " "], ["punc", "("], ["fnc", "puthash"], ["p", " "], ["var", "key"], ["p", " "], ["var", "v"], ["p", " "], ["var", "cache--tbl"], ["punc", ") "], ["var", "v"], ["punc", "))))"]], [], [["punc", "("], ["kw", "defun"], ["p", " "], ["fnd", "cache-clear"], ["p", " "], ["punc", "()"]], [["p", " "], ["doc", "\"Empty the memo table.\""]], [["p", " "], ["punc", "("], ["kw", "interactive"], ["punc", ")"]], [["p", " "], ["punc", "("], ["fnc", "clrhash"], ["p", " "], ["var", "cache--tbl"], ["punc", ")"]], [["p", " "], ["punc", "("], ["fnc", "message"], ["p", " "], ["str", "\"cleared"], ["esc", "\\n"], ["str", "\""], ["punc", "))"]], [], [["punc", "("], ["kw", "defun"], ["p", " "], ["fnd", "cache-keys"], ["p", " "], ["punc", "()"]], [["p", " "], ["doc", "\"Return all keys.\""]], [["p", " "], ["punc", "("], ["kw", "let"], ["p", " "], ["punc", "(("], ["var", "acc"], ["p", " "], ["con", "nil"], ["punc", "))"]], [["p", " "], ["punc", "("], ["fnc", "maphash"], ["p", " "], ["punc", "("], ["kw", "lambda"], ["p", " "], ["punc", "("], ["var", "k"], ["p", " "], ["var", "_v"], ["punc", ")"], ["p", " "], ["punc", "("], ["fnc", "push"], ["p", " "], ["var", "k"], ["p", " "], ["var", "acc"], ["punc", "))"]], [["p", " "], ["var", "cache--tbl"], ["punc", ")"], ["p", " "], ["var", "acc"], ["punc", "))"]], [], [["punc", "("], ["kw", "provide"], ["p", " "], ["con", "'cache"], ["punc", ")"]]], "Go": [[["cmd", "//"], ["cm", " queue.go"]], [["kw", "package"], ["p", " "], ["var", "main"]], [], [["kw", "import"], ["p", " "], ["str", "\"fmt\""]], [], [["kw", "const"], ["p", " "], ["con", "MaxItems"], ["p", " "], ["op", "="], ["p", " "], ["num", "100"]], [], [["kw", "type"], ["p", " "], ["ty", "Order"], ["p", " "], ["kw", "struct"], ["p", " "], ["punc", "{"]], [["p", " "], ["prop", "ID"], ["p", " "], ["ty", "int"]], [["p", " "], ["prop", "Name"], ["p", " "], ["ty", "string"]], [["punc", "}"]], [], [["kw", "func"], ["p", " "], ["punc", "("], ["var", "q"], ["p", " "], ["op", "*"], ["ty", "Queue"], ["punc", ")"], ["p", " "], ["fnd", "Push"], ["punc", "("], ["var", "o"], ["p", " "], ["op", "*"], ["ty", "Order"], ["punc", ")"], ["p", " "], ["ty", "error"], ["p", " "], ["punc", "{"]], [["p", " "], ["cmd", "//"], ["cm", " reject nil"]], [["p", " "], ["kw", "if"], ["p", " "], ["var", "o"], ["p", " "], ["op", "=="], ["p", " "], ["con", "nil"], ["p", " "], ["punc", "{"]], [["p", " "], ["kw", "return"], ["p", " "], ["fnc", "fmt.Errorf"], ["punc", "("], ["str", "\"nil"], ["esc", "\\n"], ["str", "\""], ["punc", ")"]], [["p", " "], ["punc", "}"]], [["p", " "], ["var", "q"], ["op", "."], ["prop", "items"], ["p", " "], ["op", "="], ["p", " "], ["bi", "append"], ["punc", "("], ["var", "q"], ["op", "."], ["prop", "items"], ["punc", ","], ["p", " "], ["var", "o"], ["punc", ")"]], [["p", " "], ["kw", "return"], ["p", " "], ["con", "nil"]], [["punc", "}"]], [], [["kw", "func"], ["p", " "], ["fnd", "main"], ["punc", "()"], ["p", " "], ["punc", "{"]], [["p", " "], ["fnc", "fmt.Println"], ["punc", "("], ["op", "&"], ["ty", "Queue"], ["punc", "{}"], ["punc", ")"]], [["punc", "}"]]], "Python": [[["cmd", "#"], ["cm", " theme.py"]], [["kw", "from"], ["p", " "], ["var", "dataclasses"], ["p", " "], ["kw", "import"], ["p", " "], ["var", "dataclass"], ["punc", ","], ["p", " "], ["var", "field"]], [], [["con", "DEFAULT_PORT"], ["op", ":"], ["p", " "], ["ty", "int"], ["p", " "], ["op", "="], ["p", " "], ["num", "8080"]], [["con", "HEX"], ["p", " "], ["op", "="], ["p", " "], ["var", "re"], ["op", "."], ["fnc", "compile"], ["punc", "("], ["re", "r\"#[0-9a-f]{6}\""], ["punc", ")"]], [], [["dec", "@dataclass"]], [["kw", "class"], ["p", " "], ["ty", "Theme"], ["op", ":"]], [["p", " "], ["doc", "\"\"\"A color theme.\"\"\""]], [["p", " "], ["prop", "name"], ["op", ":"], ["p", " "], ["ty", "str"], ["p", " "], ["op", "="], ["p", " "], ["str", "\"dupre\""]], [["p", " "], ["prop", "colors"], ["op", ":"], ["p", " "], ["ty", "dict"], ["p", " "], ["op", "="], ["p", " "], ["fnc", "field"], ["punc", "("], ["prop", "default_factory"], ["op", "="], ["ty", "dict"], ["punc", ")"]], [], [["p", " "], ["kw", "def"], ["p", " "], ["fnd", "resolve"], ["punc", "("], ["var", "self"], ["punc", ","], ["p", " "], ["var", "key"], ["op", ":"], ["p", " "], ["ty", "str"], ["punc", ")"], ["p", " "], ["op", "->"], ["p", " "], ["ty", "str"], ["p", " "], ["op", "|"], ["p", " "], ["con", "None"], ["op", ":"]], [["p", " "], ["cmd", "#"], ["cm", " fallback to none"]], [["p", " "], ["var", "v"], ["p", " "], ["op", "="], ["p", " "], ["var", "self"], ["op", "."], ["prop", "colors"], ["op", "."], ["fnc", "get"], ["punc", "("], ["var", "key"], ["punc", ","], ["p", " "], ["str", "\""], ["esc", "\\t"], ["str", "none\""], ["punc", ")"]], [["p", " "], ["kw", "if"], ["p", " "], ["bi", "len"], ["punc", "("], ["var", "v"], ["punc", ")"], ["p", " "], ["op", "=="], ["p", " "], ["num", "0"], ["op", ":"], ["p", " "], ["kw", "return"], ["p", " "], ["con", "None"]], [["p", " "], ["kw", "return"], ["p", " "], ["var", "v"]], [], [["p", " "], ["dec", "@property"]], [["p", " "], ["kw", "def"], ["p", " "], ["fnd", "size"], ["punc", "("], ["var", "self"], ["punc", ")"], ["p", " "], ["op", "->"], ["p", " "], ["ty", "int"], ["op", ":"]], [["p", " "], ["kw", "return"], ["p", " "], ["bi", "len"], ["punc", "("], ["var", "self"], ["op", "."], ["prop", "colors"], ["punc", ")"]], [], [["var", "theme"], ["p", " "], ["op", "="], ["p", " "], ["ty", "Theme"], ["punc", "("], ["str", "\"dupre\""], ["punc", ")"]], [["fnc", "print"], ["punc", "("], ["var", "theme"], ["op", "."], ["fnc", "resolve"], ["punc", "("], ["str", "\"bg\""], ["punc", "))"]]], "TypeScript": [[["cmd", "//"], ["cm", " orders.ts"]], [["kw", "import"], ["p", " "], ["punc", "{"], ["p", " "], ["ty", "Order"], ["p", " "], ["punc", "}"], ["p", " "], ["kw", "from"], ["p", " "], ["str", "\"./types\""]], [], [["kw", "export"], ["p", " "], ["kw", "interface"], ["p", " "], ["ty", "Queue"], ["p", " "], ["punc", "{"]], [["p", " "], ["prop", "max"], ["op", ":"], ["p", " "], ["ty", "number"], ["punc", ";"]], [["p", " "], ["prop", "items"], ["op", ":"], ["p", " "], ["ty", "Order"], ["punc", "[];"]], [["punc", "}"]], [], [["dec", "@Injectable"], ["punc", "()"]], [["kw", "export"], ["p", " "], ["kw", "class"], ["p", " "], ["ty", "OrderQueue"], ["p", " "], ["kw", "implements"], ["p", " "], ["ty", "Queue"], ["p", " "], ["punc", "{"]], [["p", " "], ["kw", "private"], ["p", " "], ["prop", "re"], ["p", " "], ["op", "="], ["p", " "], ["re", "/^#[0-9a-f]{6}$/i"], ["punc", ";"]], [], [["p", " "], ["fnd", "push"], ["punc", "("], ["var", "o"], ["op", ":"], ["p", " "], ["ty", "Order"], ["punc", ")"], ["op", ":"], ["p", " "], ["ty", "boolean"], ["p", " "], ["punc", "{"]], [["p", " "], ["kw", "if"], ["p", " "], ["punc", "("], ["var", "o"], ["p", " "], ["op", "==="], ["p", " "], ["con", "null"], ["punc", ")"], ["p", " "], ["kw", "return"], ["p", " "], ["con", "false"], ["punc", ";"]], [["p", " "], ["var", "console"], ["op", "."], ["fnc", "log"], ["punc", "("], ["str", "`id "], ["punc", "${"], ["var", "o"], ["op", "."], ["prop", "id"], ["punc", "}"], ["esc", "\\n"], ["str", "`"], ["punc", ");"]], [["p", " "], ["kw", "return"], ["p", " "], ["con", "true"], ["punc", ";"]], [["p", " "], ["punc", "}"]], [["punc", "}"]], [], [["kw", "const"], ["p", " "], ["con", "LIMIT"], ["op", ":"], ["p", " "], ["ty", "number"], ["p", " "], ["op", "="], ["p", " "], ["num", "50"], ["punc", ";"]], [["kw", "const"], ["p", " "], ["var", "q"], ["p", " "], ["op", "="], ["p", " "], ["kw", "new"], ["p", " "], ["ty", "OrderQueue"], ["punc", "()"], ["punc", ";"]], [["var", "q"], ["op", "."], ["fnd", "push"], ["punc", "("], ["punc", "{"], ["p", " "], ["prop", "id"], ["op", ":"], ["p", " "], ["num", "1"], ["p", " "], ["punc", "}"], ["p", " "], ["kw", "as"], ["p", " "], ["ty", "Order"], ["punc", ")"], ["punc", ";"]], [["var", "console"], ["op", "."], ["fnc", "log"], ["punc", "("], ["var", "q"], ["op", "."], ["prop", "max"], ["punc", ")"], ["punc", ";"]], [["kw", "const"], ["p", " "], ["var", "cap"], ["p", " "], ["op", "="], ["p", " "], ["var", "Math"], ["op", "."], ["bi", "max"], ["punc", "("], ["con", "LIMIT"], ["punc", ","], ["p", " "], ["num", "0"], ["punc", ")"], ["punc", ";"]]], "Shell": [[["cmd", "#!"], ["cm", "/bin/bash"]], [["cmd", "#"], ["cm", " deploy.sh"]], [["bi", "set"], ["p", " "], ["op", "-"], ["var", "euo"], ["p", " "], ["var", "pipefail"]], [], [["var", "PORT"], ["op", "="], ["num", "8080"]], [["var", "NAME"], ["op", "="], ["str", "\"dupre\""]], [], [["fnd", "deploy"], ["punc", "()"], ["p", " "], ["punc", "{"]], [["p", " "], ["kw", "local"], ["p", " "], ["var", "target"], ["op", "="], ["str", "\"$1\""]], [["p", " "], ["kw", "if"], ["p", " "], ["punc", "[["], ["p", " "], ["op", "-z"], ["p", " "], ["str", "\"$target\""], ["p", " "], ["punc", "]]"], ["punc", ";"], ["p", " "], ["kw", "then"]], [["p", " "], ["bi", "echo"], ["p", " "], ["str", "\"no target\""]], [["p", " "], ["kw", "return"], ["p", " "], ["num", "1"]], [["p", " "], ["kw", "fi"]], [["p", " "], ["fnc", "rsync"], ["p", " "], ["op", "-az"], ["p", " "], ["str", "\"$NAME\""], ["p", " "], ["str", "\"$target\""]], [["punc", "}"]], [], [["fnd", "main"], ["punc", "()"], ["p", " "], ["punc", "{"]], [["p", " "], ["kw", "for"], ["p", " "], ["var", "host"], ["p", " "], ["kw", "in"], ["p", " "], ["str", "\"$@\""], ["punc", ";"], ["p", " "], ["kw", "do"]], [["p", " "], ["fnc", "deploy"], ["p", " "], ["str", "\"$host\""], ["p", " "], ["op", "||"], ["p", " "], ["bi", "exit"], ["p", " "], ["num", "1"]], [["p", " "], ["kw", "done"]], [["p", " "], ["bi", "echo"], ["p", " "], ["op", "-e"], ["p", " "], ["str", "\"all done"], ["esc", "\\n"], ["str", "\""]], [["punc", "}"]], [], [["fnc", "main"], ["p", " "], ["str", "\"$@\""]]], "C/C++": [[["cmd", "//"], ["cm", " theme.c"]], [["pp", "#include"], ["p", " "], ["str", "<stdio.h>"]], [["pp", "#define"], ["p", " "], ["con", "MAX_PORT"], ["p", " "], ["num", "8080"]], [], [["kw", "typedef"], ["p", " "], ["kw", "struct"], ["p", " "], ["punc", "{"]], [["p", " "], ["ty", "int"], ["p", " "], ["prop", "id"], ["punc", ";"]], [["p", " "], ["ty", "char"], ["p", " "], ["op", "*"], ["prop", "name"], ["punc", ";"]], [["punc", "}"], ["p", " "], ["ty", "Order"], ["punc", ";"]], [], [["ty", "int"], ["p", " "], ["fnd", "push"], ["punc", "("], ["ty", "Order"], ["p", " "], ["op", "*"], ["var", "o"], ["punc", ")"], ["p", " "], ["punc", "{"]], [["p", " "], ["kw", "if"], ["p", " "], ["punc", "("], ["var", "o"], ["p", " "], ["op", "=="], ["p", " "], ["con", "NULL"], ["punc", ")"], ["p", " "], ["punc", "{"]], [["p", " "], ["kw", "return"], ["p", " "], ["num", "-1"], ["punc", ";"]], [["p", " "], ["punc", "}"]], [["p", " "], ["fnc", "printf"], ["punc", "("], ["str", "\"id=%d"], ["esc", "\\n"], ["str", "\""], ["punc", ","], ["p", " "], ["var", "o"], ["op", "->"], ["prop", "id"], ["punc", ");"]], [["p", " "], ["kw", "return"], ["p", " "], ["num", "0"], ["punc", ";"]], [["punc", "}"]], [], [["cmd", "//"], ["cm", " entrypoint"]], [["ty", "int"], ["p", " "], ["fnd", "main"], ["punc", "("], ["ty", "void"], ["punc", ")"], ["p", " "], ["punc", "{"]], [["p", " "], ["ty", "Order"], ["p", " "], ["var", "o"], ["p", " "], ["op", "="], ["p", " "], ["punc", "{"], ["p", " "], ["op", "."], ["prop", "id"], ["p", " "], ["op", "="], ["p", " "], ["num", "1"], ["p", " "], ["punc", "}"], ["punc", ";"]], [["p", " "], ["ty", "Order"], ["p", " "], ["op", "*"], ["var", "p2"], ["p", " "], ["op", "="], ["p", " "], ["bi", "malloc"], ["punc", "("], ["bi", "sizeof"], ["punc", "("], ["ty", "Order"], ["punc", "))"], ["punc", ";"]], [["p", " "], ["fnc", "push"], ["punc", "("], ["op", "&"], ["var", "o"], ["punc", ")"], ["punc", ";"]], [["p", " "], ["kw", "return"], ["p", " "], ["num", "0"], ["punc", ";"]], [["punc", "}"]]]}, CATS=[["bg", "background (ground)", "Aa Bb 123"], ["p", "fg \u00b7 default text", "other / whitespace"], ["kw", "keyword", "class def if return"], ["bi", "builtin", "len echo printf"], ["pp", "preprocessor", "#include #define"], ["fnd", "function \u00b7 def", "resolve push"], ["fnc", "function \u00b7 call", "printf rsync get"], ["dec", "decorator", "@dataclass"], ["ty", "type / class", "int str Order Queue"], ["prop", "property / field", "id name items"], ["con", "constant", "None nil NULL true"], ["num", "number", "8080 100 -1"], ["str", "string", "\"dupre\" \"fmt\""], ["esc", "escape", "\\n \\t"], ["re", "regexp", "/^#[0-9a-f]+/"], ["doc", "docstring", "\"\"\"...\"\"\""], ["cm", "comment", "# reject nil"], ["cmd", "comment delim", "# // ;;"], ["var", "variable / use", "value key self"], ["op", "operator", ": = -> =="], ["punc", "punctuation", "{ } ( ) ;"]], UI_FACES=[["cursor", "cursor", "Aa|"], ["region", "region (selection)", "selected text"], ["hl-line", "hl-line (current line)", "current line"], ["highlight", "highlight", "hover"], ["mode-line", "mode-line", "status active"], ["mode-line-inactive", "mode-line-inactive", "status idle"], ["fringe", "fringe", "| |"], ["line-number", "line-number", " 42"], ["line-number-current-line", "line-number-current-line", "> 42"], ["minibuffer-prompt", "minibuffer-prompt", "M-x "], ["isearch", "isearch (match)", "match"], ["lazy-highlight", "lazy-highlight", "other match"], ["isearch-fail", "isearch-fail", "no match"], ["show-paren-match", "show-paren-match", "( )"], ["show-paren-mismatch", "show-paren-mismatch", ") ("], ["link", "link", "https://"], ["error", "error", "error!"], ["warning", "warning", "warning"], ["success", "success", "ok"], ["vertical-border", "vertical-border", "|"]], APPS={"org-mode": {"label": "org-mode", "preview": "org", "faces": [["org-document-title", "document title", {"fg": "gold", "bold": true, "height": 1.5}], ["org-document-info", "document info", {"fg": "steel"}], ["org-document-info-keyword", "document info keyword", {"fg": "pewter", "inherit": "fixed-pitch"}], ["org-level-1", "level 1", {"fg": "blue", "bold": true, "height": 1.3}], ["org-level-2", "level 2", {"fg": "gold", "height": 1.2}], ["org-level-3", "level 3", {"fg": "regal", "height": 1.15}], ["org-level-4", "level 4", {"fg": "emerald", "height": 1.1}], ["org-level-5", "level 5", {"fg": "terracotta"}], ["org-level-6", "level 6", {"fg": "tan"}], ["org-level-7", "level 7", {"fg": "sage"}], ["org-level-8", "level 8", {"fg": "steel"}], ["org-headline-todo", "headline todo", {}], ["org-headline-done", "headline done", {"fg": "pewter"}], ["org-todo", "todo", {"fg": "terracotta", "bold": true}], ["org-done", "done", {"fg": "sage", "bold": true}], ["org-priority", "priority", {"fg": "gold", "bold": true}], ["org-tag", "tag", {"fg": "tan"}], ["org-tag-group", "tag group", {"fg": "tan"}], ["org-special-keyword", "special keyword", {"fg": "pewter"}], ["org-drawer", "drawer", {"fg": "pewter"}], ["org-property-value", "property value", {"fg": "steel"}], ["org-checkbox", "checkbox", {"fg": "gold", "inherit": "fixed-pitch"}], ["org-checkbox-statistics-todo", "checkbox statistics todo", {"fg": "terracotta"}], ["org-checkbox-statistics-done", "checkbox statistics done", {"fg": "sage"}], ["org-warning", "warning", {"fg": "terracotta", "bold": true}], ["org-link", "link", {"fg": "blue"}], ["org-footnote", "footnote", {"fg": "blue"}], ["org-date", "date", {"fg": "steel", "inherit": "fixed-pitch"}], ["org-sexp-date", "sexp date", {"fg": "steel"}], ["org-date-selected", "date selected", {"fg": "ground", "bg": "gold"}], ["org-target", "target", {"fg": "regal"}], ["org-macro", "macro", {"fg": "regal"}], ["org-cite", "cite", {"fg": "blue"}], ["org-cite-key", "cite key", {"fg": "blue"}], ["org-block", "block", {"fg": "white", "bg": "bg-dim", "inherit": "fixed-pitch"}], ["org-block-begin-line", "block begin line", {"fg": "pewter", "bg": "bg-dim", "inherit": "fixed-pitch"}], ["org-block-end-line", "block end line", {"fg": "pewter", "bg": "bg-dim", "inherit": "fixed-pitch"}], ["org-code", "code", {"fg": "terracotta", "inherit": "fixed-pitch"}], ["org-verbatim", "verbatim", {"fg": "steel", "inherit": "fixed-pitch"}], ["org-inline-src-block", "inline src block", {"fg": "terracotta", "inherit": "fixed-pitch"}], ["org-quote", "quote", {"fg": "silver", "italic": true}], ["org-verse", "verse", {"fg": "silver", "italic": true}], ["org-latex-and-related", "latex and related", {"fg": "gold"}], ["org-table", "table", {"fg": "steel", "inherit": "fixed-pitch"}], ["org-table-header", "table header", {"fg": "white", "bold": true, "bg": "gunmetal"}], ["org-table-row", "table row", {}], ["org-formula", "formula", {"fg": "terracotta"}], ["org-column", "column", {"bg": "gunmetal"}], ["org-column-title", "column title", {"fg": "white", "bold": true, "bg": "gunmetal"}], ["org-list-dt", "list dt", {"fg": "gold", "bold": true}], ["org-meta-line", "meta line", {"fg": "pewter", "inherit": "fixed-pitch"}], ["org-ellipsis", "ellipsis", {"fg": "pewter"}], ["org-hide", "hide", {"fg": "ground"}], ["org-indent", "indent", {"fg": "ground"}], ["org-archived", "archived", {"fg": "pewter"}], ["org-default", "default", {}], ["org-dispatcher-highlight", "dispatcher highlight", {"fg": "gold", "bold": true, "bg": "navy"}], ["org-agenda-structure", "agenda structure", {"fg": "blue", "bold": true, "height": 1.1}], ["org-agenda-structure-secondary", "agenda structure secondary", {"fg": "blue"}], ["org-agenda-structure-filter", "agenda structure filter", {"fg": "terracotta", "bold": true}], ["org-agenda-date", "agenda date", {"fg": "steel", "height": 1.05}], ["org-agenda-date-today", "agenda date today", {"fg": "gold", "bold": true, "height": 1.05}], ["org-agenda-date-weekend", "agenda date weekend", {"fg": "steel", "bold": true}], ["org-agenda-date-weekend-today", "agenda date weekend today", {"fg": "gold", "bold": true}], ["org-agenda-current-time", "agenda current time", {"fg": "gold"}], ["org-agenda-done", "agenda done", {"fg": "sage"}], ["org-agenda-dimmed-todo-face", "agenda dimmed todo", {"fg": "pewter"}], ["org-agenda-calendar-event", "agenda calendar event", {"fg": "white"}], ["org-agenda-calendar-sexp", "agenda calendar sexp", {"fg": "steel"}], ["org-agenda-calendar-daterange", "agenda calendar daterange", {"fg": "steel"}], ["org-agenda-diary", "agenda diary", {"fg": "sage"}], ["org-agenda-clocking", "agenda clocking", {"bg": "navy"}], ["org-agenda-column-dateline", "agenda column dateline", {"bg": "gunmetal"}], ["org-agenda-restriction-lock", "agenda restriction lock", {"bg": "terracotta"}], ["org-agenda-filter-category", "agenda filter category", {"fg": "gold", "bold": true}], ["org-agenda-filter-effort", "agenda filter effort", {"fg": "gold", "bold": true}], ["org-agenda-filter-regexp", "agenda filter regexp", {"fg": "gold", "bold": true}], ["org-agenda-filter-tags", "agenda filter tags", {"fg": "gold", "bold": true}], ["org-scheduled", "scheduled", {"fg": "sage"}], ["org-scheduled-today", "scheduled today", {"fg": "sage", "bold": true}], ["org-scheduled-previously", "scheduled previously", {"fg": "terracotta"}], ["org-upcoming-deadline", "upcoming deadline", {"fg": "gold"}], ["org-upcoming-distant-deadline", "upcoming distant deadline", {"fg": "tan"}], ["org-imminent-deadline", "imminent deadline", {"fg": "terracotta", "bold": true}], ["org-time-grid", "time grid", {"fg": "tan"}], ["org-clock-overlay", "clock overlay", {"bg": "navy"}], ["org-mode-line-clock", "mode line clock", {"fg": "steel"}], ["org-mode-line-clock-overrun", "mode line clock overrun", {"fg": "terracotta", "bold": true}]]}, "magit": {"label": "magit", "preview": "magit", "faces": [["magit-section-heading", "section heading", {"fg": "gold", "bold": true}], ["magit-section-secondary-heading", "section secondary heading", {"fg": "tan", "bold": true}], ["magit-section-heading-selection", "section heading selection", {"fg": "gold", "bg": "navy"}], ["magit-section-highlight", "section highlight", {"bg": "bg-dim"}], ["magit-section-child-count", "section child count", {"fg": "pewter"}], ["magit-diff-added", "diff added", {"fg": "sage"}], ["magit-diff-added-highlight", "diff added highlight", {"fg": "sage", "bg": "bg-dim"}], ["magit-diff-removed", "diff removed", {"fg": "terracotta"}], ["magit-diff-removed-highlight", "diff removed highlight", {"fg": "terracotta", "bg": "bg-dim"}], ["magit-diff-context", "diff context", {"fg": "pewter"}], ["magit-diff-context-highlight", "diff context highlight", {"fg": "silver", "bg": "bg-dim"}], ["magit-diff-file-heading", "diff file heading", {"fg": "white", "bold": true}], ["magit-diff-file-heading-highlight", "diff file heading highlight", {"fg": "white", "bold": true, "bg": "bg-dim"}], ["magit-diff-file-heading-selection", "diff file heading selection", {}], ["magit-diff-hunk-heading", "diff hunk heading", {"fg": "steel", "bg": "gunmetal"}], ["magit-diff-hunk-heading-highlight", "diff hunk heading highlight", {"fg": "white", "bg": "gunmetal"}], ["magit-diff-hunk-heading-selection", "diff hunk heading selection", {}], ["magit-diff-hunk-region", "diff hunk region", {}], ["magit-diff-lines-heading", "diff lines heading", {}], ["magit-diff-lines-boundary", "diff lines boundary", {}], ["magit-diff-base", "diff base", {}], ["magit-diff-base-highlight", "diff base highlight", {}], ["magit-diff-our", "diff our", {}], ["magit-diff-our-highlight", "diff our highlight", {}], ["magit-diff-their", "diff their", {}], ["magit-diff-their-highlight", "diff their highlight", {}], ["magit-diff-conflict-heading", "diff conflict heading", {}], ["magit-diff-conflict-heading-highlight", "diff conflict heading highlight", {}], ["magit-diff-revision-summary", "diff revision summary", {}], ["magit-diff-revision-summary-highlight", "diff revision summary highlight", {}], ["magit-diff-whitespace-warning", "diff whitespace warning", {"bg": "terracotta"}], ["magit-diffstat-added", "diffstat added", {"fg": "sage"}], ["magit-diffstat-removed", "diffstat removed", {"fg": "terracotta"}], ["magit-branch-current", "branch current", {"fg": "blue", "bold": true}], ["magit-branch-local", "branch local", {"fg": "blue"}], ["magit-branch-remote", "branch remote", {"fg": "sage"}], ["magit-branch-remote-head", "branch remote head", {"fg": "sage", "bold": true}], ["magit-branch-upstream", "branch upstream", {}], ["magit-branch-warning", "branch warning", {}], ["magit-head", "head", {"fg": "blue", "bold": true}], ["magit-tag", "tag", {"fg": "gold"}], ["magit-hash", "hash", {"fg": "pewter"}], ["magit-filename", "filename", {"fg": "steel"}], ["magit-dimmed", "dimmed", {"fg": "pewter"}], ["magit-keyword", "keyword", {"fg": "regal"}], ["magit-keyword-squash", "keyword squash", {"fg": "terracotta"}], ["magit-refname", "refname", {"fg": "pewter"}], ["magit-refname-stash", "refname stash", {}], ["magit-refname-wip", "refname wip", {}], ["magit-refname-pullreq", "refname pullreq", {}], ["magit-log-author", "log author", {"fg": "tan"}], ["magit-log-date", "log date", {"fg": "steel"}], ["magit-log-graph", "log graph", {"fg": "pewter"}], ["magit-header-line", "header line", {"fg": "white", "bold": true, "bg": "gunmetal"}], ["magit-header-line-key", "header line key", {}], ["magit-header-line-log-select", "header line log select", {}], ["magit-process-ok", "process ok", {"fg": "sage", "bold": true}], ["magit-process-ng", "process ng", {"fg": "terracotta", "bold": true}], ["magit-mode-line-process", "mode line process", {"fg": "sage"}], ["magit-mode-line-process-error", "mode line process error", {"fg": "terracotta"}], ["magit-bisect-good", "bisect good", {"fg": "sage"}], ["magit-bisect-bad", "bisect bad", {"fg": "terracotta"}], ["magit-bisect-skip", "bisect skip", {"fg": "gold"}], ["magit-blame-heading", "blame heading", {"fg": "steel", "bg": "gunmetal"}], ["magit-blame-highlight", "blame highlight", {}], ["magit-blame-hash", "blame hash", {"fg": "pewter"}], ["magit-blame-name", "blame name", {"fg": "tan"}], ["magit-blame-date", "blame date", {"fg": "steel"}], ["magit-blame-summary", "blame summary", {}], ["magit-blame-dimmed", "blame dimmed", {}], ["magit-blame-margin", "blame margin", {}], ["magit-cherry-equivalent", "cherry equivalent", {"fg": "regal"}], ["magit-cherry-unmatched", "cherry unmatched", {"fg": "sage"}], ["magit-signature-good", "signature good", {"fg": "sage"}], ["magit-signature-bad", "signature bad", {"fg": "terracotta", "bold": true}], ["magit-signature-untrusted", "signature untrusted", {"fg": "gold"}], ["magit-signature-expired", "signature expired", {"fg": "tan"}], ["magit-signature-expired-key", "signature expired key", {}], ["magit-signature-revoked", "signature revoked", {}], ["magit-signature-error", "signature error", {}], ["magit-reflog-commit", "reflog commit", {"fg": "sage"}], ["magit-reflog-amend", "reflog amend", {"fg": "regal"}], ["magit-reflog-merge", "reflog merge", {"fg": "sage"}], ["magit-reflog-checkout", "reflog checkout", {"fg": "blue"}], ["magit-reflog-reset", "reflog reset", {"fg": "terracotta"}], ["magit-reflog-rebase", "reflog rebase", {"fg": "regal"}], ["magit-reflog-cherry-pick", "reflog cherry pick", {"fg": "sage"}], ["magit-reflog-remote", "reflog remote", {"fg": "steel"}], ["magit-reflog-other", "reflog other", {"fg": "steel"}], ["magit-sequence-pick", "sequence pick", {"fg": "white"}], ["magit-sequence-stop", "sequence stop", {"fg": "terracotta"}], ["magit-sequence-part", "sequence part", {}], ["magit-sequence-head", "sequence head", {"fg": "blue"}], ["magit-sequence-drop", "sequence drop", {}], ["magit-sequence-done", "sequence done", {"fg": "pewter"}], ["magit-sequence-onto", "sequence onto", {}], ["magit-sequence-exec", "sequence exec", {}], ["magit-left-margin", "left margin", {}]]}, "elfeed": {"label": "elfeed", "preview": "elfeed", "faces": [["elfeed-search-date-face", "search date", {"fg": "steel"}], ["elfeed-search-title-face", "search title", {"fg": "silver"}], ["elfeed-search-unread-title-face", "search unread title", {"fg": "white", "bold": true}], ["elfeed-search-feed-face", "search feed", {"fg": "sage"}], ["elfeed-search-tag-face", "search tag", {"fg": "tan"}], ["elfeed-search-unread-count-face", "search unread count", {"fg": "gold"}], ["elfeed-search-filter-face", "search filter", {"fg": "blue", "bold": true}], ["elfeed-search-last-update-face", "search last update", {"fg": "pewter"}], ["elfeed-log-date-face", "log date", {"fg": "steel"}], ["elfeed-log-error-level-face", "log error level", {"fg": "terracotta", "bold": true}], ["elfeed-log-warn-level-face", "log warn level", {"fg": "gold"}], ["elfeed-log-info-level-face", "log info level", {"fg": "sage"}], ["elfeed-log-debug-level-face", "log debug level", {"fg": "pewter"}]]}}; let MAP={"kw": "#67809c", "bi": "#67809c", "pp": "#67809c", "fnd": "#a9b2bb", "fnc": "#a9b2bb", "dec": "#e8bd30", "ty": "#9b5fd0", "prop": "#838d97", "con": "#cb6b4d", "num": "#cb6b4d", "esc": "#cb6b4d", "str": "#5d9b86", "re": "#5d9b86", "doc": "#5d9b86", "cm": "#be9e74", "cmd": "#a9b2bb", "var": "#e8bd30", "op": "#a9b2bb", "punc": "#a9b2bb", "p": "#ffffff", "bg": "#000000"}, PALETTE=[["#67809c", "blue"], ["#e8bd30", "gold"], ["#9b5fd0", "regal"], ["#2ba178", "emerald"], ["#5d9b86", "sage"], ["#cb6b4d", "terracotta"], ["#be9e74", "tan"], ["#ffffff", "white"], ["#a9b2bb", "silver"], ["#838d97", "steel"], ["#5e6770", "pewter"], ["#2f343a", "gunmetal"], ["#264364", "navy"], ["#000000", "ground"], ["#1a1714", "bg-dim"]], BOLD={"kw": true, "bi": false, "pp": false, "fnd": true, "fnc": false, "dec": false, "ty": false, "prop": false, "con": false, "num": false, "esc": false, "str": false, "re": false, "doc": false, "cm": false, "cmd": false, "var": false, "op": false, "punc": false, "p": false}, ITALIC={}, UIMAP={"cursor": {"fg": null, "bg": "#a9b2bb"}, "region": {"fg": null, "bg": "#264364"}, "hl-line": {"fg": null, "bg": "#1a1714"}, "highlight": {"fg": null, "bg": "#2f343a"}, "mode-line": {"fg": "#cdced1", "bg": "#2f343a"}, "mode-line-inactive": {"fg": "#838d97", "bg": "#1a1714"}, "fringe": {"fg": null, "bg": "#0d0b0a"}, "line-number": {"fg": "#5e6770", "bg": null}, "line-number-current-line": {"fg": "#e8bd30", "bg": "#1a1714"}, "minibuffer-prompt": {"fg": "#67809c", "bg": null}, "isearch": {"fg": "#0d0b0a", "bg": "#e8bd30"}, "lazy-highlight": {"fg": "#0d0b0a", "bg": "#838d97"}, "isearch-fail": {"fg": "#cb6b4d", "bg": null}, "show-paren-match": {"fg": null, "bg": "#264364"}, "show-paren-mismatch": {"fg": "#0d0b0a", "bg": "#cb6b4d"}, "link": {"fg": "#67809c", "bg": null}, "error": {"fg": "#cb6b4d", "bg": null}, "warning": {"fg": "#e8bd30", "bg": null}, "success": {"fg": "#5d9b86", "bg": null}, "vertical-border": {"fg": "#2f343a", "bg": null}}; @@ -193,7 +212,7 @@ function renderPalette(){ d.ondragleave=()=>d.classList.remove('over'); d.ondrop=(e)=>{e.preventDefault();d.classList.remove('over');if(dragFrom===null||dragFrom===i)return;const m=PALETTE.splice(dragFrom,1)[0];PALETTE.splice(i,0,m);dragFrom=null;selectedIdx=null;renderPalette();buildTable();buildUITable();}; p.appendChild(d);}); - buildUITable(); + buildUITable();if(document.getElementById('pkgbody'))buildPkgTable(); } function notify(msg,err){const m=document.getElementById('palmsg');if(!m)return;m.textContent=msg;m.style.color=err?'#cb6b4d':'#8a9496';m.style.opacity='1';clearTimeout(m._t);m._t=setTimeout(()=>{m.style.opacity='0';},err?4000:2800);} function applyEdit(){if(selectedIdx!==null)updateColor();else addColor();} @@ -208,6 +227,7 @@ function updateColor(){ PALETTE[i]=[newHex,newName]; for(const k in MAP){if(MAP[k]===oldHex)MAP[k]=newHex;} for(const f in UIMAP){if(UIMAP[f].fg===oldHex)UIMAP[f].fg=newHex;if(UIMAP[f].bg===oldHex)UIMAP[f].bg=newHex;} + for(const ap in PKGMAP)for(const fc in PKGMAP[ap]){const o=PKGMAP[ap][fc];if(o.fg===oldHex)o.fg=newHex;if(o.bg===oldHex)o.bg=newHex;} closePicker();renderPalette();buildTable();buildUITable();renderCode();applyGround();notify('updated "'+newName+'"',false); } function normHex(s){s=s.trim();if(/^[0-9a-fA-F]{6}$/.test(s))s='#'+s;return /^#[0-9a-fA-F]{6}$/.test(s)?s.toLowerCase():null;} @@ -256,7 +276,7 @@ function importFile(ev){const f=ev.target.files[0];if(!f)return;const r=new File BOLD={};(d.bold||[]).forEach(k=>BOLD[k]=true);ITALIC={};(d.italic||[]).forEach(k=>ITALIC[k]=true); if(d.ui)Object.assign(UIMAP,d.ui); PKGMAP=seedPkgmap();if(d.packages)mergePackagesInto(PKGMAP,d.packages); - renderPalette();buildTable();buildUITable();renderCode();applyGround();updateTitle();}catch(e){alert('bad theme file: '+e.message);}}; + renderPalette();buildTable();buildUITable();buildPkgTable();buildPkgPreview();renderCode();applyGround();updateTitle();}catch(e){alert('bad theme file: '+e.message);}}; r.readAsText(f);ev.target.value='';} function applyGround(){document.querySelectorAll('pre').forEach(p=>p.style.background=MAP['bg']);document.querySelectorAll('.ex').forEach(e=>e.style.background=MAP['bg']);} function uf(f){return UIMAP[f]||{};} @@ -311,16 +331,45 @@ function buildMockFrame(){ fr.innerHTML=html;fr.style.background=bg;fr.style.color=fg; fr.onclick=(e)=>{const u=e.target.closest('[data-face]');if(u){flashUi(u.dataset.face);return;}const k=e.target.closest('[data-k]');if(k)flashAssign(k.dataset.k);}; } -function uiSelect(face,attr){ +function colorDropdown(value,onpick){ const sel=document.createElement('select');sel.className='chip'; const none=document.createElement('option');none.value='';none.textContent='— none —';none.style.background='#161412';none.style.color='#b4b1a2';sel.appendChild(none); for(const [hex,name] of PALETTE){const o=document.createElement('option');o.value=hex;o.textContent=name+' '+hex;o.style.background=hex;o.style.color=textOn(hex);sel.appendChild(o);} - sel.value=UIMAP[face][attr]||''; + sel.value=value||''; function style(){if(sel.value){sel.style.background=sel.value;sel.style.color=textOn(sel.value);}else{sel.style.background='#161412';sel.style.color='#b4b1a2';}} style(); - sel.onchange=()=>{UIMAP[face][attr]=sel.value||null;style();paintUI(face);buildMockFrame();}; + sel.onchange=()=>{style();onpick(sel.value||null);}; return sel; } +function uiSelect(face,attr){return colorDropdown(UIMAP[face][attr],v=>{UIMAP[face][attr]=v;paintUI(face);buildMockFrame();});} +const BASE_INHERITS=['fixed-pitch','variable-pitch','default','link','bold','italic','shadow']; +function seedFace(d){return {fg:pname(d.fg),bg:pname(d.bg),bold:!!d.bold,italic:!!d.italic,inherit:d.inherit||null,height:d.height||1,source:'default'};} +function curApp(){const s=document.getElementById('appsel');return s&&s.value?s.value:Object.keys(APPS)[0];} +function pkgEffFg(app,face,seen){seen=seen||{};const f=PKGMAP[app]&&PKGMAP[app][face];if(!f||seen[face])return null;seen[face]=1;if(f.fg)return f.fg;if(f.inherit&&PKGMAP[app][f.inherit])return pkgEffFg(app,f.inherit,seen);return null;} +function pkgEffBg(app,face,seen){seen=seen||{};const f=PKGMAP[app]&&PKGMAP[app][face];if(!f||seen[face])return null;seen[face]=1;if(f.bg)return f.bg;if(f.inherit&&PKGMAP[app][f.inherit])return pkgEffBg(app,f.inherit,seen);return null;} +function buildAppSel(){const s=document.getElementById('appsel');if(!s)return;s.innerHTML='';for(const app in APPS){const o=document.createElement('option');o.value=app;o.textContent=APPS[app].label;s.appendChild(o);}s.onchange=pkgChanged;} +function pkgChanged(){buildPkgTable();buildPkgPreview();syncPkgHeight();} +function buildPkgTable(){ + const app=curApp(),tb=document.getElementById('pkgbody');if(!tb)return;tb.innerHTML=''; + const flt=(document.getElementById('pkgfilter').value||'').trim().toLowerCase(); + const inh=[''].concat(BASE_INHERITS).concat(APPS[app].faces.map(r=>r[0])); + for(const [face,label,def] of APPS[app].faces){ + if(flt&&!(face.toLowerCase().includes(flt)||label.toLowerCase().includes(flt)))continue; + const f=PKGMAP[app][face],tr=document.createElement('tr'); + const c0=document.createElement('td');c0.className='cat';c0.textContent=label;c0.title=face; + const cf=document.createElement('td');cf.appendChild(colorDropdown(f.fg,v=>{f.fg=v;f.source='user';pkgChanged();})); + const cb=document.createElement('td');cb.appendChild(colorDropdown(f.bg,v=>{f.bg=v;f.source='user';pkgChanged();})); + const cw=document.createElement('td');[['B','bold'],['I','italic']].forEach(([ch,at])=>{const b=document.createElement('button');b.className='sbtn'+(f[at]?' on':'');b.textContent='a';b.style.fontWeight=at==='bold'?'bold':'normal';b.style.fontStyle=at==='italic'?'italic':'normal';b.onclick=()=>{f[at]=!f[at];f.source='user';pkgChanged();};cw.appendChild(b);}); + const ci=document.createElement('td');const isel=document.createElement('select');isel.className='chip';isel.style.cssText='width:150px;font:10pt monospace';inh.forEach(o=>{const op=document.createElement('option');op.value=o;op.textContent=o||'— none —';isel.appendChild(op);});isel.value=f.inherit||'';isel.onchange=()=>{f.inherit=isel.value||null;f.source='user';pkgChanged();};ci.appendChild(isel); + const ch=document.createElement('td');const hin=document.createElement('input');hin.type='number';hin.min='0.8';hin.max='2.5';hin.step='0.05';hin.value=f.height||1;hin.className='hstep';hin.onchange=()=>{f.height=parseFloat(hin.value)||1;f.source='user';pkgChanged();};ch.appendChild(hin); + const cc=document.createElement('td');cc.style.fontSize='10pt';cc.style.whiteSpace='nowrap';const efg=pkgEffFg(app,face)||MAP['p'],ebg=pkgEffBg(app,face)||MAP['bg'],r=contrast(efg,ebg);cc.innerHTML=`<span style="color:${ratingColor(r)}">${r.toFixed(1)} ${rating(r)}</span>`; + const cr=document.createElement('td');const rb=document.createElement('button');rb.className='sbtn';rb.textContent='↺';rb.title='reset to default';rb.onclick=()=>{PKGMAP[app][face]=seedFace(def);pkgChanged();};cr.appendChild(rb); + tr.append(c0,cf,cb,cw,ci,ch,cc,cr);tb.appendChild(tr); + } +} +function buildPkgPreview(){const app=curApp(),p=document.getElementById('pkgpreview');if(!p)return;let h='<div style="padding:10px 14px;font:15px/1.8 monospace">';for(const [face,label,def] of APPS[app].faces){const f=PKGMAP[app][face],efg=pkgEffFg(app,face)||MAP['p'],ebg=pkgEffBg(app,face);h+=`<div style="color:${efg};${ebg?'background:'+ebg+';':''}font-weight:${f.bold?'bold':'normal'};font-style:${f.italic?'italic':'normal'};font-size:${(f.height||1)}em">${esc(label)}</div>`;}p.innerHTML=h+'</div>';p.style.background=MAP['bg'];} +function resetApp(){const app=curApp();PKGMAP[app]={};for(const [face,label,d] of APPS[app].faces)PKGMAP[app][face]=seedFace(d);pkgChanged();} +function syncPkgHeight(){const t=document.getElementById('pkgtable'),m=document.getElementById('pkgpreview');if(!t||!m)return;const lb=m.previousElementSibling,lbh=lb?lb.getBoundingClientRect().height+10:30;m.style.height=Math.max(t.getBoundingClientRect().height-lbh,220)+'px';} function paintUI(face){const pv=document.getElementById('uiprev-'+face);if(!pv)return;pv.style.color=UIMAP[face].fg||MAP['p'];pv.style.background=UIMAP[face].bg||MAP['bg'];} function buildUITable(){ const tb=document.getElementById('uibody');tb.innerHTML=''; @@ -338,8 +387,8 @@ function srt(c){const tb=document.getElementById('legbody');const r=[...tb.rows] r.sort((a,b)=>{const x=(c===0?a.querySelector('select').value:a.cells[2].innerText).toLowerCase(), y=(c===0?b.querySelector('select').value:b.cells[2].innerText).toLowerCase(); return (x<y?-1:x>y?1:0)*(D[c]?1:-1);});r.forEach(x=>tb.appendChild(x));} -buildLangSel();renderPalette();buildTable();buildUITable();renderCode();applyGround();updateTitle();initPicker();syncMockHeight(); -addEventListener('resize',syncMockHeight); +buildLangSel();buildAppSel();renderPalette();buildTable();buildUITable();renderCode();applyGround();updateTitle();initPicker();buildPkgTable();buildPkgPreview();syncMockHeight();syncPkgHeight(); +addEventListener('resize',()=>{syncMockHeight();syncPkgHeight();}); // Phase-1 self-test (open with #selftest): seed -> export -> import -> compare. function pkgSelftest(){ const seeded=seedPkgmap(); |
