@kecan0406/ttheme 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (585) hide show
  1. package/README.md +252 -42
  2. package/bin/ttheme.js +7053 -514
  3. package/dist/alacritty/config/dekomori.toml +8 -0
  4. package/dist/alacritty/config/geto.toml +8 -0
  5. package/dist/alacritty/config/gojo.toml +8 -0
  6. package/dist/alacritty/config/kumin.toml +8 -0
  7. package/dist/alacritty/config/megumi.toml +8 -0
  8. package/dist/alacritty/config/nanami.toml +8 -0
  9. package/dist/alacritty/config/nobara.toml +8 -0
  10. package/dist/alacritty/config/rikka.toml +8 -0
  11. package/dist/alacritty/config/shinka.toml +8 -0
  12. package/dist/alacritty/config/sukuna.toml +8 -0
  13. package/dist/alacritty/config/yuji.toml +8 -0
  14. package/dist/alacritty/config/yuuta.toml +8 -0
  15. package/dist/alacritty/themes/alma.toml +21 -21
  16. package/dist/alacritty/themes/anko.toml +22 -22
  17. package/dist/alacritty/themes/asuka.toml +22 -22
  18. package/dist/alacritty/themes/azusa.toml +22 -22
  19. package/dist/alacritty/themes/battler.toml +22 -22
  20. package/dist/alacritty/themes/beatrice.toml +22 -22
  21. package/dist/alacritty/themes/bernkastel.toml +21 -21
  22. package/dist/alacritty/themes/bocchi.toml +22 -22
  23. package/dist/alacritty/themes/cirno.toml +23 -23
  24. package/dist/alacritty/themes/david.toml +21 -21
  25. package/dist/alacritty/themes/dekomori.toml +34 -0
  26. package/dist/alacritty/themes/determination.toml +23 -23
  27. package/dist/alacritty/themes/dorothy.toml +22 -22
  28. package/dist/alacritty/themes/eva01.toml +22 -22
  29. package/dist/alacritty/themes/flandre.toml +22 -22
  30. package/dist/alacritty/themes/fox.toml +22 -22
  31. package/dist/alacritty/themes/geto.toml +34 -0
  32. package/dist/alacritty/themes/glitch.toml +23 -23
  33. package/dist/alacritty/themes/gojo.toml +34 -0
  34. package/dist/alacritty/themes/hinamizawa.toml +22 -22
  35. package/dist/alacritty/themes/hitagi.toml +22 -22
  36. package/dist/alacritty/themes/homura.toml +23 -23
  37. package/dist/alacritty/themes/jill.toml +22 -22
  38. package/dist/alacritty/themes/joker.toml +22 -22
  39. package/dist/alacritty/themes/jupiter.toml +22 -22
  40. package/dist/alacritty/themes/kagami.toml +23 -23
  41. package/dist/alacritty/themes/kaito.toml +23 -23
  42. package/dist/alacritty/themes/kaworu.toml +22 -22
  43. package/dist/alacritty/themes/kita.toml +22 -22
  44. package/dist/alacritty/themes/konata.toml +23 -23
  45. package/dist/alacritty/themes/kou.toml +23 -23
  46. package/dist/alacritty/themes/kumin.toml +34 -0
  47. package/dist/alacritty/themes/kumori.toml +23 -23
  48. package/dist/alacritty/themes/kurisu.toml +21 -21
  49. package/dist/alacritty/themes/kyoko.toml +22 -22
  50. package/dist/alacritty/themes/kyubey.toml +22 -22
  51. package/dist/alacritty/themes/lain.toml +22 -22
  52. package/dist/alacritty/themes/lambdadelta.toml +22 -22
  53. package/dist/alacritty/themes/len.toml +23 -23
  54. package/dist/alacritty/themes/lucy.toml +21 -21
  55. package/dist/alacritty/themes/luka.toml +22 -22
  56. package/dist/alacritty/themes/madoka.toml +21 -21
  57. package/dist/alacritty/themes/magi.toml +21 -21
  58. package/dist/alacritty/themes/mami.toml +23 -23
  59. package/dist/alacritty/themes/marisa.toml +23 -23
  60. package/dist/alacritty/themes/mars.toml +22 -22
  61. package/dist/alacritty/themes/mayuri.toml +22 -22
  62. package/dist/alacritty/themes/megumi.toml +34 -0
  63. package/dist/alacritty/themes/meiko.toml +23 -23
  64. package/dist/alacritty/themes/mercury.toml +21 -21
  65. package/dist/alacritty/themes/mettaton.toml +23 -23
  66. package/dist/alacritty/themes/miku.toml +22 -22
  67. package/dist/alacritty/themes/mio.toml +21 -21
  68. package/dist/alacritty/themes/mion.toml +22 -22
  69. package/dist/alacritty/themes/misato.toml +22 -22
  70. package/dist/alacritty/themes/miyuki.toml +23 -23
  71. package/dist/alacritty/themes/monika.toml +23 -23
  72. package/dist/alacritty/themes/moon.toml +21 -21
  73. package/dist/alacritty/themes/mugi.toml +21 -21
  74. package/dist/alacritty/themes/nadeko.toml +21 -21
  75. package/dist/alacritty/themes/nagisa.toml +21 -21
  76. package/dist/alacritty/themes/nanami.toml +34 -0
  77. package/dist/alacritty/themes/natsuki.toml +22 -22
  78. package/dist/alacritty/themes/nazuna.toml +22 -22
  79. package/dist/alacritty/themes/neutral.toml +20 -20
  80. package/dist/alacritty/themes/nightcity.toml +23 -23
  81. package/dist/alacritty/themes/nijika.toml +21 -21
  82. package/dist/alacritty/themes/nobara.toml +34 -0
  83. package/dist/alacritty/themes/oracle.toml +21 -21
  84. package/dist/alacritty/themes/panther.toml +22 -22
  85. package/dist/alacritty/themes/papyrus.toml +23 -23
  86. package/dist/alacritty/themes/patchouli.toml +22 -22
  87. package/dist/alacritty/themes/queen.toml +22 -22
  88. package/dist/alacritty/themes/rebecca.toml +22 -22
  89. package/dist/alacritty/themes/rei.toml +21 -21
  90. package/dist/alacritty/themes/reimu.toml +21 -21
  91. package/dist/alacritty/themes/rena.toml +22 -22
  92. package/dist/alacritty/themes/rika.toml +22 -22
  93. package/dist/alacritty/themes/rikka.toml +34 -0
  94. package/dist/alacritty/themes/rin.toml +23 -23
  95. package/dist/alacritty/themes/ritsu.toml +22 -22
  96. package/dist/alacritty/themes/rokkenjima.toml +21 -21
  97. package/dist/alacritty/themes/ryo.toml +22 -22
  98. package/dist/alacritty/themes/sans.toml +22 -22
  99. package/dist/alacritty/themes/satoko.toml +22 -22
  100. package/dist/alacritty/themes/sayaka.toml +22 -22
  101. package/dist/alacritty/themes/sayori.toml +23 -23
  102. package/dist/alacritty/themes/sei.toml +22 -22
  103. package/dist/alacritty/themes/seri.toml +22 -22
  104. package/dist/alacritty/themes/shinka.toml +34 -0
  105. package/dist/alacritty/themes/shinobu.toml +21 -21
  106. package/dist/alacritty/themes/skull.toml +22 -22
  107. package/dist/alacritty/themes/stella.toml +22 -22
  108. package/dist/alacritty/themes/sukuna.toml +34 -0
  109. package/dist/alacritty/themes/suzuha.toml +21 -21
  110. package/dist/alacritty/themes/toriel.toml +23 -23
  111. package/dist/alacritty/themes/tsubasa.toml +22 -22
  112. package/dist/alacritty/themes/tsukasa.toml +23 -23
  113. package/dist/alacritty/themes/undyne.toml +23 -23
  114. package/dist/alacritty/themes/valhalla.toml +22 -22
  115. package/dist/alacritty/themes/velvet.toml +22 -22
  116. package/dist/alacritty/themes/venus.toml +19 -19
  117. package/dist/alacritty/themes/yofukashi.toml +21 -21
  118. package/dist/alacritty/themes/youmu.toml +23 -23
  119. package/dist/alacritty/themes/yui.toml +22 -22
  120. package/dist/alacritty/themes/yuji.toml +34 -0
  121. package/dist/alacritty/themes/yuri.toml +23 -23
  122. package/dist/alacritty/themes/yuuta.toml +34 -0
  123. package/dist/ghostty/themes/alma +21 -21
  124. package/dist/ghostty/themes/anko +23 -23
  125. package/dist/ghostty/themes/asuka +23 -23
  126. package/dist/ghostty/themes/azusa +23 -23
  127. package/dist/ghostty/themes/battler +23 -23
  128. package/dist/ghostty/themes/beatrice +23 -23
  129. package/dist/ghostty/themes/bernkastel +21 -21
  130. package/dist/ghostty/themes/bocchi +23 -23
  131. package/dist/ghostty/themes/cirno +24 -24
  132. package/dist/ghostty/themes/david +21 -21
  133. package/dist/ghostty/themes/dekomori +29 -0
  134. package/dist/ghostty/themes/determination +24 -24
  135. package/dist/ghostty/themes/dorothy +23 -23
  136. package/dist/ghostty/themes/eva01 +23 -23
  137. package/dist/ghostty/themes/flandre +23 -23
  138. package/dist/ghostty/themes/fox +23 -23
  139. package/dist/ghostty/themes/geto +29 -0
  140. package/dist/ghostty/themes/glitch +24 -24
  141. package/dist/ghostty/themes/gojo +29 -0
  142. package/dist/ghostty/themes/hinamizawa +23 -23
  143. package/dist/ghostty/themes/hitagi +23 -23
  144. package/dist/ghostty/themes/homura +24 -24
  145. package/dist/ghostty/themes/jill +23 -23
  146. package/dist/ghostty/themes/joker +23 -23
  147. package/dist/ghostty/themes/jupiter +23 -23
  148. package/dist/ghostty/themes/kagami +24 -24
  149. package/dist/ghostty/themes/kaito +24 -24
  150. package/dist/ghostty/themes/kaworu +23 -23
  151. package/dist/ghostty/themes/kita +23 -23
  152. package/dist/ghostty/themes/konata +24 -24
  153. package/dist/ghostty/themes/kou +24 -24
  154. package/dist/ghostty/themes/kumin +29 -0
  155. package/dist/ghostty/themes/kumori +23 -23
  156. package/dist/ghostty/themes/kurisu +21 -21
  157. package/dist/ghostty/themes/kyoko +23 -23
  158. package/dist/ghostty/themes/kyubey +23 -23
  159. package/dist/ghostty/themes/lain +23 -23
  160. package/dist/ghostty/themes/lambdadelta +23 -23
  161. package/dist/ghostty/themes/len +24 -24
  162. package/dist/ghostty/themes/lucy +21 -21
  163. package/dist/ghostty/themes/luka +22 -22
  164. package/dist/ghostty/themes/madoka +21 -21
  165. package/dist/ghostty/themes/magi +21 -21
  166. package/dist/ghostty/themes/mami +24 -24
  167. package/dist/ghostty/themes/marisa +24 -24
  168. package/dist/ghostty/themes/mars +23 -23
  169. package/dist/ghostty/themes/mayuri +23 -23
  170. package/dist/ghostty/themes/megumi +29 -0
  171. package/dist/ghostty/themes/meiko +24 -24
  172. package/dist/ghostty/themes/mercury +21 -21
  173. package/dist/ghostty/themes/mettaton +24 -24
  174. package/dist/ghostty/themes/miku +22 -22
  175. package/dist/ghostty/themes/mio +21 -21
  176. package/dist/ghostty/themes/mion +23 -23
  177. package/dist/ghostty/themes/misato +23 -23
  178. package/dist/ghostty/themes/miyuki +24 -24
  179. package/dist/ghostty/themes/monika +24 -24
  180. package/dist/ghostty/themes/moon +21 -21
  181. package/dist/ghostty/themes/mugi +21 -21
  182. package/dist/ghostty/themes/nadeko +21 -21
  183. package/dist/ghostty/themes/nagisa +21 -21
  184. package/dist/ghostty/themes/nanami +29 -0
  185. package/dist/ghostty/themes/natsuki +22 -22
  186. package/dist/ghostty/themes/nazuna +23 -23
  187. package/dist/ghostty/themes/neutral +22 -22
  188. package/dist/ghostty/themes/nightcity +24 -24
  189. package/dist/ghostty/themes/nijika +21 -21
  190. package/dist/ghostty/themes/nobara +29 -0
  191. package/dist/ghostty/themes/oracle +21 -21
  192. package/dist/ghostty/themes/panther +23 -23
  193. package/dist/ghostty/themes/papyrus +24 -24
  194. package/dist/ghostty/themes/patchouli +23 -23
  195. package/dist/ghostty/themes/queen +23 -23
  196. package/dist/ghostty/themes/rebecca +23 -23
  197. package/dist/ghostty/themes/rei +21 -21
  198. package/dist/ghostty/themes/reimu +22 -22
  199. package/dist/ghostty/themes/rena +23 -23
  200. package/dist/ghostty/themes/rika +23 -23
  201. package/dist/ghostty/themes/rikka +29 -0
  202. package/dist/ghostty/themes/rin +24 -24
  203. package/dist/ghostty/themes/ritsu +23 -23
  204. package/dist/ghostty/themes/rokkenjima +21 -21
  205. package/dist/ghostty/themes/ryo +23 -23
  206. package/dist/ghostty/themes/sans +22 -22
  207. package/dist/ghostty/themes/satoko +23 -23
  208. package/dist/ghostty/themes/sayaka +23 -23
  209. package/dist/ghostty/themes/sayori +24 -24
  210. package/dist/ghostty/themes/sei +23 -23
  211. package/dist/ghostty/themes/seri +22 -22
  212. package/dist/ghostty/themes/shinka +29 -0
  213. package/dist/ghostty/themes/shinobu +21 -21
  214. package/dist/ghostty/themes/skull +23 -23
  215. package/dist/ghostty/themes/stella +23 -23
  216. package/dist/ghostty/themes/sukuna +29 -0
  217. package/dist/ghostty/themes/suzuha +21 -21
  218. package/dist/ghostty/themes/toriel +24 -24
  219. package/dist/ghostty/themes/tsubasa +23 -23
  220. package/dist/ghostty/themes/tsukasa +24 -24
  221. package/dist/ghostty/themes/undyne +24 -24
  222. package/dist/ghostty/themes/valhalla +23 -23
  223. package/dist/ghostty/themes/velvet +23 -23
  224. package/dist/ghostty/themes/venus +19 -19
  225. package/dist/ghostty/themes/yofukashi +21 -21
  226. package/dist/ghostty/themes/youmu +24 -24
  227. package/dist/ghostty/themes/yui +23 -23
  228. package/dist/ghostty/themes/yuji +29 -0
  229. package/dist/ghostty/themes/yuri +24 -24
  230. package/dist/ghostty/themes/yuuta +29 -0
  231. package/dist/iterm2/alma.itermcolors +65 -65
  232. package/dist/iterm2/anko.itermcolors +68 -68
  233. package/dist/iterm2/asuka.itermcolors +68 -68
  234. package/dist/iterm2/azusa.itermcolors +68 -68
  235. package/dist/iterm2/battler.itermcolors +65 -65
  236. package/dist/iterm2/beatrice.itermcolors +69 -69
  237. package/dist/iterm2/bernkastel.itermcolors +64 -64
  238. package/dist/iterm2/bocchi.itermcolors +69 -69
  239. package/dist/iterm2/cirno.itermcolors +69 -69
  240. package/dist/iterm2/david.itermcolors +61 -61
  241. package/dist/iterm2/dekomori.itermcolors +305 -0
  242. package/dist/iterm2/determination.itermcolors +63 -63
  243. package/dist/iterm2/dorothy.itermcolors +63 -63
  244. package/dist/iterm2/eva01.itermcolors +66 -66
  245. package/dist/iterm2/flandre.itermcolors +65 -65
  246. package/dist/iterm2/fox.itermcolors +68 -68
  247. package/dist/iterm2/geto.itermcolors +305 -0
  248. package/dist/iterm2/glitch.itermcolors +64 -64
  249. package/dist/iterm2/gojo.itermcolors +305 -0
  250. package/dist/iterm2/hinamizawa.itermcolors +65 -65
  251. package/dist/iterm2/hitagi.itermcolors +68 -68
  252. package/dist/iterm2/homura.itermcolors +65 -65
  253. package/dist/iterm2/jill.itermcolors +67 -67
  254. package/dist/iterm2/joker.itermcolors +65 -65
  255. package/dist/iterm2/jupiter.itermcolors +66 -66
  256. package/dist/iterm2/kagami.itermcolors +69 -69
  257. package/dist/iterm2/kaito.itermcolors +67 -67
  258. package/dist/iterm2/kaworu.itermcolors +68 -68
  259. package/dist/iterm2/kita.itermcolors +66 -66
  260. package/dist/iterm2/konata.itermcolors +69 -69
  261. package/dist/iterm2/kou.itermcolors +66 -66
  262. package/dist/iterm2/kumin.itermcolors +305 -0
  263. package/dist/iterm2/kumori.itermcolors +63 -63
  264. package/dist/iterm2/kurisu.itermcolors +64 -64
  265. package/dist/iterm2/kyoko.itermcolors +68 -68
  266. package/dist/iterm2/kyubey.itermcolors +69 -69
  267. package/dist/iterm2/lain.itermcolors +67 -67
  268. package/dist/iterm2/lambdadelta.itermcolors +64 -64
  269. package/dist/iterm2/len.itermcolors +68 -68
  270. package/dist/iterm2/lucy.itermcolors +66 -66
  271. package/dist/iterm2/luka.itermcolors +66 -66
  272. package/dist/iterm2/madoka.itermcolors +61 -61
  273. package/dist/iterm2/magi.itermcolors +66 -66
  274. package/dist/iterm2/mami.itermcolors +66 -66
  275. package/dist/iterm2/marisa.itermcolors +65 -65
  276. package/dist/iterm2/mars.itermcolors +68 -68
  277. package/dist/iterm2/mayuri.itermcolors +67 -67
  278. package/dist/iterm2/megumi.itermcolors +305 -0
  279. package/dist/iterm2/meiko.itermcolors +66 -66
  280. package/dist/iterm2/mercury.itermcolors +66 -66
  281. package/dist/iterm2/mettaton.itermcolors +68 -68
  282. package/dist/iterm2/miku.itermcolors +64 -64
  283. package/dist/iterm2/mio.itermcolors +66 -66
  284. package/dist/iterm2/mion.itermcolors +68 -68
  285. package/dist/iterm2/misato.itermcolors +63 -63
  286. package/dist/iterm2/miyuki.itermcolors +66 -66
  287. package/dist/iterm2/monika.itermcolors +68 -68
  288. package/dist/iterm2/moon.itermcolors +63 -63
  289. package/dist/iterm2/mugi.itermcolors +64 -64
  290. package/dist/iterm2/nadeko.itermcolors +60 -60
  291. package/dist/iterm2/nagisa.itermcolors +63 -63
  292. package/dist/iterm2/nanami.itermcolors +305 -0
  293. package/dist/iterm2/natsuki.itermcolors +62 -62
  294. package/dist/iterm2/nazuna.itermcolors +69 -69
  295. package/dist/iterm2/neutral.itermcolors +62 -62
  296. package/dist/iterm2/nightcity.itermcolors +63 -63
  297. package/dist/iterm2/nijika.itermcolors +60 -60
  298. package/dist/iterm2/nobara.itermcolors +305 -0
  299. package/dist/iterm2/oracle.itermcolors +64 -64
  300. package/dist/iterm2/panther.itermcolors +69 -69
  301. package/dist/iterm2/papyrus.itermcolors +67 -67
  302. package/dist/iterm2/patchouli.itermcolors +69 -69
  303. package/dist/iterm2/queen.itermcolors +63 -63
  304. package/dist/iterm2/rebecca.itermcolors +61 -61
  305. package/dist/iterm2/rei.itermcolors +63 -63
  306. package/dist/iterm2/reimu.itermcolors +66 -66
  307. package/dist/iterm2/rena.itermcolors +65 -65
  308. package/dist/iterm2/rika.itermcolors +65 -65
  309. package/dist/iterm2/rikka.itermcolors +305 -0
  310. package/dist/iterm2/rin.itermcolors +61 -61
  311. package/dist/iterm2/ritsu.itermcolors +67 -67
  312. package/dist/iterm2/rokkenjima.itermcolors +65 -65
  313. package/dist/iterm2/ryo.itermcolors +69 -69
  314. package/dist/iterm2/sans.itermcolors +63 -63
  315. package/dist/iterm2/satoko.itermcolors +69 -69
  316. package/dist/iterm2/sayaka.itermcolors +69 -69
  317. package/dist/iterm2/sayori.itermcolors +60 -60
  318. package/dist/iterm2/sei.itermcolors +63 -63
  319. package/dist/iterm2/seri.itermcolors +65 -65
  320. package/dist/iterm2/shinka.itermcolors +305 -0
  321. package/dist/iterm2/shinobu.itermcolors +63 -63
  322. package/dist/iterm2/skull.itermcolors +62 -62
  323. package/dist/iterm2/stella.itermcolors +62 -62
  324. package/dist/iterm2/sukuna.itermcolors +305 -0
  325. package/dist/iterm2/suzuha.itermcolors +64 -64
  326. package/dist/iterm2/toriel.itermcolors +63 -63
  327. package/dist/iterm2/tsubasa.itermcolors +69 -69
  328. package/dist/iterm2/tsukasa.itermcolors +66 -66
  329. package/dist/iterm2/undyne.itermcolors +69 -69
  330. package/dist/iterm2/valhalla.itermcolors +68 -68
  331. package/dist/iterm2/velvet.itermcolors +67 -67
  332. package/dist/iterm2/venus.itermcolors +57 -57
  333. package/dist/iterm2/yofukashi.itermcolors +64 -64
  334. package/dist/iterm2/youmu.itermcolors +69 -69
  335. package/dist/iterm2/yui.itermcolors +67 -67
  336. package/dist/iterm2/yuji.itermcolors +305 -0
  337. package/dist/iterm2/yuri.itermcolors +65 -65
  338. package/dist/iterm2/yuuta.itermcolors +305 -0
  339. package/dist/kitty/config/dekomori.conf +4 -0
  340. package/dist/kitty/config/geto.conf +4 -0
  341. package/dist/kitty/config/gojo.conf +4 -0
  342. package/dist/kitty/config/kumin.conf +4 -0
  343. package/dist/kitty/config/megumi.conf +4 -0
  344. package/dist/kitty/config/nanami.conf +4 -0
  345. package/dist/kitty/config/nobara.conf +4 -0
  346. package/dist/kitty/config/rikka.conf +4 -0
  347. package/dist/kitty/config/shinka.conf +4 -0
  348. package/dist/kitty/config/sukuna.conf +4 -0
  349. package/dist/kitty/config/yuji.conf +4 -0
  350. package/dist/kitty/config/yuuta.conf +4 -0
  351. package/dist/kitty/themes/alma.conf +21 -21
  352. package/dist/kitty/themes/anko.conf +22 -22
  353. package/dist/kitty/themes/asuka.conf +22 -22
  354. package/dist/kitty/themes/azusa.conf +22 -22
  355. package/dist/kitty/themes/battler.conf +22 -22
  356. package/dist/kitty/themes/beatrice.conf +22 -22
  357. package/dist/kitty/themes/bernkastel.conf +21 -21
  358. package/dist/kitty/themes/bocchi.conf +22 -22
  359. package/dist/kitty/themes/cirno.conf +23 -23
  360. package/dist/kitty/themes/david.conf +21 -21
  361. package/dist/kitty/themes/dekomori.conf +24 -0
  362. package/dist/kitty/themes/determination.conf +23 -23
  363. package/dist/kitty/themes/dorothy.conf +22 -22
  364. package/dist/kitty/themes/eva01.conf +22 -22
  365. package/dist/kitty/themes/flandre.conf +22 -22
  366. package/dist/kitty/themes/fox.conf +22 -22
  367. package/dist/kitty/themes/geto.conf +24 -0
  368. package/dist/kitty/themes/glitch.conf +23 -23
  369. package/dist/kitty/themes/gojo.conf +24 -0
  370. package/dist/kitty/themes/hinamizawa.conf +22 -22
  371. package/dist/kitty/themes/hitagi.conf +22 -22
  372. package/dist/kitty/themes/homura.conf +23 -23
  373. package/dist/kitty/themes/jill.conf +22 -22
  374. package/dist/kitty/themes/joker.conf +22 -22
  375. package/dist/kitty/themes/jupiter.conf +22 -22
  376. package/dist/kitty/themes/kagami.conf +23 -23
  377. package/dist/kitty/themes/kaito.conf +23 -23
  378. package/dist/kitty/themes/kaworu.conf +22 -22
  379. package/dist/kitty/themes/kita.conf +22 -22
  380. package/dist/kitty/themes/konata.conf +23 -23
  381. package/dist/kitty/themes/kou.conf +23 -23
  382. package/dist/kitty/themes/kumin.conf +24 -0
  383. package/dist/kitty/themes/kumori.conf +23 -23
  384. package/dist/kitty/themes/kurisu.conf +21 -21
  385. package/dist/kitty/themes/kyoko.conf +22 -22
  386. package/dist/kitty/themes/kyubey.conf +22 -22
  387. package/dist/kitty/themes/lain.conf +22 -22
  388. package/dist/kitty/themes/lambdadelta.conf +22 -22
  389. package/dist/kitty/themes/len.conf +23 -23
  390. package/dist/kitty/themes/lucy.conf +21 -21
  391. package/dist/kitty/themes/luka.conf +22 -22
  392. package/dist/kitty/themes/madoka.conf +21 -21
  393. package/dist/kitty/themes/magi.conf +21 -21
  394. package/dist/kitty/themes/mami.conf +23 -23
  395. package/dist/kitty/themes/marisa.conf +23 -23
  396. package/dist/kitty/themes/mars.conf +22 -22
  397. package/dist/kitty/themes/mayuri.conf +22 -22
  398. package/dist/kitty/themes/megumi.conf +24 -0
  399. package/dist/kitty/themes/meiko.conf +23 -23
  400. package/dist/kitty/themes/mercury.conf +21 -21
  401. package/dist/kitty/themes/mettaton.conf +23 -23
  402. package/dist/kitty/themes/miku.conf +22 -22
  403. package/dist/kitty/themes/mio.conf +21 -21
  404. package/dist/kitty/themes/mion.conf +22 -22
  405. package/dist/kitty/themes/misato.conf +22 -22
  406. package/dist/kitty/themes/miyuki.conf +23 -23
  407. package/dist/kitty/themes/monika.conf +23 -23
  408. package/dist/kitty/themes/moon.conf +21 -21
  409. package/dist/kitty/themes/mugi.conf +21 -21
  410. package/dist/kitty/themes/nadeko.conf +21 -21
  411. package/dist/kitty/themes/nagisa.conf +21 -21
  412. package/dist/kitty/themes/nanami.conf +24 -0
  413. package/dist/kitty/themes/natsuki.conf +22 -22
  414. package/dist/kitty/themes/nazuna.conf +22 -22
  415. package/dist/kitty/themes/neutral.conf +20 -20
  416. package/dist/kitty/themes/nightcity.conf +23 -23
  417. package/dist/kitty/themes/nijika.conf +21 -21
  418. package/dist/kitty/themes/nobara.conf +24 -0
  419. package/dist/kitty/themes/oracle.conf +21 -21
  420. package/dist/kitty/themes/panther.conf +22 -22
  421. package/dist/kitty/themes/papyrus.conf +23 -23
  422. package/dist/kitty/themes/patchouli.conf +22 -22
  423. package/dist/kitty/themes/queen.conf +22 -22
  424. package/dist/kitty/themes/rebecca.conf +22 -22
  425. package/dist/kitty/themes/rei.conf +21 -21
  426. package/dist/kitty/themes/reimu.conf +21 -21
  427. package/dist/kitty/themes/rena.conf +22 -22
  428. package/dist/kitty/themes/rika.conf +22 -22
  429. package/dist/kitty/themes/rikka.conf +24 -0
  430. package/dist/kitty/themes/rin.conf +23 -23
  431. package/dist/kitty/themes/ritsu.conf +22 -22
  432. package/dist/kitty/themes/rokkenjima.conf +21 -21
  433. package/dist/kitty/themes/ryo.conf +22 -22
  434. package/dist/kitty/themes/sans.conf +22 -22
  435. package/dist/kitty/themes/satoko.conf +22 -22
  436. package/dist/kitty/themes/sayaka.conf +22 -22
  437. package/dist/kitty/themes/sayori.conf +23 -23
  438. package/dist/kitty/themes/sei.conf +22 -22
  439. package/dist/kitty/themes/seri.conf +22 -22
  440. package/dist/kitty/themes/shinka.conf +24 -0
  441. package/dist/kitty/themes/shinobu.conf +21 -21
  442. package/dist/kitty/themes/skull.conf +22 -22
  443. package/dist/kitty/themes/stella.conf +22 -22
  444. package/dist/kitty/themes/sukuna.conf +24 -0
  445. package/dist/kitty/themes/suzuha.conf +21 -21
  446. package/dist/kitty/themes/toriel.conf +23 -23
  447. package/dist/kitty/themes/tsubasa.conf +22 -22
  448. package/dist/kitty/themes/tsukasa.conf +23 -23
  449. package/dist/kitty/themes/undyne.conf +23 -23
  450. package/dist/kitty/themes/valhalla.conf +22 -22
  451. package/dist/kitty/themes/velvet.conf +22 -22
  452. package/dist/kitty/themes/venus.conf +19 -19
  453. package/dist/kitty/themes/yofukashi.conf +21 -21
  454. package/dist/kitty/themes/youmu.conf +23 -23
  455. package/dist/kitty/themes/yui.conf +22 -22
  456. package/dist/kitty/themes/yuji.conf +24 -0
  457. package/dist/kitty/themes/yuri.conf +23 -23
  458. package/dist/kitty/themes/yuuta.conf +24 -0
  459. package/dist/manifest.json +5139 -0
  460. package/dist/shell/palettes.zsh +297 -113
  461. package/dist/wezterm/colors/alma.toml +7 -7
  462. package/dist/wezterm/colors/anko.toml +9 -9
  463. package/dist/wezterm/colors/asuka.toml +9 -9
  464. package/dist/wezterm/colors/azusa.toml +9 -9
  465. package/dist/wezterm/colors/battler.toml +9 -9
  466. package/dist/wezterm/colors/beatrice.toml +9 -9
  467. package/dist/wezterm/colors/bernkastel.toml +7 -7
  468. package/dist/wezterm/colors/bocchi.toml +9 -9
  469. package/dist/wezterm/colors/cirno.toml +10 -10
  470. package/dist/wezterm/colors/david.toml +7 -7
  471. package/dist/wezterm/colors/dekomori.toml +15 -0
  472. package/dist/wezterm/colors/determination.toml +9 -9
  473. package/dist/wezterm/colors/dorothy.toml +9 -9
  474. package/dist/wezterm/colors/eva01.toml +9 -9
  475. package/dist/wezterm/colors/flandre.toml +9 -9
  476. package/dist/wezterm/colors/fox.toml +9 -9
  477. package/dist/wezterm/colors/geto.toml +15 -0
  478. package/dist/wezterm/colors/glitch.toml +9 -9
  479. package/dist/wezterm/colors/gojo.toml +15 -0
  480. package/dist/wezterm/colors/hinamizawa.toml +9 -9
  481. package/dist/wezterm/colors/hitagi.toml +9 -9
  482. package/dist/wezterm/colors/homura.toml +10 -10
  483. package/dist/wezterm/colors/jill.toml +9 -9
  484. package/dist/wezterm/colors/joker.toml +9 -9
  485. package/dist/wezterm/colors/jupiter.toml +9 -9
  486. package/dist/wezterm/colors/kagami.toml +10 -10
  487. package/dist/wezterm/colors/kaito.toml +9 -9
  488. package/dist/wezterm/colors/kaworu.toml +9 -9
  489. package/dist/wezterm/colors/kita.toml +9 -9
  490. package/dist/wezterm/colors/konata.toml +10 -10
  491. package/dist/wezterm/colors/kou.toml +10 -10
  492. package/dist/wezterm/colors/kumin.toml +15 -0
  493. package/dist/wezterm/colors/kumori.toml +8 -8
  494. package/dist/wezterm/colors/kurisu.toml +7 -7
  495. package/dist/wezterm/colors/kyoko.toml +9 -9
  496. package/dist/wezterm/colors/kyubey.toml +9 -9
  497. package/dist/wezterm/colors/lain.toml +9 -9
  498. package/dist/wezterm/colors/lambdadelta.toml +9 -9
  499. package/dist/wezterm/colors/len.toml +9 -9
  500. package/dist/wezterm/colors/lucy.toml +7 -7
  501. package/dist/wezterm/colors/luka.toml +7 -7
  502. package/dist/wezterm/colors/madoka.toml +7 -7
  503. package/dist/wezterm/colors/magi.toml +7 -7
  504. package/dist/wezterm/colors/mami.toml +10 -10
  505. package/dist/wezterm/colors/marisa.toml +10 -10
  506. package/dist/wezterm/colors/mars.toml +9 -9
  507. package/dist/wezterm/colors/mayuri.toml +9 -9
  508. package/dist/wezterm/colors/megumi.toml +15 -0
  509. package/dist/wezterm/colors/meiko.toml +9 -9
  510. package/dist/wezterm/colors/mercury.toml +7 -7
  511. package/dist/wezterm/colors/mettaton.toml +9 -9
  512. package/dist/wezterm/colors/miku.toml +7 -7
  513. package/dist/wezterm/colors/mio.toml +7 -7
  514. package/dist/wezterm/colors/mion.toml +9 -9
  515. package/dist/wezterm/colors/misato.toml +9 -9
  516. package/dist/wezterm/colors/miyuki.toml +10 -10
  517. package/dist/wezterm/colors/monika.toml +9 -9
  518. package/dist/wezterm/colors/moon.toml +7 -7
  519. package/dist/wezterm/colors/mugi.toml +7 -7
  520. package/dist/wezterm/colors/nadeko.toml +7 -7
  521. package/dist/wezterm/colors/nagisa.toml +7 -7
  522. package/dist/wezterm/colors/nanami.toml +15 -0
  523. package/dist/wezterm/colors/natsuki.toml +7 -7
  524. package/dist/wezterm/colors/nazuna.toml +9 -9
  525. package/dist/wezterm/colors/neutral.toml +7 -7
  526. package/dist/wezterm/colors/nightcity.toml +10 -10
  527. package/dist/wezterm/colors/nijika.toml +7 -7
  528. package/dist/wezterm/colors/nobara.toml +15 -0
  529. package/dist/wezterm/colors/oracle.toml +7 -7
  530. package/dist/wezterm/colors/panther.toml +9 -9
  531. package/dist/wezterm/colors/papyrus.toml +9 -9
  532. package/dist/wezterm/colors/patchouli.toml +9 -9
  533. package/dist/wezterm/colors/queen.toml +9 -9
  534. package/dist/wezterm/colors/rebecca.toml +9 -9
  535. package/dist/wezterm/colors/rei.toml +7 -7
  536. package/dist/wezterm/colors/reimu.toml +9 -9
  537. package/dist/wezterm/colors/rena.toml +9 -9
  538. package/dist/wezterm/colors/rika.toml +9 -9
  539. package/dist/wezterm/colors/rikka.toml +15 -0
  540. package/dist/wezterm/colors/rin.toml +9 -9
  541. package/dist/wezterm/colors/ritsu.toml +9 -9
  542. package/dist/wezterm/colors/rokkenjima.toml +7 -7
  543. package/dist/wezterm/colors/ryo.toml +9 -9
  544. package/dist/wezterm/colors/sans.toml +7 -7
  545. package/dist/wezterm/colors/satoko.toml +9 -9
  546. package/dist/wezterm/colors/sayaka.toml +9 -9
  547. package/dist/wezterm/colors/sayori.toml +9 -9
  548. package/dist/wezterm/colors/sei.toml +9 -9
  549. package/dist/wezterm/colors/seri.toml +8 -8
  550. package/dist/wezterm/colors/shinka.toml +15 -0
  551. package/dist/wezterm/colors/shinobu.toml +7 -7
  552. package/dist/wezterm/colors/skull.toml +9 -9
  553. package/dist/wezterm/colors/stella.toml +9 -9
  554. package/dist/wezterm/colors/sukuna.toml +15 -0
  555. package/dist/wezterm/colors/suzuha.toml +7 -7
  556. package/dist/wezterm/colors/toriel.toml +9 -9
  557. package/dist/wezterm/colors/tsubasa.toml +9 -9
  558. package/dist/wezterm/colors/tsukasa.toml +10 -10
  559. package/dist/wezterm/colors/undyne.toml +9 -9
  560. package/dist/wezterm/colors/valhalla.toml +9 -9
  561. package/dist/wezterm/colors/velvet.toml +9 -9
  562. package/dist/wezterm/colors/venus.toml +6 -6
  563. package/dist/wezterm/colors/yofukashi.toml +7 -7
  564. package/dist/wezterm/colors/youmu.toml +10 -10
  565. package/dist/wezterm/colors/yui.toml +9 -9
  566. package/dist/wezterm/colors/yuji.toml +15 -0
  567. package/dist/wezterm/colors/yuri.toml +9 -9
  568. package/dist/wezterm/colors/yuuta.toml +15 -0
  569. package/dist/wezterm/config/dekomori.lua +10 -0
  570. package/dist/wezterm/config/geto.lua +10 -0
  571. package/dist/wezterm/config/gojo.lua +10 -0
  572. package/dist/wezterm/config/kumin.lua +10 -0
  573. package/dist/wezterm/config/megumi.lua +10 -0
  574. package/dist/wezterm/config/nanami.lua +10 -0
  575. package/dist/wezterm/config/nobara.lua +10 -0
  576. package/dist/wezterm/config/rikka.lua +10 -0
  577. package/dist/wezterm/config/shinka.lua +10 -0
  578. package/dist/wezterm/config/sukuna.lua +10 -0
  579. package/dist/wezterm/config/yuji.lua +10 -0
  580. package/dist/wezterm/config/yuuta.lua +10 -0
  581. package/package.json +7 -1
  582. package/shell/adapters/_osc.zsh +34 -5
  583. package/shell/adapters/ghostty.zsh +509 -0
  584. package/shell/adapters/kitty.zsh +4 -3
  585. package/shell/ttheme.zsh +1086 -204
