From eb5abe0a15bf0fd904bed2b27289bfb55089ee2a Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Mon, 8 Jun 2026 02:27:53 -0500 Subject: feat(theme-selector): org-mode bespoke preview (tier-3 phase 4) I added renderOrgPreview, a mock org document painted live from the org package faces. It exercises the prominent ones in context: document title, headings with their heights, a TODO and a DONE, tags, a scheduled timestamp, a property drawer, inline code and verbatim, a link, a checkbox, a quote, a src block with begin and end lines, and a header-row table. The preview pane now dispatches on the app's preview key, so org-mode gets this bespoke document and every other app keeps the generic face-name list until its own preview lands. It rebuilds on any package-face or palette edit. --- scripts/theme-selector/generate.py | 31 +++++++++++++++++++++++++++++- scripts/theme-selector/theme-selector.html | 31 +++++++++++++++++++++++++++++- 2 files changed, 60 insertions(+), 2 deletions(-) (limited to 'scripts/theme-selector') diff --git a/scripts/theme-selector/generate.py b/scripts/theme-selector/generate.py index d66ae4fb..7fc00145 100644 --- a/scripts/theme-selector/generate.py +++ b/scripts/theme-selector/generate.py @@ -543,7 +543,36 @@ function buildPkgTable(){ 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='
';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+=`
${esc(label)}
`;}p.innerHTML=h+'
';p.style.background=MAP['bg'];} +function ofs(app,face){const f=PKGMAP[app][face]||{},fg=pkgEffFg(app,face)||MAP['p'],bg=pkgEffBg(app,face);return `color:${fg};${bg?'background:'+bg+';':''}font-weight:${f.bold?'bold':'normal'};font-style:${f.italic?'italic':'normal'};font-size:${(f.height||1)}em`;} +function os(app,face,txt){return `${txt}`;} +function renderOrgPreview(){const a='org-mode',L=[]; + L.push(os(a,'org-document-info-keyword','#+TITLE:')+' '+os(a,'org-document-title','Project Notes')); + L.push(os(a,'org-document-info-keyword','#+AUTHOR:')+' '+os(a,'org-document-info','Craig Jennings')); + L.push(''); + L.push(os(a,'org-level-1','* Inbox')+' '+os(a,'org-tag',':work:')); + L.push(os(a,'org-level-2','** ')+os(a,'org-todo','TODO')+os(a,'org-level-2',' Draft the spec')+' '+os(a,'org-priority','[#A]')); + L.push(' '+os(a,'org-special-keyword','SCHEDULED:')+' '+os(a,'org-date','<2026-06-08 Sun>')); + L.push(' '+os(a,'org-drawer',':PROPERTIES:')); + L.push(' '+os(a,'org-special-keyword',':ID:')+' '+os(a,'org-property-value','abc-123')); + L.push(' '+os(a,'org-drawer',':END:')); + L.push(os(a,'org-level-2','** ')+os(a,'org-done','DONE')+os(a,'org-headline-done',' Ship the tool')); + L.push(os(a,'org-level-3','*** Heading three')); + L.push(' A line with '+os(a,'org-code','=inline code=')+', '+os(a,'org-verbatim','~verbatim~')+','); + L.push(' and a '+os(a,'org-link','[[https://gnu.org][link]]')+'.'); + L.push(' - '+os(a,'org-checkbox','[X]')+' a checkbox item'); + L.push(' '+os(a,'org-quote','> a quoted line')); + L.push(''); + L.push(' '+os(a,'org-block-begin-line','#+begin_src elisp')); + L.push(' '+os(a,'org-block',' (message "hi")')); + L.push(' '+os(a,'org-block-end-line','#+end_src')); + L.push(''); + L.push(' '+os(a,'org-table-header','| name | hex |')); + L.push(' '+os(a,'org-table','|------+---------|')); + L.push(' '+os(a,'org-table','| blue | #67809c |')); + return `
${L.join('\\n')}
`; +} +function genericPreview(app){let h='
';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+=`
${esc(label)}
`;}return h+'
';} +function buildPkgPreview(){const app=curApp(),p=document.getElementById('pkgpreview');if(!p)return;p.innerHTML=(APPS[app].preview==='org')?renderOrgPreview():genericPreview(app);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'];} diff --git a/scripts/theme-selector/theme-selector.html b/scripts/theme-selector/theme-selector.html index 0f865f7d..92190bc5 100644 --- a/scripts/theme-selector/theme-selector.html +++ b/scripts/theme-selector/theme-selector.html @@ -367,7 +367,36 @@ function buildPkgTable(){ 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='
';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+=`
${esc(label)}
`;}p.innerHTML=h+'
';p.style.background=MAP['bg'];} +function ofs(app,face){const f=PKGMAP[app][face]||{},fg=pkgEffFg(app,face)||MAP['p'],bg=pkgEffBg(app,face);return `color:${fg};${bg?'background:'+bg+';':''}font-weight:${f.bold?'bold':'normal'};font-style:${f.italic?'italic':'normal'};font-size:${(f.height||1)}em`;} +function os(app,face,txt){return `${txt}`;} +function renderOrgPreview(){const a='org-mode',L=[]; + L.push(os(a,'org-document-info-keyword','#+TITLE:')+' '+os(a,'org-document-title','Project Notes')); + L.push(os(a,'org-document-info-keyword','#+AUTHOR:')+' '+os(a,'org-document-info','Craig Jennings')); + L.push(''); + L.push(os(a,'org-level-1','* Inbox')+' '+os(a,'org-tag',':work:')); + L.push(os(a,'org-level-2','** ')+os(a,'org-todo','TODO')+os(a,'org-level-2',' Draft the spec')+' '+os(a,'org-priority','[#A]')); + L.push(' '+os(a,'org-special-keyword','SCHEDULED:')+' '+os(a,'org-date','<2026-06-08 Sun>')); + L.push(' '+os(a,'org-drawer',':PROPERTIES:')); + L.push(' '+os(a,'org-special-keyword',':ID:')+' '+os(a,'org-property-value','abc-123')); + L.push(' '+os(a,'org-drawer',':END:')); + L.push(os(a,'org-level-2','** ')+os(a,'org-done','DONE')+os(a,'org-headline-done',' Ship the tool')); + L.push(os(a,'org-level-3','*** Heading three')); + L.push(' A line with '+os(a,'org-code','=inline code=')+', '+os(a,'org-verbatim','~verbatim~')+','); + L.push(' and a '+os(a,'org-link','[[https://gnu.org][link]]')+'.'); + L.push(' - '+os(a,'org-checkbox','[X]')+' a checkbox item'); + L.push(' '+os(a,'org-quote','> a quoted line')); + L.push(''); + L.push(' '+os(a,'org-block-begin-line','#+begin_src elisp')); + L.push(' '+os(a,'org-block',' (message "hi")')); + L.push(' '+os(a,'org-block-end-line','#+end_src')); + L.push(''); + L.push(' '+os(a,'org-table-header','| name | hex |')); + L.push(' '+os(a,'org-table','|------+---------|')); + L.push(' '+os(a,'org-table','| blue | #67809c |')); + return `
${L.join('\n')}
`; +} +function genericPreview(app){let h='
';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+=`
${esc(label)}
`;}return h+'
';} +function buildPkgPreview(){const app=curApp(),p=document.getElementById('pkgpreview');if(!p)return;p.innerHTML=(APPS[app].preview==='org')?renderOrgPreview():genericPreview(app);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'];} -- cgit v1.2.3