@dst0/p-tui 0.4.41 → 5.0.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 (387) hide show
  1. package/dist/autocomplete.d.ts.map +1 -1
  2. package/dist/autocomplete.js.map +1 -1
  3. package/dist/components/box.d.ts +3 -1
  4. package/dist/components/box.d.ts.map +1 -1
  5. package/dist/components/box.js +19 -10
  6. package/dist/components/box.js.map +1 -1
  7. package/dist/components/cancellable-loader.d.ts.map +1 -1
  8. package/dist/components/cancellable-loader.js.map +1 -1
  9. package/dist/components/editor/constants.d.ts +9 -0
  10. package/dist/components/editor/constants.d.ts.map +1 -0
  11. package/dist/components/editor/constants.js +12 -0
  12. package/dist/components/editor/constants.js.map +1 -0
  13. package/dist/components/editor/editor-methods/autocomplete-matching.d.ts +29 -0
  14. package/dist/components/editor/editor-methods/autocomplete-matching.d.ts.map +1 -0
  15. package/dist/components/editor/editor-methods/autocomplete-matching.js +104 -0
  16. package/dist/components/editor/editor-methods/autocomplete-matching.js.map +1 -0
  17. package/dist/components/editor/editor-methods/autocomplete-request.d.ts +14 -0
  18. package/dist/components/editor/editor-methods/autocomplete-request.d.ts.map +1 -0
  19. package/dist/components/editor/editor-methods/autocomplete-request.js +72 -0
  20. package/dist/components/editor/editor-methods/autocomplete-request.js.map +1 -0
  21. package/dist/components/editor/editor-methods/backspace-cursor.d.ts +9 -0
  22. package/dist/components/editor/editor-methods/backspace-cursor.d.ts.map +1 -0
  23. package/dist/components/editor/editor-methods/backspace-cursor.js +122 -0
  24. package/dist/components/editor/editor-methods/backspace-cursor.js.map +1 -0
  25. package/dist/components/editor/editor-methods/configuration.d.ts +17 -0
  26. package/dist/components/editor/editor-methods/configuration.d.ts.map +1 -0
  27. package/dist/components/editor/editor-methods/configuration.js +107 -0
  28. package/dist/components/editor/editor-methods/configuration.js.map +1 -0
  29. package/dist/components/editor/editor-methods/cursor-movement.d.ts +7 -0
  30. package/dist/components/editor/editor-methods/cursor-movement.d.ts.map +1 -0
  31. package/dist/components/editor/editor-methods/cursor-movement.js +112 -0
  32. package/dist/components/editor/editor-methods/cursor-movement.js.map +1 -0
  33. package/dist/components/editor/editor-methods/input-handling.d.ts +3 -0
  34. package/dist/components/editor/editor-methods/input-handling.d.ts.map +1 -0
  35. package/dist/components/editor/editor-methods/input-handling.js +257 -0
  36. package/dist/components/editor/editor-methods/input-handling.js.map +1 -0
  37. package/dist/components/editor/editor-methods/paste-submit.d.ts +7 -0
  38. package/dist/components/editor/editor-methods/paste-submit.d.ts.map +1 -0
  39. package/dist/components/editor/editor-methods/paste-submit.js +105 -0
  40. package/dist/components/editor/editor-methods/paste-submit.js.map +1 -0
  41. package/dist/components/editor/editor-methods/render.d.ts +3 -0
  42. package/dist/components/editor/editor-methods/render.d.ts.map +1 -0
  43. package/dist/components/editor/editor-methods/render.js +114 -0
  44. package/dist/components/editor/editor-methods/render.js.map +1 -0
  45. package/dist/components/editor/editor-methods/text-insertion.d.ts +4 -0
  46. package/dist/components/editor/editor-methods/text-insertion.d.ts.map +1 -0
  47. package/dist/components/editor/editor-methods/text-insertion.js +91 -0
  48. package/dist/components/editor/editor-methods/text-insertion.js.map +1 -0
  49. package/dist/components/editor/editor-methods/text-layout.d.ts +15 -0
  50. package/dist/components/editor/editor-methods/text-layout.d.ts.map +1 -0
  51. package/dist/components/editor/editor-methods/text-layout.js +129 -0
  52. package/dist/components/editor/editor-methods/text-layout.js.map +1 -0
  53. package/dist/components/editor/editor-methods/vertical-movement.d.ts +8 -0
  54. package/dist/components/editor/editor-methods/vertical-movement.d.ts.map +1 -0
  55. package/dist/components/editor/editor-methods/vertical-movement.js +123 -0
  56. package/dist/components/editor/editor-methods/vertical-movement.js.map +1 -0
  57. package/dist/components/editor/editor-methods/word-operations.d.ts +19 -0
  58. package/dist/components/editor/editor-methods/word-operations.d.ts.map +1 -0
  59. package/dist/components/editor/editor-methods/word-operations.js +122 -0
  60. package/dist/components/editor/editor-methods/word-operations.js.map +1 -0
  61. package/dist/components/editor/editor-methods/yank-undo.d.ts +11 -0
  62. package/dist/components/editor/editor-methods/yank-undo.d.ts.map +1 -0
  63. package/dist/components/editor/editor-methods/yank-undo.js +132 -0
  64. package/dist/components/editor/editor-methods/yank-undo.js.map +1 -0
  65. package/dist/components/editor/editor.d.ts +67 -0
  66. package/dist/components/editor/editor.d.ts.map +1 -0
  67. package/dist/components/editor/editor.js +93 -0
  68. package/dist/components/editor/editor.js.map +1 -0
  69. package/dist/components/editor/helpers.d.ts +3 -0
  70. package/dist/components/editor/helpers.d.ts.map +1 -0
  71. package/dist/components/editor/helpers.js +3 -0
  72. package/dist/components/editor/helpers.js.map +1 -0
  73. package/dist/components/editor/index.d.ts +4 -0
  74. package/dist/components/editor/index.d.ts.map +1 -0
  75. package/dist/components/editor/index.js +3 -0
  76. package/dist/components/editor/index.js.map +1 -0
  77. package/dist/components/editor/paste-marker.d.ts +5 -0
  78. package/dist/components/editor/paste-marker.d.ts.map +1 -0
  79. package/dist/components/editor/paste-marker.js +134 -0
  80. package/dist/components/editor/paste-marker.js.map +1 -0
  81. package/dist/components/editor/trigger-patterns.d.ts +4 -0
  82. package/dist/components/editor/trigger-patterns.d.ts.map +1 -0
  83. package/dist/components/editor/trigger-patterns.js +11 -0
  84. package/dist/components/editor/trigger-patterns.js.map +1 -0
  85. package/dist/components/editor/types.d.ts +25 -0
  86. package/dist/components/editor/types.d.ts.map +1 -0
  87. package/dist/components/editor/types.js +2 -0
  88. package/dist/components/editor/types.js.map +1 -0
  89. package/dist/components/editor.d.ts +1 -253
  90. package/dist/components/editor.d.ts.map +1 -1
  91. package/dist/components/editor.js +1 -1915
  92. package/dist/components/editor.js.map +1 -1
  93. package/dist/components/image.d.ts.map +1 -1
  94. package/dist/components/image.js.map +1 -1
  95. package/dist/components/input/constants.d.ts +2 -0
  96. package/dist/components/input/constants.d.ts.map +1 -0
  97. package/dist/components/input/constants.js +3 -0
  98. package/dist/components/input/constants.js.map +1 -0
  99. package/dist/components/input/index.d.ts +2 -0
  100. package/dist/components/input/index.d.ts.map +1 -0
  101. package/dist/components/input/index.js +2 -0
  102. package/dist/components/input/index.js.map +1 -0
  103. package/dist/components/input/input-methods/input-handling.d.ts +3 -0
  104. package/dist/components/input/input-methods/input-handling.d.ts.map +1 -0
  105. package/dist/components/input/input-methods/input-handling.js +145 -0
  106. package/dist/components/input/input-methods/input-handling.js.map +1 -0
  107. package/dist/components/input/input-methods/render.d.ts +3 -0
  108. package/dist/components/input/input-methods/render.d.ts.map +1 -0
  109. package/dist/components/input/input-methods/render.js +62 -0
  110. package/dist/components/input/input-methods/render.js.map +1 -0
  111. package/dist/components/input/input-methods/text-editing.d.ts +17 -0
  112. package/dist/components/input/input-methods/text-editing.d.ts.map +1 -0
  113. package/dist/components/input/input-methods/text-editing.js +145 -0
  114. package/dist/components/input/input-methods/text-editing.js.map +1 -0
  115. package/dist/components/input/input-methods/value-access.d.ts +4 -0
  116. package/dist/components/input/input-methods/value-access.d.ts.map +1 -0
  117. package/dist/components/input/input-methods/value-access.js +20 -0
  118. package/dist/components/input/input-methods/value-access.js.map +1 -0
  119. package/dist/components/input/input.d.ts +37 -0
  120. package/dist/components/input/input.d.ts.map +1 -0
  121. package/dist/components/input/input.js +77 -0
  122. package/dist/components/input/input.js.map +1 -0
  123. package/dist/components/input/types.d.ts +5 -0
  124. package/dist/components/input/types.d.ts.map +1 -0
  125. package/dist/components/input/types.js +2 -0
  126. package/dist/components/input/types.js.map +1 -0
  127. package/dist/components/input.d.ts +1 -36
  128. package/dist/components/input.d.ts.map +1 -1
  129. package/dist/components/input.js +1 -377
  130. package/dist/components/input.js.map +1 -1
  131. package/dist/components/loader.d.ts.map +1 -1
  132. package/dist/components/loader.js.map +1 -1
  133. package/dist/components/markdown/constants.d.ts +4 -0
  134. package/dist/components/markdown/constants.d.ts.map +1 -0
  135. package/dist/components/markdown/constants.js +8 -0
  136. package/dist/components/markdown/constants.js.map +1 -0
  137. package/dist/components/markdown/index.d.ts +3 -0
  138. package/dist/components/markdown/index.d.ts.map +1 -0
  139. package/dist/components/markdown/index.js +2 -0
  140. package/dist/components/markdown/index.js.map +1 -0
  141. package/dist/components/markdown/markdown-methods/inline-rendering.d.ts +7 -0
  142. package/dist/components/markdown/markdown-methods/inline-rendering.d.ts.map +1 -0
  143. package/dist/components/markdown/markdown-methods/inline-rendering.js +95 -0
  144. package/dist/components/markdown/markdown-methods/inline-rendering.js.map +1 -0
  145. package/dist/components/markdown/markdown-methods/list-table-helpers.d.ts +7 -0
  146. package/dist/components/markdown/markdown-methods/list-table-helpers.d.ts.map +1 -0
  147. package/dist/components/markdown/markdown-methods/list-table-helpers.js +61 -0
  148. package/dist/components/markdown/markdown-methods/list-table-helpers.js.map +1 -0
  149. package/dist/components/markdown/markdown-methods/table-rendering.d.ts +5 -0
  150. package/dist/components/markdown/markdown-methods/table-rendering.d.ts.map +1 -0
  151. package/dist/components/markdown/markdown-methods/table-rendering.js +146 -0
  152. package/dist/components/markdown/markdown-methods/table-rendering.js.map +1 -0
  153. package/dist/components/markdown/markdown-methods/text-rendering.d.ts +6 -0
  154. package/dist/components/markdown/markdown-methods/text-rendering.d.ts.map +1 -0
  155. package/dist/components/markdown/markdown-methods/text-rendering.js +115 -0
  156. package/dist/components/markdown/markdown-methods/text-rendering.js.map +1 -0
  157. package/dist/components/markdown/markdown-methods/theming.d.ts +6 -0
  158. package/dist/components/markdown/markdown-methods/theming.d.ts.map +1 -0
  159. package/dist/components/markdown/markdown-methods/theming.js +41 -0
  160. package/dist/components/markdown/markdown-methods/theming.js.map +1 -0
  161. package/dist/components/markdown/markdown-methods/token-rendering.d.ts +5 -0
  162. package/dist/components/markdown/markdown-methods/token-rendering.d.ts.map +1 -0
  163. package/dist/components/markdown/markdown-methods/token-rendering.js +142 -0
  164. package/dist/components/markdown/markdown-methods/token-rendering.js.map +1 -0
  165. package/dist/components/markdown/markdown.d.ts +32 -0
  166. package/dist/components/markdown/markdown.d.ts.map +1 -0
  167. package/dist/components/markdown/markdown.js +72 -0
  168. package/dist/components/markdown/markdown.js.map +1 -0
  169. package/dist/components/markdown/strictstrikethroughtokenizer.d.ts +6 -0
  170. package/dist/components/markdown/strictstrikethroughtokenizer.d.ts.map +1 -0
  171. package/dist/components/markdown/strictstrikethroughtokenizer.js +18 -0
  172. package/dist/components/markdown/strictstrikethroughtokenizer.js.map +1 -0
  173. package/dist/components/markdown/types.d.ts +42 -0
  174. package/dist/components/markdown/types.d.ts.map +1 -0
  175. package/dist/components/markdown/types.js +2 -0
  176. package/dist/components/markdown/types.js.map +1 -0
  177. package/dist/components/markdown.d.ts +1 -96
  178. package/dist/components/markdown.d.ts.map +1 -1
  179. package/dist/components/markdown.js +1 -653
  180. package/dist/components/markdown.js.map +1 -1
  181. package/dist/components/select-list.d.ts.map +1 -1
  182. package/dist/components/select-list.js +8 -3
  183. package/dist/components/select-list.js.map +1 -1
  184. package/dist/components/settings-list.d.ts.map +1 -1
  185. package/dist/components/settings-list.js +2 -6
  186. package/dist/components/settings-list.js.map +1 -1
  187. package/dist/components/spacer.d.ts.map +1 -1
  188. package/dist/components/spacer.js.map +1 -1
  189. package/dist/components/text.d.ts.map +1 -1
  190. package/dist/components/text.js +2 -2
  191. package/dist/components/text.js.map +1 -1
  192. package/dist/components/truncated-text.d.ts.map +1 -1
  193. package/dist/components/truncated-text.js.map +1 -1
  194. package/dist/editor-component.d.ts.map +1 -1
  195. package/dist/editor-component.js.map +1 -1
  196. package/dist/fuzzy.d.ts.map +1 -1
  197. package/dist/fuzzy.js.map +1 -1
  198. package/dist/index.d.ts +1 -1
  199. package/dist/index.d.ts.map +1 -1
  200. package/dist/index.js +1 -1
  201. package/dist/index.js.map +1 -1
  202. package/dist/keybindings.d.ts.map +1 -1
  203. package/dist/keybindings.js.map +1 -1
  204. package/dist/keys.d.ts.map +1 -1
  205. package/dist/keys.js +145 -14
  206. package/dist/keys.js.map +1 -1
  207. package/dist/kill-ring.d.ts.map +1 -1
  208. package/dist/kill-ring.js.map +1 -1
  209. package/dist/native-modifiers.d.ts +9 -0
  210. package/dist/native-modifiers.d.ts.map +1 -1
  211. package/dist/native-modifiers.js +5 -0
  212. package/dist/native-modifiers.js.map +1 -1
  213. package/dist/stdin-buffer.d.ts +3 -0
  214. package/dist/stdin-buffer.d.ts.map +1 -1
  215. package/dist/stdin-buffer.js +24 -21
  216. package/dist/stdin-buffer.js.map +1 -1
  217. package/dist/terminal/constants.d.ts +9 -0
  218. package/dist/terminal/constants.d.ts.map +1 -0
  219. package/dist/terminal/constants.js +10 -0
  220. package/dist/terminal/constants.js.map +1 -0
  221. package/dist/terminal/helpers.d.ts +6 -0
  222. package/dist/terminal/helpers.d.ts.map +1 -0
  223. package/dist/terminal/helpers.js +23 -0
  224. package/dist/terminal/helpers.js.map +1 -0
  225. package/dist/terminal/index.d.ts +4 -0
  226. package/dist/terminal/index.d.ts.map +1 -0
  227. package/dist/terminal/index.js +3 -0
  228. package/dist/terminal/index.js.map +1 -0
  229. package/dist/terminal/processterminal-methods/cursor-screen.d.ts +11 -0
  230. package/dist/terminal/processterminal-methods/cursor-screen.d.ts.map +1 -0
  231. package/dist/terminal/processterminal-methods/cursor-screen.js +50 -0
  232. package/dist/terminal/processterminal-methods/cursor-screen.js.map +1 -0
  233. package/dist/terminal/processterminal-methods/keyboard-protocol.d.ts +14 -0
  234. package/dist/terminal/processterminal-methods/keyboard-protocol.d.ts.map +1 -0
  235. package/dist/terminal/processterminal-methods/keyboard-protocol.js +147 -0
  236. package/dist/terminal/processterminal-methods/keyboard-protocol.js.map +1 -0
  237. package/dist/terminal/processterminal-methods/terminal-io.d.ts +9 -0
  238. package/dist/terminal/processterminal-methods/terminal-io.d.ts.map +1 -0
  239. package/dist/terminal/processterminal-methods/terminal-io.js +153 -0
  240. package/dist/terminal/processterminal-methods/terminal-io.js.map +1 -0
  241. package/dist/terminal/processterminal.d.ts +49 -0
  242. package/dist/terminal/processterminal.d.ts.map +1 -0
  243. package/dist/terminal/processterminal.js +129 -0
  244. package/dist/terminal/processterminal.js.map +1 -0
  245. package/dist/terminal/types.d.ts +31 -0
  246. package/dist/terminal/types.d.ts.map +1 -0
  247. package/dist/terminal/types.js +2 -0
  248. package/dist/terminal/types.js.map +1 -0
  249. package/dist/terminal-colors.d.ts +2 -0
  250. package/dist/terminal-colors.d.ts.map +1 -1
  251. package/dist/terminal-colors.js +17 -5
  252. package/dist/terminal-colors.js.map +1 -1
  253. package/dist/terminal-image.d.ts.map +1 -1
  254. package/dist/terminal-image.js.map +1 -1
  255. package/dist/terminal.d.ts +1 -109
  256. package/dist/terminal.d.ts.map +1 -1
  257. package/dist/terminal.js +1 -432
  258. package/dist/terminal.js.map +1 -1
  259. package/dist/tui/constants.d.ts +3 -0
  260. package/dist/tui/constants.d.ts.map +1 -0
  261. package/dist/tui/constants.js +3 -0
  262. package/dist/tui/constants.js.map +1 -0
  263. package/dist/tui/container.d.ts +10 -0
  264. package/dist/tui/container.d.ts.map +1 -0
  265. package/dist/tui/container.js +31 -0
  266. package/dist/tui/container.js.map +1 -0
  267. package/dist/tui/helpers.d.ts +8 -0
  268. package/dist/tui/helpers.d.ts.map +1 -0
  269. package/dist/tui/helpers.js +53 -0
  270. package/dist/tui/helpers.js.map +1 -0
  271. package/dist/tui/index.d.ts +6 -0
  272. package/dist/tui/index.d.ts.map +1 -0
  273. package/dist/tui/index.js +5 -0
  274. package/dist/tui/index.js.map +1 -0
  275. package/dist/tui/tui-methods/configuration.d.ts +20 -0
  276. package/dist/tui/tui-methods/configuration.d.ts.map +1 -0
  277. package/dist/tui/tui-methods/configuration.js +131 -0
  278. package/dist/tui/tui-methods/configuration.js.map +1 -0
  279. package/dist/tui/tui-methods/cursor-background.d.ts +10 -0
  280. package/dist/tui/tui-methods/cursor-background.d.ts.map +1 -0
  281. package/dist/tui/tui-methods/cursor-background.js +52 -0
  282. package/dist/tui/tui-methods/cursor-background.js.map +1 -0
  283. package/dist/tui/tui-methods/incremental-render.d.ts +17 -0
  284. package/dist/tui/tui-methods/incremental-render.d.ts.map +1 -0
  285. package/dist/tui/tui-methods/incremental-render.js +259 -0
  286. package/dist/tui/tui-methods/incremental-render.js.map +1 -0
  287. package/dist/tui/tui-methods/input-handling.d.ts +5 -0
  288. package/dist/tui/tui-methods/input-handling.d.ts.map +1 -0
  289. package/dist/tui/tui-methods/input-handling.js +111 -0
  290. package/dist/tui/tui-methods/input-handling.js.map +1 -0
  291. package/dist/tui/tui-methods/line-compositing.d.ts +7 -0
  292. package/dist/tui/tui-methods/line-compositing.d.ts.map +1 -0
  293. package/dist/tui/tui-methods/line-compositing.js +61 -0
  294. package/dist/tui/tui-methods/line-compositing.js.map +1 -0
  295. package/dist/tui/tui-methods/overlay-compositing.d.ts +12 -0
  296. package/dist/tui/tui-methods/overlay-compositing.d.ts.map +1 -0
  297. package/dist/tui/tui-methods/overlay-compositing.js +123 -0
  298. package/dist/tui/tui-methods/overlay-compositing.js.map +1 -0
  299. package/dist/tui/tui-methods/overlay-layout.d.ts +11 -0
  300. package/dist/tui/tui-methods/overlay-layout.d.ts.map +1 -0
  301. package/dist/tui/tui-methods/overlay-layout.js +124 -0
  302. package/dist/tui/tui-methods/overlay-layout.js.map +1 -0
  303. package/dist/tui/tui-methods/overlay-management.d.ts +11 -0
  304. package/dist/tui/tui-methods/overlay-management.d.ts.map +1 -0
  305. package/dist/tui/tui-methods/overlay-management.js +152 -0
  306. package/dist/tui/tui-methods/overlay-management.js.map +1 -0
  307. package/dist/tui/tui-methods/render-pipeline.d.ts +3 -0
  308. package/dist/tui/tui-methods/render-pipeline.d.ts.map +1 -0
  309. package/dist/tui/tui-methods/render-pipeline.js +176 -0
  310. package/dist/tui/tui-methods/render-pipeline.js.map +1 -0
  311. package/dist/tui/tui-methods/render-width-error.d.ts +3 -0
  312. package/dist/tui/tui-methods/render-width-error.d.ts.map +1 -0
  313. package/dist/tui/tui-methods/render-width-error.js +28 -0
  314. package/dist/tui/tui-methods/render-width-error.js.map +1 -0
  315. package/dist/tui/tui-methods/terminal-control.d.ts +8 -0
  316. package/dist/tui/tui-methods/terminal-control.d.ts.map +1 -0
  317. package/dist/tui/tui-methods/terminal-control.js +101 -0
  318. package/dist/tui/tui-methods/terminal-control.js.map +1 -0
  319. package/dist/tui/tui.d.ts +59 -0
  320. package/dist/tui/tui.d.ts.map +1 -0
  321. package/dist/tui/tui.js +78 -0
  322. package/dist/tui/tui.js.map +1 -0
  323. package/dist/tui/types.d.ts +124 -0
  324. package/dist/tui/types.d.ts.map +1 -0
  325. package/dist/tui/types.js +2 -0
  326. package/dist/tui/types.js.map +1 -0
  327. package/dist/tui.d.ts +1 -254
  328. package/dist/tui.d.ts.map +1 -1
  329. package/dist/tui.js +1 -1344
  330. package/dist/tui.js.map +1 -1
  331. package/dist/undo-stack.d.ts.map +1 -1
  332. package/dist/undo-stack.js.map +1 -1
  333. package/dist/utils/ansi-wrapping.d.ts +5 -0
  334. package/dist/utils/ansi-wrapping.d.ts.map +1 -0
  335. package/dist/utils/ansi-wrapping.js +52 -0
  336. package/dist/utils/ansi-wrapping.js.map +1 -0
  337. package/dist/utils/ansicodetracker.d.ts +27 -0
  338. package/dist/utils/ansicodetracker.d.ts.map +1 -0
  339. package/dist/utils/ansicodetracker.js +222 -0
  340. package/dist/utils/ansicodetracker.js.map +1 -0
  341. package/dist/utils/column-slicing.d.ts +12 -0
  342. package/dist/utils/column-slicing.d.ts.map +1 -0
  343. package/dist/utils/column-slicing.js +111 -0
  344. package/dist/utils/column-slicing.js.map +1 -0
  345. package/dist/utils/column-truncation.d.ts +2 -0
  346. package/dist/utils/column-truncation.d.ts.map +1 -0
  347. package/dist/utils/column-truncation.js +129 -0
  348. package/dist/utils/column-truncation.js.map +1 -0
  349. package/dist/utils/constants.d.ts +12 -0
  350. package/dist/utils/constants.d.ts.map +1 -0
  351. package/dist/utils/constants.js +12 -0
  352. package/dist/utils/constants.js.map +1 -0
  353. package/dist/utils/index.d.ts +8 -0
  354. package/dist/utils/index.d.ts.map +1 -0
  355. package/dist/utils/index.js +8 -0
  356. package/dist/utils/index.js.map +1 -0
  357. package/dist/utils/install-delegated-methods.d.ts +5 -0
  358. package/dist/utils/install-delegated-methods.d.ts.map +1 -0
  359. package/dist/utils/install-delegated-methods.js +27 -0
  360. package/dist/utils/install-delegated-methods.js.map +1 -0
  361. package/dist/utils/segmentation.d.ts +10 -0
  362. package/dist/utils/segmentation.d.ts.map +1 -0
  363. package/dist/utils/segmentation.js +111 -0
  364. package/dist/utils/segmentation.js.map +1 -0
  365. package/dist/utils/terminal-output.d.ts +10 -0
  366. package/dist/utils/terminal-output.d.ts.map +1 -0
  367. package/dist/utils/terminal-output.js +122 -0
  368. package/dist/utils/terminal-output.js.map +1 -0
  369. package/dist/utils/types.d.ts +7 -0
  370. package/dist/utils/types.d.ts.map +1 -0
  371. package/dist/utils/types.js +2 -0
  372. package/dist/utils/types.js.map +1 -0
  373. package/dist/utils/width-truncation.d.ts +6 -0
  374. package/dist/utils/width-truncation.d.ts.map +1 -0
  375. package/dist/utils/width-truncation.js +121 -0
  376. package/dist/utils/width-truncation.js.map +1 -0
  377. package/dist/utils/word-wrapping.d.ts +4 -0
  378. package/dist/utils/word-wrapping.d.ts.map +1 -0
  379. package/dist/utils/word-wrapping.js +139 -0
  380. package/dist/utils/word-wrapping.js.map +1 -0
  381. package/dist/utils.d.ts +1 -84
  382. package/dist/utils.d.ts.map +1 -1
  383. package/dist/utils.js +1 -1059
  384. package/dist/utils.js.map +1 -1
  385. package/dist/word-navigation.d.ts.map +1 -1
  386. package/dist/word-navigation.js.map +1 -1
  387. package/package.json +2 -1