package/shell/ttheme.zsh CHANGED
@@ -2,38 +2,65 @@ typeset -g TTHEME_HOME=${${(%):-%x}:A:h}
2
2
 
3
3
  if [[ -r $TTHEME_HOME/palettes.zsh ]]; then
4
4
  source $TTHEME_HOME/palettes.zsh
5
- elif [[ -r $TTHEME_HOME/../dist/shell/palettes.zsh ]]; then
6
- source $TTHEME_HOME/../dist/shell/palettes.zsh
7
5
  else
8
- print -u2 "ttheme: palettes.zsh not found — run \`mise run build\` in the repo"
6
+ print -u2 "ttheme: palettes.zsh not found — run \`npx @kecan0406/ttheme@latest init\`"
9
7
  return 1
10
8
  fi
11
9
 
10
+ typeset -g TTHEME_CONFIG=${XDG_CONFIG_HOME:-$HOME/.config}/ttheme/config.zsh
11
+
12
+ [[ -r $TTHEME_CONFIG ]] && source $TTHEME_CONFIG
13
+
14
+ typeset -g TTHEME_PINS_FILE=${TTHEME_CONFIG:h}/pins
15
+ typeset -g TTHEME_PINS_RAW=""
16
+ typeset -gA TTHEME_PINS=()
17
+ typeset -g TTHEME_PIN="" TTHEME_PIN_SPEC="" TTHEME_BASE_SPEC=""
18
+
19
+ __tt_tilde() { REPLY=${1/#$HOME\//\~/} }
20
+
21
+ __tt_pins_load() {
22
+ setopt localoptions extendedglob
23
+ local raw="" line key name
24
+ [[ -r $TTHEME_PINS_FILE ]] && raw="$(<$TTHEME_PINS_FILE)"
25
+ [[ $raw == "$TTHEME_PINS_RAW" ]] && return 0
26
+ TTHEME_PINS_RAW=$raw
27
+ TTHEME_PINS=()
28
+ for line in "${(@f)raw}"; do
29
+ line=${line%%[[:space:]]##}
30
+ [[ $line == [~/]*[[:space:]]* ]] || continue
31
+ name=${line##*[[:space:]]} key=${${line%[[:space:]]*}%%[[:space:]]##}
32
+ TTHEME_PINS[${key/#\~\//$HOME/}]=$name
33
+ [[ -n ${TTHEME_PALETTE[$name]} ]] || print -u2 "ttheme: unknown palette '$name' pinned to $key"
34
+ done
35
+ }
36
+
37
+ __tt_pins_load
38
+
12
39
  : ${TTHEME_TAB_PALETTE:=seq}
13
40
 
14
41
  : ${TTHEME_ANNOUNCE:=1}
15
42
 
16
- typeset -g TTHEME_STATE_DIR=${XDG_STATE_HOME:-$HOME/.local/state}/ttheme
43
+ : ${TTHEME_FX:=typewriter}
17
44
 
18
- __tt_detect() {
19
- if [[ -n $GHOSTTY_RESOURCES_DIR || $TERM_PROGRAM == ghostty ]]; then
20
- print -r -- ghostty
21
- elif [[ -n $KITTY_WINDOW_ID ]]; then
22
- print -r -- kitty
23
- elif [[ -n $WEZTERM_PANE ]]; then
24
- print -r -- wezterm
25
- elif [[ -n $ALACRITTY_WINDOW_ID ]]; then
26
- print -r -- alacritty
27
- elif [[ -n $ITERM_SESSION_ID || $TERM_PROGRAM == iTerm.app ]]; then
28
- print -r -- iterm2
29
- elif [[ $TERM == foot* ]]; then
30
- print -r -- foot
31
- else
32
- print -r -- unknown
33
- fi
34
- }
45
+ : ${TTHEME_SORT:=abc}
35
46
 
36
- typeset -g TTHEME_ADAPTER=$(__tt_detect)
47
+ typeset -g TTHEME_STATE_DIR=${XDG_STATE_HOME:-$HOME/.local/state}/ttheme
48
+
49
+ if [[ -n $GHOSTTY_RESOURCES_DIR || $TERM_PROGRAM == ghostty ]]; then
50
+ typeset -g TTHEME_ADAPTER=ghostty
51
+ elif [[ -n $KITTY_WINDOW_ID ]]; then
52
+ typeset -g TTHEME_ADAPTER=kitty
53
+ elif [[ -n $WEZTERM_PANE ]]; then
54
+ typeset -g TTHEME_ADAPTER=wezterm
55
+ elif [[ -n $ALACRITTY_WINDOW_ID ]]; then
56
+ typeset -g TTHEME_ADAPTER=alacritty
57
+ elif [[ -n $ITERM_SESSION_ID || $TERM_PROGRAM == iTerm.app ]]; then
58
+ typeset -g TTHEME_ADAPTER=iterm2
59
+ elif [[ $TERM == foot* ]]; then
60
+ typeset -g TTHEME_ADAPTER=foot
61
+ else
62
+ typeset -g TTHEME_ADAPTER=unknown
63
+ fi
37
64
 
38
65
  source $TTHEME_HOME/adapters/_osc.zsh
39
66
  [[ -r $TTHEME_HOME/adapters/$TTHEME_ADAPTER.zsh ]] &&
@@ -41,22 +68,22 @@ source $TTHEME_HOME/adapters/_osc.zsh
41
68
 
42
69
  __tt_active() {
43
70
  [[ -o interactive ]] || return 1
71
+ (( ${#TTHEME_PALETTE} )) || return 1
44
72
  [[ $TTHEME_ADAPTER != unknown || -n $TTHEME_FORCE ]]
45
73
  }
46
74
 
75
+ __tt_empty() {
76
+ print -u2 'ttheme: no palettes installed yet — run `ttheme browse` to pick some'
77
+ return 1
78
+ }
79
+
47
80
  __tt_spec() {
48
81
  local spec=${TTHEME_PALETTE[$1]}
49
82
  [[ -n $spec ]] || return 1
50
83
  print -r -- "$spec"
51
84
  }
52
85
 
53
- __tt_name_of() {
54
- local k
55
- for k in ${(k)TTHEME_PALETTE}; do
56
- [[ $TTHEME_PALETTE[$k] == $1 ]] && { print -r -- "$k"; return 0 }
57
- done
58
- print -r -- custom
59
- }
86
+ __tt_name_of() { REPLY=${${(k)TTHEME_PALETTE[(re)$1]}:-custom} }
60
87
 
61
88
  __tt_color() { [[ -t 1 && -z $NO_COLOR ]] }
62
89
 
@@ -65,17 +92,21 @@ __tt_palette_line() {
65
92
  local -a p=(${=TTHEME_PALETTE[$name]})
66
93
  (( ${#p} >= 20 )) || return 1
67
94
  local bg=${p[1]#\#} cur=${p[3]#\#}
68
- printf '\033[48;2;%d;%d;%d;38;2;%d;%d;%dm ● \033[0m %-8s \033[2m· ANSI %s\033[0m%s\n' \
95
+ printf '%s\033[48;2;%d;%d;%d;38;2;%d;%d;%dm ● \033[0m %-8s \033[2m· ANSI %s\033[0m\n' \
96
+ "$marker" \
69
97
  $((16#${bg:0:2})) $((16#${bg:2:2})) $((16#${bg:4:2})) \
70
98
  $((16#${cur:0:2})) $((16#${cur:2:2})) $((16#${cur:4:2})) \
71
- "$name" "${TTHEME_SRC[$name]:-unknown}" "$marker"
99
+ "$name" "${TTHEME_SRC[$name]:-unknown}"
72
100
  }
73
101
 
74
102
  __tt_announce() {
75
103
  (( TTHEME_ANNOUNCE )) || return 0
76
104
  local -a p=(${=TTHEME_SPEC})
77
105
  (( ${#p} >= 20 )) || return 0
78
- local name=$(__tt_name_of "$TTHEME_SPEC")
106
+ local REPLY
107
+ __tt_name_of "$TTHEME_SPEC"
108
+ [[ -n ${TTHEME_PALETTE[$REPLY]} ]] || return 0
109
+ local name=$REPLY
79
110
  local grp=${TTHEME_GROUP[$name]:-Other} src=${TTHEME_SRC[$name]:-unknown}
80
111
  if ! __tt_color; then
81
112
  print -r -- "$name · $grp · ANSI $src"
@@ -87,16 +118,148 @@ __tt_announce() {
87
118
  $((16#${cur:0:2})) $((16#${cur:2:2})) $((16#${cur:4:2})) "$name" "$src"
88
119
  }
89
120
 
121
+ __tt_dir_rule() {
122
+ local k base best="" bestlen=-1 p=${1:A}
123
+ for k in ${(k)TTHEME_PINS}; do
124
+ [[ -n ${TTHEME_PALETTE[$TTHEME_PINS[$k]]} ]] || continue
125
+ base=${${k%/\*\*}:A}
126
+ if [[ $k == *"/**" ]]; then
127
+ [[ $p == "$base" || $p == "$base"/* ]] || continue
128
+ else
129
+ [[ $p == "$base" ]] || continue
130
+ fi
131
+ (( ${#base} > bestlen )) && { best=$k; bestlen=${#base} }
132
+ done
133
+ [[ -n $best ]] || return 1
134
+ REPLY=$best
135
+ }
136
+
137
+ __tt_dir_sync() {
138
+ local REPLY="" spec=""
139
+ __tt_dir_rule "$PWD" || REPLY=""
140
+ [[ $REPLY == "$TTHEME_PIN" ]] && return 0
141
+ if [[ -n $REPLY ]]; then
142
+ [[ -n $TTHEME_PIN ]] || TTHEME_BASE_SPEC=$TTHEME_SPEC
143
+ spec=${TTHEME_PALETTE[$TTHEME_PINS[$REPLY]]}
144
+ elif [[ $TTHEME_SPEC == "$TTHEME_PIN_SPEC" ]]; then
145
+ spec=$TTHEME_BASE_SPEC
146
+ fi
147
+ TTHEME_PIN=$REPLY TTHEME_PIN_SPEC=$spec
148
+ [[ -n $spec && $spec != "$TTHEME_SPEC" ]] || return 0
149
+ __tt_apply "$spec"
150
+ TTHEME_SPEC=$spec
151
+ }
152
+
153
+ __tt_chpwd() {
154
+ __tt_pins_load
155
+ __tt_dir_sync
156
+ }
157
+
158
+ __tt_pins_write() {
159
+ local k REPLY w=0
160
+ local -a keys=(${(ok)TTHEME_PINS}) lines=()
161
+ for k in $keys; do
162
+ __tt_tilde "$k"
163
+ (( ${#REPLY} > w )) && w=${#REPLY}
164
+ done
165
+ for k in $keys; do
166
+ __tt_tilde "$k"
167
+ printf -v REPLY '%-*s %s' $w "$REPLY" "${TTHEME_PINS[$k]}"
168
+ lines+=("$REPLY")
169
+ done
170
+ if (( ! ${#lines} )); then
171
+ rm -f $TTHEME_PINS_FILE || return 1
172
+ TTHEME_PINS_RAW=""
173
+ return 0
174
+ fi
175
+ mkdir -p ${TTHEME_PINS_FILE:h} || return 1
176
+ print -rl -- "${lines[@]}" > $TTHEME_PINS_FILE || return 1
177
+ TTHEME_PINS_RAW="$(<$TTHEME_PINS_FILE)"
178
+ }
179
+
180
+ __tt_pin_save() {
181
+ local name=$1 key=$PWD REPLY
182
+ (( $2 == 2 )) && key="$PWD/**"
183
+ unset "TTHEME_PINS[$PWD]" "TTHEME_PINS[$PWD/**]"
184
+ TTHEME_PINS[$key]=$name
185
+ if ! __tt_pins_write; then
186
+ print -u2 "ttheme pin: could not write $TTHEME_PINS_FILE"
187
+ return 1
188
+ fi
189
+ [[ -n $TTHEME_PIN ]] || TTHEME_BASE_SPEC=$3
190
+ TTHEME_PIN=$key TTHEME_PIN_SPEC=${TTHEME_PALETTE[$name]}
191
+ __tt_tilde "$key"
192
+ if __tt_color; then
193
+ printf '\033[2mpinned · %s → %s\033[0m\n' "$REPLY" "$name"
194
+ else
195
+ print -r -- "pinned · $REPLY → $name"
196
+ fi
197
+ }
198
+
199
+ __tt_unpin() {
200
+ local key REPLY
201
+ for key in "$PWD" "$PWD/**"; do
202
+ [[ -n ${TTHEME_PINS[$key]} ]] || continue
203
+ unset "TTHEME_PINS[$key]"
204
+ if ! __tt_pins_write; then
205
+ print -u2 "ttheme unpin: could not write $TTHEME_PINS_FILE"
206
+ return 1
207
+ fi
208
+ __tt_dir_sync
209
+ __tt_tilde "$key"
210
+ if __tt_color; then
211
+ printf '\033[2munpinned · %s\033[0m\n' "$REPLY"
212
+ else
213
+ print -r -- "unpinned · $REPLY"
214
+ fi
215
+ return 0
216
+ done
217
+ if __tt_dir_rule "$PWD"; then
218
+ __tt_tilde "$REPLY"
219
+ print -u2 "ttheme unpin: nothing pinned here — $REPLY covers this directory"
220
+ else
221
+ print -u2 "ttheme unpin: nothing pinned here"
222
+ fi
223
+ return 1
224
+ }
225
+
226
+ __tt_keep() {
227
+ __tt_cli default "$1" > /dev/null || return 1
228
+ __tt_reload
229
+ if __tt_color; then
230
+ printf '\033[2mdefault · new tabs open with %s\033[0m\n' "$1"
231
+ else
232
+ print -r -- "default · new tabs open with $1"
233
+ fi
234
+ }
235
+
236
+ __tt_order() {
237
+ if [[ $TTHEME_SORT == series ]]; then
238
+ reply=($TTHEME_ORDER)
239
+ else
240
+ reply=($TTHEME_ABC)
241
+ fi
242
+ }
243
+
90
244
  __tt_menu() {
91
- local k cur="" mark grp last_grp=""
245
+ local k cur="" mark grp last_grp="" REPLY
246
+ local -a reply
247
+ __tt_order
92
248
  if ! __tt_color; then
93
- for k in $TTHEME_ORDER; do
249
+ for k in $reply; do
94
250
  printf '%s\t%s\t%s\n' "$k" "${TTHEME_GROUP[$k]:-Other}" "${TTHEME_SRC[$k]:-unknown}"
95
251
  done
96
252
  return 0
97
253
  fi
98
- [[ -n $TTHEME_SPEC ]] && cur=$(__tt_name_of "$TTHEME_SPEC")
99
- for k in $TTHEME_ORDER; do
254
+ [[ -n $TTHEME_SPEC ]] && __tt_name_of "$TTHEME_SPEC" && cur=$REPLY
255
+ local gutter=""
256
+ if [[ -n ${TTHEME_PALETTE[$cur]} ]]; then
257
+ local -a cp=(${=TTHEME_PALETTE[$cur]})
258
+ local ch=${cp[3]#\#}
259
+ printf -v gutter '\033[38;2;%d;%d;%dm◆\033[0m ' \
260
+ $((16#${ch:0:2})) $((16#${ch:2:2})) $((16#${ch:4:2}))
261
+ fi
262
+ for k in $reply; do
100
263
  grp=${TTHEME_GROUP[$k]:-Other}
101
264
  if [[ $grp != $last_grp ]]; then
102
265
  printf '\033[1m%s\033[0m' "$grp"
@@ -104,8 +267,8 @@ __tt_menu() {
104
267
  printf '\n'
105
268
  last_grp=$grp
106
269
  fi
107
- mark=""
108
- [[ $k == $cur ]] && mark=" ← current"
270
+ mark=" "
271
+ [[ $k == $cur ]] && mark=$gutter
109
272
  __tt_palette_line "$k" "$mark"
110
273
  done
111
274
  printf '\n\033[2mttheme <name> paints this tab · ttheme preview · ttheme help\033[0m\n'
@@ -116,12 +279,68 @@ __tt_help() {
116
279
 
117
280
  ttheme list every palette, grouped, with previews
118
281
  ttheme homura paint this tab (a unique prefix works: ttheme ho)
119
- ttheme preview browse live — focus repaints, enter keeps, esc restores
282
+ ttheme preview browse live — focus repaints, enter keeps (this tab or default), esc restores, ? lists keys
120
283
  ttheme next advance this tab to the next palette
121
- ttheme current what this tab is using (just the name when piped)
284
+ ttheme pin pick a palette for this directory cd into it repaints, cd out restores
285
+ ttheme unpin drop the palette pinned to this directory
286
+ ttheme config edit settings in $EDITOR — they apply in new tabs
287
+
288
+ ttheme browse pick palettes from the catalog in a live picker
289
+ ttheme list show the catalog, marking what is installed
290
+ ttheme add install palettes from the catalog
291
+ ttheme remove uninstall palettes
292
+ ttheme update refresh the catalog from the registry'
293
+ }
122
294
 
123
- TTHEME_TAB_PALETTE=off new tabs inherit the window'\''s colors
124
- TTHEME_ANNOUNCE=0 silence the notice under "Last login:"'
295
+ __tt_cli() { node $TTHEME_HOME/ttheme.js "$@" }
296
+
297
+ __tt_catalog() {
298
+ __tt_cli "$@" || return
299
+ [[ $1 == list ]] && return 0
300
+ [[ -r $TTHEME_HOME/palettes.zsh ]] || return 0
301
+ unset TTHEME_PALETTE TTHEME_GROUP TTHEME_NATIVE TTHEME_SRC
302
+ source $TTHEME_HOME/palettes.zsh
303
+ }
304
+
305
+ __tt_config() {
306
+ if [[ ! -e $TTHEME_CONFIG ]]; then
307
+ mkdir -p ${TTHEME_CONFIG:h} || return 1
308
+ print -r -- "$TTHEME_CONFIG_TEMPLATE" > $TTHEME_CONFIG
309
+ fi
310
+ ${=${VISUAL:-${EDITOR:-vi}}} $TTHEME_CONFIG || return
311
+ print -r -- "settings apply in new tabs — $TTHEME_CONFIG"
312
+ }
313
+
314
+ __tt_config_write() {
315
+ local line name doc
316
+ local -a out=()
317
+ local -A want=("$@")
318
+ local -i i
319
+ if [[ ! -e $TTHEME_CONFIG ]]; then
320
+ mkdir -p ${TTHEME_CONFIG:h} 2>/dev/null || return 1
321
+ print -r -- "$TTHEME_CONFIG_TEMPLATE" 2>/dev/null > $TTHEME_CONFIG || return 1
322
+ fi
323
+ [[ -r $TTHEME_CONFIG && -w $TTHEME_CONFIG ]] || return 1
324
+ for line in "${(@f)$(<$TTHEME_CONFIG)}"; do
325
+ for name in ${(k)want}; do
326
+ [[ $line == (|\#)(| )': ${'${name}[:=}]* ]] || continue
327
+ line=": \${$name:=${want[$name]}}"
328
+ unset "want[$name]"
329
+ break
330
+ done
331
+ out+=("$line")
332
+ done
333
+ for (( i = 1; i < $#; i += 2 )); do
334
+ name=${@[i]}
335
+ (( ${+want[$name]} )) || continue
336
+ doc=""
337
+ for line in "${(@f)TTHEME_CONFIG_TEMPLATE}"; do
338
+ [[ $line == ": \${$name:="* ]] && break
339
+ doc=$line
340
+ done
341
+ out+=("" "$doc" ": \${$name:=${want[$name]}}")
342
+ done
343
+ print -rl -- "${out[@]}" 2>/dev/null > $TTHEME_CONFIG
125
344
  }
126
345
 
127
346
  __tt_resolve() {
@@ -150,27 +369,12 @@ __tt_resolve() {
150
369
 
151
370
  __tt_next() {
152
371
  local f=$TTHEME_STATE_DIR/.rotation idx=0
153
- mkdir -p $TTHEME_STATE_DIR 2>/dev/null
372
+ [[ -d $TTHEME_STATE_DIR ]] || mkdir -p $TTHEME_STATE_DIR 2>/dev/null
154
373
  [[ -r $f ]] && idx=$(<$f)
155
374
  [[ $idx == <-> ]] || idx=0
156
- (( idx = idx % ${#TTHEME_ROTATION} + 1 ))
375
+ (( idx = idx % ${#TTHEME_ORDER} + 1 ))
157
376
  print -r -- $idx > $f 2>/dev/null
158
- REPLY=${TTHEME_PALETTE[$TTHEME_ROTATION[idx]]}
159
- }
160
-
161
- __tt_current() {
162
- if [[ -z $TTHEME_SPEC ]]; then
163
- print -u2 "ttheme current: no palette assigned to this shell"
164
- return 1
165
- fi
166
- local name=$(__tt_name_of "$TTHEME_SPEC")
167
- if ! __tt_color; then
168
- print -r -- "$name"
169
- elif [[ -n ${TTHEME_PALETTE[$name]} ]]; then
170
- __tt_palette_line "$name"
171
- else
172
- print -r -- "custom $TTHEME_SPEC"
173
- fi
377
+ REPLY=${TTHEME_PALETTE[$TTHEME_ORDER[idx]]}
174
378
  }
175
379
 
176
380
  __tt_rotate() {
@@ -186,25 +390,32 @@ __tt_rotate() {
186
390
  }
187
391
 
188
392
  __tt_pv_rows() {
189
- rtype=() rval=()
190
- local g t
393
+ rtype=() rval=() rcnt=()
394
+ local g t gm
191
395
  local -a ts
192
396
  for g in $groups; do
193
397
  ts=()
398
+ gm=""
399
+ [[ -n $flt && ${(L)g} == *$flt* ]] && gm=1
194
400
  for t in ${=gthemes[$g]}; do
195
- [[ -z $flt || $t == *$flt* ]] && ts+=($t)
401
+ [[ -z $flt || -n $gm || $t == *$flt* ]] && ts+=($t)
196
402
  done
197
403
  [[ -n $flt ]] && (( ! ${#ts} )) && continue
198
- rtype+=(hdr); rval+=($g)
404
+ rtype+=(hdr); rval+=($g); rcnt+=(${#ts})
199
405
  if [[ -n $flt || -n ${exp[$g]} ]]; then
200
- for t in $ts; do rtype+=(thm); rval+=($t); done
406
+ for t in $ts; do rtype+=(thm); rval+=($t); rcnt+=(0); done
201
407
  fi
202
408
  done
203
409
  }
204
410
 
205
411
  __tt_pv_first() {
206
- local i
412
+ local name=$1 i
207
413
  cur=1 top=1
414
+ if [[ -n $name ]]; then
415
+ for (( i = 1; i <= ${#rval}; i++ )); do
416
+ [[ ${rtype[i]} == thm && ${rval[i]} == $name ]] && { cur=$i; return 0 }
417
+ done
418
+ fi
208
419
  for (( i = 1; i <= ${#rtype}; i++ )); do
209
420
  [[ ${rtype[i]} == thm ]] && { cur=$i; return 0 }
210
421
  done
@@ -223,6 +434,7 @@ __tt_pv_goto() {
223
434
 
224
435
  __tt_pv_focus() {
225
436
  [[ ${rtype[cur]} == thm ]] || return 0
437
+ (( resized )) || [[ ${rval[cur]} == "$bgname" ]] || __tt_pv_bg_show "${rval[cur]}"
226
438
  local spec=${TTHEME_PALETTE[${rval[cur]}]}
227
439
  [[ $spec == "$applied" ]] && return 0
228
440
  __tt_apply "$spec"
@@ -254,139 +466,704 @@ __tt_pv_left() {
254
466
  __tt_pv_rows
255
467
  }
256
468
 
257
- __tt_pv_draw() {
258
- local h=$(( ${LINES:-24} - 2 )) i out line g arrow chunk hidden
259
- (( h < 1 )) && h=1
260
- (( cur < top )) && top=$cur
261
- (( cur >= top + h )) && top=$(( cur - h + 1 ))
262
- (( top < 1 )) && top=1
263
- out=$'\e[H'
264
- line="ttheme preview"
265
- (( color )) && line=$'\e[1m'"ttheme preview"$'\e[0m'
266
- if [[ -n ${TTHEME_PALETTE[$cn]} ]]; then
469
+ typeset -gA TTHEME_GLYPHS=(
470
+ 0 111101101101111 1 010110010010111 2 111001111100111 3 111001111001111 4 101101111001001
471
+ 5 111100111001111 6 111100111101111 7 111001001001001 8 111101111101111 9 111101111001111
472
+ '%' 101001010100101 F 111100110100100 I 111010010010111 L 100100100100111
473
+ )
474
+
475
+ __tt_pv_osd() {
476
+ local text=${(U)osd} bits line oc=$'\e[1m' blank
477
+ local -i s=2 n=${#text} w r c k i top left
478
+ (( n * 16 + 4 <= pw && ph >= 14 )) || s=1
479
+ w=$(( n * 8 * s - 2 * s + 4 ))
480
+ top=$(( (ph - 5 * s) / 2 )) left=$(( (pw - w) / 2 + 1 ))
481
+ (( top < 2 )) && top=2
482
+ (( left < 1 )) && left=1
483
+ if (( color )) && [[ ${rtype[cur]} == thm ]]; then
484
+ local -a fp=(${=TTHEME_PALETTE[${rval[cur]}]})
485
+ local fc=${fp[3]#\#}
486
+ printf -v oc '\e[1;38;2;%d;%d;%dm' $((16#${fc:0:2})) $((16#${fc:2:2})) $((16#${fc:4:2}))
487
+ fi
488
+ blank=${(l:w:: :)}
489
+ out+=$'\e['$(( top - 1 ))';'${left}H$blank
490
+ for (( r = 0; r < 5; r++ )); do
491
+ line=" "
492
+ for (( k = 1; k <= n; k++ )); do
493
+ bits=${TTHEME_GLYPHS[${text[k]}]}
494
+ for (( c = 1; c <= 3; c++ )); do
495
+ if [[ ${bits[r * 3 + c]} == 1 ]]; then
496
+ line+=${(l:2*s::█:)}
497
+ else
498
+ line+=${(l:2*s:: :)}
499
+ fi
500
+ done
501
+ (( k < n )) && line+=${(l:2*s:: :)}
502
+ done
503
+ line+=" "
504
+ for (( i = 0; i < s; i++ )); do
505
+ out+=$'\e['$(( top + r * s + i ))';'${left}H$oc$line$'\e[0m'
506
+ done
507
+ done
508
+ out+=$'\e['$(( top + 5 * s ))';'${left}H$blank
509
+ }
510
+
511
+ __tt_pv_lw() {
512
+ local -i lw=$(( pw - 2 < 48 ? pw - 2 : 48 )) l=$(( pw * 3 / 10 )) sw=$(( pw * 45 / 100 ))
513
+ (( l < 38 )) && l=38
514
+ (( l > 56 )) && l=56
515
+ (( sw > 64 )) && sw=64
516
+ (( sw > pw - l - 6 )) && sw=$(( pw - l - 6 ))
517
+ if (( color && sw >= 32 )); then
518
+ lw=$l
519
+ else
520
+ sw=0
521
+ fi
522
+ reply=($lw $sw)
523
+ }
524
+
525
+ __tt_pv_hl() {
526
+ local t=$1 lt=${(L)1} pre
527
+ REPLY=$t
528
+ (( color )) && [[ -n $flt && $lt == *$flt* ]] || return 0
529
+ pre=${lt%%$flt*}
530
+ REPLY=${t[1,${#pre}]}$'\e[1;4m'$ac${t[${#pre}+1,${#pre}+${#flt}]}$'\e[22;24;39m'$2${t[${#pre}+${#flt}+1,-1]}
531
+ }
532
+
533
+ __tt_pv_row() {
534
+ local t=${rval[$1]} b=$'\e[1m' d=$'\e[2m' r=$'\e[22;24;39m' z=$'\e[0m' on="" base="" lead=$'\e[2m' mark=" " name arrow=▸
535
+ local -i w
536
+ (( color )) || b= d= r= z= lead=
537
+ (( $1 == cur && color )) && on=$sb
538
+ if [[ ${rtype[$1]} == hdr ]]; then
539
+ [[ -n $flt || -n ${exp[$t]} ]] && arrow=▾
540
+ name=$t
541
+ (( ${(m)#name} > lw - 8 )) && name="${name[1,lw-9]}…"
542
+ base=$b
543
+ if (( color )) && [[ $t == "$ag" ]]; then
544
+ base+=$ac lead=$ac
545
+ elif (( $1 == cur )); then
546
+ lead=""
547
+ fi
548
+ __tt_pv_hl "$name" "$base"
549
+ w=$(( lw - 2 - ${(m)#name} - ${#rcnt[$1]} ))
550
+ (( w < 1 )) && w=1
551
+ REPLY=$on$lead$arrow$r" "$base$REPLY$r${(l:w:: :)}$d${rcnt[$1]}$z
552
+ return 0
553
+ fi
554
+ if (( $1 == cur )); then
555
+ mark=$cmark base=$b
556
+ elif [[ -n $cdot && $t == "$cn" ]]; then
557
+ mark=$cdot
558
+ fi
559
+ __tt_pv_hl "$t" "$base"
560
+ if (( color )); then
561
+ [[ -n ${tstrip[$t]} ]] || __tt_pv_strip $t
562
+ w=$(( lw - 20 - ${#t} ))
563
+ (( w < 1 )) && w=1
564
+ REPLY="$on $mark $base$REPLY$r${(l:w:: :)}${tstrip[$t]}"
565
+ else
566
+ REPLY=" $mark $REPLY"
567
+ fi
568
+ }
569
+
570
+ __tt_pv_head() {
571
+ local b=$'\e[1m' d=$'\e[2m' z=$'\e[0m' right=$6
572
+ (( color )) || b= d= z=
573
+ out+=$'\e['$1';'$2'H'$b$ac$4$z
574
+ [[ -n $5 ]] && out+=" "$d$5$z
575
+ [[ -n $right ]] && out+=$'\e['$(( $3 - ${(m)#right} + 1 ))'G'$d$right$z
576
+ return 0
577
+ }
578
+
579
+ __tt_pv_foot() {
580
+ setopt localoptions extendedglob
581
+ local b=$'\e[1m' d=$'\e[2m' z=$'\e[0m' y=$'\e[33m' on=$'\e[7;1m'$ac badge="" lead="" note="" right="" line plain
582
+ local -a kk=() kl=() seg=()
583
+ local -i end=$1 i lwid rwid
584
+ (( color )) || b= d= z= y= on=
585
+ if (( help )); then
586
+ badge=KEYS right=$b"? esc"$z$d" close"$z
587
+ elif [[ -n $pick ]]; then
588
+ local a=$plabel[1] c=$plabel[2]
267
589
  if (( color )); then
268
- line+=" $cdot $cn"
590
+ if (( pk == 1 )); then a=$on$a$z c=$d$c$z; else a=$d$a$z c=$on$c$z; fi
269
591
  else
270
- line+=" current $cn"
592
+ if (( pk == 1 )); then a="[${${a# }% }]"; else c="[${${c# }% }]"; fi
271
593
  fi
272
- fi
273
- [[ -n $flt ]] && line+=" /$flt"
274
- out+=$line$'\e[K\n'
275
- for (( i = top; i < top + h; i++ )); do
276
- if (( ! ${#rval} && i == 1 )); then
277
- out+=" no palettes match '$flt'"$'\e[K\n'
278
- continue
594
+ badge=APPLY lead="$pick → $a $c"
595
+ if [[ $mode == pin ]]; then
596
+ __tt_tilde "$PWD"
597
+ note=$REPLY
598
+ (( pk == 2 )) && note+="/**"
599
+ elif (( pk == 1 )); then
600
+ note="until this tab closes"
601
+ else
602
+ note="new tabs · ghostty config"
279
603
  fi
280
- if (( i > ${#rval} )); then
281
- out+=$'\e[K\n'
282
- continue
604
+ kk=(enter) kl=(confirm)
605
+ right=$b"esc"$z$d" back"$z
606
+ elif [[ -n $tune ]]; then
607
+ badge=TUNE kk=(↑↓ ←→) kl=(field step)
608
+ if (( tf == 2 )); then
609
+ kl[2]=move kk+=(1-9) kl+=(place)
610
+ else
611
+ kk+=(⇧←→) kl+=(×10)
283
612
  fi
284
- if [[ ${rtype[i]} == hdr ]]; then
285
- g=${rval[i]}
286
- arrow=▸
287
- [[ -n $flt || -n ${exp[$g]} ]] && arrow=▾
288
- if (( i == cur )); then
289
- if (( color )); then
290
- chunk=$'\e[1;7m'" $g "$'\e[0m'
291
- else
292
- chunk="[$g]"
293
- fi
294
- else
295
- chunk=${hchip[$g]}
613
+ kk+=(space '=' enter)
614
+ if (( bgoff[$tune] )); then kl+=(show default keep); else kl+=(hide default keep); fi
615
+ __tt_pv_bg_findable $tune && { kk+=(f); kl+=(find) }
616
+ right=$b"esc"$z$d" undo"$z
617
+ elif (( conf )); then
618
+ badge=CONFIG kk=(↑↓ ←→ enter) kl=(setting value save)
619
+ right=$b"esc"$z$d" undo"$z
620
+ else
621
+ [[ -n $flt ]] && badge=FILTER
622
+ if (( ! ${#rval} )); then
623
+ kk=(bksp) kl=(edit)
624
+ elif [[ ${rtype[cur]} == hdr ]]; then
625
+ if [[ -z $flt && -n ${exp[${rval[cur]}]} ]]; then
626
+ kk=(←) kl=(close)
627
+ elif [[ -z $flt ]]; then
628
+ kk=(→) kl=(open)
296
629
  fi
297
- line="$arrow"$chunk${hnat[$g]}
298
- if [[ -n ${TTHEME_PALETTE[$cn]} && ${TTHEME_GROUP[$cn]:-Other} == $g ]]; then
299
- hidden=1
300
- if [[ -n $flt ]]; then
301
- [[ $cn == *$flt* ]] && hidden=0
302
- elif [[ -n ${exp[$g]} ]]; then
303
- hidden=0
304
- fi
305
- if (( hidden )); then
306
- if (( color )); then
307
- line+=$cchip
308
- else
309
- line+=" · current"
310
- fi
311
- fi
630
+ else
631
+ kk=(enter) kl=(apply)
632
+ [[ $mode == pin ]] && kl[1]=pin
633
+ if __tt_pv_bg_state ${rval[cur]}; then
634
+ kk+=(tab) kl+=("tune bg")
635
+ elif __tt_pv_bg_findable ${rval[cur]}; then
636
+ kk+=(tab) kl+=("find bg")
312
637
  fi
313
- elif (( i == cur )); then
314
- line=" ▶ "${tbody[${rval[i]}]}
638
+ [[ -n $flt ]] && { kk+=(bksp); kl+=(edit) }
639
+ fi
640
+ kk+=('?') kl+=(keys)
641
+ if [[ -n $flt ]]; then
642
+ right=$b"esc"$z$d" clear filter"$z
315
643
  else
316
- line=" "${tbody[${rval[i]}]}
644
+ right=$b"esc"$z$d" restore"$z
645
+ [[ -n $cdot ]] && right+=" $cdot$z $cn"
646
+ fi
647
+ fi
648
+ if (( msgt > 0 )) && [[ -z $pick ]]; then
649
+ lead=$y$msg$z note="" kk=() kl=()
650
+ fi
651
+ while :; do
652
+ seg=()
653
+ [[ -n $lead ]] && seg+=("$lead")
654
+ [[ -n $note ]] && seg+=("$d$note$z")
655
+ for (( i = 1; i <= ${#kk}; i++ )); do
656
+ seg+=("$b${kk[i]}$z$d ${kl[i]}$z")
657
+ done
658
+ line=${(j: :)seg}
659
+ if [[ -n $badge ]]; then
660
+ if (( color )); then
661
+ line=$'\e[7;1m'$ac" $badge "$z" "$line
662
+ else
663
+ line="[$badge] $line"
664
+ fi
665
+ fi
666
+ plain=${line//$'\e'\[[0-9;]##m/}
667
+ lwid=${(m)#plain}
668
+ plain=${right//$'\e'\[[0-9;]##m/}
669
+ rwid=${(m)#plain}
670
+ (( lwid <= end && (! rwid || lwid + 3 + rwid <= end) )) && break
671
+ if [[ -n $note ]]; then
672
+ note=""
673
+ elif (( ${#kk} > 2 )); then
674
+ kk[-2]=() kl[-2]=()
675
+ elif [[ -n $right ]]; then
676
+ right=""
677
+ elif (( ${#kk} > 1 )); then
678
+ kk[-2]=() kl[-2]=()
679
+ else
680
+ break
317
681
  fi
318
- out+=$line$'\e[K\n'
319
682
  done
320
- line="↑↓ move · ←→ fold · type to filter · enter apply · esc restore"
321
- (( color )) && line=$'\e[2m'$line$'\e[0m'
322
683
  out+=$line$'\e[K'
323
- print -rn -- "$out"
684
+ [[ -n $right ]] && out+=$'\e['$(( end - rwid + 1 ))'G'$right
685
+ return 0
324
686
  }
325
687
 
326
- __tt_pv_init() {
327
- local k g
328
- for k in $TTHEME_ORDER; do
329
- g=${TTHEME_GROUP[$k]:-Other}
330
- if [[ -z ${gthemes[$g]} ]]; then
331
- groups+=($g)
332
- gnative[$g]=$TTHEME_NATIVE[$k]
688
+ __tt_pv_help() {
689
+ local back="the tab" z=$'\e[0m' b=$'\e[1m' blank
690
+ [[ -n ${TTHEME_PALETTE[$cn]} ]] && back=$cn
691
+ local -a hk=(move series filter apply) hv=(
692
+ "↑↓ home end pgup pgdn"
693
+ "←→ · enter or space on a series"
694
+ "a-z 0-9 - · bksp · ctrl-u clears"
695
+ "enter · esc restores $back"
696
+ )
697
+ if (( bgcw )); then
698
+ hk+=("tune bg" "" "" "")
699
+ hv+=("tab · finds one on safebooru if none" "↑↓ field ←→ step ⇧←→ ×10 1-9 place" "space hides · = default · f replaces" "enter keeps · esc undoes")
700
+ fi
701
+ hk+=(config "")
702
+ hv+=("alt-c · ↑↓ setting ←→ value" "enter saves · esc undoes")
703
+ hk+=(close)
704
+ hv+=("? esc")
705
+ (( color )) || z= b=
706
+ local -i i r x y w hh
707
+ if (( split && sw >= 48 )); then
708
+ for (( i = 1; i <= ${#hk}; i++ )); do
709
+ r=$(( i + 3 ))
710
+ (( r < ph )) || break
711
+ out+=$'\e['$r';'$sc'H'$b${hk[i]}$z$'\e['$r';'$(( sc + 10 ))'H'${hv[i][1,se-sc-9]}
712
+ done
713
+ return 0
714
+ fi
715
+ w=$(( pw - 2 < 58 ? pw - 2 : 58 )) hh=$(( ${#hk} + 4 ))
716
+ x=$(( (pw - w) / 2 + 1 )) y=$(( (ph - hh) / 2 ))
717
+ (( y < 4 )) && y=4
718
+ blank=${(l:w:: :)}
719
+ out+=$'\e['$y';'$x'H'"╭─ keys ${(l:$(( w - 9 ))::─:)}╮"
720
+ for (( r = y + 1; r < y + hh - 1; r++ )); do
721
+ out+=$'\e['$r';'$x'H'$blank$'\e['$r';'$x'H│'$'\e['$r';'$(( x + w - 1 ))'H│'
722
+ done
723
+ for (( i = 1; i <= ${#hk}; i++ )); do
724
+ r=$(( y + 1 + i ))
725
+ out+=$'\e['$r';'$(( x + 3 ))'H'$b${hk[i]}$z$'\e['$r';'$(( x + 13 ))'H'${hv[i][1,w-16]}
726
+ done
727
+ out+=$'\e['$(( y + hh - 1 ))';'$x'H'"╰${(l:$(( w - 2 ))::─:)}╯"
728
+ }
729
+
730
+ __tt_pv_specimen() {
731
+ local -a sp=(${=applied}) ln=()
732
+ (( ${#sp} >= 20 )) || return 0
733
+ local z=$'\e[0m' d=$'\e[2m' pr=$'\e[32m❯\e[0m ' sel cu cell line="" lo hi
734
+ local -i i r cw=4
735
+ (( sw < 44 )) && cw=3
736
+ (( sw >= 56 )) && cw=$(( (sw + 1) / 8 - 1 ))
737
+ (( cw > 7 )) && cw=7
738
+ printf -v sel '\e[48;2;%d;%d;%dm' $((16#${sp[4]:1:2})) $((16#${sp[4]:3:2})) $((16#${sp[4]:5:2}))
739
+ printf -v cu '\e[48;2;%d;%d;%dm' $((16#${sp[3]:1:2})) $((16#${sp[3]:3:2})) $((16#${sp[3]:5:2}))
740
+ for (( i = 0; i < 8; i++ )); do
741
+ lo=${sp[i+5]#\#} hi=${sp[i+13]#\#}
742
+ printf -v cell '\e[38;2;%d;%d;%d;48;2;%d;%d;%dm%s\e[0m ' \
743
+ $((16#${lo:0:2})) $((16#${lo:2:2})) $((16#${lo:4:2})) \
744
+ $((16#${hi:0:2})) $((16#${hi:2:2})) $((16#${hi:4:2})) "${(l:cw::▀:)}"
745
+ line+=$cell
746
+ done
747
+ out+=$'\e[4;'$sc'H'$line
748
+ ln=($'\e[1;34m~/code/demo\e[0m'$d' on '$z$'\e[35mmain\e[32m +2\e[33m ~1\e[0m' "${pr}git status -sb")
749
+ (( sw >= 44 )) && ln+=($'## \e[32mmain\e[0m...\e[31morigin/main\e[33m [ahead 1]\e[0m')
750
+ ln+=($'\e[31m M\e[0m src/main.rs' $'\e[31m??\e[0m notes.md' "")
751
+ (( sw >= 44 )) && ln+=("${pr}ls" $'\e[1;34mdocs\e[0m \e[1;34msrc\e[0m \e[1;34mtests\e[0m Cargo.toml README.md' "")
752
+ ln+=("${pr}cargo test" $'\e[32m ✓\e[0m parses config' $'\e[31m ✗\e[0m renders frame')
753
+ (( sw >= 44 )) && ln[-1]+=$d' expected '$z$'\e[32m3\e[0m'$d', received '$z$'\e[31m2\e[0m'
754
+ ln+=("" "${pr}echo ${sel}selected text${z} ${cu} ${z}")
755
+ for (( r = 1; r <= ${#ln}; r++ )); do
756
+ (( r + 5 < ph )) || break
757
+ out+=$'\e['$(( r + 5 ))';'$sc'H'${ln[r]}
758
+ done
759
+ }
760
+
761
+ __tt_pv_tune() {
762
+ local -a fields=(size pos op)
763
+ local -i n=1
764
+ local name
765
+ case $key in
766
+ $'\x03') return 1 ;;
767
+ up) (( tf > 1 )) && tf=$(( tf - 1 )) ;;
768
+ down) (( tf < 3 )) && tf=$(( tf + 1 )) ;;
769
+ left|right|sleft|sright)
770
+ [[ $key == *left ]] && n=-1
771
+ [[ $key == s* ]] && (( tf != 2 )) && n=$(( n * 10 ))
772
+ __tt_pv_bg_adjust ${fields[tf]} $n
773
+ ;;
774
+ [1-9])
775
+ tf=2
776
+ __tt_pv_bg_adjust at $key
777
+ ;;
778
+ ' ') __tt_pv_bg_adjust on ;;
779
+ '=') __tt_pv_bg_adjust def ;;
780
+ f)
781
+ __tt_pv_bg_findable $tune || return 0
782
+ name=$tune
783
+ __tt_pv_untune
784
+ __tt_pv_bg_find $name
785
+ tune=$name tf=1 tsnap="${bgsize[$name]} ${bgpos[$name]} ${bgop[$name]} ${bgoff[$name]}"
786
+ ;;
787
+ $'\r'|$'\n')
788
+ if [[ "${bgsize[$tune]} ${bgpos[$tune]} ${bgop[$tune]} ${bgoff[$tune]}" != "$tsnap" ]]; then
789
+ bgedit[$tune]=1 msg="kept · saved when preview closes" msgt=200
790
+ fi
791
+ tune=""
792
+ ;;
793
+ esc) __tt_pv_untune ;;
794
+ '?') help=1 ;;
795
+ esac
796
+ return 0
797
+ }
798
+
799
+ __tt_pv_untune() {
800
+ local -a s=(${=tsnap})
801
+ bgsize[$tune]=$s[1] bgpos[$tune]=$s[2] bgop[$tune]=$s[3] bgoff[$tune]=$s[4] bgname="" tune=""
802
+ }
803
+
804
+ __tt_pv_regroup() {
805
+ local ty=${rtype[cur]} v=${rval[cur]} i
806
+ __tt_pv_group
807
+ __tt_pv_rows
808
+ for (( i = 1; i <= ${#rval}; i++ )); do
809
+ [[ ${rtype[i]} == "$ty" && ${rval[i]} == "$v" ]] && { cur=$i; return 0 }
810
+ done
811
+ cur=1
812
+ }
813
+
814
+ __tt_pv_conf() {
815
+ case $key in
816
+ $'\x03') return 1 ;;
817
+ up) (( cf > 1 )) && cf=$(( cf - 1 )) ;;
818
+ down) (( cf < ${#cvars} )) && cf=$(( cf + 1 )) ;;
819
+ left|sleft) __tt_pv_conf_step -1 ;;
820
+ right|sright) __tt_pv_conf_step 1 ;;
821
+ $'\r'|$'\n') __tt_pv_conf_save ;;
822
+ esc) __tt_pv_unconf ;;
823
+ '?') help=1 ;;
824
+ esac
825
+ return 0
826
+ }
827
+
828
+ __tt_pv_conf_step() {
829
+ local var=${cvars[cf]}
830
+ local -a ch=(${=cchoice[cf]})
831
+ local -i i=${ch[(Ie)${(P)var}]}
832
+ (( i += $1 ))
833
+ (( i >= 1 && i <= ${#ch} )) || return 0
834
+ __tt_pv_conf_put $var ${ch[i]}
835
+ }
836
+
837
+ __tt_pv_conf_put() {
838
+ [[ ${(P)1} == "$2" ]] && return 0
839
+ typeset -g "$1=$2"
840
+ case $1 in
841
+ TTHEME_SORT) __tt_pv_regroup ;;
842
+ TTHEME_FX) [[ -n $flt ]] || { __tt_pv_roll; gstep=8 } ;;
843
+ TTHEME_TAB_PALETTE) __tt_pv_canpick ;;
844
+ esac
845
+ }
846
+
847
+ __tt_pv_unconf() {
848
+ local -i i
849
+ for (( i = 1; i <= ${#cvars}; i++ )); do
850
+ __tt_pv_conf_put ${cvars[i]} "${csnap[i]}"
851
+ done
852
+ conf=0
853
+ }
854
+
855
+ __tt_pv_conf_save() {
856
+ local var REPLY
857
+ local -a pairs=()
858
+ local -i i
859
+ for (( i = 1; i <= ${#cvars}; i++ )); do
860
+ var=${cvars[i]}
861
+ [[ ${(P)var} == "${csnap[i]}" ]] || pairs+=($var "${(P)var}")
862
+ done
863
+ if (( ! ${#pairs} )); then
864
+ conf=0
865
+ return 0
866
+ fi
867
+ __tt_tilde "$TTHEME_CONFIG"
868
+ if __tt_config_write "${pairs[@]}"; then
869
+ conf=0 msg="saved · $REPLY" msgt=200
870
+ else
871
+ __tt_pv_unconf
872
+ msg="could not write $REPLY" msgt=200
873
+ fi
874
+ }
875
+
876
+ __tt_pv_conf_panel() {
877
+ local z=$'\e[0m' b=$'\e[1m' d=$'\e[2m' c=$ac on=$'\e[7;1m'$ac var v note
878
+ local -a ch sh
879
+ local -i r0=$1 col=$2 end=$3 k i j fit=1
880
+ (( color )) || z= b= d= c= on=
881
+ for (( k = 1; k <= ${#cvars}; k++ )); do
882
+ sh=(${=cshow[k]})
883
+ (( 13 + ${#${(j: :)sh}} + 2 * ${#sh} > end - col + 1 )) && fit=0
884
+ done
885
+ for (( k = 1; k <= ${#cvars}; k++ )); do
886
+ var=${cvars[k]} ch=(${=cchoice[k]}) sh=(${=cshow[k]})
887
+ i=${ch[(Ie)${(P)var}]}
888
+ out+=$'\e['$(( r0 + k - 1 ))';'$col'H'
889
+ if (( k == cf )); then
890
+ out+=$c"▶"$z" "$b
891
+ else
892
+ out+=" "$d
333
893
  fi
334
- gthemes[$g]+=" $k"
894
+ out+=${(r:11:)clabel[k]}$z
895
+ if (( ! fit )); then
896
+ v=${(P)var}
897
+ (( i )) && v=${sh[i]}
898
+ if (( k == cf )); then
899
+ out+=$c"‹ "$z$b$v$z$c" ›"$z
900
+ else
901
+ out+=" "$v
902
+ fi
903
+ continue
904
+ fi
905
+ for (( j = 1; j <= ${#sh}; j++ )); do
906
+ (( j > 1 )) && out+=" "
907
+ if (( j != i )); then
908
+ out+=$d" ${sh[j]} "$z
909
+ elif (( ! color )); then
910
+ out+="[${sh[j]}]"
911
+ elif (( k == cf )); then
912
+ out+=$on" ${sh[j]} "$z
913
+ else
914
+ out+=" ${sh[j]} "
915
+ fi
916
+ done
335
917
  done
336
- [[ -n $orig ]] && cn=$(__tt_name_of "$orig")
337
- if [[ -n ${TTHEME_PALETTE[$cn]} ]] && (( color )); then
338
- local -a cp=(${=TTHEME_PALETTE[$cn]})
339
- local ch=${cp[3]#\#}
340
- printf -v cdot '\e[38;2;%d;%d;%dm●\e[0m' \
341
- $((16#${ch:0:2})) $((16#${ch:2:2})) $((16#${ch:4:2}))
342
- printf -v cchip ' \e[7;1;38;2;%d;%d;%dm current \e[0m' \
343
- $((16#${ch:0:2})) $((16#${ch:2:2})) $((16#${ch:4:2}))
918
+ var=${cvars[cf]}
919
+ note=${cnote[${(P)var}]}
920
+ [[ -n $note ]] && out+=$'\e['$(( r0 + ${#cvars} + 1 ))';'$col'H'$d${note[1,end-col+1]}$z
921
+ return 0
922
+ }
923
+
924
+ __tt_pv_flush() {
925
+ print -rn -- "$out"
926
+ if (( wiped )); then
927
+ local bn=$bgname
928
+ [[ ${rtype[cur]} == thm ]] && bn=${rval[cur]}
929
+ [[ -n $bn ]] && __tt_pv_bg_show "$bn" 1
344
930
  fi
345
- local body nat
346
- for g in $groups; do
347
- nat=${gnative[$g]}
931
+ printf '\e[?2026l'
932
+ }
933
+
934
+ __tt_pv_draw() {
935
+ local out line cnt ex ag="" ac="" sb="" cmark="▶" rthumb="#" rtrack="." dd="" zz="" state=on src="" REPLY
936
+ local -i lw sw split sc se=$(( pw - 2 )) h k i N=${#rval} rail=0 rl=0 rs=0 mt=${#TTHEME_ORDER} wiped=0
937
+ __tt_pv_lw
938
+ lw=$reply[1] sw=$reply[2]
939
+ split=$(( sw > 0 )) sc=$(( pw - 1 - sw ))
940
+ h=$(( ph - 5 ))
941
+ [[ -n $tune ]] && (( ! split )) && h=$(( ph - 14 ))
942
+ (( conf && ! split )) && h=$(( ph - 12 ))
943
+ (( h < 1 )) && h=1
944
+ (( cur < top )) && top=$cur
945
+ (( cur >= top + h )) && top=$(( cur - h + 1 ))
946
+ (( top < 1 )) && top=1
947
+ (( N > h && top > N - h + 1 )) && top=$(( N - h + 1 ))
948
+ if (( N > h )); then
949
+ rail=1
950
+ rl=$(( h * h / N ))
951
+ (( rl < 1 )) && rl=1
952
+ rs=$(( 1 + (top - 1) * (h - rl) / (N - h) ))
953
+ fi
954
+ if (( color )); then
955
+ dd=$'\e[2m' zz=$'\e[0m' rtrack=$'\e[2m░\e[0m'
956
+ if [[ -n $applied ]]; then
957
+ local -a ap=(${=applied})
958
+ local acx=${ap[3]#\#} sbx=${ap[4]#\#}
959
+ printf -v ac '\e[38;2;%d;%d;%dm' $((16#${acx:0:2})) $((16#${acx:2:2})) $((16#${acx:4:2}))
960
+ printf -v sb '\e[48;2;%d;%d;%dm' $((16#${sbx:0:2})) $((16#${sbx:2:2})) $((16#${sbx:4:2}))
961
+ fi
962
+ rthumb=$ac"█"$zz cmark=$ac"▶"$'\e[39m'
963
+ [[ ${rtype[cur]} == thm ]] && ag=${TTHEME_GROUP[${rval[cur]}]:-Other}
964
+ fi
965
+ if [[ -n $flt ]]; then
966
+ local -a mm=(${(M)rtype:#thm})
967
+ mt=${#mm}
968
+ fi
969
+ cnt="$mt/${#TTHEME_ORDER}"
970
+ out=$'\e[H'
971
+ if (( resized )); then
972
+ out+=$'\e[2J'
973
+ resized=0 wiped=1
974
+ fi
975
+ if (( pw < 40 || ph < 12 )); then
976
+ line="ttheme preview"
977
+ (( color )) && line=$'\e[1m'$ac$line$'\e[0m'
978
+ out+=$line$'\e[K\n'"needs 40×12 — now ${pw}×${ph}"$'\e[K\n'
979
+ line="esc quits"
980
+ (( color )) && line=$'\e[2m'$line$'\e[0m'
981
+ out+=$line$'\e[K\e[J'
982
+ __tt_pv_flush
983
+ return 0
984
+ fi
985
+ if [[ -n $flt ]]; then
348
986
  if (( color )); then
349
- local -a gp=(${=TTHEME_PALETTE[${${=gthemes[$g]}[1]}]})
350
- local sb=${gp[4]#\#}
351
- printf -v body '\e[48;2;%d;%d;%dm %s \e[0m' \
352
- $((16#${sb:0:2})) $((16#${sb:2:2})) $((16#${sb:4:2})) "$g"
353
- hchip[$g]=$body
354
- hnat[$g]=${nat:+$'\e[2m'$nat$'\e[0m'}
987
+ line="⌕ "$'\e[1m'$flt$zz$ac$'\e[7m \e[0m'
355
988
  else
356
- hchip[$g]=" $g "
357
- hnat[$g]=$nat
989
+ line=" ${flt}_"
358
990
  fi
359
- done
360
- local t mark
361
- for t in $TTHEME_ORDER; do
362
- mark=""
363
- if [[ $t == $cn ]]; then
364
- if (( color )); then
365
- mark=$cchip
991
+ else
992
+ ex="$expal | $exgrp"
993
+ (( ${#ex} > lw - 17 - ${#cnt} )) && ex="${ex[1,lw-18-${#cnt}]}…"
994
+ if (( gstep > 0 )); then
995
+ local gkeep=$(( ${#ex} * (8 - gstep) / 8 ))
996
+ if [[ $TTHEME_FX == (decode|glitch) ]]; then
997
+ local gpool='▓▒░#*+=<>?/-_' gstill=' ' gout="" gi
998
+ [[ $TTHEME_FX == decode ]] && gpool='abcdefghijklmnopqrstuvwxyz' gstill='[^[:alnum:]]'
999
+ for (( gi = 1; gi <= ${#ex}; gi++ )); do
1000
+ if (( gi + (gi * 7 + gseed) % 3 <= gkeep )) || [[ ${ex[gi]} == $~gstill ]]; then
1001
+ gout+=${ex[gi]}
1002
+ else
1003
+ gout+=${gpool[RANDOM % ${#gpool} + 1]}
1004
+ fi
1005
+ done
1006
+ ex=$gout
366
1007
  else
367
- mark=" ← current"
1008
+ ex="${ex[1,gkeep]}▏"
368
1009
  fi
369
1010
  fi
370
- if (( color )); then
371
- local -a tp=(${=TTHEME_PALETTE[$t]})
372
- local bg=${tp[1]#\#} cu=${tp[3]#\#}
373
- printf -v body '\e[48;2;%d;%d;%d;38;2;%d;%d;%dm ● \e[0m %-13s \e[2m· ANSI %s\e[0m%s' \
374
- $((16#${bg:0:2})) $((16#${bg:2:2})) $((16#${bg:4:2})) \
375
- $((16#${cu:0:2})) $((16#${cu:2:2})) $((16#${cu:4:2})) \
376
- "$t" "${TTHEME_SRC[$t]:-unknown}" "$mark"
1011
+ line="⌕ "$dd"search… e.g. $ex"$zz
1012
+ fi
1013
+ out+=$line$'\e[K\e['$(( lw - ${#cnt} + 1 ))'G'
1014
+ if [[ -n $flt ]]; then
1015
+ out+=$cnt$'\n'$ac
1016
+ else
1017
+ out+=$dd$cnt$zz$'\n'$dd
1018
+ fi
1019
+ out+=${(l:lw::─:)}$zz$'\e[K\n\e[K\n'
1020
+ for (( k = 0; k < ph - 4; k++ )); do
1021
+ i=$(( top + k ))
1022
+ line=""
1023
+ if (( k < h )); then
1024
+ if (( ! N )); then
1025
+ (( k == 0 )) && line=" ${dd}no palettes match '$flt'$zz"
1026
+ elif (( i <= N )); then
1027
+ __tt_pv_row $i
1028
+ line=$REPLY
1029
+ fi
1030
+ fi
1031
+ out+=$line$'\e[K'
1032
+ if (( rail && k < h )); then
1033
+ if (( k + 1 >= rs && k + 1 < rs + rl )); then
1034
+ out+=$'\e['$(( lw + 2 ))'G'$rthumb
1035
+ else
1036
+ out+=$'\e['$(( lw + 2 ))'G'$rtrack
1037
+ fi
1038
+ fi
1039
+ out+=$'\n'
1040
+ done
1041
+ __tt_pv_foot $(( split ? se : pw ))
1042
+ if (( split )); then
1043
+ out+=$'\e[2;'$sc'H'$dd${(l:$(( se - sc + 1 ))::─:)}$zz
1044
+ if (( help && sw >= 48 )); then
1045
+ __tt_pv_head 1 $sc $se keys
1046
+ __tt_pv_help
1047
+ elif [[ -n $tune ]]; then
1048
+ (( bgoff[$tune] )) && state=off
1049
+ src=background
1050
+ [[ -n ${bgfrom[$tune]} ]] && src+=" · ${bgfrom[$tune]}"
1051
+ (( ${#tune} + ${#src} + 6 > sw )) && src=background
1052
+ __tt_pv_head 1 $sc $se $tune "$src" $state
1053
+ __tt_pv_bg_panel $tune 4 $sc $se
1054
+ elif (( conf )); then
1055
+ __tt_tilde "$TTHEME_CONFIG"
1056
+ src=$REPLY
1057
+ (( 8 + ${#src} > sw )) && src=""
1058
+ __tt_pv_head 1 $sc $se config "" "$src"
1059
+ __tt_pv_conf_panel 4 $sc $se
377
1060
  else
378
- printf -v body '● %-13s · ANSI %s%s' "$t" "${TTHEME_SRC[$t]:-unknown}" "$mark"
1061
+ [[ -n $an ]] && src=${TTHEME_SRC[$an]}
1062
+ (( ${#an} + 2 + ${#src} > sw )) && src=""
1063
+ __tt_pv_head 1 $sc $se ${an:-custom} "" "$src"
1064
+ __tt_pv_specimen
1065
+ fi
1066
+ (( help && sw < 48 )) && __tt_pv_help
1067
+ else
1068
+ if [[ -n $tune ]]; then
1069
+ (( bgoff[$tune] )) && state=off
1070
+ src=background
1071
+ [[ -n ${bgfrom[$tune]} ]] && src+=" · ${bgfrom[$tune]}"
1072
+ (( ${#tune} + ${#src} + 6 > lw )) && src=background
1073
+ __tt_pv_head $(( ph - 9 )) 1 $lw $tune "$src" $state
1074
+ __tt_pv_bg_panel $tune $(( ph - 8 )) 1 $lw
1075
+ elif (( conf )); then
1076
+ __tt_pv_head $(( ph - 7 )) 1 $lw config
1077
+ __tt_pv_conf_panel $(( ph - 6 )) 1 $lw
379
1078
  fi
380
- tbody[$t]=$body
1079
+ (( help )) && __tt_pv_help
1080
+ fi
1081
+ (( osdt > 0 )) && __tt_pv_osd
1082
+ __tt_pv_flush
1083
+ }
1084
+
1085
+ __tt_pv_group() {
1086
+ local k g
1087
+ groups=() gthemes=()
1088
+ __tt_order
1089
+ for k in $reply; do
1090
+ g=${TTHEME_GROUP[$k]:-Other}
1091
+ [[ -n ${gthemes[$g]} ]] || groups+=($g)
1092
+ gthemes[$g]+=" $k"
1093
+ done
1094
+ }
1095
+
1096
+ __tt_pv_canpick() {
1097
+ canpick=0
1098
+ if [[ $mode == pin ]]; then
1099
+ canpick=1
1100
+ elif (( $+functions[__tt_reload] )) && [[ $TTHEME_TAB_PALETTE == off ]]; then
1101
+ canpick=1
1102
+ fi
1103
+ }
1104
+
1105
+ __tt_pv_strip() {
1106
+ local lo hi cell
1107
+ local -a tp=(${=TTHEME_PALETTE[$1]}) v=()
1108
+ local -i j
1109
+ for (( j = 5; j <= 12; j++ )); do
1110
+ lo=${tp[j]#\#} hi=${tp[j+8]#\#}
1111
+ v+=($((16#${lo:0:2})) $((16#${lo:2:2})) $((16#${lo:4:2})) $((16#${hi:0:2})) $((16#${hi:2:2})) $((16#${hi:4:2})))
381
1112
  done
1113
+ printf -v cell '\e[38;2;%d;%d;%d;48;2;%d;%d;%dm▀▀' $v
1114
+ tstrip[$1]=$cell$'\e[0m'
1115
+ }
1116
+
1117
+ __tt_pv_init() {
1118
+ local lo
1119
+ local -a tp
1120
+ __tt_pv_group
1121
+ [[ -n $orig ]] && __tt_name_of "$orig" && cn=$REPLY
1122
+ [[ -n ${TTHEME_PALETTE[$cn]} ]] || return 0
1123
+ cdot="◆"
1124
+ (( color )) || return 0
1125
+ tp=(${=TTHEME_PALETTE[$cn]})
1126
+ lo=${tp[3]#\#}
1127
+ printf -v cdot '\e[38;2;%d;%d;%dm◆\e[39m' $((16#${lo:0:2})) $((16#${lo:2:2})) $((16#${lo:4:2}))
1128
+ }
1129
+
1130
+ __tt_pv_roll() {
1131
+ expal=${TTHEME_ORDER[RANDOM % ${#TTHEME_ORDER} + 1]}
1132
+ exgrp=${groups[RANDOM % ${#groups} + 1]}
1133
+ gseed=$RANDOM
1134
+ exnext=$(( SECONDS + 3 ))
1135
+ }
1136
+
1137
+ __tt_pv_size() {
1138
+ local sz=$(stty size 2>/dev/null)
1139
+ [[ $sz == <1->" "<1-> ]] || return 1
1140
+ [[ $sz == "$ph $pw" ]] && return 1
1141
+ ph=${sz%% *} pw=${sz##* } resized=1
1142
+ return 0
382
1143
  }
383
1144
 
384
1145
  __tt_pv_getch() {
385
1146
  if (( $# )); then
386
1147
  read -sk 1 -t $1 2>/dev/null
387
- else
388
- read -sk 1 2>/dev/null
1148
+ return
389
1149
  fi
1150
+ local t=0.2
1151
+ (( gstep )) && t=0.06
1152
+ while ! read -sk 1 -t $t 2>/dev/null; do
1153
+ [[ -t 0 ]] || return 1
1154
+ __tt_pv_size && return 1
1155
+ if (( osdt > 0 )); then
1156
+ (( osdt -= gstep ? 6 : 20 ))
1157
+ (( osdt > 0 )) || return 1
1158
+ fi
1159
+ if (( msgt > 0 )); then
1160
+ (( msgt -= gstep ? 6 : 20 ))
1161
+ (( msgt > 0 )) || return 1
1162
+ fi
1163
+ (( gstep )) && { gstep=$(( gstep - 1 )); return 1 }
1164
+ (( SECONDS >= exnext )) && { __tt_pv_roll; gstep=8; return 1 }
1165
+ done
1166
+ return 0
390
1167
  }
391
1168
 
392
1169
  __tt_pv_read() {
@@ -397,6 +1174,7 @@ __tt_pv_read() {
397
1174
  __tt_pv_getch || return 1
398
1175
  fi
399
1176
  key=$REPLY
1177
+ [[ $key == ç ]] && key=altc
400
1178
  [[ $key == $'\e' ]] || return 0
401
1179
  local seq=""
402
1180
  if ! __tt_pv_getch 0.05; then
@@ -405,6 +1183,7 @@ __tt_pv_read() {
405
1183
  fi
406
1184
  if [[ $REPLY != '[' && $REPLY != O ]]; then
407
1185
  key=nop
1186
+ [[ $REPLY == c ]] && key=altc
408
1187
  return 0
409
1188
  fi
410
1189
  while __tt_pv_getch 0.05; do
@@ -420,12 +1199,46 @@ __tt_pv_read() {
420
1199
  F|"4~"|"8~") key=end ;;
421
1200
  "5~") key=pgup ;;
422
1201
  "6~") key=pgdn ;;
1202
+ "1;2C") key=sright ;;
1203
+ "1;2D") key=sleft ;;
423
1204
  *) key=nop ;;
424
1205
  esac
425
1206
  }
426
1207
 
1208
+ __tt_pv_pick() {
1209
+ case $key in
1210
+ $'\x03') return 1 ;;
1211
+ esc) pick="" ;;
1212
+ left|right|$'\t') pk=$(( 3 - pk )) ;;
1213
+ $'\r'|$'\n')
1214
+ sel=$pick picked=$pk
1215
+ return 1
1216
+ ;;
1217
+ esac
1218
+ return 0
1219
+ }
1220
+
427
1221
  __tt_pv_handle() {
428
1222
  local name
1223
+ if (( help )); then
1224
+ case $key in
1225
+ $'\x03') return 1 ;;
1226
+ '?'|esc) help=0 ;;
1227
+ esac
1228
+ return 0
1229
+ fi
1230
+ if [[ -n $pick ]]; then
1231
+ __tt_pv_pick
1232
+ return
1233
+ fi
1234
+ if [[ -n $tune ]]; then
1235
+ __tt_pv_tune
1236
+ return
1237
+ fi
1238
+ if (( conf )); then
1239
+ __tt_pv_conf
1240
+ return
1241
+ fi
429
1242
  case $key in
430
1243
  $'\x03') return 1 ;;
431
1244
  esc|$'\x15')
@@ -446,8 +1259,12 @@ __tt_pv_handle() {
446
1259
  ;;
447
1260
  $'\r'|$'\n')
448
1261
  if [[ ${rtype[cur]} == thm ]]; then
449
- sel=${rval[cur]}
450
- return 1
1262
+ if (( canpick )); then
1263
+ pick=${rval[cur]} pk=$pkdef
1264
+ else
1265
+ sel=${rval[cur]}
1266
+ return 1
1267
+ fi
451
1268
  elif [[ ${rtype[cur]} == hdr ]]; then
452
1269
  __tt_pv_toggle
453
1270
  fi
@@ -459,26 +1276,50 @@ __tt_pv_handle() {
459
1276
  home) cur=1 ;;
460
1277
  end) (( ${#rval} )) && cur=${#rval} ;;
461
1278
  pgup)
462
- cur=$(( cur - ${LINES:-24} + 2 ))
1279
+ cur=$(( cur - ph + 5 ))
463
1280
  (( cur < 1 )) && cur=1
464
1281
  ;;
465
1282
  pgdn)
466
- cur=$(( cur + ${LINES:-24} - 2 ))
1283
+ cur=$(( cur + ph - 5 ))
467
1284
  (( cur > ${#rval} )) && cur=${#rval}
468
1285
  (( cur < 1 )) && cur=1
469
1286
  ;;
470
1287
  ' ') [[ ${rtype[cur]} == hdr ]] && __tt_pv_toggle ;;
1288
+ $'\t')
1289
+ [[ ${rtype[cur]} == thm ]] || return 0
1290
+ name=${rval[cur]}
1291
+ if __tt_pv_bg_state $name || { __tt_pv_bg_findable $name && __tt_pv_bg_find $name }; then
1292
+ tune=$name tf=1 tsnap="${bgsize[$name]} ${bgpos[$name]} ${bgop[$name]} ${bgoff[$name]}"
1293
+ elif __tt_pv_bg_findable $name; then
1294
+ :
1295
+ elif (( bgcw )); then
1296
+ msg="no background image for $name" msgt=200
1297
+ fi
1298
+ ;;
1299
+ altc)
1300
+ conf=1 cf=1 csnap=()
1301
+ for name in $cvars; do
1302
+ csnap+=("${(P)name}")
1303
+ done
1304
+ ;;
1305
+ '?') help=1 ;;
471
1306
  $'\x7f'|$'\x08')
472
1307
  if [[ -n $flt ]]; then
1308
+ name=""
1309
+ [[ ${rtype[cur]} == thm ]] && name=${rval[cur]}
473
1310
  flt=${flt%?}
474
1311
  __tt_pv_rows
475
- __tt_pv_first
1312
+ __tt_pv_first "$name"
476
1313
  fi
477
1314
  ;;
478
1315
  [a-zA-Z0-9-])
1316
+ __tt_pv_lw
1317
+ (( ${#flt} >= reply[1] - 12 )) && return 0
1318
+ name=""
1319
+ [[ ${rtype[cur]} == thm ]] && name=${rval[cur]}
479
1320
  flt+=${(L)key}
480
1321
  __tt_pv_rows
481
- __tt_pv_first
1322
+ __tt_pv_first "$name"
482
1323
  ;;
483
1324
  esac
484
1325
  return 0
@@ -486,21 +1327,42 @@ __tt_pv_handle() {
486
1327
 
487
1328
  __tt_preview() {
488
1329
  emulate -L zsh
1330
+ local mode=$1
489
1331
  if [[ ! -t 0 || ! -t 1 ]]; then
490
- print -u2 "ttheme preview: needs a terminal"
1332
+ print -u2 "ttheme ${mode:-preview}: needs a terminal"
491
1333
  return 1
492
1334
  fi
493
- local orig=$TTHEME_SPEC applied=$TTHEME_SPEC flt="" sel="" cn="" cdot="" cchip="" key="" REPLY="" cur=1 top=1 color=0
494
- local -a groups=() rtype=() rval=()
495
- local -A gnative=() gthemes=() exp=() hchip=() hnat=() tbody=()
1335
+ local orig=$TTHEME_SPEC applied=$TTHEME_SPEC flt="" sel="" cn="" cdot="" key="" REPLY="" cur=1 top=1 color=0 pw=80 ph=24 resized=1 expal="" exgrp="" exnext=0 gstep=0 gseed=0
1336
+ local pick="" pk=1 pkdef=1 picked=0 canpick=0 bgcw=0 bgch=0 bgname="" bgshown="" bginc="" osd="" osdt=0
1337
+ local tune="" tsnap="" tf=1 help=0 msg="" msgt=0 an="" bgrel=0 bgmx=0 bgmy=0 bganchor=0
1338
+ local -A bgfrom=() bgsent=() bgdim=() bgsrc=() bgfill=() bgfocus=() bgsize=() bgpos=() bgop=() bgdef=() bgoff=() bgbase=() bgload=() bgshot=() bgshotkey=() bgedit=()
1339
+ local conf=0 cf=1
1340
+ local -a plabel=(" this tab " " default ") csnap=()
1341
+ local -a cvars=(TTHEME_TAB_PALETTE TTHEME_ANNOUNCE TTHEME_FX TTHEME_SORT) clabel=("new tabs" announce "search fx" sort)
1342
+ local -a cchoice=("seq off" "1 0" "typewriter decode glitch" "abc series") cshow=("seq off" "on off" "typewriter decode glitch" "abc series")
1343
+ local -A cnote=(
1344
+ seq "new tabs rotate through palettes" off "new tabs keep the terminal theme"
1345
+ 1 "shows the palette notice" 0 "silences the palette notice"
1346
+ typewriter "the search hint types itself" decode "the search hint decodes" glitch "the search hint glitches in"
1347
+ abc "series and palettes by name" series "series in the order added"
1348
+ )
1349
+ [[ $mode == pin ]] && pkdef=2 plabel=(" this directory " " and below ")
1350
+ __tt_pv_canpick
1351
+ __tt_pv_size
1352
+ local -a groups=() rtype=() rval=() rcnt=() reply=()
1353
+ local -A gthemes=() exp=() tstrip=()
496
1354
  __tt_color && color=1
497
1355
  __tt_pv_init
1356
+ __tt_pv_roll
498
1357
  __tt_pv_rows
499
1358
  [[ -n ${TTHEME_PALETTE[$cn]} ]] && __tt_pv_goto "$cn"
500
- printf '\e[?1049h\e[?7l\e[?25l\e[2J'
1359
+ printf '\e[?2026h\e[?1049h\e[?7l\e[?25l'
1360
+ __tt_pv_bg_open
501
1361
  {
502
1362
  while :; do
1363
+ printf '\e[?2026h'
503
1364
  __tt_pv_focus
1365
+ [[ ${rtype[cur]} == thm ]] && an=${rval[cur]}
504
1366
  __tt_pv_draw
505
1367
  if ! __tt_pv_read; then
506
1368
  [[ -t 0 ]] && continue
@@ -512,13 +1374,25 @@ __tt_preview() {
512
1374
  done
513
1375
  done
514
1376
  } always {
515
- printf '\e[?7h\e[?1049l\e[?25h'
1377
+ printf '\e[?2026h'
1378
+ __tt_pv_bg_close
1379
+ printf '\e[?7h\e[?1049l\e[?25h\e[?2026l'
1380
+ [[ -n $tune ]] && __tt_pv_untune
1381
+ (( conf )) && __tt_pv_unconf
1382
+ __tt_pv_bg_save
516
1383
  if [[ -n $sel ]]; then
517
1384
  local spec=${TTHEME_PALETTE[$sel]}
518
1385
  [[ $spec == "$applied" ]] || __tt_apply "$spec"
519
1386
  TTHEME_SPEC=$spec
520
1387
  __tt_announce
521
- elif [[ -n $orig && $orig != "$applied" ]]; then
1388
+ if [[ $mode == pin ]]; then
1389
+ __tt_pin_save "$sel" $picked "$orig"
1390
+ elif (( picked == 2 )); then
1391
+ __tt_keep "$sel"
1392
+ fi
1393
+ elif [[ -z $orig && -n $applied ]]; then
1394
+ __tt_osc_reset
1395
+ elif [[ $orig != "$applied" ]]; then
522
1396
  __tt_apply "$orig"
523
1397
  fi
524
1398
  }
@@ -527,15 +1401,24 @@ __tt_preview() {
527
1401
 
528
1402
  ttheme() {
529
1403
  if (( ! $# )); then
1404
+ (( ${#TTHEME_PALETTE} )) || { __tt_empty; return }
530
1405
  __tt_menu
531
1406
  return 0
532
1407
  fi
533
1408
 
534
1409
  case $1 in
535
1410
  -h|--help|help) __tt_help; return 0 ;;
1411
+ browse|list|add|remove|update) __tt_catalog "$@"; return ;;
1412
+ config) __tt_config; return ;;
1413
+ esac
1414
+
1415
+ (( ${#TTHEME_PALETTE} )) || { __tt_empty; return }
1416
+
1417
+ case $1 in
536
1418
  next) __tt_rotate; return ;;
537
- current) __tt_current; return ;;
538
1419
  preview) __tt_preview; return ;;
1420
+ pin) __tt_preview pin; return ;;
1421
+ unpin) __tt_unpin; return ;;
539
1422
  -*) print -u2 "ttheme: unknown option $1 — see \`ttheme help\`"; return 1 ;;
540
1423
  esac
541
1424
 
@@ -549,35 +1432,34 @@ ttheme() {
549
1432
 
550
1433
  if (( $+functions[compdef] )); then
551
1434
  __tt_complete() {
552
- (( CURRENT == 2 )) && compadd -- preview next current help
1435
+ (( CURRENT == 2 )) && compadd -- preview next pin unpin config help browse list add remove update
553
1436
  compadd -- $TTHEME_ORDER
554
1437
  }
555
1438
  compdef __tt_complete ttheme
556
1439
  fi
557
1440
 
558
1441
  if __tt_active; then
559
- if [[ -n $TTHEME_SPEC ]]; then
560
- :
561
- elif [[ $TTHEME_TAB_PALETTE == off ]]; then
562
- __tt_bg=$(__tt_query_bg)
563
- if [[ -n $__tt_bg ]]; then
564
- for __k in ${(k)TTHEME_PALETTE}; do
565
- if [[ ${TTHEME_PALETTE[$__k]%% *} == $__tt_bg ]]; then
566
- TTHEME_SPEC=$TTHEME_PALETTE[$__k]
567
- break
568
- fi
569
- done
570
- [[ -n $TTHEME_SPEC ]] || TTHEME_SPEC="$__tt_bg ${TTHEME_PALETTE[neutral]#* }"
1442
+ () {
1443
+ local REPLY k
1444
+ if [[ -n $TTHEME_SPEC ]]; then
1445
+ :
1446
+ elif [[ $TTHEME_TAB_PALETTE == off ]]; then
1447
+ if __tt_query_bg; then
1448
+ for k in ${(k)TTHEME_PALETTE}; do
1449
+ [[ ${TTHEME_PALETTE[$k]%% *} == "$REPLY" ]] && { TTHEME_SPEC=$TTHEME_PALETTE[$k]; break }
1450
+ done
1451
+ [[ -n $TTHEME_SPEC ]] || TTHEME_SPEC="$REPLY ${TTHEME_PALETTE[neutral]#* }"
1452
+ else
1453
+ TTHEME_SPEC="- ${TTHEME_PALETTE[neutral]#* }"
1454
+ fi
571
1455
  else
572
- TTHEME_SPEC="- ${TTHEME_PALETTE[neutral]#* }"
1456
+ __tt_next
1457
+ TTHEME_SPEC=$REPLY
1458
+ __tt_apply "$TTHEME_SPEC"
573
1459
  fi
574
- unset __tt_bg __k
575
- else
576
- __tt_next
577
- TTHEME_SPEC=$REPLY
578
- __tt_apply "$TTHEME_SPEC"
579
- unset REPLY
580
- fi
581
-
1460
+ __tt_dir_sync
1461
+ }
1462
+ autoload -Uz add-zsh-hook
1463
+ add-zsh-hook chpwd __tt_chpwd
582
1464
  __tt_announce
583
1465
  fi