import json, os HERE=os.path.dirname(os.path.abspath(__file__)) ns={} src=open(os.path.join(HERE,'samples.py')).read() exec(src[:src.index('cols=')], ns) SAMPLES={"Elisp":ns['ELS'],"Go":ns['GOS'],"Python":ns['PYS'],"TypeScript":ns['TSS'],"Shell":ns['SHS'],"C/C++":ns['CS']} COLS=ns['COLS'] MAP={k:v[0] for k,v in COLS.items()}; BOLD={k:v[1] for k,v in COLS.items()}; MAP['str']='#5d9b86'; MAP['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"]] CATS=[["bg","background (ground)","Aa Bb 123"],["p","fg · default text","other / whitespace"],["kw","keyword","class def if return"],["bi","builtin","len echo printf"], ["pp","preprocessor","#include #define"],["fnd","function · def","resolve push"], ["fnc","function · 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","|"]] UIMAP={"cursor":{"fg":None,"bg":"#a9b2bb"},"region":{"fg":None,"bg":"#264364"}, "hl-line":{"fg":None,"bg":"#1a1714"},"highlight":{"fg":None,"bg":"#2f343a"}, "mode-line":{"fg":"#cdced1","bg":"#2f343a"},"mode-line-inactive":{"fg":"#838d97","bg":"#1a1714"}, "fringe":{"fg":None,"bg":"#0d0b0a"},"line-number":{"fg":"#5e6770","bg":None}, "line-number-current-line":{"fg":"#e8bd30","bg":"#1a1714"},"minibuffer-prompt":{"fg":"#67809c","bg":None}, "isearch":{"fg":"#0d0b0a","bg":"#e8bd30"},"lazy-highlight":{"fg":"#0d0b0a","bg":"#838d97"}, "isearch-fail":{"fg":"#cb6b4d","bg":None},"show-paren-match":{"fg":None,"bg":"#264364"}, "show-paren-mismatch":{"fg":"#0d0b0a","bg":"#cb6b4d"},"link":{"fg":"#67809c","bg":None}, "error":{"fg":"#cb6b4d","bg":None},"warning":{"fg":"#e8bd30","bg":None}, "success":{"fg":"#5d9b86","bg":None},"vertical-border":{"fg":"#2f343a","bg":None}} # Tier-3 package faces. Phase 1 ships the schema + an org starter; Phase 2 fills # the complete org/magit/elfeed sets. Defaults reference palette names. APPS={"org-mode":{"label":"org-mode","preview":"org","faces":[ ["org-document-title","document title",{"fg":"gold","bold":True,"height":1.5}], ["org-level-1","heading 1",{"fg":"blue","bold":True,"height":1.3}], ["org-level-2","heading 2",{"fg":"gold","height":1.2}], ["org-level-3","heading 3",{"fg":"regal","height":1.15}], ["org-todo","TODO keyword",{"fg":"terracotta","bold":True}], ["org-done","DONE keyword",{"fg":"sage","bold":True}], ["org-link","link",{"fg":"blue"}], ["org-code","inline code",{"fg":"terracotta","inherit":"fixed-pitch"}], ["org-verbatim","verbatim",{"fg":"steel","inherit":"fixed-pitch"}], ["org-block","src block body",{"fg":"white","bg":"bg-dim","inherit":"fixed-pitch"}], ["org-block-begin-line","block delim",{"fg":"pewter","bg":"bg-dim","inherit":"fixed-pitch"}], ["org-table","table",{"fg":"steel","inherit":"fixed-pitch"}], ["org-date","timestamp",{"fg":"steel","inherit":"fixed-pitch"}], ["org-tag","tag",{"fg":"tan"}], ["org-special-keyword","keyword/drawer",{"fg":"pewter"}], ["org-meta-line","#+meta line",{"fg":"pewter","inherit":"fixed-pitch"}], ["org-checkbox","checkbox",{"fg":"gold","inherit":"fixed-pitch"}], ["org-headline-done","done headline",{"fg":"pewter"}] ]}} HTML = """theme-selector

Untitled: theme

palette

#888888
limit

export, import, and save

code/color assignments

color △styleelements △examplecontrast

 

ui faces

faceforegroundbackgroundpreview
""" HTML=(HTML.replace("SAMPLES_J",json.dumps(SAMPLES)) .replace("PALETTE_J",json.dumps(PALETTE)).replace("CATS_J",json.dumps(CATS)) .replace("UIFACES_J",json.dumps(UI_FACES)).replace("UIMAP_J",json.dumps(UIMAP)).replace("APPS_J",json.dumps(APPS)) .replace("BOLD_J",json.dumps(BOLD)).replace("MAP_J",json.dumps(MAP))) OUT=os.path.join(HERE,'theme-selector.html') open(OUT,"w").write(HTML) print("wrote",OUT)