@@ -0,0 +1,147 @@
1
+ import { setKittyProtocolActive } from "../../keys.js";
2
+ import { isNativeModifierPressed } from "../../native-modifiers.js";
3
+ import { StdinBuffer } from "../../stdin-buffer.js";
4
+ import { KEYBOARD_PROTOCOL_RESPONSE_FRAGMENT_TIMEOUT_MS, KITTY_KEYBOARD_PROTOCOL_QUERY } from "../constants.js";
5
+ import { isAppleTerminalSession, isKeyboardProtocolNegotiationSequencePrefix, normalizeAppleTerminalInput, parseKeyboardProtocolNegotiationSequence, } from "../helpers.js";
6
+ export function do_start(self, onInput, onResize) {
7
+ self.inputHandler = onInput;
8
+ self.resizeHandler = onResize;
9
+ // Save previous state and enable raw mode
10
+ self.wasRaw = process.stdin.isRaw || false;
11
+ if (process.stdin.setRawMode) {
12
+ process.stdin.setRawMode(true);
13
+ }
14
+ process.stdin.setEncoding("utf8");
15
+ process.stdin.resume();
16
+ // Enable bracketed paste mode - terminal will wrap pastes in \x1b[200~ ... \x1b[201~
17
+ process.stdout.write("\x1b[?2004h");
18
+ // Set up resize handler immediately
19
+ process.stdout.on("resize", self.resizeHandler);
20
+ // Refresh terminal dimensions - they may be stale after suspend/resume
21
+ // (SIGWINCH is lost while process is stopped). Unix only.
22
+ if (process.platform !== "win32") {
23
+ process.kill(process.pid, "SIGWINCH");
24
+ }
25
+ // On Windows, enable ENABLE_VIRTUAL_TERMINAL_INPUT so the console sends
26
+ // VT escape sequences (e.g. \x1b[Z for Shift+Tab) instead of raw console
27
+ // events that lose modifier information. Must run AFTER setRawMode(true)
28
+ // since that resets console mode flags.
29
+ self.enableWindowsVTInput();
30
+ // Query Kitty keyboard protocol and fall back to modifyOtherKeys when DA confirms no Kitty response.
31
+ // See: https://sw.kovidgoyal.net/kitty/keyboard-protocol/
32
+ self.queryAndEnableKittyProtocol();
33
+ }
34
+ export function do_setupStdinBuffer(self) {
35
+ self.stdinBuffer = new StdinBuffer({ timeout: 10 });
36
+ // Forward individual sequences to the input handler
37
+ self.stdinBuffer.on("data", (sequence) => {
38
+ const negotiationSequence = self.readKeyboardProtocolNegotiationSequence(sequence);
39
+ if (negotiationSequence === "pending") {
40
+ self.scheduleKeyboardProtocolNegotiationBufferFlush();
41
+ return; // Wait briefly for the rest of a split Kitty response.
42
+ }
43
+ if (self.handleKeyboardProtocolNegotiationSequence(negotiationSequence)) {
44
+ return;
45
+ }
46
+ self.forwardInputSequence(sequence);
47
+ });
48
+ // Re-wrap paste content with bracketed paste markers for existing editor handling
49
+ self.stdinBuffer.on("paste", (content) => {
50
+ if (self.inputHandler) {
51
+ self.inputHandler(`\x1b[200~${content}\x1b[201~`);
52
+ }
53
+ });
54
+ // Handler that pipes stdin data through the buffer
55
+ self.stdinDataHandler = (data) => {
56
+ self.stdinBuffer.process(data);
57
+ };
58
+ }
59
+ export function do_queryAndEnableKittyProtocol(self) {
60
+ self.setupStdinBuffer();
61
+ process.stdin.on("data", self.stdinDataHandler);
62
+ self.keyboardProtocolPushed = true;
63
+ self.clearKeyboardProtocolNegotiationBuffer();
64
+ process.stdout.write(KITTY_KEYBOARD_PROTOCOL_QUERY);
65
+ }
66
+ export function do_handleKeyboardProtocolNegotiationSequence(self, negotiationSequence) {
67
+ if (!negotiationSequence)
68
+ return false;
69
+ self.clearKeyboardProtocolNegotiationBuffer();
70
+ if (negotiationSequence.type === "kitty-flags") {
71
+ if (negotiationSequence.flags !== 0) {
72
+ self.disableModifyOtherKeys();
73
+ if (!self._kittyProtocolActive) {
74
+ self._kittyProtocolActive = true;
75
+ setKittyProtocolActive(true);
76
+ }
77
+ }
78
+ else {
79
+ self.enableModifyOtherKeys();
80
+ }
81
+ return true;
82
+ }
83
+ if (!self._kittyProtocolActive) {
84
+ self.enableModifyOtherKeys();
85
+ }
86
+ return true;
87
+ }
88
+ export function do_readKeyboardProtocolNegotiationSequence(self, sequence) {
89
+ if (self.keyboardProtocolNegotiationBuffer) {
90
+ const bufferedSequence = self.keyboardProtocolNegotiationBuffer + sequence;
91
+ const negotiationSequence = parseKeyboardProtocolNegotiationSequence(bufferedSequence);
92
+ if (negotiationSequence) {
93
+ self.clearKeyboardProtocolNegotiationBuffer();
94
+ return negotiationSequence;
95
+ }
96
+ if (isKeyboardProtocolNegotiationSequencePrefix(bufferedSequence)) {
97
+ self.setKeyboardProtocolNegotiationBuffer(bufferedSequence);
98
+ return "pending";
99
+ }
100
+ self.flushKeyboardProtocolNegotiationBufferAsInput();
101
+ }
102
+ const negotiationSequence = parseKeyboardProtocolNegotiationSequence(sequence);
103
+ if (negotiationSequence)
104
+ return negotiationSequence;
105
+ if (isKeyboardProtocolNegotiationSequencePrefix(sequence)) {
106
+ self.setKeyboardProtocolNegotiationBuffer(sequence);
107
+ return "pending";
108
+ }
109
+ return undefined;
110
+ }
111
+ export function do_setKeyboardProtocolNegotiationBuffer(self, sequence) {
112
+ self.clearKeyboardProtocolNegotiationBufferFlushTimer();
113
+ self.keyboardProtocolNegotiationBuffer = sequence;
114
+ }
115
+ export function do_clearKeyboardProtocolNegotiationBuffer(self) {
116
+ self.clearKeyboardProtocolNegotiationBufferFlushTimer();
117
+ self.keyboardProtocolNegotiationBuffer = "";
118
+ }
119
+ export function do_flushKeyboardProtocolNegotiationBufferAsInput(self) {
120
+ if (!self.keyboardProtocolNegotiationBuffer)
121
+ return;
122
+ const sequence = self.keyboardProtocolNegotiationBuffer;
123
+ self.clearKeyboardProtocolNegotiationBuffer();
124
+ self.forwardInputSequence(sequence);
125
+ }
126
+ export function do_scheduleKeyboardProtocolNegotiationBufferFlush(self) {
127
+ if (!self.keyboardProtocolNegotiationBuffer || self.keyboardProtocolBufferFlushTimer)
128
+ return;
129
+ self.keyboardProtocolBufferFlushTimer = setTimeout(() => {
130
+ self.keyboardProtocolBufferFlushTimer = undefined;
131
+ self.flushKeyboardProtocolNegotiationBufferAsInput();
132
+ }, KEYBOARD_PROTOCOL_RESPONSE_FRAGMENT_TIMEOUT_MS);
133
+ }
134
+ export function do_clearKeyboardProtocolNegotiationBufferFlushTimer(self) {
135
+ if (!self.keyboardProtocolBufferFlushTimer)
136
+ return;
137
+ clearTimeout(self.keyboardProtocolBufferFlushTimer);
138
+ self.keyboardProtocolBufferFlushTimer = undefined;
139
+ }
140
+ export function do_forwardInputSequence(self, sequence) {
141
+ if (!self.inputHandler)
142
+ return;
143
+ const isAppleTerminal = sequence === "\r" && isAppleTerminalSession();
144
+ const input = normalizeAppleTerminalInput(sequence, isAppleTerminal, isAppleTerminal && isNativeModifierPressed("shift"));
145
+ self.inputHandler(input);
146
+ }
147
+ //# sourceMappingURL=keyboard-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyboard-protocol.js","sourceRoot":"","sources":["../../../src/terminal/processterminal-methods/keyboard-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,8CAA8C,EAAE,6BAA6B,EAAE,MAAM,iBAAiB,CAAC;AAChH,OAAO,EACL,sBAAsB,EACtB,2CAA2C,EAC3C,2BAA2B,EAC3B,wCAAwC,GACzC,MAAM,eAAe,CAAC;AAIvB,MAAM,UAAU,QAAQ,CAAC,IAAqB,EAAE,OAA+B,EAAE,QAAoB,EAAQ;IAC3G,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC;IAC5B,IAAI,CAAC,aAAa,GAAG,QAAQ,CAAC;IAE9B,0CAA0C;IAC1C,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC;IAC3C,IAAI,OAAO,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;QAC7B,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAClC,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;IAEvB,qFAAqF;IACrF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IAEpC,oCAAoC;IACpC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IAEhD,uEAAuE;IACvE,0DAA0D;IAC1D,IAAI,OAAO,CAAC,QAAQ,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iDAAiD,CAAC,IAAqB,EAAQ;IAC7F,IAAI,CAAC,IAAI,CAAC,iCAAiC,IAAI,IAAI,CAAC,gCAAgC;QAAE,OAAO;IAC7F,IAAI,CAAC,gCAAgC,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC;QACvD,IAAI,CAAC,gCAAgC,GAAG,SAAS,CAAC;QAClD,IAAI,CAAC,6CAA6C,EAAE,CAAC;IAAA,CACtD,EAAE,8CAA8C,CAAC,CAAC;AAAA,CACpD;AAED,MAAM,UAAU,mDAAmD,CAAC,IAAqB,EAAQ;IAC/F,IAAI,CAAC,IAAI,CAAC,gCAAgC;QAAE,OAAO;IACnD,YAAY,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;IACpD,IAAI,CAAC,gCAAgC,GAAG,SAAS,CAAC;AAAA,CACnD;AAED,MAAM,UAAU,uBAAuB,CAAC,IAAqB,EAAE,QAAgB,EAAQ;IACrF,IAAI,CAAC,IAAI,CAAC,YAAY;QAAE,OAAO;IAC/B,MAAM,eAAe,GAAG,QAAQ,KAAK,IAAI,IAAI,sBAAsB,EAAE,CAAC;IACtE,MAAM,KAAK,GAAG,2BAA2B,CACvC,QAAQ,EACR,eAAe,EACf,eAAe,IAAI,uBAAuB,CAAC,OAAO,CAAC,CACpD,CAAC;IACF,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;AAAA,CAC1B","sourcesContent":["import { setKittyProtocolActive } from \"../../keys.ts\";\nimport { isNativeModifierPressed } from \"../../native-modifiers.ts\";\nimport { StdinBuffer } from \"../../stdin-buffer.ts\";\nimport { KEYBOARD_PROTOCOL_RESPONSE_FRAGMENT_TIMEOUT_MS, KITTY_KEYBOARD_PROTOCOL_QUERY } from \"../constants.ts\";\nimport {\n isAppleTerminalSession,\n isKeyboardProtocolNegotiationSequencePrefix,\n normalizeAppleTerminalInput,\n parseKeyboardProtocolNegotiationSequence,\n} from \"../helpers.ts\";\nimport type { ProcessTerminal } from \"../processterminal.ts\";\nimport type { KeyboardProtocolNegotiationSequence } from \"../types.ts\";\n\nexport function do_start(self: ProcessTerminal, onInput: (data: string) => void, onResize: () => void): void {\n self.inputHandler = onInput;\n self.resizeHandler = onResize;\n\n // Save previous state and enable raw mode\n self.wasRaw = process.stdin.isRaw || false;\n if (process.stdin.setRawMode) {\n process.stdin.setRawMode(true);\n }\n process.stdin.setEncoding(\"utf8\");\n process.stdin.resume();\n\n // Enable bracketed paste mode - terminal will wrap pastes in \\x1b[200~ ... \\x1b[201~\n process.stdout.write(\"\\x1b[?2004h\");\n\n // Set up resize handler immediately\n process.stdout.on(\"resize\", self.resizeHandler);\n\n // Refresh terminal dimensions - they may be stale after suspend/resume\n // (SIGWINCH is lost while process is stopped). Unix only.\n if (process.platform !== \"win32\") {\n process.kill(process.pid, \"SIGWINCH\");\n }\n\n // On Windows, enable ENABLE_VIRTUAL_TERMINAL_INPUT so the console sends\n // VT escape sequences (e.g. \\x1b[Z for Shift+Tab) instead of raw console\n // events that lose modifier information. Must run AFTER setRawMode(true)\n // since that resets console mode flags.\n self.enableWindowsVTInput();\n\n // Query Kitty keyboard protocol and fall back to modifyOtherKeys when DA confirms no Kitty response.\n // See: https://sw.kovidgoyal.net/kitty/keyboard-protocol/\n self.queryAndEnableKittyProtocol();\n}\n\nexport function do_setupStdinBuffer(self: ProcessTerminal): void {\n self.stdinBuffer = new StdinBuffer({ timeout: 10 });\n\n // Forward individual sequences to the input handler\n self.stdinBuffer.on(\"data\", (sequence) => {\n const negotiationSequence = self.readKeyboardProtocolNegotiationSequence(sequence);\n if (negotiationSequence === \"pending\") {\n self.scheduleKeyboardProtocolNegotiationBufferFlush();\n return; // Wait briefly for the rest of a split Kitty response.\n }\n if (self.handleKeyboardProtocolNegotiationSequence(negotiationSequence)) {\n return;\n }\n\n self.forwardInputSequence(sequence);\n });\n\n // Re-wrap paste content with bracketed paste markers for existing editor handling\n self.stdinBuffer.on(\"paste\", (content) => {\n if (self.inputHandler) {\n self.inputHandler(`\\x1b[200~${content}\\x1b[201~`);\n }\n });\n\n // Handler that pipes stdin data through the buffer\n self.stdinDataHandler = (data: string) => {\n self.stdinBuffer!.process(data);\n };\n}\n\nexport function do_queryAndEnableKittyProtocol(self: ProcessTerminal): void {\n self.setupStdinBuffer();\n process.stdin.on(\"data\", self.stdinDataHandler!);\n self.keyboardProtocolPushed = true;\n self.clearKeyboardProtocolNegotiationBuffer();\n process.stdout.write(KITTY_KEYBOARD_PROTOCOL_QUERY);\n}\n\nexport function do_handleKeyboardProtocolNegotiationSequence(\n self: ProcessTerminal,\n negotiationSequence: KeyboardProtocolNegotiationSequence | undefined,\n): boolean {\n if (!negotiationSequence) return false;\n self.clearKeyboardProtocolNegotiationBuffer();\n if (negotiationSequence.type === \"kitty-flags\") {\n if (negotiationSequence.flags !== 0) {\n self.disableModifyOtherKeys();\n if (!self._kittyProtocolActive) {\n self._kittyProtocolActive = true;\n setKittyProtocolActive(true);\n }\n } else {\n self.enableModifyOtherKeys();\n }\n return true;\n }\n\n if (!self._kittyProtocolActive) {\n self.enableModifyOtherKeys();\n }\n return true;\n}\n\nexport function do_readKeyboardProtocolNegotiationSequence(\n self: ProcessTerminal,\n sequence: string,\n): KeyboardProtocolNegotiationSequence | \"pending\" | undefined {\n if (self.keyboardProtocolNegotiationBuffer) {\n const bufferedSequence = self.keyboardProtocolNegotiationBuffer + sequence;\n const negotiationSequence = parseKeyboardProtocolNegotiationSequence(bufferedSequence);\n if (negotiationSequence) {\n self.clearKeyboardProtocolNegotiationBuffer();\n return negotiationSequence;\n }\n if (isKeyboardProtocolNegotiationSequencePrefix(bufferedSequence)) {\n self.setKeyboardProtocolNegotiationBuffer(bufferedSequence);\n return \"pending\";\n }\n self.flushKeyboardProtocolNegotiationBufferAsInput();\n }\n\n const negotiationSequence = parseKeyboardProtocolNegotiationSequence(sequence);\n if (negotiationSequence) return negotiationSequence;\n if (isKeyboardProtocolNegotiationSequencePrefix(sequence)) {\n self.setKeyboardProtocolNegotiationBuffer(sequence);\n return \"pending\";\n }\n return undefined;\n}\n\nexport function do_setKeyboardProtocolNegotiationBuffer(self: ProcessTerminal, sequence: string): void {\n self.clearKeyboardProtocolNegotiationBufferFlushTimer();\n self.keyboardProtocolNegotiationBuffer = sequence;\n}\n\nexport function do_clearKeyboardProtocolNegotiationBuffer(self: ProcessTerminal): void {\n self.clearKeyboardProtocolNegotiationBufferFlushTimer();\n self.keyboardProtocolNegotiationBuffer = \"\";\n}\n\nexport function do_flushKeyboardProtocolNegotiationBufferAsInput(self: ProcessTerminal): void {\n if (!self.keyboardProtocolNegotiationBuffer) return;\n const sequence = self.keyboardProtocolNegotiationBuffer;\n self.clearKeyboardProtocolNegotiationBuffer();\n self.forwardInputSequence(sequence);\n}\n\nexport function do_scheduleKeyboardProtocolNegotiationBufferFlush(self: ProcessTerminal): void {\n if (!self.keyboardProtocolNegotiationBuffer || self.keyboardProtocolBufferFlushTimer) return;\n self.keyboardProtocolBufferFlushTimer = setTimeout(() => {\n self.keyboardProtocolBufferFlushTimer = undefined;\n self.flushKeyboardProtocolNegotiationBufferAsInput();\n }, KEYBOARD_PROTOCOL_RESPONSE_FRAGMENT_TIMEOUT_MS);\n}\n\nexport function do_clearKeyboardProtocolNegotiationBufferFlushTimer(self: ProcessTerminal): void {\n if (!self.keyboardProtocolBufferFlushTimer) return;\n clearTimeout(self.keyboardProtocolBufferFlushTimer);\n self.keyboardProtocolBufferFlushTimer = undefined;\n}\n\nexport function do_forwardInputSequence(self: ProcessTerminal, sequence: string): void {\n if (!self.inputHandler) return;\n const isAppleTerminal = sequence === \"\\r\" && isAppleTerminalSession();\n const input = normalizeAppleTerminalInput(\n sequence,\n isAppleTerminal,\n isAppleTerminal && isNativeModifierPressed(\"shift\"),\n );\n self.inputHandler(input);\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import type { ProcessTerminal } from "../processterminal.ts";
2
+ export declare function do_enableModifyOtherKeys(self: ProcessTerminal): void;
3
+ export declare function do_disableModifyOtherKeys(self: ProcessTerminal): void;
4
+ export declare function do_enableWindowsVTInput(_self: ProcessTerminal): void;
5
+ export declare function do_drainInput(self: ProcessTerminal, maxMs?: number, idleMs?: number): Promise<void>;
6
+ export declare function do_stop(self: ProcessTerminal): void;
7
+ export declare function do_write(self: ProcessTerminal, data: string): void;
8
+ export declare function do_moveBy(_self: ProcessTerminal, lines: number): void;
9
+ //# sourceMappingURL=terminal-io.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"terminal-io.d.ts","sourceRoot":"","sources":["../../../src/terminal/processterminal-methods/terminal-io.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,CAIpE;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,CAIrE;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CA4BpE;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,eAAe,EAAE,KAAK,SAAO,EAAE,MAAM,SAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAwCnG;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,CAiDnD;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CASlE;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CASrE","sourcesContent":["import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { setKittyProtocolActive } from \"../../keys.ts\";\nimport { cjsRequire, TERMINAL_PROGRESS_CLEAR_SEQUENCE } from \"../constants.ts\";\nimport type { ProcessTerminal } from \"../processterminal.ts\";\n\nexport function do_enableModifyOtherKeys(self: ProcessTerminal): void {\n if (self._kittyProtocolActive || self._modifyOtherKeysActive) return;\n process.stdout.write(\"\\x1b[>4;2m\");\n self._modifyOtherKeysActive = true;\n}\n\nexport function do_disableModifyOtherKeys(self: ProcessTerminal): void {\n if (!self._modifyOtherKeysActive) return;\n process.stdout.write(\"\\x1b[>4;0m\");\n self._modifyOtherKeysActive = false;\n}\n\nexport function do_enableWindowsVTInput(_self: ProcessTerminal): void {\n if (process.platform !== \"win32\") return;\n try {\n const arch = process.arch;\n if (arch !== \"x64\" && arch !== \"arm64\") return;\n\n // Dynamic require so non-Windows and bundled/browser paths never load the\n // native helper. In the npm package native/ is next to dist/; in compiled\n // binary archives native/ is copied next to the executable.\n const moduleDir = path.dirname(fileURLToPath(import.meta.url));\n const nativePath = path.join(\"native\", \"win32\", \"prebuilds\", `win32-${arch}`, \"win32-console-mode.node\");\n const candidates = [\n path.join(moduleDir, \"..\", nativePath),\n path.join(moduleDir, nativePath),\n path.join(path.dirname(process.execPath), nativePath),\n ];\n for (const modulePath of candidates) {\n try {\n const helper = cjsRequire(modulePath) as { enableVirtualTerminalInput?: () => boolean };\n helper.enableVirtualTerminalInput?.();\n return;\n } catch {\n // Try the next possible packaging location.\n }\n }\n } catch {\n // Native helper not available — Shift+Tab won't be distinguishable from Tab.\n }\n}\n\nexport async function do_drainInput(self: ProcessTerminal, maxMs = 1000, idleMs = 50): Promise<void> {\n self.setMouseTracking(false);\n const shouldDisableKittyProtocol = self.keyboardProtocolPushed || self._kittyProtocolActive;\n self.clearKeyboardProtocolNegotiationBuffer();\n if (shouldDisableKittyProtocol) {\n // Disable Kitty keyboard protocol first so any late key releases\n // do not generate new Kitty escape sequences.\n process.stdout.write(\"\\x1b[<u\");\n self.keyboardProtocolPushed = false;\n self._kittyProtocolActive = false;\n setKittyProtocolActive(false);\n }\n self.disableModifyOtherKeys();\n\n const previousHandler = self.inputHandler;\n self.inputHandler = undefined;\n\n let lastDataTime = Date.now();\n const onData = () => {\n lastDataTime = Date.now();\n };\n\n process.stdin.on(\"data\", onData);\n const endTime = Date.now() + maxMs;\n\n const check = async (): Promise<void> => {\n const now = Date.now();\n const timeLeft = endTime - now;\n if (timeLeft <= 0) return;\n if (now - lastDataTime >= idleMs) return;\n await new Promise((resolve) => setTimeout(resolve, Math.min(idleMs, timeLeft)));\n return check();\n };\n\n try {\n await check();\n } finally {\n process.stdin.removeListener(\"data\", onData);\n self.inputHandler = previousHandler;\n }\n}\n\nexport function do_stop(self: ProcessTerminal): void {\n if (self.clearProgressInterval()) {\n process.stdout.write(TERMINAL_PROGRESS_CLEAR_SEQUENCE);\n }\n\n self.setMouseTracking(false);\n\n // Disable bracketed paste mode\n process.stdout.write(\"\\x1b[?2004l\");\n\n const shouldDisableKittyProtocol = self.keyboardProtocolPushed || self._kittyProtocolActive;\n self.clearKeyboardProtocolNegotiationBuffer();\n\n /* c8 ignore stop */\n // Disable Kitty keyboard protocol if not already done by drainInput()\n if (shouldDisableKittyProtocol) {\n process.stdout.write(\"\\x1b[<u\");\n self.keyboardProtocolPushed = false;\n self._kittyProtocolActive = false;\n setKittyProtocolActive(false);\n }\n self.disableModifyOtherKeys();\n\n // Clean up StdinBuffer\n if (self.stdinBuffer) {\n self.stdinBuffer.destroy();\n self.stdinBuffer = undefined;\n }\n\n // Remove event handlers\n if (self.stdinDataHandler) {\n process.stdin.removeListener(\"data\", self.stdinDataHandler);\n self.stdinDataHandler = undefined;\n }\n self.inputHandler = undefined;\n if (self.resizeHandler) {\n process.stdout.removeListener(\"resize\", self.resizeHandler);\n self.resizeHandler = undefined;\n }\n\n // Pause stdin to prevent any buffered input (e.g., Ctrl+D) from being\n // re-interpreted after raw mode is disabled. This fixes a race condition\n // where Ctrl+D could close the parent shell over SSH.\n process.stdin.pause();\n\n // Restore raw mode state\n if (process.stdin.setRawMode) {\n process.stdin.setRawMode(self.wasRaw);\n }\n}\n\nexport function do_write(self: ProcessTerminal, data: string): void {\n process.stdout.write(data);\n if (self.writeLogPath) {\n try {\n fs.appendFileSync(self.writeLogPath, data, { encoding: \"utf8\" });\n } catch {\n // Ignore logging errors\n }\n }\n}\n\nexport function do_moveBy(_self: ProcessTerminal, lines: number): void {\n if (lines > 0) {\n // Move down\n process.stdout.write(`\\x1b[${lines}B`);\n } else if (lines < 0) {\n // Move up\n process.stdout.write(`\\x1b[${-lines}A`);\n }\n // lines === 0: no movement\n}\n"]}
@@ -0,0 +1,153 @@
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { setKittyProtocolActive } from "../../keys.js";
5
+ import { cjsRequire, TERMINAL_PROGRESS_CLEAR_SEQUENCE } from "../constants.js";
6
+ export function do_enableModifyOtherKeys(self) {
7
+ if (self._kittyProtocolActive || self._modifyOtherKeysActive)
8
+ return;
9
+ process.stdout.write("\x1b[>4;2m");
10
+ self._modifyOtherKeysActive = true;
11
+ }
12
+ export function do_disableModifyOtherKeys(self) {
13
+ if (!self._modifyOtherKeysActive)
14
+ return;
15
+ process.stdout.write("\x1b[>4;0m");
16
+ self._modifyOtherKeysActive = false;
17
+ }
18
+ export function do_enableWindowsVTInput(_self) {
19
+ if (process.platform !== "win32")
20
+ return;
21
+ try {
22
+ const arch = process.arch;
23
+ if (arch !== "x64" && arch !== "arm64")
24
+ return;
25
+ // Dynamic require so non-Windows and bundled/browser paths never load the
26
+ // native helper. In the npm package native/ is next to dist/; in compiled
27
+ // binary archives native/ is copied next to the executable.
28
+ const moduleDir = path.dirname(fileURLToPath(import.meta.url));
29
+ const nativePath = path.join("native", "win32", "prebuilds", `win32-${arch}`, "win32-console-mode.node");
30
+ const candidates = [
31
+ path.join(moduleDir, "..", nativePath),
32
+ path.join(moduleDir, nativePath),
33
+ path.join(path.dirname(process.execPath), nativePath),
34
+ ];
35
+ for (const modulePath of candidates) {
36
+ try {
37
+ const helper = cjsRequire(modulePath);
38
+ helper.enableVirtualTerminalInput?.();
39
+ return;
40
+ }
41
+ catch {
42
+ // Try the next possible packaging location.
43
+ }
44
+ }
45
+ }
46
+ catch {
47
+ // Native helper not available — Shift+Tab won't be distinguishable from Tab.
48
+ }
49
+ }
50
+ export async function do_drainInput(self, maxMs = 1000, idleMs = 50) {
51
+ self.setMouseTracking(false);
52
+ const shouldDisableKittyProtocol = self.keyboardProtocolPushed || self._kittyProtocolActive;
53
+ self.clearKeyboardProtocolNegotiationBuffer();
54
+ if (shouldDisableKittyProtocol) {
55
+ // Disable Kitty keyboard protocol first so any late key releases
56
+ // do not generate new Kitty escape sequences.
57
+ process.stdout.write("\x1b[<u");
58
+ self.keyboardProtocolPushed = false;
59
+ self._kittyProtocolActive = false;
60
+ setKittyProtocolActive(false);
61
+ }
62
+ self.disableModifyOtherKeys();
63
+ const previousHandler = self.inputHandler;
64
+ self.inputHandler = undefined;
65
+ let lastDataTime = Date.now();
66
+ const onData = () => {
67
+ lastDataTime = Date.now();
68
+ };
69
+ process.stdin.on("data", onData);
70
+ const endTime = Date.now() + maxMs;
71
+ const check = async () => {
72
+ const now = Date.now();
73
+ const timeLeft = endTime - now;
74
+ if (timeLeft <= 0)
75
+ return;
76
+ if (now - lastDataTime >= idleMs)
77
+ return;
78
+ await new Promise((resolve) => setTimeout(resolve, Math.min(idleMs, timeLeft)));
79
+ return check();
80
+ };
81
+ try {
82
+ await check();
83
+ }
84
+ finally {
85
+ process.stdin.removeListener("data", onData);
86
+ self.inputHandler = previousHandler;
87
+ }
88
+ }
89
+ export function do_stop(self) {
90
+ if (self.clearProgressInterval()) {
91
+ process.stdout.write(TERMINAL_PROGRESS_CLEAR_SEQUENCE);
92
+ }
93
+ self.setMouseTracking(false);
94
+ // Disable bracketed paste mode
95
+ process.stdout.write("\x1b[?2004l");
96
+ const shouldDisableKittyProtocol = self.keyboardProtocolPushed || self._kittyProtocolActive;
97
+ self.clearKeyboardProtocolNegotiationBuffer();
98
+ /* c8 ignore stop */
99
+ // Disable Kitty keyboard protocol if not already done by drainInput()
100
+ if (shouldDisableKittyProtocol) {
101
+ process.stdout.write("\x1b[<u");
102
+ self.keyboardProtocolPushed = false;
103
+ self._kittyProtocolActive = false;
104
+ setKittyProtocolActive(false);
105
+ }
106
+ self.disableModifyOtherKeys();
107
+ // Clean up StdinBuffer
108
+ if (self.stdinBuffer) {
109
+ self.stdinBuffer.destroy();
110
+ self.stdinBuffer = undefined;
111
+ }
112
+ // Remove event handlers
113
+ if (self.stdinDataHandler) {
114
+ process.stdin.removeListener("data", self.stdinDataHandler);
115
+ self.stdinDataHandler = undefined;
116
+ }
117
+ self.inputHandler = undefined;
118
+ if (self.resizeHandler) {
119
+ process.stdout.removeListener("resize", self.resizeHandler);
120
+ self.resizeHandler = undefined;
121
+ }
122
+ // Pause stdin to prevent any buffered input (e.g., Ctrl+D) from being
123
+ // re-interpreted after raw mode is disabled. This fixes a race condition
124
+ // where Ctrl+D could close the parent shell over SSH.
125
+ process.stdin.pause();
126
+ // Restore raw mode state
127
+ if (process.stdin.setRawMode) {
128
+ process.stdin.setRawMode(self.wasRaw);
129
+ }
130
+ }
131
+ export function do_write(self, data) {
132
+ process.stdout.write(data);
133
+ if (self.writeLogPath) {
134
+ try {
135
+ fs.appendFileSync(self.writeLogPath, data, { encoding: "utf8" });
136
+ }
137
+ catch {
138
+ // Ignore logging errors
139
+ }
140
+ }
141
+ }
142
+ export function do_moveBy(_self, lines) {
143
+ if (lines > 0) {
144
+ // Move down
145
+ process.stdout.write(`\x1b[${lines}B`);
146
+ }
147
+ else if (lines < 0) {
148
+ // Move up
149
+ process.stdout.write(`\x1b[${-lines}A`);
150
+ }
151
+ // lines === 0: no movement
152
+ }
153
+ //# sourceMappingURL=terminal-io.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"terminal-io.js","sourceRoot":"","sources":["../../../src/terminal/processterminal-methods/terminal-io.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,sBAAsB,E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AAC;IAC3B,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;QACtB,IAAI,CAAC;YACH,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;QACnE,CAAC;QAAC,MAAM,CAAC;YACP,wBAAwB;QAC1B,CAAC;IACH,CAAC;AAAA,CACF;AAED,MAAM,UAAU,SAAS,CAAC,KAAsB,EAAE,KAAa,EAAQ;IACrE,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACd,YAAY;QACZ,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,KAAK,GAAG,CAAC,CAAC;IACzC,CAAC;SAAM,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACrB,UAAU;QACV,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC;IAC1C,CAAC;IACD,2BAA2B;AAD1B,CAEF","sourcesContent":["import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { setKittyProtocolActive } from \"../../keys.ts\";\nimport { cjsRequire, TERMINAL_PROGRESS_CLEAR_SEQUENCE } from \"../constants.ts\";\nimport type { ProcessTerminal } from \"../processterminal.ts\";\n\nexport function do_enableModifyOtherKeys(self: ProcessTerminal): void {\n if (self._kittyProtocolActive || self._modifyOtherKeysActive) return;\n process.stdout.write(\"\\x1b[>4;2m\");\n self._modifyOtherKeysActive = true;\n}\n\nexport function do_disableModifyOtherKeys(self: ProcessTerminal): void {\n if (!self._modifyOtherKeysActive) return;\n process.stdout.write(\"\\x1b[>4;0m\");\n self._modifyOtherKeysActive = false;\n}\n\nexport function do_enableWindowsVTInput(_self: ProcessTerminal): void {\n if (process.platform !== \"win32\") return;\n try {\n const arch = process.arch;\n if (arch !== \"x64\" && arch !== \"arm64\") return;\n\n // Dynamic require so non-Windows and bundled/browser paths never load the\n // native helper. In the npm package native/ is next to dist/; in compiled\n // binary archives native/ is copied next to the executable.\n const moduleDir = path.dirname(fileURLToPath(import.meta.url));\n const nativePath = path.join(\"native\", \"win32\", \"prebuilds\", `win32-${arch}`, \"win32-console-mode.node\");\n const candidates = [\n path.join(moduleDir, \"..\", nativePath),\n path.join(moduleDir, nativePath),\n path.join(path.dirname(process.execPath), nativePath),\n ];\n for (const modulePath of candidates) {\n try {\n const helper = cjsRequire(modulePath) as { enableVirtualTerminalInput?: () => boolean };\n helper.enableVirtualTerminalInput?.();\n return;\n } catch {\n // Try the next possible packaging location.\n }\n }\n } catch {\n // Native helper not available — Shift+Tab won't be distinguishable from Tab.\n }\n}\n\nexport async function do_drainInput(self: ProcessTerminal, maxMs = 1000, idleMs = 50): Promise<void> {\n self.setMouseTracking(false);\n const shouldDisableKittyProtocol = self.keyboardProtocolPushed || self._kittyProtocolActive;\n self.clearKeyboardProtocolNegotiationBuffer();\n if (shouldDisableKittyProtocol) {\n // Disable Kitty keyboard protocol first so any late key releases\n // do not generate new Kitty escape sequences.\n process.stdout.write(\"\\x1b[<u\");\n self.keyboardProtocolPushed = false;\n self._kittyProtocolActive = false;\n setKittyProtocolActive(false);\n }\n self.disableModifyOtherKeys();\n\n const previousHandler = self.inputHandler;\n self.inputHandler = undefined;\n\n let lastDataTime = Date.now();\n const onData = () => {\n lastDataTime = Date.now();\n };\n\n process.stdin.on(\"data\", onData);\n const endTime = Date.now() + maxMs;\n\n const check = async (): Promise<void> => {\n const now = Date.now();\n const timeLeft = endTime - now;\n if (timeLeft <= 0) return;\n if (now - lastDataTime >= idleMs) return;\n await new Promise((resolve) => setTimeout(resolve, Math.min(idleMs, timeLeft)));\n return check();\n };\n\n try {\n await check();\n } finally {\n process.stdin.removeListener(\"data\", onData);\n self.inputHandler = previousHandler;\n }\n}\n\nexport function do_stop(self: ProcessTerminal): void {\n if (self.clearProgressInterval()) {\n process.stdout.write(TERMINAL_PROGRESS_CLEAR_SEQUENCE);\n }\n\n self.setMouseTracking(false);\n\n // Disable bracketed paste mode\n process.stdout.write(\"\\x1b[?2004l\");\n\n const shouldDisableKittyProtocol = self.keyboardProtocolPushed || self._kittyProtocolActive;\n self.clearKeyboardProtocolNegotiationBuffer();\n\n /* c8 ignore stop */\n // Disable Kitty keyboard protocol if not already done by drainInput()\n if (shouldDisableKittyProtocol) {\n process.stdout.write(\"\\x1b[<u\");\n self.keyboardProtocolPushed = false;\n self._kittyProtocolActive = false;\n setKittyProtocolActive(false);\n }\n self.disableModifyOtherKeys();\n\n // Clean up StdinBuffer\n if (self.stdinBuffer) {\n self.stdinBuffer.destroy();\n self.stdinBuffer = undefined;\n }\n\n // Remove event handlers\n if (self.stdinDataHandler) {\n process.stdin.removeListener(\"data\", self.stdinDataHandler);\n self.stdinDataHandler = undefined;\n }\n self.inputHandler = undefined;\n if (self.resizeHandler) {\n process.stdout.removeListener(\"resize\", self.resizeHandler);\n self.resizeHandler = undefined;\n }\n\n // Pause stdin to prevent any buffered input (e.g., Ctrl+D) from being\n // re-interpreted after raw mode is disabled. This fixes a race condition\n // where Ctrl+D could close the parent shell over SSH.\n process.stdin.pause();\n\n // Restore raw mode state\n if (process.stdin.setRawMode) {\n process.stdin.setRawMode(self.wasRaw);\n }\n}\n\nexport function do_write(self: ProcessTerminal, data: string): void {\n process.stdout.write(data);\n if (self.writeLogPath) {\n try {\n fs.appendFileSync(self.writeLogPath, data, { encoding: \"utf8\" });\n } catch {\n // Ignore logging errors\n }\n }\n}\n\nexport function do_moveBy(_self: ProcessTerminal, lines: number): void {\n if (lines > 0) {\n // Move down\n process.stdout.write(`\\x1b[${lines}B`);\n } else if (lines < 0) {\n // Move up\n process.stdout.write(`\\x1b[${-lines}A`);\n }\n // lines === 0: no movement\n}\n"]}
@@ -0,0 +1,49 @@
1
+ import type { StdinBuffer } from "../stdin-buffer.ts";
2
+ import type { KeyboardProtocolNegotiationSequence, Terminal } from "./types.ts";
3
+ export declare class ProcessTerminal implements Terminal {
4
+ wasRaw: boolean;
5
+ inputHandler?: (data: string) => void;
6
+ resizeHandler?: () => void;
7
+ _kittyProtocolActive: boolean;
8
+ _modifyOtherKeysActive: boolean;
9
+ keyboardProtocolPushed: boolean;
10
+ keyboardProtocolNegotiationBuffer: string;
11
+ keyboardProtocolBufferFlushTimer?: ReturnType<typeof setTimeout>;
12
+ stdinBuffer?: StdinBuffer;
13
+ stdinDataHandler?: (data: string) => void;
14
+ progressInterval?: ReturnType<typeof setInterval>;
15
+ mouseTrackingActive: boolean;
16
+ writeLogPath: string;
17
+ get kittyProtocolActive(): boolean;
18
+ get modifyOtherKeysActive(): boolean;
19
+ get columns(): number;
20
+ get rows(): number;
21
+ start(onInput: (data: string) => void, onResize: () => void): void;
22
+ setupStdinBuffer(): void;
23
+ queryAndEnableKittyProtocol(): void;
24
+ handleKeyboardProtocolNegotiationSequence(negotiationSequence: KeyboardProtocolNegotiationSequence | undefined): boolean;
25
+ readKeyboardProtocolNegotiationSequence(sequence: string): KeyboardProtocolNegotiationSequence | "pending" | undefined;
26
+ setKeyboardProtocolNegotiationBuffer(sequence: string): void;
27
+ clearKeyboardProtocolNegotiationBuffer(): void;
28
+ flushKeyboardProtocolNegotiationBufferAsInput(): void;
29
+ scheduleKeyboardProtocolNegotiationBufferFlush(): void;
30
+ clearKeyboardProtocolNegotiationBufferFlushTimer(): void;
31
+ forwardInputSequence(sequence: string): void;
32
+ enableModifyOtherKeys(): void;
33
+ disableModifyOtherKeys(): void;
34
+ enableWindowsVTInput(): void;
35
+ drainInput(maxMs?: number, idleMs?: number): Promise<void>;
36
+ stop(): void;
37
+ write(data: string): void;
38
+ moveBy(lines: number): void;
39
+ hideCursor(): void;
40
+ showCursor(): void;
41
+ clearLine(): void;
42
+ clearFromCursor(): void;
43
+ clearScreen(): void;
44
+ setTitle(title: string): void;
45
+ setProgress(active: boolean): void;
46
+ setMouseTracking(active: boolean): void;
47
+ clearProgressInterval(): boolean;
48
+ }
49
+ //# sourceMappingURL=processterminal.d.ts.map
@@ -0,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oC,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAE3D;IAED,sCAAsC,IAAI,IAAI,CAE7C;IAED,6CAA6C,IAAI,IAAI,CAEpD;IAED,8CAA8C,IAAI,IAAI,CAErD;IAED,gDAAgD,IAAI,IAAI,CAEvD;IAED,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAE3C;IAED,qBAAqB,IAAI,IAAI,CAE5B;IAED,sBAAsB,IAAI,IAAI,CAE7B;IAED,oBAAoB,IAAI,IAAI,CAE3B;IAEK,UAAU,CAAC,KAAK,SAAO,EAAE,MAAM,SAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAEzD;IAED,IAAI,IAAI,IAAI,CAEX;IAED,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAExB;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAE1B;IAED,UAAU,IAAI,IAAI,CAEjB;IAED,UAAU,IAAI,IAAI,CAEjB;IAED,SAAS,IAAI,IAAI,CAEhB;IAED,eAAe,IAAI,IAAI,CAEtB;IAED,WAAW,IAAI,IAAI,CAElB;IAED,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAE5B;IAED,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAEjC;IAED,gBAAgB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAEtC;IAED,qBAAqB,IAAI,OAAO,CAE/B;CACF","sourcesContent":["import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport type { StdinBuffer } from \"../stdin-buffer.ts\";\nimport {\n do_clearFromCursor,\n do_clearLine,\n do_clearProgressInterval,\n do_clearScreen,\n do_hideCursor,\n do_setMouseTracking,\n do_setProgress,\n do_setTitle,\n do_showCursor,\n} from \"./processterminal-methods/cursor-screen.ts\";\nimport {\n do_clearKeyboardProtocolNegotiationBuffer,\n do_clearKeyboardProtocolNegotiationBufferFlushTimer,\n do_flushKeyboardProtocolNegotiationBufferAsInput,\n do_forwardInputSequence,\n do_handleKeyboardProtocolNegotiationSequence,\n do_queryAndEnableKittyProtocol,\n do_readKeyboardProtocolNegotiationSequence,\n do_scheduleKeyboardProtocolNegotiationBufferFlush,\n do_setKeyboardProtocolNegotiationBuffer,\n do_setupStdinBuffer,\n do_start,\n} from \"./processterminal-methods/keyboard-protocol.ts\";\nimport {\n do_disableModifyOtherKeys,\n do_drainInput,\n do_enableModifyOtherKeys,\n do_enableWindowsVTInput,\n do_moveBy,\n do_stop,\n do_write,\n} from \"./processterminal-methods/terminal-io.ts\";\nimport type { KeyboardProtocolNegotiationSequence, Terminal } from \"./types.ts\";\n\nexport class ProcessTerminal implements Terminal {\n public wasRaw = false;\n\n public inputHandler?: (data: string) => void;\n\n public resizeHandler?: () => void;\n\n public _kittyProtocolActive = false;\n\n public _modifyOtherKeysActive = false;\n\n public keyboardProtocolPushed = false;\n\n public keyboardProtocolNegotiationBuffer = \"\";\n\n public keyboardProtocolBufferFlushTimer?: ReturnType<typeof setTimeout>;\n\n public stdinBuffer?: StdinBuffer;\n\n public stdinDataHandler?: (data: string) => void;\n\n public progressInterval?: ReturnType<typeof setInterval>;\n\n public mouseTrackingActive = false;\n\n public writeLogPath = (() => {\n const env = process.env.PI_TUI_WRITE_LOG || \"\";\n if (!env) return \"\";\n try {\n if (fs.statSync(env).isDirectory()) {\n const now = new Date();\n const ts = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, \"0\")}-${String(now.getDate()).padStart(2, \"0\")}_${String(now.getHours()).padStart(2, \"0\")}-${String(now.getMinutes()).padStart(2, \"0\")}-${String(now.getSeconds()).padStart(2, \"0\")}`;\n return path.join(env, `tui-${ts}-${process.pid}.log`);\n }\n } catch {\n // Not an existing directory - use as-is (file path)\n }\n return env;\n })();\n\n get kittyProtocolActive(): boolean {\n return this._kittyProtocolActive;\n }\n\n get modifyOtherKeysActive(): boolean {\n return this._modifyOtherKeysActive;\n }\n\n get columns(): number {\n return process.stdout.columns || Number(process.env.COLUMNS) || 80;\n }\n\n get rows(): number {\n return process.stdout.rows || Number(process.env.LINES) || 24;\n }\n\n start(onInput: (data: string) => void, onResize: () => void): void {\n do_start(this, onInput, onResize);\n }\n\n setupStdinBuffer(): void {\n do_setupStdinBuffer(this);\n }\n\n queryAndEnableKittyProtocol(): void {\n do_queryAndEnableKittyProtocol(this);\n }\n\n handleKeyboardProtocolNegotiationSequence(\n negotiationSequence: KeyboardProtocolNegotiationSequence | undefined,\n ): boolean {\n return do_handleKeyboardProtocolNegotiationSequence(this, negotiationSequence);\n }\n\n readKeyboardProtocolNegotiationSequence(\n sequence: string,\n ): KeyboardProtocolNegotiationSequence | \"pending\" | undefined {\n return do_readKeyboardProtocolNegotiationSequence(this, sequence);\n }\n\n setKeyboardProtocolNegotiationBuffer(sequence: string): void {\n do_setKeyboardProtocolNegotiationBuffer(this, sequence);\n }\n\n clearKeyboardProtocolNegotiationBuffer(): void {\n do_clearKeyboardProtocolNegotiationBuffer(this);\n }\n\n flushKeyboardProtocolNegotiationBufferAsInput(): void {\n do_flushKeyboardProtocolNegotiationBufferAsInput(this);\n }\n\n scheduleKeyboardProtocolNegotiationBufferFlush(): void {\n do_scheduleKeyboardProtocolNegotiationBufferFlush(this);\n }\n\n clearKeyboardProtocolNegotiationBufferFlushTimer(): void {\n do_clearKeyboardProtocolNegotiationBufferFlushTimer(this);\n }\n\n forwardInputSequence(sequence: string): void {\n do_forwardInputSequence(this, sequence);\n }\n\n enableModifyOtherKeys(): void {\n do_enableModifyOtherKeys(this);\n }\n\n disableModifyOtherKeys(): void {\n do_disableModifyOtherKeys(this);\n }\n\n enableWindowsVTInput(): void {\n do_enableWindowsVTInput(this);\n }\n\n async drainInput(maxMs = 1000, idleMs = 50): Promise<void> {\n return do_drainInput(this, maxMs, idleMs);\n }\n\n stop(): void {\n do_stop(this);\n }\n\n write(data: string): void {\n do_write(this, data);\n }\n\n moveBy(lines: number): void {\n do_moveBy(this, lines);\n }\n\n hideCursor(): void {\n do_hideCursor(this);\n }\n\n showCursor(): void {\n do_showCursor(this);\n }\n\n clearLine(): void {\n do_clearLine(this);\n }\n\n clearFromCursor(): void {\n do_clearFromCursor(this);\n }\n\n clearScreen(): void {\n do_clearScreen(this);\n }\n\n setTitle(title: string): void {\n do_setTitle(this, title);\n }\n\n setProgress(active: boolean): void {\n do_setProgress(this, active);\n }\n\n setMouseTracking(active: boolean): void {\n do_setMouseTracking(this, active);\n }\n\n clearProgressInterval(): boolean {\n return do_clearProgressInterval(this);\n }\n}\n"]}
@@ -0,0 +1,129 @@
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+ import { do_clearFromCursor, do_clearLine, do_clearProgressInterval, do_clearScreen, do_hideCursor, do_setMouseTracking, do_setProgress, do_setTitle, do_showCursor, } from "./processterminal-methods/cursor-screen.js";
4
+ import { do_clearKeyboardProtocolNegotiationBuffer, do_clearKeyboardProtocolNegotiationBufferFlushTimer, do_flushKeyboardProtocolNegotiationBufferAsInput, do_forwardInputSequence, do_handleKeyboardProtocolNegotiationSequence, do_queryAndEnableKittyProtocol, do_readKeyboardProtocolNegotiationSequence, do_scheduleKeyboardProtocolNegotiationBufferFlush, do_setKeyboardProtocolNegotiationBuffer, do_setupStdinBuffer, do_start, } from "./processterminal-methods/keyboard-protocol.js";
5
+ import { do_disableModifyOtherKeys, do_drainInput, do_enableModifyOtherKeys, do_enableWindowsVTInput, do_moveBy, do_stop, do_write, } from "./processterminal-methods/terminal-io.js";
6
+ export class ProcessTerminal {
7
+ wasRaw = false;
8
+ inputHandler;
9
+ resizeHandler;
10
+ _kittyProtocolActive = false;
11
+ _modifyOtherKeysActive = false;
12
+ keyboardProtocolPushed = false;
13
+ keyboardProtocolNegotiationBuffer = "";
14
+ keyboardProtocolBufferFlushTimer;
15
+ stdinBuffer;
16
+ stdinDataHandler;
17
+ progressInterval;
18
+ mouseTrackingActive = false;
19
+ writeLogPath = (() => {
20
+ const env = process.env.PI_TUI_WRITE_LOG || "";
21
+ if (!env)
22
+ return "";
23
+ try {
24
+ if (fs.statSync(env).isDirectory()) {
25
+ const now = new Date();
26
+ const ts = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, "0")}-${String(now.getDate()).padStart(2, "0")}_${String(now.getHours()).padStart(2, "0")}-${String(now.getMinutes()).padStart(2, "0")}-${String(now.getSeconds()).padStart(2, "0")}`;
27
+ return path.join(env, `tui-${ts}-${process.pid}.log`);
28
+ }
29
+ }
30
+ catch {
31
+ // Not an existing directory - use as-is (file path)
32
+ }
33
+ return env;
34
+ })();
35
+ get kittyProtocolActive() {
36
+ return this._kittyProtocolActive;
37
+ }
38
+ get modifyOtherKeysActive() {
39
+ return this._modifyOtherKeysActive;
40
+ }
41
+ get columns() {
42
+ return process.stdout.columns || Number(process.env.COLUMNS) || 80;
43
+ }
44
+ get rows() {
45
+ return process.stdout.rows || Number(process.env.LINES) || 24;
46
+ }
47
+ start(onInput, onResize) {
48
+ do_start(this, onInput, onResize);
49
+ }
50
+ setupStdinBuffer() {
51
+ do_setupStdinBuffer(this);
52
+ }
53
+ queryAndEnableKittyProtocol() {
54
+ do_queryAndEnableKittyProtocol(this);
55
+ }
56
+ handleKeyboardProtocolNegotiationSequence(negotiationSequence) {
57
+ return do_handleKeyboardProtocolNegotiationSequence(this, negotiationSequence);
58
+ }
59
+ readKeyboardProtocolNegotiationSequence(sequence) {
60
+ return do_readKeyboardProtocolNegotiationSequence(this, sequence);
61
+ }
62
+ setKeyboardProtocolNegotiationBuffer(sequence) {
63
+ do_setKeyboardProtocolNegotiationBuffer(this, sequence);
64
+ }
65
+ clearKeyboardProtocolNegotiationBuffer() {
66
+ do_clearKeyboardProtocolNegotiationBuffer(this);
67
+ }
68
+ flushKeyboardProtocolNegotiationBufferAsInput() {
69
+ do_flushKeyboardProtocolNegotiationBufferAsInput(this);
70
+ }
71
+ scheduleKeyboardProtocolNegotiationBufferFlush() {
72
+ do_scheduleKeyboardProtocolNegotiationBufferFlush(this);
73
+ }
74
+ clearKeyboardProtocolNegotiationBufferFlushTimer() {
75
+ do_clearKeyboardProtocolNegotiationBufferFlushTimer(this);
76
+ }
77
+ forwardInputSequence(sequence) {
78
+ do_forwardInputSequence(this, sequence);
79
+ }
80
+ enableModifyOtherKeys() {
81
+ do_enableModifyOtherKeys(this);
82
+ }
83
+ disableModifyOtherKeys() {
84
+ do_disableModifyOtherKeys(this);
85
+ }
86
+ enableWindowsVTInput() {
87
+ do_enableWindowsVTInput(this);
88
+ }
89
+ async drainInput(maxMs = 1000, idleMs = 50) {
90
+ return do_drainInput(this, maxMs, idleMs);
91
+ }
92
+ stop() {
93
+ do_stop(this);
94
+ }
95
+ write(data) {
96
+ do_write(this, data);
97
+ }
98
+ moveBy(lines) {
99
+ do_moveBy(this, lines);
100
+ }
101
+ hideCursor() {
102
+ do_hideCursor(this);
103
+ }
104
+ showCursor() {
105
+ do_showCursor(this);
106
+ }
107
+ clearLine() {
108
+ do_clearLine(this);
109
+ }
110
+ clearFromCursor() {
111
+ do_clearFromCursor(this);
112
+ }
113
+ clearScreen() {
114
+ do_clearScreen(this);
115
+ }
116
+ setTitle(title) {
117
+ do_setTitle(this, title);
118
+ }
119
+ setProgress(active) {
120
+ do_setProgress(this, active);
121
+ }
122
+ setMouseTracking(active) {
123
+ do_setMouseTracking(this, active);
124
+ }
125
+ clearProgressInterval() {
126
+ return do_clearProgressInterval(this);
127
+ }
128
+ }
129
+ //# sourceMappingURL=processterminal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processterminal.js","sourceRoot":"","sources":["../../src/terminal/processterminal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,wBAAwB,EACxB,cAAc,EACd,aAAa,EACb,mBAAmB,EACnB,cAAc,EACd,WAAW,EACX,aAAa,GACd,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAC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,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAAA,CACxB;IAED,UAAU,GAAS;QACjB,aAAa,CAAC,IAAI,CAAC,CAAC;IAAA,CACrB;IAED,UAAU,GAAS;QACjB,aAAa,CAAC,IAAI,CAAC,CAAC;IAAA,CACrB;IAED,SAAS,GAAS;QAChB,YAAY,CAAC,IAAI,CAAC,CAAC;IAAA,CACpB;IAED,eAAe,GAAS;QACtB,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAAA,CAC1B;IAED,WAAW,GAAS;QAClB,cAAc,CAAC,IAAI,CAAC,CAAC;IAAA,CACtB;IAED,QAAQ,CAAC,KAAa,EAAQ;QAC5B,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAAA,CAC1B;IAED,WAAW,CAAC,MAAe,EAAQ;QACjC,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAAA,CAC9B;IAED,gBAAgB,CAAC,MAAe,EAAQ;QACtC,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAAA,CACnC;IAED,qBAAqB,GAAY;QAC/B,OAAO,wBAAwB,CAAC,IAAI,CAAC,CAAC;IAAA,CACvC;CACF","sourcesContent":["import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport type { StdinBuffer } from \"../stdin-buffer.ts\";\nimport {\n do_clearFromCursor,\n do_clearLine,\n do_clearProgressInterval,\n do_clearScreen,\n do_hideCursor,\n do_setMouseTracking,\n do_setProgress,\n do_setTitle,\n do_showCursor,\n} from \"./processterminal-methods/cursor-screen.ts\";\nimport {\n do_clearKeyboardProtocolNegotiationBuffer,\n do_clearKeyboardProtocolNegotiationBufferFlushTimer,\n do_flushKeyboardProtocolNegotiationBufferAsInput,\n do_forwardInputSequence,\n do_handleKeyboardProtocolNegotiationSequence,\n do_queryAndEnableKittyProtocol,\n do_readKeyboardProtocolNegotiationSequence,\n do_scheduleKeyboardProtocolNegotiationBufferFlush,\n do_setKeyboardProtocolNegotiationBuffer,\n do_setupStdinBuffer,\n do_start,\n} from \"./processterminal-methods/keyboard-protocol.ts\";\nimport {\n do_disableModifyOtherKeys,\n do_drainInput,\n do_enableModifyOtherKeys,\n do_enableWindowsVTInput,\n do_moveBy,\n do_stop,\n do_write,\n} from \"./processterminal-methods/terminal-io.ts\";\nimport type { KeyboardProtocolNegotiationSequence, Terminal } from \"./types.ts\";\n\nexport class ProcessTerminal implements Terminal {\n public wasRaw = false;\n\n public inputHandler?: (data: string) => void;\n\n public resizeHandler?: () => void;\n\n public _kittyProtocolActive = false;\n\n public _modifyOtherKeysActive = false;\n\n public keyboardProtocolPushed = false;\n\n public keyboardProtocolNegotiationBuffer = \"\";\n\n public keyboardProtocolBufferFlushTimer?: ReturnType<typeof setTimeout>;\n\n public stdinBuffer?: StdinBuffer;\n\n public stdinDataHandler?: (data: string) => void;\n\n public progressInterval?: ReturnType<typeof setInterval>;\n\n public mouseTrackingActive = false;\n\n public writeLogPath = (() => {\n const env = process.env.PI_TUI_WRITE_LOG || \"\";\n if (!env) return \"\";\n try {\n if (fs.statSync(env).isDirectory()) {\n const now = new Date();\n const ts = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, \"0\")}-${String(now.getDate()).padStart(2, \"0\")}_${String(now.getHours()).padStart(2, \"0\")}-${String(now.getMinutes()).padStart(2, \"0\")}-${String(now.getSeconds()).padStart(2, \"0\")}`;\n return path.join(env, `tui-${ts}-${process.pid}.log`);\n }\n } catch {\n // Not an existing directory - use as-is (file path)\n }\n return env;\n })();\n\n get kittyProtocolActive(): boolean {\n return this._kittyProtocolActive;\n }\n\n get modifyOtherKeysActive(): boolean {\n return this._modifyOtherKeysActive;\n }\n\n get columns(): number {\n return process.stdout.columns || Number(process.env.COLUMNS) || 80;\n }\n\n get rows(): number {\n return process.stdout.rows || Number(process.env.LINES) || 24;\n }\n\n start(onInput: (data: string) => void, onResize: () => void): void {\n do_start(this, onInput, onResize);\n }\n\n setupStdinBuffer(): void {\n do_setupStdinBuffer(this);\n }\n\n queryAndEnableKittyProtocol(): void {\n do_queryAndEnableKittyProtocol(this);\n }\n\n handleKeyboardProtocolNegotiationSequence(\n negotiationSequence: KeyboardProtocolNegotiationSequence | undefined,\n ): boolean {\n return do_handleKeyboardProtocolNegotiationSequence(this, negotiationSequence);\n }\n\n readKeyboardProtocolNegotiationSequence(\n sequence: string,\n ): KeyboardProtocolNegotiationSequence | \"pending\" | undefined {\n return do_readKeyboardProtocolNegotiationSequence(this, sequence);\n }\n\n setKeyboardProtocolNegotiationBuffer(sequence: string): void {\n do_setKeyboardProtocolNegotiationBuffer(this, sequence);\n }\n\n clearKeyboardProtocolNegotiationBuffer(): void {\n do_clearKeyboardProtocolNegotiationBuffer(this);\n }\n\n flushKeyboardProtocolNegotiationBufferAsInput(): void {\n do_flushKeyboardProtocolNegotiationBufferAsInput(this);\n }\n\n scheduleKeyboardProtocolNegotiationBufferFlush(): void {\n do_scheduleKeyboardProtocolNegotiationBufferFlush(this);\n }\n\n clearKeyboardProtocolNegotiationBufferFlushTimer(): void {\n do_clearKeyboardProtocolNegotiationBufferFlushTimer(this);\n }\n\n forwardInputSequence(sequence: string): void {\n do_forwardInputSequence(this, sequence);\n }\n\n enableModifyOtherKeys(): void {\n do_enableModifyOtherKeys(this);\n }\n\n disableModifyOtherKeys(): void {\n do_disableModifyOtherKeys(this);\n }\n\n enableWindowsVTInput(): void {\n do_enableWindowsVTInput(this);\n }\n\n async drainInput(maxMs = 1000, idleMs = 50): Promise<void> {\n return do_drainInput(this, maxMs, idleMs);\n }\n\n stop(): void {\n do_stop(this);\n }\n\n write(data: string): void {\n do_write(this, data);\n }\n\n moveBy(lines: number): void {\n do_moveBy(this, lines);\n }\n\n hideCursor(): void {\n do_hideCursor(this);\n }\n\n showCursor(): void {\n do_showCursor(this);\n }\n\n clearLine(): void {\n do_clearLine(this);\n }\n\n clearFromCursor(): void {\n do_clearFromCursor(this);\n }\n\n clearScreen(): void {\n do_clearScreen(this);\n }\n\n setTitle(title: string): void {\n do_setTitle(this, title);\n }\n\n setProgress(active: boolean): void {\n do_setProgress(this, active);\n }\n\n setMouseTracking(active: boolean): void {\n do_setMouseTracking(this, active);\n }\n\n clearProgressInterval(): boolean {\n return do_clearProgressInterval(this);\n }\n}\n"]}
@@ -0,0 +1,31 @@
1
+ export type KeyboardProtocolNegotiationSequence = {
2
+ type: "kitty-flags";
3
+ flags: number;
4
+ } | {
5
+ type: "device-attributes";
6
+ };
7
+ export interface Terminal {
8
+ start(onInput: (data: string) => void, onResize: () => void): void;
9
+ stop(): void;
10
+ /**
11
+ * Drain stdin before exiting to prevent Kitty key release events from
12
+ * leaking to the parent shell over slow SSH connections.
13
+ * @param maxMs - Maximum time to drain (default: 1000ms)
14
+ * @param idleMs - Exit early if no input arrives within this time (default: 50ms)
15
+ */
16
+ drainInput(maxMs?: number, idleMs?: number): Promise<void>;
17
+ write(data: string): void;
18
+ get columns(): number;
19
+ get rows(): number;
20
+ get kittyProtocolActive(): boolean;
21
+ moveBy(lines: number): void;
22
+ hideCursor(): void;
23
+ showCursor(): void;
24
+ clearLine(): void;
25
+ clearFromCursor(): void;
26
+ clearScreen(): void;
27
+ setTitle(title: string): void;
28
+ setProgress(active: boolean): void;
29
+ setMouseTracking?(active: boolean): void;
30
+ }
31
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/terminal/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mCAAmC,GAC3C;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACtC;IAAE,IAAI,EAAE,mBAAmB,CAAA;CAAE,CAAC;AAElC,MAAM,WAAW,QAAQ;IAEvB,KAAK,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAGnE,IAAI,IAAI,IAAI,CAAC;IAEb;;;;;OAKG;IACH,UAAU,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAG3D,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAG1B,IAAI,OAAO,IAAI,MAAM,CAAC;IACtB,IAAI,IAAI,IAAI,MAAM,CAAC;IAGnB,IAAI,mBAAmB,IAAI,OAAO,CAAC;IAGnC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAG5B,UAAU,IAAI,IAAI,CAAC;IACnB,UAAU,IAAI,IAAI,CAAC;IAGnB,SAAS,IAAI,IAAI,CAAC;IAClB,eAAe,IAAI,IAAI,CAAC;IACxB,WAAW,IAAI,IAAI,CAAC;IAGpB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAG9B,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IAGnC,gBAAgB,CAAC,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;CAC1C","sourcesContent":["export type KeyboardProtocolNegotiationSequence =\n | { type: \"kitty-flags\"; flags: number }\n | { type: \"device-attributes\" };\n\nexport interface Terminal {\n // Start the terminal with input and resize handlers\n start(onInput: (data: string) => void, onResize: () => void): void;\n\n // Stop the terminal and restore state\n stop(): void;\n\n /**\n * Drain stdin before exiting to prevent Kitty key release events from\n * leaking to the parent shell over slow SSH connections.\n * @param maxMs - Maximum time to drain (default: 1000ms)\n * @param idleMs - Exit early if no input arrives within this time (default: 50ms)\n */\n drainInput(maxMs?: number, idleMs?: number): Promise<void>;\n\n // Write output to terminal\n write(data: string): void;\n\n // Get terminal dimensions\n get columns(): number;\n get rows(): number;\n\n // Whether Kitty keyboard protocol is active\n get kittyProtocolActive(): boolean;\n\n // Cursor positioning (relative to current position)\n moveBy(lines: number): void; // Move cursor up (negative) or down (positive) by N lines\n\n // Cursor visibility\n hideCursor(): void; // Hide the cursor\n showCursor(): void; // Show the cursor\n\n // Clear operations\n clearLine(): void; // Clear current line\n clearFromCursor(): void; // Clear from cursor to end of screen\n clearScreen(): void; // Clear entire screen and move cursor to (0,0)\n\n // Title operations\n setTitle(title: string): void; // Set terminal window title\n\n // Progress indicator (OSC 9;4)\n setProgress(active: boolean): void;\n\n // Mouse button-motion and SGR coordinate reporting\n setMouseTracking?(active: boolean): void;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map