@bigpixelrocket/uiok 0.0.0-stage → 0.1.1

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 (280) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/LICENSE +21 -0
  3. package/NOTICE +569 -0
  4. package/README.md +44 -2
  5. package/dist/VisuallyHidden.d.ts +13 -0
  6. package/dist/VisuallyHidden.js +13 -0
  7. package/dist/activity/ActivityBar.d.ts +29 -0
  8. package/dist/activity/ActivityBar.js +21 -0
  9. package/dist/activity/activity.css +43 -0
  10. package/dist/activity/index.d.ts +2 -0
  11. package/dist/activity/index.js +2 -0
  12. package/dist/button/Button.d.ts +26 -0
  13. package/dist/button/Button.js +14 -0
  14. package/dist/button/IconButton.d.ts +18 -0
  15. package/dist/button/IconButton.js +14 -0
  16. package/dist/button/button.css +95 -0
  17. package/dist/button/index.d.ts +3 -0
  18. package/dist/button/index.js +3 -0
  19. package/dist/charts/Drawing.d.ts +27 -0
  20. package/dist/charts/Drawing.js +117 -0
  21. package/dist/charts/Drawing.logic.d.ts +2 -0
  22. package/dist/charts/Drawing.logic.js +22 -0
  23. package/dist/charts/Line.logic.d.ts +33 -0
  24. package/dist/charts/Line.logic.js +72 -0
  25. package/dist/charts/LineChart.d.ts +34 -0
  26. package/dist/charts/LineChart.js +100 -0
  27. package/dist/charts/Pie.logic.d.ts +16 -0
  28. package/dist/charts/Pie.logic.js +28 -0
  29. package/dist/charts/PieChart.d.ts +20 -0
  30. package/dist/charts/PieChart.js +16 -0
  31. package/dist/charts/ResultChart.d.ts +47 -0
  32. package/dist/charts/ResultChart.js +175 -0
  33. package/dist/charts/ResultChart.logic.d.ts +42 -0
  34. package/dist/charts/ResultChart.logic.js +165 -0
  35. package/dist/charts/Scatter.logic.d.ts +55 -0
  36. package/dist/charts/Scatter.logic.js +134 -0
  37. package/dist/charts/ScatterChart.d.ts +36 -0
  38. package/dist/charts/ScatterChart.js +99 -0
  39. package/dist/charts/charts.css +310 -0
  40. package/dist/charts/index.d.ts +14 -0
  41. package/dist/charts/index.js +11 -0
  42. package/dist/charts/seriesColour.d.ts +2 -0
  43. package/dist/charts/seriesColour.js +8 -0
  44. package/dist/clock/index.d.ts +2 -0
  45. package/dist/clock/index.js +2 -0
  46. package/dist/clock/useClock.d.ts +14 -0
  47. package/dist/clock/useClock.js +57 -0
  48. package/dist/datetime/DateTimePicker.d.ts +50 -0
  49. package/dist/datetime/DateTimePicker.js +98 -0
  50. package/dist/datetime/DateTimePicker.logic.d.ts +59 -0
  51. package/dist/datetime/DateTimePicker.logic.js +103 -0
  52. package/dist/datetime/datetime.css +115 -0
  53. package/dist/datetime/index.d.ts +7 -0
  54. package/dist/datetime/index.js +7 -0
  55. package/dist/dialog/ConfirmDialog.d.ts +73 -0
  56. package/dist/dialog/ConfirmDialog.js +30 -0
  57. package/dist/dialog/DialogLegend.d.ts +21 -0
  58. package/dist/dialog/DialogLegend.js +28 -0
  59. package/dist/dialog/DialogLegend.logic.d.ts +145 -0
  60. package/dist/dialog/DialogLegend.logic.js +71 -0
  61. package/dist/dialog/ModalDialog.d.ts +101 -0
  62. package/dist/dialog/ModalDialog.js +184 -0
  63. package/dist/dialog/dialog.css +283 -0
  64. package/dist/dialog/index.d.ts +8 -0
  65. package/dist/dialog/index.js +8 -0
  66. package/dist/filter/FilterEscape.d.ts +16 -0
  67. package/dist/filter/FilterEscape.js +15 -0
  68. package/dist/filter/FilterIcon.d.ts +8 -0
  69. package/dist/filter/FilterIcon.js +11 -0
  70. package/dist/filter/filter.css +42 -0
  71. package/dist/filter/index.d.ts +3 -0
  72. package/dist/filter/index.js +3 -0
  73. package/dist/grid/DataGrid.d.ts +149 -0
  74. package/dist/grid/DataGrid.js +373 -0
  75. package/dist/grid/DataGrid.logic.d.ts +57 -0
  76. package/dist/grid/DataGrid.logic.js +121 -0
  77. package/dist/grid/grid.css +206 -0
  78. package/dist/grid/index.d.ts +7 -0
  79. package/dist/grid/index.js +7 -0
  80. package/dist/index.d.ts +32 -0
  81. package/dist/index.js +32 -0
  82. package/dist/keyboard/BrowserKeys.d.ts +15 -0
  83. package/dist/keyboard/BrowserKeys.js +28 -0
  84. package/dist/keyboard/KeyChord.logic.d.ts +25 -0
  85. package/dist/keyboard/KeyChord.logic.js +50 -0
  86. package/dist/keyboard/Keyboard.logic.d.ts +84 -0
  87. package/dist/keyboard/Keyboard.logic.js +137 -0
  88. package/dist/keyboard/OverlayWatch.d.ts +28 -0
  89. package/dist/keyboard/OverlayWatch.js +119 -0
  90. package/dist/keyboard/PageSelectAll.d.ts +14 -0
  91. package/dist/keyboard/PageSelectAll.js +22 -0
  92. package/dist/keyboard/index.d.ts +9 -0
  93. package/dist/keyboard/index.js +9 -0
  94. package/dist/keychord/KeyChord.d.ts +16 -0
  95. package/dist/keychord/KeyChord.js +55 -0
  96. package/dist/keychord/index.d.ts +2 -0
  97. package/dist/keychord/index.js +2 -0
  98. package/dist/keychord/keychord.css +41 -0
  99. package/dist/labels/UiokLabels.d.ts +41 -0
  100. package/dist/labels/UiokLabels.js +31 -0
  101. package/dist/labels/UiokProvider.d.ts +44 -0
  102. package/dist/labels/UiokProvider.js +54 -0
  103. package/dist/labels/charts.d.ts +34 -0
  104. package/dist/labels/charts.js +15 -0
  105. package/dist/labels/dateTime.d.ts +32 -0
  106. package/dist/labels/dateTime.js +14 -0
  107. package/dist/labels/dialog.d.ts +18 -0
  108. package/dist/labels/dialog.js +6 -0
  109. package/dist/labels/index.d.ts +13 -0
  110. package/dist/labels/index.js +13 -0
  111. package/dist/labels/keys.d.ts +28 -0
  112. package/dist/labels/keys.js +53 -0
  113. package/dist/labels/legend.d.ts +21 -0
  114. package/dist/labels/legend.js +7 -0
  115. package/dist/labels/listing.d.ts +16 -0
  116. package/dist/labels/listing.js +8 -0
  117. package/dist/labels/pager.d.ts +32 -0
  118. package/dist/labels/pager.js +20 -0
  119. package/dist/labels/palette.d.ts +17 -0
  120. package/dist/labels/palette.js +6 -0
  121. package/dist/labels/selectAll.d.ts +15 -0
  122. package/dist/labels/selectAll.js +6 -0
  123. package/dist/labels/terminal.d.ts +25 -0
  124. package/dist/labels/terminal.js +9 -0
  125. package/dist/legend/KeyLegend.logic.d.ts +84 -0
  126. package/dist/legend/KeyLegend.logic.js +109 -0
  127. package/dist/legend/KeyLegendStrip.d.ts +36 -0
  128. package/dist/legend/KeyLegendStrip.js +82 -0
  129. package/dist/legend/index.d.ts +3 -0
  130. package/dist/legend/index.js +3 -0
  131. package/dist/legend/legend.css +148 -0
  132. package/dist/listing/CurrentDot.d.ts +15 -0
  133. package/dist/listing/CurrentDot.js +13 -0
  134. package/dist/listing/Listing.d.ts +230 -0
  135. package/dist/listing/Listing.js +265 -0
  136. package/dist/listing/PathParts.logic.d.ts +17 -0
  137. package/dist/listing/PathParts.logic.js +18 -0
  138. package/dist/listing/index.d.ts +10 -0
  139. package/dist/listing/index.js +10 -0
  140. package/dist/listing/listing.css +867 -0
  141. package/dist/menu/MenuQuery.logic.d.ts +69 -0
  142. package/dist/menu/MenuQuery.logic.js +75 -0
  143. package/dist/menu/fuzzyMatch.d.ts +31 -0
  144. package/dist/menu/fuzzyMatch.js +296 -0
  145. package/dist/menu/index.d.ts +9 -0
  146. package/dist/menu/index.js +9 -0
  147. package/dist/menu/menu.css +203 -0
  148. package/dist/menu/useBellBeat.d.ts +8 -0
  149. package/dist/menu/useBellBeat.js +26 -0
  150. package/dist/namecut/NameCut.d.ts +22 -0
  151. package/dist/namecut/NameCut.js +28 -0
  152. package/dist/namecut/NameCut.logic.d.ts +51 -0
  153. package/dist/namecut/NameCut.logic.js +120 -0
  154. package/dist/namecut/index.d.ts +3 -0
  155. package/dist/namecut/index.js +3 -0
  156. package/dist/namecut/namecut.css +67 -0
  157. package/dist/pager/Pager.d.ts +37 -0
  158. package/dist/pager/Pager.js +38 -0
  159. package/dist/pager/Pager.logic.d.ts +13 -0
  160. package/dist/pager/Pager.logic.js +63 -0
  161. package/dist/pager/index.d.ts +7 -0
  162. package/dist/pager/index.js +7 -0
  163. package/dist/pager/pager.css +62 -0
  164. package/dist/palette/Palette.d.ts +79 -0
  165. package/dist/palette/Palette.js +60 -0
  166. package/dist/palette/index.d.ts +6 -0
  167. package/dist/palette/index.js +6 -0
  168. package/dist/palette/palette.css +159 -0
  169. package/dist/pane/PaneActions.d.ts +104 -0
  170. package/dist/pane/PaneActions.js +62 -0
  171. package/dist/pane/PaneFrame.d.ts +51 -0
  172. package/dist/pane/PaneFrame.js +28 -0
  173. package/dist/pane/PaneKeys.d.ts +41 -0
  174. package/dist/pane/PaneKeys.js +104 -0
  175. package/dist/pane/PaneKeys.logic.d.ts +95 -0
  176. package/dist/pane/PaneKeys.logic.js +109 -0
  177. package/dist/pane/index.d.ts +11 -0
  178. package/dist/pane/index.js +11 -0
  179. package/dist/pane/usePaneKeys.d.ts +141 -0
  180. package/dist/pane/usePaneKeys.js +313 -0
  181. package/dist/run/RunHeader.d.ts +50 -0
  182. package/dist/run/RunHeader.js +31 -0
  183. package/dist/run/RunProgress.logic.d.ts +29 -0
  184. package/dist/run/RunProgress.logic.js +34 -0
  185. package/dist/run/index.d.ts +3 -0
  186. package/dist/run/index.js +3 -0
  187. package/dist/run/run.css +190 -0
  188. package/dist/segmented/SegmentedChoice.d.ts +22 -0
  189. package/dist/segmented/SegmentedChoice.js +31 -0
  190. package/dist/segmented/index.d.ts +2 -0
  191. package/dist/segmented/index.js +2 -0
  192. package/dist/segmented/segmented.css +49 -0
  193. package/dist/selectall/CheckRange.logic.d.ts +8 -0
  194. package/dist/selectall/CheckRange.logic.js +23 -0
  195. package/dist/selectall/SelectAllBar.d.ts +25 -0
  196. package/dist/selectall/SelectAllBar.js +24 -0
  197. package/dist/selectall/index.d.ts +7 -0
  198. package/dist/selectall/index.js +7 -0
  199. package/dist/selectall/selectall.css +31 -0
  200. package/dist/store/KeepUnchanged.logic.d.ts +19 -0
  201. package/dist/store/KeepUnchanged.logic.js +33 -0
  202. package/dist/store/SameProps.d.ts +15 -0
  203. package/dist/store/SameProps.js +46 -0
  204. package/dist/store/ValueStore.d.ts +17 -0
  205. package/dist/store/ValueStore.js +23 -0
  206. package/dist/store/index.d.ts +8 -0
  207. package/dist/store/index.js +8 -0
  208. package/dist/store/useStableHandlers.d.ts +13 -0
  209. package/dist/store/useStableHandlers.js +22 -0
  210. package/dist/styles.css +85 -0
  211. package/dist/tabs/PageTabs.d.ts +38 -0
  212. package/dist/tabs/PageTabs.js +33 -0
  213. package/dist/tabs/index.d.ts +2 -0
  214. package/dist/tabs/index.js +2 -0
  215. package/dist/tabs/tabs.css +64 -0
  216. package/dist/terminal/Terminal.d.ts +104 -0
  217. package/dist/terminal/Terminal.js +309 -0
  218. package/dist/terminal/Terminal.logic.d.ts +66 -0
  219. package/dist/terminal/Terminal.logic.js +156 -0
  220. package/dist/terminal/TerminalMenu.d.ts +36 -0
  221. package/dist/terminal/TerminalMenu.js +87 -0
  222. package/dist/terminal/TerminalMenu.logic.d.ts +78 -0
  223. package/dist/terminal/TerminalMenu.logic.js +68 -0
  224. package/dist/terminal/TerminalScrollback.d.ts +10 -0
  225. package/dist/terminal/TerminalScrollback.js +11 -0
  226. package/dist/terminal/ghostty/LICENSE +21 -0
  227. package/dist/terminal/ghostty/core.d.ts +315 -0
  228. package/dist/terminal/ghostty/core.js +1189 -0
  229. package/dist/terminal/ghostty/fallbackColors.d.ts +12 -0
  230. package/dist/terminal/ghostty/fallbackColors.js +23 -0
  231. package/dist/terminal/ghostty/fonts/LICENSE +21 -0
  232. package/dist/terminal/ghostty/fonts/SymbolsNerdFontMono-Regular.woff2 +0 -0
  233. package/dist/terminal/ghostty/keyCodes.logic.d.ts +20 -0
  234. package/dist/terminal/ghostty/keyCodes.logic.js +249 -0
  235. package/dist/terminal/ghostty/links.logic.d.ts +39 -0
  236. package/dist/terminal/ghostty/links.logic.js +84 -0
  237. package/dist/terminal/ghostty/renderer.d.ts +98 -0
  238. package/dist/terminal/ghostty/renderer.js +481 -0
  239. package/dist/terminal/ghostty/runtime.d.ts +126 -0
  240. package/dist/terminal/ghostty/runtime.js +346 -0
  241. package/dist/terminal/ghostty/spriteGlyphs.logic.d.ts +64 -0
  242. package/dist/terminal/ghostty/spriteGlyphs.logic.js +546 -0
  243. package/dist/terminal/ghostty/surface.d.ts +285 -0
  244. package/dist/terminal/ghostty/surface.js +1565 -0
  245. package/dist/terminal/ghostty/surface.logic.d.ts +181 -0
  246. package/dist/terminal/ghostty/surface.logic.js +392 -0
  247. package/dist/terminal/ghostty/vendor/LICENSE +21 -0
  248. package/dist/terminal/ghostty/vendor/ghostty-effects.wasm +0 -0
  249. package/dist/terminal/ghostty/vendor/ghostty-vt.wasm +0 -0
  250. package/dist/terminal/index.d.ts +12 -0
  251. package/dist/terminal/index.js +12 -0
  252. package/dist/terminal/terminal.css +169 -0
  253. package/dist/text/MarkedText.d.ts +14 -0
  254. package/dist/text/MarkedText.js +11 -0
  255. package/dist/text/highlightSegments.d.ts +13 -0
  256. package/dist/text/highlightSegments.js +29 -0
  257. package/dist/text/index.d.ts +3 -0
  258. package/dist/text/index.js +3 -0
  259. package/dist/text/text.css +11 -0
  260. package/dist/themes/attributes.d.ts +21 -0
  261. package/dist/themes/attributes.js +41 -0
  262. package/dist/themes/catalog.d.ts +125 -0
  263. package/dist/themes/catalog.js +940 -0
  264. package/dist/themes/color.d.ts +29 -0
  265. package/dist/themes/color.js +52 -0
  266. package/dist/themes/ids.d.ts +139 -0
  267. package/dist/themes/ids.js +59 -0
  268. package/dist/themes/index.d.ts +12 -0
  269. package/dist/themes/index.js +12 -0
  270. package/dist/themes/themes.generated.css +1830 -0
  271. package/dist/themes/tokens.d.ts +189 -0
  272. package/dist/themes/tokens.js +462 -0
  273. package/dist/tooltip/Tooltip.d.ts +21 -0
  274. package/dist/tooltip/Tooltip.js +105 -0
  275. package/dist/tooltip/Tooltip.logic.d.ts +49 -0
  276. package/dist/tooltip/Tooltip.logic.js +50 -0
  277. package/dist/tooltip/index.d.ts +3 -0
  278. package/dist/tooltip/index.js +3 -0
  279. package/dist/tooltip/tooltip.css +45 -0
  280. package/package.json +91 -4
@@ -0,0 +1,546 @@
1
+ /**
2
+ * Block elements and box drawing as shapes computed from the cell box, the way
3
+ * Ghostty's sprite font draws them (`src/font/sprite/draw/block.zig` and
4
+ * `box.zig` upstream). A font's glyphs for these characters rarely fill the
5
+ * cell, so text drawn with `fillText` leaves seams between neighbours; shapes
6
+ * that reach the cell's edges exactly tile into solid art and joined lines.
7
+ *
8
+ * Every size here is in whole device pixels: the renderer rounds each cell's
9
+ * edges to device pixels before asking, so neighbouring cells share an edge.
10
+ */
11
+ const BOX_FIRST = 0x2500;
12
+ const BLOCK_LAST = 0x259f;
13
+ const DIAGONAL_FIRST = 0x2571;
14
+ const DIAGONAL_LAST = 0x2573;
15
+ /**
16
+ * Underline thickness as a share of the font size, standing in for the face's
17
+ * own figure, which canvas text metrics do not expose. Typical monospace faces
18
+ * (SF Mono, Menlo, JetBrains Mono) sit near 0.05 em.
19
+ */
20
+ const UNDERLINE_EM = 0.05;
21
+ /**
22
+ * The light line thickness in device pixels for a font size and pixel ratio.
23
+ * Ghostty uses the face's underline thickness rounded up to a whole pixel;
24
+ * heavy lines are twice this.
25
+ */
26
+ export function ghosttySpriteThickness(fontSize, pixelRatio) {
27
+ // The small slack keeps a product that lands a hair above a whole pixel
28
+ // through floating point from rounding up to the next one.
29
+ return Math.max(1, Math.ceil(fontSize * pixelRatio * UNDERLINE_EM - 1e-6));
30
+ }
31
+ /**
32
+ * The codepoint a cell's text is drawn procedurally as, or -1 when it stays on
33
+ * the font path: anything but a single character in Box Drawing or Block
34
+ * Elements, and the three diagonals, which need clipping to the cell.
35
+ */
36
+ export function ghosttySpriteCodepoint(text) {
37
+ if (text.length !== 1)
38
+ return -1;
39
+ const codepoint = text.charCodeAt(0);
40
+ if (codepoint < BOX_FIRST || codepoint > BLOCK_LAST)
41
+ return -1;
42
+ if (codepoint >= DIAGONAL_FIRST && codepoint <= DIAGONAL_LAST)
43
+ return -1;
44
+ return codepoint;
45
+ }
46
+ // Shade coverage, as Ghostty's `Shade` enum: 0x40, 0x80, and 0xc0 out of 0xff.
47
+ const SHADE_LIGHT = 0x40 / 0xff;
48
+ const SHADE_MEDIUM = 0x80 / 0xff;
49
+ const SHADE_DARK = 0xc0 / 0xff;
50
+ /**
51
+ * Each line-drawing character's four arms, in the order up, right, down,
52
+ * left: `-` none, `l` light, `h` heavy, `d` double. Transcribed from
53
+ * `box.zig`'s `linesChar` calls.
54
+ */
55
+ const LINES = {
56
+ 0x2500: '-l-l', // ─
57
+ 0x2501: '-h-h', // ━
58
+ 0x2502: 'l-l-', // │
59
+ 0x2503: 'h-h-', // ┃
60
+ 0x250c: '-ll-', // ┌
61
+ 0x250d: '-hl-', // ┍
62
+ 0x250e: '-lh-', // ┎
63
+ 0x250f: '-hh-', // ┏
64
+ 0x2510: '--ll', // ┐
65
+ 0x2511: '--lh', // ┑
66
+ 0x2512: '--hl', // ┒
67
+ 0x2513: '--hh', // ┓
68
+ 0x2514: 'll--', // └
69
+ 0x2515: 'lh--', // ┕
70
+ 0x2516: 'hl--', // ┖
71
+ 0x2517: 'hh--', // ┗
72
+ 0x2518: 'l--l', // ┘
73
+ 0x2519: 'l--h', // ┙
74
+ 0x251a: 'h--l', // ┚
75
+ 0x251b: 'h--h', // ┛
76
+ 0x251c: 'lll-', // ├
77
+ 0x251d: 'lhl-', // ┝
78
+ 0x251e: 'hll-', // ┞
79
+ 0x251f: 'llh-', // ┟
80
+ 0x2520: 'hlh-', // ┠
81
+ 0x2521: 'hhl-', // ┡
82
+ 0x2522: 'lhh-', // ┢
83
+ 0x2523: 'hhh-', // ┣
84
+ 0x2524: 'l-ll', // ┤
85
+ 0x2525: 'l-lh', // ┥
86
+ 0x2526: 'h-ll', // ┦
87
+ 0x2527: 'l-hl', // ┧
88
+ 0x2528: 'h-hl', // ┨
89
+ 0x2529: 'h-lh', // ┩
90
+ 0x252a: 'l-hh', // ┪
91
+ 0x252b: 'h-hh', // ┫
92
+ 0x252c: '-lll', // ┬
93
+ 0x252d: '-llh', // ┭
94
+ 0x252e: '-hll', // ┮
95
+ 0x252f: '-hlh', // ┯
96
+ 0x2530: '-lhl', // ┰
97
+ 0x2531: '-lhh', // ┱
98
+ 0x2532: '-hhl', // ┲
99
+ 0x2533: '-hhh', // ┳
100
+ 0x2534: 'll-l', // ┴
101
+ 0x2535: 'll-h', // ┵
102
+ 0x2536: 'lh-l', // ┶
103
+ 0x2537: 'lh-h', // ┷
104
+ 0x2538: 'hl-l', // ┸
105
+ 0x2539: 'hl-h', // ┹
106
+ 0x253a: 'hh-l', // ┺
107
+ 0x253b: 'hh-h', // ┻
108
+ 0x253c: 'llll', // ┼
109
+ 0x253d: 'lllh', // ┽
110
+ 0x253e: 'lhll', // ┾
111
+ 0x253f: 'lhlh', // ┿
112
+ 0x2540: 'hlll', // ╀
113
+ 0x2541: 'llhl', // ╁
114
+ 0x2542: 'hlhl', // ╂
115
+ 0x2543: 'hllh', // ╃
116
+ 0x2544: 'hhll', // ╄
117
+ 0x2545: 'llhh', // ╅
118
+ 0x2546: 'lhhl', // ╆
119
+ 0x2547: 'hhlh', // ╇
120
+ 0x2548: 'lhhh', // ╈
121
+ 0x2549: 'hlhh', // ╉
122
+ 0x254a: 'hhhl', // ╊
123
+ 0x254b: 'hhhh', // ╋
124
+ 0x2550: '-d-d', // ═
125
+ 0x2551: 'd-d-', // ║
126
+ 0x2552: '-dl-', // ╒
127
+ 0x2553: '-ld-', // ╓
128
+ 0x2554: '-dd-', // ╔
129
+ 0x2555: '--ld', // ╕
130
+ 0x2556: '--dl', // ╖
131
+ 0x2557: '--dd', // ╗
132
+ 0x2558: 'ld--', // ╘
133
+ 0x2559: 'dl--', // ╙
134
+ 0x255a: 'dd--', // ╚
135
+ 0x255b: 'l--d', // ╛
136
+ 0x255c: 'd--l', // ╜
137
+ 0x255d: 'd--d', // ╝
138
+ 0x255e: 'ldl-', // ╞
139
+ 0x255f: 'dld-', // ╟
140
+ 0x2560: 'ddd-', // ╠
141
+ 0x2561: 'l-ld', // ╡
142
+ 0x2562: 'd-dl', // ╢
143
+ 0x2563: 'd-dd', // ╣
144
+ 0x2564: '-dld', // ╤
145
+ 0x2565: '-ldl', // ╥
146
+ 0x2566: '-ddd', // ╦
147
+ 0x2567: 'ld-d', // ╧
148
+ 0x2568: 'dl-l', // ╨
149
+ 0x2569: 'dd-d', // ╩
150
+ 0x256a: 'ldld', // ╪
151
+ 0x256b: 'dldl', // ╫
152
+ 0x256c: 'dddd', // ╬
153
+ 0x2574: '---l', // ╴
154
+ 0x2575: 'l---', // ╵
155
+ 0x2576: '-l--', // ╶
156
+ 0x2577: '--l-', // ╷
157
+ 0x2578: '---h', // ╸
158
+ 0x2579: 'h---', // ╹
159
+ 0x257a: '-h--', // ╺
160
+ 0x257b: '--h-', // ╻
161
+ 0x257c: '-h-l', // ╼
162
+ 0x257d: 'l-h-', // ╽
163
+ 0x257e: '-l-h', // ╾
164
+ 0x257f: 'h-l-' // ╿
165
+ };
166
+ /** Saturating subtraction, as Zig's `-|` on the unsigned sizes upstream. */
167
+ function minus(left, right) {
168
+ return Math.max(0, left - right);
169
+ }
170
+ /** Collects rectangles clamped to the cell, dropping any left empty. */
171
+ class RectList {
172
+ width;
173
+ height;
174
+ rects = [];
175
+ constructor(width, height) {
176
+ this.width = width;
177
+ this.height = height;
178
+ }
179
+ box(left, top, right, bottom) {
180
+ const l = Math.min(this.width, Math.max(0, left));
181
+ const t = Math.min(this.height, Math.max(0, top));
182
+ const r = Math.min(this.width, Math.max(0, right));
183
+ const b = Math.min(this.height, Math.max(0, bottom));
184
+ if (r > l && b > t)
185
+ this.rects.push({ left: l, top: t, right: r, bottom: b });
186
+ }
187
+ }
188
+ /** Where a fraction of `size` lands as a block's left or top edge (`Fraction.min` upstream). */
189
+ function fractionMin(fraction, size) {
190
+ // Rounding from the far end makes `start` to `half` and `half` to `end`
191
+ // meet or overlap by a pixel on odd sizes, never leave one uncovered.
192
+ return size - Math.round((1 - fraction) * size);
193
+ }
194
+ /** Where a fraction of `size` lands as a block's right or bottom edge (`Fraction.max` upstream). */
195
+ function fractionMax(fraction, size) {
196
+ return Math.round(fraction * size);
197
+ }
198
+ /** A block a fraction of the cell wide and tall, against one side (`blockShade` upstream). */
199
+ function block(out, width, height, alignment, widthFraction, heightFraction) {
200
+ const w = Math.round(width * widthFraction);
201
+ const h = Math.round(height * heightFraction);
202
+ const x = alignment === 'right' ? width - w : alignment === 'left' ? 0 : Math.floor(minus(width, w) / 2);
203
+ const y = alignment === 'lower'
204
+ ? height - h
205
+ : alignment === 'upper'
206
+ ? 0
207
+ : Math.floor(minus(height, h) / 2);
208
+ out.box(x, y, x + w, y + h);
209
+ }
210
+ /** The quadrants a quadrant character fills, as `tl`, `tr`, `bl`, `br` flags. */
211
+ function quadrants(out, width, height, tl, tr, bl, br) {
212
+ const leftEnd = fractionMax(0.5, width);
213
+ const rightStart = fractionMin(0.5, width);
214
+ const topEnd = fractionMax(0.5, height);
215
+ const bottomStart = fractionMin(0.5, height);
216
+ if (tl)
217
+ out.box(0, 0, leftEnd, topEnd);
218
+ if (tr)
219
+ out.box(rightStart, 0, width, topEnd);
220
+ if (bl)
221
+ out.box(0, bottomStart, leftEnd, height);
222
+ if (br)
223
+ out.box(rightStart, bottomStart, width, height);
224
+ }
225
+ function blockElement(codepoint, width, height) {
226
+ const out = new RectList(width, height);
227
+ let alpha = 1;
228
+ switch (codepoint) {
229
+ case 0x2580: // ▀
230
+ block(out, width, height, 'upper', 1, 1 / 2);
231
+ break;
232
+ case 0x2581: // ▁
233
+ case 0x2582: // ▂
234
+ case 0x2583: // ▃
235
+ case 0x2584: // ▄
236
+ case 0x2585: // ▅
237
+ case 0x2586: // ▆
238
+ case 0x2587: // ▇
239
+ block(out, width, height, 'lower', 1, (codepoint - 0x2580) / 8);
240
+ break;
241
+ case 0x2588: // █
242
+ out.box(0, 0, width, height);
243
+ break;
244
+ case 0x2589: // ▉
245
+ case 0x258a: // ▊
246
+ case 0x258b: // ▋
247
+ case 0x258c: // ▌
248
+ case 0x258d: // ▍
249
+ case 0x258e: // ▎
250
+ case 0x258f: // ▏
251
+ block(out, width, height, 'left', (0x2590 - codepoint) / 8, 1);
252
+ break;
253
+ case 0x2590: // ▐
254
+ block(out, width, height, 'right', 1 / 2, 1);
255
+ break;
256
+ case 0x2591: // ░
257
+ case 0x2592: // ▒
258
+ case 0x2593: // ▓
259
+ // Ghostty fills shades solidly at partial coverage, not with a dot
260
+ // pattern, so shaded art stays smooth at any cell size.
261
+ out.box(0, 0, width, height);
262
+ alpha = codepoint === 0x2591 ? SHADE_LIGHT : codepoint === 0x2592 ? SHADE_MEDIUM : SHADE_DARK;
263
+ break;
264
+ case 0x2594: // ▔
265
+ block(out, width, height, 'upper', 1, 1 / 8);
266
+ break;
267
+ case 0x2595: // ▕
268
+ block(out, width, height, 'right', 1 / 8, 1);
269
+ break;
270
+ case 0x2596: // ▖
271
+ quadrants(out, width, height, false, false, true, false);
272
+ break;
273
+ case 0x2597: // ▗
274
+ quadrants(out, width, height, false, false, false, true);
275
+ break;
276
+ case 0x2598: // ▘
277
+ quadrants(out, width, height, true, false, false, false);
278
+ break;
279
+ case 0x2599: // ▙
280
+ quadrants(out, width, height, true, false, true, true);
281
+ break;
282
+ case 0x259a: // ▚
283
+ quadrants(out, width, height, true, false, false, true);
284
+ break;
285
+ case 0x259b: // ▛
286
+ quadrants(out, width, height, true, true, true, false);
287
+ break;
288
+ case 0x259c: // ▜
289
+ quadrants(out, width, height, true, true, false, true);
290
+ break;
291
+ case 0x259d: // ▝
292
+ quadrants(out, width, height, false, true, false, false);
293
+ break;
294
+ case 0x259e: // ▞
295
+ quadrants(out, width, height, false, true, true, false);
296
+ break;
297
+ default: // ▟
298
+ quadrants(out, width, height, false, true, true, true);
299
+ break;
300
+ }
301
+ return { alpha, rects: out.rects, arc: null };
302
+ }
303
+ /**
304
+ * A line-drawing character from its four arms (`linesChar` upstream): each arm
305
+ * runs from its cell edge to the centre, and where arms of different weights
306
+ * or doubled arms meet, each stops at the edge of the stroke across it so the
307
+ * joint stays square.
308
+ */
309
+ function linesChar(arms, width, height, thickness) {
310
+ const up = arms[0];
311
+ const right = arms[1];
312
+ const down = arms[2];
313
+ const left = arms[3];
314
+ const light = thickness;
315
+ const heavy = thickness * 2;
316
+ const hLightTop = Math.floor(minus(height, light) / 2);
317
+ const hLightBottom = hLightTop + light;
318
+ const hHeavyTop = Math.floor(minus(height, heavy) / 2);
319
+ const hHeavyBottom = hHeavyTop + heavy;
320
+ const hDoubleTop = minus(hLightTop, light);
321
+ const hDoubleBottom = hLightBottom + light;
322
+ const vLightLeft = Math.floor(minus(width, light) / 2);
323
+ const vLightRight = vLightLeft + light;
324
+ const vHeavyLeft = Math.floor(minus(width, heavy) / 2);
325
+ const vHeavyRight = vHeavyLeft + heavy;
326
+ const vDoubleLeft = minus(vLightLeft, light);
327
+ const vDoubleRight = vLightRight + light;
328
+ const upBottom = left === 'h' || right === 'h'
329
+ ? hHeavyBottom
330
+ : left !== right || down === up
331
+ ? left === 'd' || right === 'd'
332
+ ? hDoubleBottom
333
+ : hLightBottom
334
+ : left === '-' && right === '-'
335
+ ? hLightBottom
336
+ : hLightTop;
337
+ const downTop = left === 'h' || right === 'h'
338
+ ? hHeavyTop
339
+ : left !== right || up === down
340
+ ? left === 'd' || right === 'd'
341
+ ? hDoubleTop
342
+ : hLightTop
343
+ : left === '-' && right === '-'
344
+ ? hLightTop
345
+ : hLightBottom;
346
+ const leftRight = up === 'h' || down === 'h'
347
+ ? vHeavyRight
348
+ : up !== down || left === right
349
+ ? up === 'd' || down === 'd'
350
+ ? vDoubleRight
351
+ : vLightRight
352
+ : up === '-' && down === '-'
353
+ ? vLightRight
354
+ : vLightLeft;
355
+ const rightLeft = up === 'h' || down === 'h'
356
+ ? vHeavyLeft
357
+ : up !== down || right === left
358
+ ? up === 'd' || down === 'd'
359
+ ? vDoubleLeft
360
+ : vLightLeft
361
+ : up === '-' && down === '-'
362
+ ? vLightLeft
363
+ : vLightRight;
364
+ const out = new RectList(width, height);
365
+ if (up === 'l')
366
+ out.box(vLightLeft, 0, vLightRight, upBottom);
367
+ else if (up === 'h')
368
+ out.box(vHeavyLeft, 0, vHeavyRight, upBottom);
369
+ else if (up === 'd') {
370
+ out.box(vDoubleLeft, 0, vLightLeft, left === 'd' ? hLightTop : upBottom);
371
+ out.box(vLightRight, 0, vDoubleRight, right === 'd' ? hLightTop : upBottom);
372
+ }
373
+ if (right === 'l')
374
+ out.box(rightLeft, hLightTop, width, hLightBottom);
375
+ else if (right === 'h')
376
+ out.box(rightLeft, hHeavyTop, width, hHeavyBottom);
377
+ else if (right === 'd') {
378
+ out.box(up === 'd' ? vLightRight : rightLeft, hDoubleTop, width, hLightTop);
379
+ out.box(down === 'd' ? vLightRight : rightLeft, hLightBottom, width, hDoubleBottom);
380
+ }
381
+ if (down === 'l')
382
+ out.box(vLightLeft, downTop, vLightRight, height);
383
+ else if (down === 'h')
384
+ out.box(vHeavyLeft, downTop, vHeavyRight, height);
385
+ else if (down === 'd') {
386
+ out.box(vDoubleLeft, left === 'd' ? hLightBottom : downTop, vLightLeft, height);
387
+ out.box(vLightRight, right === 'd' ? hLightBottom : downTop, vDoubleRight, height);
388
+ }
389
+ if (left === 'l')
390
+ out.box(0, hLightTop, leftRight, hLightBottom);
391
+ else if (left === 'h')
392
+ out.box(0, hHeavyTop, leftRight, hHeavyBottom);
393
+ else if (left === 'd') {
394
+ out.box(0, hDoubleTop, up === 'd' ? vLightLeft : leftRight, hLightTop);
395
+ out.box(0, hLightBottom, down === 'd' ? vLightLeft : leftRight, hDoubleBottom);
396
+ }
397
+ return { alpha: 1, rects: out.rects, arc: null };
398
+ }
399
+ /**
400
+ * A horizontal dashed line (`dashHorizontal` upstream): `count` dashes with
401
+ * half a gap at either end, so the line tiles evenly across cells; spare
402
+ * pixels widen dashes, which shows less than uneven gaps.
403
+ */
404
+ function dashHorizontal(width, height, light, count, thick, desiredGap) {
405
+ const out = new RectList(width, height);
406
+ if (width < count * 2) {
407
+ const top = Math.floor(minus(height, light) / 2);
408
+ out.box(0, top, width, top + light);
409
+ return { alpha: 1, rects: out.rects, arc: null };
410
+ }
411
+ const gap = Math.min(desiredGap, Math.floor(width / (2 * count)));
412
+ const totalDash = width - count * gap;
413
+ const dash = Math.floor(totalDash / count);
414
+ let extra = totalDash % count;
415
+ const top = Math.floor(minus(height, thick) / 2);
416
+ let x = Math.floor(gap / 2);
417
+ for (let index = 0; index < count; index += 1) {
418
+ let x1 = x + dash;
419
+ if (extra > 0) {
420
+ extra -= 1;
421
+ x1 += 1;
422
+ }
423
+ out.box(x, top, x1, top + thick);
424
+ x = x1 + gap;
425
+ }
426
+ return { alpha: 1, rects: out.rects, arc: null };
427
+ }
428
+ /**
429
+ * A vertical dashed line (`dashVertical` upstream): `count` dashes from the
430
+ * top with one whole gap at the bottom, which joins solid lines above without
431
+ * a half-gap seam.
432
+ */
433
+ function dashVertical(width, height, light, count, thick, desiredGap) {
434
+ const out = new RectList(width, height);
435
+ if (height < count * 2) {
436
+ const left = Math.floor(minus(width, light) / 2);
437
+ out.box(left, 0, left + light, height);
438
+ return { alpha: 1, rects: out.rects, arc: null };
439
+ }
440
+ const gap = Math.min(desiredGap, Math.floor(height / (2 * count)));
441
+ const totalDash = height - count * gap;
442
+ const dash = Math.floor(totalDash / count);
443
+ let extra = totalDash % count;
444
+ const left = Math.floor(minus(width, thick) / 2);
445
+ let y = 0;
446
+ for (let index = 0; index < count; index += 1) {
447
+ let y1 = y + dash;
448
+ if (extra > 0) {
449
+ extra -= 1;
450
+ y1 += 1;
451
+ }
452
+ out.box(left, y, left + thick, y1);
453
+ y = y1 + gap;
454
+ }
455
+ return { alpha: 1, rects: out.rects, arc: null };
456
+ }
457
+ function dash(codepoint, width, height, light) {
458
+ const heavy = light * 2;
459
+ const shortGap = Math.max(4, light);
460
+ switch (codepoint) {
461
+ case 0x2504: // ┄
462
+ return dashHorizontal(width, height, light, 3, light, shortGap);
463
+ case 0x2505: // ┅
464
+ return dashHorizontal(width, height, light, 3, heavy, shortGap);
465
+ case 0x2506: // ┆
466
+ return dashVertical(width, height, light, 3, light, shortGap);
467
+ case 0x2507: // ┇
468
+ return dashVertical(width, height, light, 3, heavy, shortGap);
469
+ case 0x2508: // ┈
470
+ return dashHorizontal(width, height, light, 4, light, shortGap);
471
+ case 0x2509: // ┉
472
+ return dashHorizontal(width, height, light, 4, heavy, shortGap);
473
+ case 0x250a: // ┊
474
+ return dashVertical(width, height, light, 4, light, shortGap);
475
+ case 0x250b: // ┋
476
+ return dashVertical(width, height, light, 4, heavy, shortGap);
477
+ case 0x254c: // ╌
478
+ return dashHorizontal(width, height, light, 2, light, light);
479
+ case 0x254d: // ╍
480
+ return dashHorizontal(width, height, light, 2, heavy, heavy);
481
+ case 0x254e: // ╎
482
+ return dashVertical(width, height, light, 2, light, heavy);
483
+ default: // ╏
484
+ return dashVertical(width, height, light, 2, heavy, heavy);
485
+ }
486
+ }
487
+ /**
488
+ * A light rounded corner (`arc` upstream): straight from the edge to a radius
489
+ * of half the cell's shorter side from the centre, then a curve to the other
490
+ * arm. The stroke is centred on the light line's pixels, so it meets `│` and
491
+ * `─` in the neighbouring cells exactly.
492
+ */
493
+ function roundedCorner(codepoint, width, height, thickness) {
494
+ const centerX = Math.floor(minus(width, thickness) / 2) + thickness / 2;
495
+ const centerY = Math.floor(minus(height, thickness) / 2) + thickness / 2;
496
+ const radius = Math.min(width, height) / 2;
497
+ // How far from the centre the curve's control points sit, as a share of the radius.
498
+ const pull = 0.25;
499
+ // ╭ opens to the bottom right, ╮ bottom left, ╯ top left, ╰ top right.
500
+ const down = codepoint === 0x256d || codepoint === 0x256e;
501
+ const toRight = codepoint === 0x256d || codepoint === 0x2570;
502
+ const vertical = down ? 1 : -1;
503
+ const horizontal = toRight ? 1 : -1;
504
+ return {
505
+ alpha: 1,
506
+ rects: [],
507
+ arc: {
508
+ lineWidth: thickness,
509
+ startX: centerX,
510
+ startY: down ? height : 0,
511
+ bendStartX: centerX,
512
+ bendStartY: centerY + vertical * radius,
513
+ control1X: centerX,
514
+ control1Y: centerY + vertical * pull * radius,
515
+ control2X: centerX + horizontal * pull * radius,
516
+ control2Y: centerY,
517
+ bendEndX: centerX + horizontal * radius,
518
+ bendEndY: centerY,
519
+ endX: toRight ? width : 0,
520
+ endY: centerY
521
+ }
522
+ };
523
+ }
524
+ /**
525
+ * The shapes for a Box Drawing or Block Elements codepoint in a cell `width`
526
+ * by `height` device pixels, with light lines `thickness` pixels thick; null
527
+ * for a codepoint left to the font (see `ghosttySpriteCodepoint`). All three
528
+ * sizes must be whole pixels.
529
+ */
530
+ export function ghosttySpriteGlyph(codepoint, width, height, thickness) {
531
+ if (codepoint < BOX_FIRST || codepoint > BLOCK_LAST)
532
+ return null;
533
+ if (codepoint >= 0x2580)
534
+ return blockElement(codepoint, width, height);
535
+ const arms = LINES[codepoint];
536
+ if (arms !== undefined)
537
+ return linesChar(arms, width, height, thickness);
538
+ if (codepoint >= 0x256d && codepoint <= 0x2570) {
539
+ return roundedCorner(codepoint, width, height, thickness);
540
+ }
541
+ if ((codepoint >= 0x2504 && codepoint <= 0x250b) ||
542
+ (codepoint >= 0x254c && codepoint <= 0x254f)) {
543
+ return dash(codepoint, width, height, thickness);
544
+ }
545
+ return null;
546
+ }