@socketsecurity/cli-with-sentry 1.1.25 → 2.0.0

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 (914) hide show
  1. package/CHANGELOG.md +51 -218
  2. package/README.md +41 -74
  3. package/dist/cli.js.bz +0 -0
  4. package/dist/cli.js.bz.sha256 +1 -0
  5. package/dist/index.js +2 -0
  6. package/package.json +31 -274
  7. package/bin/cli.js +0 -52
  8. package/bin/npm-cli.js +0 -29
  9. package/bin/npx-cli.js +0 -29
  10. package/bin/pnpm-cli.js +0 -29
  11. package/bin/yarn-cli.js +0 -29
  12. package/dist/cli.js +0 -14999
  13. package/dist/cli.js.map +0 -1
  14. package/dist/constants.js +0 -845
  15. package/dist/constants.js.map +0 -1
  16. package/dist/flags.js +0 -212
  17. package/dist/flags.js.map +0 -1
  18. package/dist/init.gradle +0 -250
  19. package/dist/instrument-with-sentry.js +0 -44
  20. package/dist/instrument-with-sentry.js.map +0 -1
  21. package/dist/npm-cli.js +0 -30
  22. package/dist/npm-cli.js.map +0 -1
  23. package/dist/npx-cli.js +0 -26
  24. package/dist/npx-cli.js.map +0 -1
  25. package/dist/pnpm-cli.js +0 -30
  26. package/dist/pnpm-cli.js.map +0 -1
  27. package/dist/shadow-npm-bin.js +0 -8
  28. package/dist/shadow-npm-bin.js.map +0 -1
  29. package/dist/shadow-npm-bin2.js +0 -102
  30. package/dist/shadow-npm-bin2.js.map +0 -1
  31. package/dist/shadow-npm-inject.js +0 -307
  32. package/dist/shadow-npm-inject.js.map +0 -1
  33. package/dist/shadow-npx-bin.js +0 -12
  34. package/dist/shadow-npx-bin.js.map +0 -1
  35. package/dist/shadow-pnpm-bin.js +0 -8
  36. package/dist/shadow-pnpm-bin.js.map +0 -1
  37. package/dist/shadow-pnpm-bin2.js +0 -300
  38. package/dist/shadow-pnpm-bin2.js.map +0 -1
  39. package/dist/shadow-yarn-bin.js +0 -96
  40. package/dist/shadow-yarn-bin.js.map +0 -1
  41. package/dist/tsconfig.dts.tsbuildinfo +0 -1
  42. package/dist/types/cli.d.mts +0 -3
  43. package/dist/types/cli.d.mts.map +0 -1
  44. package/dist/types/commands/analytics/cmd-analytics.d.mts +0 -10
  45. package/dist/types/commands/analytics/cmd-analytics.d.mts.map +0 -1
  46. package/dist/types/commands/analytics/fetch-org-analytics.d.mts +0 -8
  47. package/dist/types/commands/analytics/fetch-org-analytics.d.mts.map +0 -1
  48. package/dist/types/commands/analytics/fetch-repo-analytics.d.mts +0 -8
  49. package/dist/types/commands/analytics/fetch-repo-analytics.d.mts.map +0 -1
  50. package/dist/types/commands/analytics/handle-analytics.d.mts +0 -10
  51. package/dist/types/commands/analytics/handle-analytics.d.mts.map +0 -1
  52. package/dist/types/commands/analytics/output-analytics.d.mts +0 -29
  53. package/dist/types/commands/analytics/output-analytics.d.mts.map +0 -1
  54. package/dist/types/commands/audit-log/cmd-audit-log.d.mts +0 -10
  55. package/dist/types/commands/audit-log/cmd-audit-log.d.mts.map +0 -1
  56. package/dist/types/commands/audit-log/fetch-audit-log.d.mts +0 -15
  57. package/dist/types/commands/audit-log/fetch-audit-log.d.mts.map +0 -1
  58. package/dist/types/commands/audit-log/handle-audit-log.d.mts +0 -9
  59. package/dist/types/commands/audit-log/handle-audit-log.d.mts.map +0 -1
  60. package/dist/types/commands/audit-log/output-audit-log.d.mts +0 -22
  61. package/dist/types/commands/audit-log/output-audit-log.d.mts.map +0 -1
  62. package/dist/types/commands/ci/cmd-ci.d.mts +0 -9
  63. package/dist/types/commands/ci/cmd-ci.d.mts.map +0 -1
  64. package/dist/types/commands/ci/fetch-default-org-slug.d.mts +0 -4
  65. package/dist/types/commands/ci/fetch-default-org-slug.d.mts.map +0 -1
  66. package/dist/types/commands/ci/handle-ci.d.mts +0 -2
  67. package/dist/types/commands/ci/handle-ci.d.mts.map +0 -1
  68. package/dist/types/commands/config/cmd-config-auto.d.mts +0 -10
  69. package/dist/types/commands/config/cmd-config-auto.d.mts.map +0 -1
  70. package/dist/types/commands/config/cmd-config-get.d.mts +0 -9
  71. package/dist/types/commands/config/cmd-config-get.d.mts.map +0 -1
  72. package/dist/types/commands/config/cmd-config-list.d.mts +0 -9
  73. package/dist/types/commands/config/cmd-config-list.d.mts.map +0 -1
  74. package/dist/types/commands/config/cmd-config-set.d.mts +0 -10
  75. package/dist/types/commands/config/cmd-config-set.d.mts.map +0 -1
  76. package/dist/types/commands/config/cmd-config-unset.d.mts +0 -10
  77. package/dist/types/commands/config/cmd-config-unset.d.mts.map +0 -1
  78. package/dist/types/commands/config/cmd-config.d.mts +0 -3
  79. package/dist/types/commands/config/cmd-config.d.mts.map +0 -1
  80. package/dist/types/commands/config/discover-config-value.d.mts +0 -3
  81. package/dist/types/commands/config/discover-config-value.d.mts.map +0 -1
  82. package/dist/types/commands/config/handle-config-auto.d.mts +0 -7
  83. package/dist/types/commands/config/handle-config-auto.d.mts.map +0 -1
  84. package/dist/types/commands/config/handle-config-get.d.mts +0 -7
  85. package/dist/types/commands/config/handle-config-get.d.mts.map +0 -1
  86. package/dist/types/commands/config/handle-config-set.d.mts +0 -8
  87. package/dist/types/commands/config/handle-config-set.d.mts.map +0 -1
  88. package/dist/types/commands/config/handle-config-unset.d.mts +0 -7
  89. package/dist/types/commands/config/handle-config-unset.d.mts.map +0 -1
  90. package/dist/types/commands/config/output-config-auto.d.mts +0 -4
  91. package/dist/types/commands/config/output-config-auto.d.mts.map +0 -1
  92. package/dist/types/commands/config/output-config-get.d.mts +0 -4
  93. package/dist/types/commands/config/output-config-get.d.mts.map +0 -1
  94. package/dist/types/commands/config/output-config-list.d.mts +0 -6
  95. package/dist/types/commands/config/output-config-list.d.mts.map +0 -1
  96. package/dist/types/commands/config/output-config-set.d.mts +0 -3
  97. package/dist/types/commands/config/output-config-set.d.mts.map +0 -1
  98. package/dist/types/commands/config/output-config-unset.d.mts +0 -3
  99. package/dist/types/commands/config/output-config-unset.d.mts.map +0 -1
  100. package/dist/types/commands/fix/cmd-fix.d.mts +0 -10
  101. package/dist/types/commands/fix/cmd-fix.d.mts.map +0 -1
  102. package/dist/types/commands/fix/coana-fix.d.mts +0 -6
  103. package/dist/types/commands/fix/coana-fix.d.mts.map +0 -1
  104. package/dist/types/commands/fix/env-helpers.d.mts +0 -26
  105. package/dist/types/commands/fix/env-helpers.d.mts.map +0 -1
  106. package/dist/types/commands/fix/git.d.mts +0 -13
  107. package/dist/types/commands/fix/git.d.mts.map +0 -1
  108. package/dist/types/commands/fix/handle-fix.d.mts +0 -20
  109. package/dist/types/commands/fix/handle-fix.d.mts.map +0 -1
  110. package/dist/types/commands/fix/output-fix-result.d.mts +0 -3
  111. package/dist/types/commands/fix/output-fix-result.d.mts.map +0 -1
  112. package/dist/types/commands/fix/pull-request.d.mts +0 -31
  113. package/dist/types/commands/fix/pull-request.d.mts.map +0 -1
  114. package/dist/types/commands/fix/types.d.mts +0 -21
  115. package/dist/types/commands/fix/types.d.mts.map +0 -1
  116. package/dist/types/commands/install/cmd-install-completion.d.mts +0 -9
  117. package/dist/types/commands/install/cmd-install-completion.d.mts.map +0 -1
  118. package/dist/types/commands/install/cmd-install.d.mts +0 -3
  119. package/dist/types/commands/install/cmd-install.d.mts.map +0 -1
  120. package/dist/types/commands/install/handle-install-completion.d.mts +0 -2
  121. package/dist/types/commands/install/handle-install-completion.d.mts.map +0 -1
  122. package/dist/types/commands/install/output-install-completion.d.mts +0 -12
  123. package/dist/types/commands/install/output-install-completion.d.mts.map +0 -1
  124. package/dist/types/commands/install/setup-tab-completion.d.mts +0 -13
  125. package/dist/types/commands/install/setup-tab-completion.d.mts.map +0 -1
  126. package/dist/types/commands/json/cmd-json.d.mts +0 -9
  127. package/dist/types/commands/json/cmd-json.d.mts.map +0 -1
  128. package/dist/types/commands/json/handle-cmd-json.d.mts +0 -2
  129. package/dist/types/commands/json/handle-cmd-json.d.mts.map +0 -1
  130. package/dist/types/commands/json/output-cmd-json.d.mts +0 -2
  131. package/dist/types/commands/json/output-cmd-json.d.mts.map +0 -1
  132. package/dist/types/commands/login/apply-login.d.mts +0 -2
  133. package/dist/types/commands/login/apply-login.d.mts.map +0 -1
  134. package/dist/types/commands/login/attempt-login.d.mts +0 -6
  135. package/dist/types/commands/login/attempt-login.d.mts.map +0 -1
  136. package/dist/types/commands/login/cmd-login.d.mts +0 -10
  137. package/dist/types/commands/login/cmd-login.d.mts.map +0 -1
  138. package/dist/types/commands/logout/apply-logout.d.mts +0 -2
  139. package/dist/types/commands/logout/apply-logout.d.mts.map +0 -1
  140. package/dist/types/commands/logout/attempt-logout.d.mts +0 -2
  141. package/dist/types/commands/logout/attempt-logout.d.mts.map +0 -1
  142. package/dist/types/commands/logout/cmd-logout.d.mts +0 -9
  143. package/dist/types/commands/logout/cmd-logout.d.mts.map +0 -1
  144. package/dist/types/commands/manifest/cmd-manifest-auto.d.mts +0 -9
  145. package/dist/types/commands/manifest/cmd-manifest-auto.d.mts.map +0 -1
  146. package/dist/types/commands/manifest/cmd-manifest-cdxgen.d.mts +0 -9
  147. package/dist/types/commands/manifest/cmd-manifest-cdxgen.d.mts.map +0 -1
  148. package/dist/types/commands/manifest/cmd-manifest-conda.d.mts +0 -9
  149. package/dist/types/commands/manifest/cmd-manifest-conda.d.mts.map +0 -1
  150. package/dist/types/commands/manifest/cmd-manifest-gradle.d.mts +0 -9
  151. package/dist/types/commands/manifest/cmd-manifest-gradle.d.mts.map +0 -1
  152. package/dist/types/commands/manifest/cmd-manifest-kotlin.d.mts +0 -9
  153. package/dist/types/commands/manifest/cmd-manifest-kotlin.d.mts.map +0 -1
  154. package/dist/types/commands/manifest/cmd-manifest-scala.d.mts +0 -9
  155. package/dist/types/commands/manifest/cmd-manifest-scala.d.mts.map +0 -1
  156. package/dist/types/commands/manifest/cmd-manifest-setup.d.mts +0 -9
  157. package/dist/types/commands/manifest/cmd-manifest-setup.d.mts.map +0 -1
  158. package/dist/types/commands/manifest/cmd-manifest.d.mts +0 -9
  159. package/dist/types/commands/manifest/cmd-manifest.d.mts.map +0 -1
  160. package/dist/types/commands/manifest/convert-conda-to-requirements.d.mts +0 -8
  161. package/dist/types/commands/manifest/convert-conda-to-requirements.d.mts.map +0 -1
  162. package/dist/types/commands/manifest/convert_gradle_to_maven.d.mts +0 -7
  163. package/dist/types/commands/manifest/convert_gradle_to_maven.d.mts.map +0 -1
  164. package/dist/types/commands/manifest/convert_sbt_to_maven.d.mts +0 -8
  165. package/dist/types/commands/manifest/convert_sbt_to_maven.d.mts.map +0 -1
  166. package/dist/types/commands/manifest/detect-manifest-actions.d.mts +0 -13
  167. package/dist/types/commands/manifest/detect-manifest-actions.d.mts.map +0 -1
  168. package/dist/types/commands/manifest/generate_auto_manifest.d.mts +0 -9
  169. package/dist/types/commands/manifest/generate_auto_manifest.d.mts.map +0 -1
  170. package/dist/types/commands/manifest/handle-manifest-conda.d.mts +0 -9
  171. package/dist/types/commands/manifest/handle-manifest-conda.d.mts.map +0 -1
  172. package/dist/types/commands/manifest/handle-manifest-setup.d.mts +0 -2
  173. package/dist/types/commands/manifest/handle-manifest-setup.d.mts.map +0 -1
  174. package/dist/types/commands/manifest/output-manifest-setup.d.mts +0 -3
  175. package/dist/types/commands/manifest/output-manifest-setup.d.mts.map +0 -1
  176. package/dist/types/commands/manifest/output-requirements.d.mts +0 -6
  177. package/dist/types/commands/manifest/output-requirements.d.mts.map +0 -1
  178. package/dist/types/commands/manifest/run-cdxgen.d.mts +0 -6
  179. package/dist/types/commands/manifest/run-cdxgen.d.mts.map +0 -1
  180. package/dist/types/commands/manifest/setup-manifest-config.d.mts +0 -3
  181. package/dist/types/commands/manifest/setup-manifest-config.d.mts.map +0 -1
  182. package/dist/types/commands/npm/cmd-npm.d.mts +0 -10
  183. package/dist/types/commands/npm/cmd-npm.d.mts.map +0 -1
  184. package/dist/types/commands/npx/cmd-npx.d.mts +0 -9
  185. package/dist/types/commands/npx/cmd-npx.d.mts.map +0 -1
  186. package/dist/types/commands/oops/cmd-oops.d.mts +0 -9
  187. package/dist/types/commands/oops/cmd-oops.d.mts.map +0 -1
  188. package/dist/types/commands/optimize/add-overrides.d.mts +0 -20
  189. package/dist/types/commands/optimize/add-overrides.d.mts.map +0 -1
  190. package/dist/types/commands/optimize/apply-optimization.d.mts +0 -14
  191. package/dist/types/commands/optimize/apply-optimization.d.mts.map +0 -1
  192. package/dist/types/commands/optimize/cmd-optimize.d.mts +0 -10
  193. package/dist/types/commands/optimize/cmd-optimize.d.mts.map +0 -1
  194. package/dist/types/commands/optimize/deps-includes-by-agent.d.mts +0 -5
  195. package/dist/types/commands/optimize/deps-includes-by-agent.d.mts.map +0 -1
  196. package/dist/types/commands/optimize/get-dependency-entries.d.mts +0 -3
  197. package/dist/types/commands/optimize/get-dependency-entries.d.mts.map +0 -1
  198. package/dist/types/commands/optimize/get-overrides-by-agent.d.mts +0 -42
  199. package/dist/types/commands/optimize/get-overrides-by-agent.d.mts.map +0 -1
  200. package/dist/types/commands/optimize/handle-optimize.d.mts +0 -8
  201. package/dist/types/commands/optimize/handle-optimize.d.mts.map +0 -1
  202. package/dist/types/commands/optimize/lockfile-includes-by-agent.d.mts +0 -8
  203. package/dist/types/commands/optimize/lockfile-includes-by-agent.d.mts.map +0 -1
  204. package/dist/types/commands/optimize/ls-by-agent.d.mts +0 -13
  205. package/dist/types/commands/optimize/ls-by-agent.d.mts.map +0 -1
  206. package/dist/types/commands/optimize/output-optimize-result.d.mts +0 -9
  207. package/dist/types/commands/optimize/output-optimize-result.d.mts.map +0 -1
  208. package/dist/types/commands/optimize/shared.d.mts +0 -2
  209. package/dist/types/commands/optimize/shared.d.mts.map +0 -1
  210. package/dist/types/commands/optimize/types.d.mts +0 -9
  211. package/dist/types/commands/optimize/types.d.mts.map +0 -1
  212. package/dist/types/commands/optimize/update-lockfile.d.mts +0 -11
  213. package/dist/types/commands/optimize/update-lockfile.d.mts.map +0 -1
  214. package/dist/types/commands/optimize/update-manifest-by-agent.d.mts +0 -8
  215. package/dist/types/commands/optimize/update-manifest-by-agent.d.mts.map +0 -1
  216. package/dist/types/commands/organization/cmd-organization-dependencies.d.mts +0 -10
  217. package/dist/types/commands/organization/cmd-organization-dependencies.d.mts.map +0 -1
  218. package/dist/types/commands/organization/cmd-organization-list.d.mts +0 -10
  219. package/dist/types/commands/organization/cmd-organization-list.d.mts.map +0 -1
  220. package/dist/types/commands/organization/cmd-organization-policy-license.d.mts +0 -10
  221. package/dist/types/commands/organization/cmd-organization-policy-license.d.mts.map +0 -1
  222. package/dist/types/commands/organization/cmd-organization-policy-security.d.mts +0 -10
  223. package/dist/types/commands/organization/cmd-organization-policy-security.d.mts.map +0 -1
  224. package/dist/types/commands/organization/cmd-organization-policy.d.mts +0 -3
  225. package/dist/types/commands/organization/cmd-organization-policy.d.mts.map +0 -1
  226. package/dist/types/commands/organization/cmd-organization-quota.d.mts +0 -9
  227. package/dist/types/commands/organization/cmd-organization-quota.d.mts.map +0 -1
  228. package/dist/types/commands/organization/cmd-organization.d.mts +0 -3
  229. package/dist/types/commands/organization/cmd-organization.d.mts.map +0 -1
  230. package/dist/types/commands/organization/fetch-dependencies.d.mts +0 -12
  231. package/dist/types/commands/organization/fetch-dependencies.d.mts.map +0 -1
  232. package/dist/types/commands/organization/fetch-license-policy.d.mts +0 -8
  233. package/dist/types/commands/organization/fetch-license-policy.d.mts.map +0 -1
  234. package/dist/types/commands/organization/fetch-organization-list.d.mts +0 -20
  235. package/dist/types/commands/organization/fetch-organization-list.d.mts.map +0 -1
  236. package/dist/types/commands/organization/fetch-quota.d.mts +0 -8
  237. package/dist/types/commands/organization/fetch-quota.d.mts.map +0 -1
  238. package/dist/types/commands/organization/fetch-security-policy.d.mts +0 -8
  239. package/dist/types/commands/organization/fetch-security-policy.d.mts.map +0 -1
  240. package/dist/types/commands/organization/handle-dependencies.d.mts +0 -7
  241. package/dist/types/commands/organization/handle-dependencies.d.mts.map +0 -1
  242. package/dist/types/commands/organization/handle-license-policy.d.mts +0 -3
  243. package/dist/types/commands/organization/handle-license-policy.d.mts.map +0 -1
  244. package/dist/types/commands/organization/handle-organization-list.d.mts +0 -3
  245. package/dist/types/commands/organization/handle-organization-list.d.mts.map +0 -1
  246. package/dist/types/commands/organization/handle-quota.d.mts +0 -3
  247. package/dist/types/commands/organization/handle-quota.d.mts.map +0 -1
  248. package/dist/types/commands/organization/handle-security-policy.d.mts +0 -3
  249. package/dist/types/commands/organization/handle-security-policy.d.mts.map +0 -1
  250. package/dist/types/commands/organization/output-dependencies.d.mts +0 -8
  251. package/dist/types/commands/organization/output-dependencies.d.mts.map +0 -1
  252. package/dist/types/commands/organization/output-license-policy.d.mts +0 -4
  253. package/dist/types/commands/organization/output-license-policy.d.mts.map +0 -1
  254. package/dist/types/commands/organization/output-organization-list.d.mts +0 -4
  255. package/dist/types/commands/organization/output-organization-list.d.mts.map +0 -1
  256. package/dist/types/commands/organization/output-quota.d.mts +0 -4
  257. package/dist/types/commands/organization/output-quota.d.mts.map +0 -1
  258. package/dist/types/commands/organization/output-security-policy.d.mts +0 -4
  259. package/dist/types/commands/organization/output-security-policy.d.mts.map +0 -1
  260. package/dist/types/commands/package/cmd-package-score.d.mts +0 -10
  261. package/dist/types/commands/package/cmd-package-score.d.mts.map +0 -1
  262. package/dist/types/commands/package/cmd-package-shallow.d.mts +0 -17
  263. package/dist/types/commands/package/cmd-package-shallow.d.mts.map +0 -1
  264. package/dist/types/commands/package/cmd-package.d.mts +0 -3
  265. package/dist/types/commands/package/cmd-package.d.mts.map +0 -1
  266. package/dist/types/commands/package/fetch-purl-deep-score.d.mts +0 -51
  267. package/dist/types/commands/package/fetch-purl-deep-score.d.mts.map +0 -1
  268. package/dist/types/commands/package/fetch-purls-shallow-score.d.mts +0 -8
  269. package/dist/types/commands/package/fetch-purls-shallow-score.d.mts.map +0 -1
  270. package/dist/types/commands/package/handle-purl-deep-score.d.mts +0 -3
  271. package/dist/types/commands/package/handle-purl-deep-score.d.mts.map +0 -1
  272. package/dist/types/commands/package/handle-purls-shallow-score.d.mts +0 -6
  273. package/dist/types/commands/package/handle-purls-shallow-score.d.mts.map +0 -1
  274. package/dist/types/commands/package/output-purls-deep-score.d.mts +0 -5
  275. package/dist/types/commands/package/output-purls-deep-score.d.mts.map +0 -1
  276. package/dist/types/commands/package/output-purls-shallow-score.d.mts +0 -29
  277. package/dist/types/commands/package/output-purls-shallow-score.d.mts.map +0 -1
  278. package/dist/types/commands/package/parse-package-specifiers.d.mts +0 -9
  279. package/dist/types/commands/package/parse-package-specifiers.d.mts.map +0 -1
  280. package/dist/types/commands/patch/cmd-patch.d.mts +0 -10
  281. package/dist/types/commands/patch/cmd-patch.d.mts.map +0 -1
  282. package/dist/types/commands/patch/handle-patch.d.mts +0 -12
  283. package/dist/types/commands/patch/handle-patch.d.mts.map +0 -1
  284. package/dist/types/commands/patch/manifest-schema.d.mts +0 -34
  285. package/dist/types/commands/patch/manifest-schema.d.mts.map +0 -1
  286. package/dist/types/commands/patch/output-patch-result.d.mts +0 -5
  287. package/dist/types/commands/patch/output-patch-result.d.mts.map +0 -1
  288. package/dist/types/commands/pnpm/cmd-pnpm.d.mts +0 -10
  289. package/dist/types/commands/pnpm/cmd-pnpm.d.mts.map +0 -1
  290. package/dist/types/commands/raw-npm/cmd-raw-npm.d.mts +0 -9
  291. package/dist/types/commands/raw-npm/cmd-raw-npm.d.mts.map +0 -1
  292. package/dist/types/commands/raw-npm/run-raw-npm.d.mts +0 -2
  293. package/dist/types/commands/raw-npm/run-raw-npm.d.mts.map +0 -1
  294. package/dist/types/commands/raw-npx/cmd-raw-npx.d.mts +0 -9
  295. package/dist/types/commands/raw-npx/cmd-raw-npx.d.mts.map +0 -1
  296. package/dist/types/commands/raw-npx/run-raw-npx.d.mts +0 -2
  297. package/dist/types/commands/raw-npx/run-raw-npx.d.mts.map +0 -1
  298. package/dist/types/commands/repository/cmd-repository-create.d.mts +0 -10
  299. package/dist/types/commands/repository/cmd-repository-create.d.mts.map +0 -1
  300. package/dist/types/commands/repository/cmd-repository-del.d.mts +0 -10
  301. package/dist/types/commands/repository/cmd-repository-del.d.mts.map +0 -1
  302. package/dist/types/commands/repository/cmd-repository-list.d.mts +0 -10
  303. package/dist/types/commands/repository/cmd-repository-list.d.mts.map +0 -1
  304. package/dist/types/commands/repository/cmd-repository-update.d.mts +0 -10
  305. package/dist/types/commands/repository/cmd-repository-update.d.mts.map +0 -1
  306. package/dist/types/commands/repository/cmd-repository-view.d.mts +0 -10
  307. package/dist/types/commands/repository/cmd-repository-view.d.mts.map +0 -1
  308. package/dist/types/commands/repository/cmd-repository.d.mts +0 -3
  309. package/dist/types/commands/repository/cmd-repository.d.mts.map +0 -1
  310. package/dist/types/commands/repository/fetch-create-repo.d.mts +0 -16
  311. package/dist/types/commands/repository/fetch-create-repo.d.mts.map +0 -1
  312. package/dist/types/commands/repository/fetch-delete-repo.d.mts +0 -8
  313. package/dist/types/commands/repository/fetch-delete-repo.d.mts.map +0 -1
  314. package/dist/types/commands/repository/fetch-list-all-repos.d.mts +0 -10
  315. package/dist/types/commands/repository/fetch-list-all-repos.d.mts.map +0 -1
  316. package/dist/types/commands/repository/fetch-list-repos.d.mts +0 -15
  317. package/dist/types/commands/repository/fetch-list-repos.d.mts.map +0 -1
  318. package/dist/types/commands/repository/fetch-update-repo.d.mts +0 -16
  319. package/dist/types/commands/repository/fetch-update-repo.d.mts.map +0 -1
  320. package/dist/types/commands/repository/fetch-view-repo.d.mts +0 -8
  321. package/dist/types/commands/repository/fetch-view-repo.d.mts.map +0 -1
  322. package/dist/types/commands/repository/handle-create-repo.d.mts +0 -10
  323. package/dist/types/commands/repository/handle-create-repo.d.mts.map +0 -1
  324. package/dist/types/commands/repository/handle-delete-repo.d.mts +0 -3
  325. package/dist/types/commands/repository/handle-delete-repo.d.mts.map +0 -1
  326. package/dist/types/commands/repository/handle-list-repos.d.mts +0 -12
  327. package/dist/types/commands/repository/handle-list-repos.d.mts.map +0 -1
  328. package/dist/types/commands/repository/handle-update-repo.d.mts +0 -10
  329. package/dist/types/commands/repository/handle-update-repo.d.mts.map +0 -1
  330. package/dist/types/commands/repository/handle-view-repo.d.mts +0 -3
  331. package/dist/types/commands/repository/handle-view-repo.d.mts.map +0 -1
  332. package/dist/types/commands/repository/output-create-repo.d.mts +0 -4
  333. package/dist/types/commands/repository/output-create-repo.d.mts.map +0 -1
  334. package/dist/types/commands/repository/output-delete-repo.d.mts +0 -4
  335. package/dist/types/commands/repository/output-delete-repo.d.mts.map +0 -1
  336. package/dist/types/commands/repository/output-list-repos.d.mts +0 -5
  337. package/dist/types/commands/repository/output-list-repos.d.mts.map +0 -1
  338. package/dist/types/commands/repository/output-update-repo.d.mts +0 -4
  339. package/dist/types/commands/repository/output-update-repo.d.mts.map +0 -1
  340. package/dist/types/commands/repository/output-view-repo.d.mts +0 -4
  341. package/dist/types/commands/repository/output-view-repo.d.mts.map +0 -1
  342. package/dist/types/commands/repository/types.d.mts +0 -2
  343. package/dist/types/commands/repository/types.d.mts.map +0 -1
  344. package/dist/types/commands/scan/cmd-scan-create.d.mts +0 -10
  345. package/dist/types/commands/scan/cmd-scan-create.d.mts.map +0 -1
  346. package/dist/types/commands/scan/cmd-scan-del.d.mts +0 -10
  347. package/dist/types/commands/scan/cmd-scan-del.d.mts.map +0 -1
  348. package/dist/types/commands/scan/cmd-scan-diff.d.mts +0 -10
  349. package/dist/types/commands/scan/cmd-scan-diff.d.mts.map +0 -1
  350. package/dist/types/commands/scan/cmd-scan-github.d.mts +0 -10
  351. package/dist/types/commands/scan/cmd-scan-github.d.mts.map +0 -1
  352. package/dist/types/commands/scan/cmd-scan-list.d.mts +0 -4
  353. package/dist/types/commands/scan/cmd-scan-list.d.mts.map +0 -1
  354. package/dist/types/commands/scan/cmd-scan-metadata.d.mts +0 -4
  355. package/dist/types/commands/scan/cmd-scan-metadata.d.mts.map +0 -1
  356. package/dist/types/commands/scan/cmd-scan-reach.d.mts +0 -10
  357. package/dist/types/commands/scan/cmd-scan-reach.d.mts.map +0 -1
  358. package/dist/types/commands/scan/cmd-scan-report.d.mts +0 -4
  359. package/dist/types/commands/scan/cmd-scan-report.d.mts.map +0 -1
  360. package/dist/types/commands/scan/cmd-scan-setup.d.mts +0 -9
  361. package/dist/types/commands/scan/cmd-scan-setup.d.mts.map +0 -1
  362. package/dist/types/commands/scan/cmd-scan-view.d.mts +0 -4
  363. package/dist/types/commands/scan/cmd-scan-view.d.mts.map +0 -1
  364. package/dist/types/commands/scan/cmd-scan.d.mts +0 -3
  365. package/dist/types/commands/scan/cmd-scan.d.mts.map +0 -1
  366. package/dist/types/commands/scan/create-scan-from-github.d.mts +0 -12
  367. package/dist/types/commands/scan/create-scan-from-github.d.mts.map +0 -1
  368. package/dist/types/commands/scan/fetch-create-org-full-scan.d.mts +0 -20
  369. package/dist/types/commands/scan/fetch-create-org-full-scan.d.mts.map +0 -1
  370. package/dist/types/commands/scan/fetch-delete-org-full-scan.d.mts +0 -8
  371. package/dist/types/commands/scan/fetch-delete-org-full-scan.d.mts.map +0 -1
  372. package/dist/types/commands/scan/fetch-diff-scan.d.mts +0 -8
  373. package/dist/types/commands/scan/fetch-diff-scan.d.mts.map +0 -1
  374. package/dist/types/commands/scan/fetch-list-scans.d.mts +0 -18
  375. package/dist/types/commands/scan/fetch-list-scans.d.mts.map +0 -1
  376. package/dist/types/commands/scan/fetch-report-data.d.mts +0 -17
  377. package/dist/types/commands/scan/fetch-report-data.d.mts.map +0 -1
  378. package/dist/types/commands/scan/fetch-scan-metadata.d.mts +0 -8
  379. package/dist/types/commands/scan/fetch-scan-metadata.d.mts.map +0 -1
  380. package/dist/types/commands/scan/fetch-scan.d.mts +0 -4
  381. package/dist/types/commands/scan/fetch-scan.d.mts.map +0 -1
  382. package/dist/types/commands/scan/fetch-supported-scan-file-names.d.mts +0 -10
  383. package/dist/types/commands/scan/fetch-supported-scan-file-names.d.mts.map +0 -1
  384. package/dist/types/commands/scan/finalize-tier1-scan.d.mts +0 -12
  385. package/dist/types/commands/scan/finalize-tier1-scan.d.mts.map +0 -1
  386. package/dist/types/commands/scan/generate-report.d.mts +0 -44
  387. package/dist/types/commands/scan/generate-report.d.mts.map +0 -1
  388. package/dist/types/commands/scan/handle-create-github-scan.d.mts +0 -12
  389. package/dist/types/commands/scan/handle-create-github-scan.d.mts.map +0 -1
  390. package/dist/types/commands/scan/handle-create-new-scan.d.mts +0 -29
  391. package/dist/types/commands/scan/handle-create-new-scan.d.mts.map +0 -1
  392. package/dist/types/commands/scan/handle-delete-scan.d.mts +0 -3
  393. package/dist/types/commands/scan/handle-delete-scan.d.mts.map +0 -1
  394. package/dist/types/commands/scan/handle-diff-scan.d.mts +0 -10
  395. package/dist/types/commands/scan/handle-diff-scan.d.mts.map +0 -1
  396. package/dist/types/commands/scan/handle-list-scans.d.mts +0 -13
  397. package/dist/types/commands/scan/handle-list-scans.d.mts.map +0 -1
  398. package/dist/types/commands/scan/handle-scan-config.d.mts +0 -2
  399. package/dist/types/commands/scan/handle-scan-config.d.mts.map +0 -1
  400. package/dist/types/commands/scan/handle-scan-metadata.d.mts +0 -3
  401. package/dist/types/commands/scan/handle-scan-metadata.d.mts.map +0 -1
  402. package/dist/types/commands/scan/handle-scan-reach.d.mts +0 -12
  403. package/dist/types/commands/scan/handle-scan-reach.d.mts.map +0 -1
  404. package/dist/types/commands/scan/handle-scan-report.d.mts +0 -14
  405. package/dist/types/commands/scan/handle-scan-report.d.mts.map +0 -1
  406. package/dist/types/commands/scan/handle-scan-view.d.mts +0 -3
  407. package/dist/types/commands/scan/handle-scan-view.d.mts.map +0 -1
  408. package/dist/types/commands/scan/output-create-new-scan.d.mts +0 -10
  409. package/dist/types/commands/scan/output-create-new-scan.d.mts.map +0 -1
  410. package/dist/types/commands/scan/output-delete-scan.d.mts +0 -4
  411. package/dist/types/commands/scan/output-delete-scan.d.mts.map +0 -1
  412. package/dist/types/commands/scan/output-diff-scan.d.mts +0 -8
  413. package/dist/types/commands/scan/output-diff-scan.d.mts.map +0 -1
  414. package/dist/types/commands/scan/output-list-scans.d.mts +0 -4
  415. package/dist/types/commands/scan/output-list-scans.d.mts.map +0 -1
  416. package/dist/types/commands/scan/output-scan-config-result.d.mts +0 -3
  417. package/dist/types/commands/scan/output-scan-config-result.d.mts.map +0 -1
  418. package/dist/types/commands/scan/output-scan-github.d.mts +0 -3
  419. package/dist/types/commands/scan/output-scan-github.d.mts.map +0 -1
  420. package/dist/types/commands/scan/output-scan-metadata.d.mts +0 -4
  421. package/dist/types/commands/scan/output-scan-metadata.d.mts.map +0 -1
  422. package/dist/types/commands/scan/output-scan-reach.d.mts +0 -7
  423. package/dist/types/commands/scan/output-scan-reach.d.mts.map +0 -1
  424. package/dist/types/commands/scan/output-scan-report.d.mts +0 -22
  425. package/dist/types/commands/scan/output-scan-report.d.mts.map +0 -1
  426. package/dist/types/commands/scan/output-scan-view.d.mts +0 -4
  427. package/dist/types/commands/scan/output-scan-view.d.mts.map +0 -1
  428. package/dist/types/commands/scan/perform-reachability-analysis.d.mts +0 -27
  429. package/dist/types/commands/scan/perform-reachability-analysis.d.mts.map +0 -1
  430. package/dist/types/commands/scan/reachability-flags.d.mts +0 -3
  431. package/dist/types/commands/scan/reachability-flags.d.mts.map +0 -1
  432. package/dist/types/commands/scan/setup-scan-config.d.mts +0 -3
  433. package/dist/types/commands/scan/setup-scan-config.d.mts.map +0 -1
  434. package/dist/types/commands/scan/stream-scan.d.mts +0 -7
  435. package/dist/types/commands/scan/stream-scan.d.mts.map +0 -1
  436. package/dist/types/commands/scan/suggest-org-slug.d.mts +0 -2
  437. package/dist/types/commands/scan/suggest-org-slug.d.mts.map +0 -1
  438. package/dist/types/commands/scan/suggest-to-persist-orgslug.d.mts +0 -2
  439. package/dist/types/commands/scan/suggest-to-persist-orgslug.d.mts.map +0 -1
  440. package/dist/types/commands/scan/suggest_branch_slug.d.mts +0 -2
  441. package/dist/types/commands/scan/suggest_branch_slug.d.mts.map +0 -1
  442. package/dist/types/commands/scan/suggest_target.d.mts +0 -2
  443. package/dist/types/commands/scan/suggest_target.d.mts.map +0 -1
  444. package/dist/types/commands/scan/types.d.mts +0 -3
  445. package/dist/types/commands/scan/types.d.mts.map +0 -1
  446. package/dist/types/commands/threat-feed/cmd-threat-feed.d.mts +0 -10
  447. package/dist/types/commands/threat-feed/cmd-threat-feed.d.mts.map +0 -1
  448. package/dist/types/commands/threat-feed/fetch-threat-feed.d.mts +0 -13
  449. package/dist/types/commands/threat-feed/fetch-threat-feed.d.mts.map +0 -1
  450. package/dist/types/commands/threat-feed/handle-threat-feed.d.mts +0 -13
  451. package/dist/types/commands/threat-feed/handle-threat-feed.d.mts.map +0 -1
  452. package/dist/types/commands/threat-feed/output-threat-feed.d.mts +0 -4
  453. package/dist/types/commands/threat-feed/output-threat-feed.d.mts.map +0 -1
  454. package/dist/types/commands/threat-feed/types.d.mts +0 -15
  455. package/dist/types/commands/threat-feed/types.d.mts.map +0 -1
  456. package/dist/types/commands/uninstall/cmd-uninstall-completion.d.mts +0 -8
  457. package/dist/types/commands/uninstall/cmd-uninstall-completion.d.mts.map +0 -1
  458. package/dist/types/commands/uninstall/cmd-uninstall.d.mts +0 -3
  459. package/dist/types/commands/uninstall/cmd-uninstall.d.mts.map +0 -1
  460. package/dist/types/commands/uninstall/handle-uninstall-completion.d.mts +0 -2
  461. package/dist/types/commands/uninstall/handle-uninstall-completion.d.mts.map +0 -1
  462. package/dist/types/commands/uninstall/output-uninstall-completion.d.mts +0 -6
  463. package/dist/types/commands/uninstall/output-uninstall-completion.d.mts.map +0 -1
  464. package/dist/types/commands/uninstall/teardown-tab-completion.d.mts +0 -6
  465. package/dist/types/commands/uninstall/teardown-tab-completion.d.mts.map +0 -1
  466. package/dist/types/commands/wrapper/add-socket-wrapper.d.mts +0 -2
  467. package/dist/types/commands/wrapper/add-socket-wrapper.d.mts.map +0 -1
  468. package/dist/types/commands/wrapper/check-socket-wrapper-setup.d.mts +0 -2
  469. package/dist/types/commands/wrapper/check-socket-wrapper-setup.d.mts.map +0 -1
  470. package/dist/types/commands/wrapper/cmd-wrapper.d.mts +0 -9
  471. package/dist/types/commands/wrapper/cmd-wrapper.d.mts.map +0 -1
  472. package/dist/types/commands/wrapper/postinstall-wrapper.d.mts +0 -2
  473. package/dist/types/commands/wrapper/postinstall-wrapper.d.mts.map +0 -1
  474. package/dist/types/commands/wrapper/remove-socket-wrapper.d.mts +0 -2
  475. package/dist/types/commands/wrapper/remove-socket-wrapper.d.mts.map +0 -1
  476. package/dist/types/commands/yarn/cmd-yarn.d.mts +0 -10
  477. package/dist/types/commands/yarn/cmd-yarn.d.mts.map +0 -1
  478. package/dist/types/commands.d.mts +0 -203
  479. package/dist/types/commands.d.mts.map +0 -1
  480. package/dist/types/constants.d.mts +0 -299
  481. package/dist/types/constants.d.mts.map +0 -1
  482. package/dist/types/flags.d.mts +0 -18
  483. package/dist/types/flags.d.mts.map +0 -1
  484. package/dist/types/instrument-with-sentry.d.mts +0 -2
  485. package/dist/types/instrument-with-sentry.d.mts.map +0 -1
  486. package/dist/types/npm-cli.d.mts +0 -3
  487. package/dist/types/npm-cli.d.mts.map +0 -1
  488. package/dist/types/npx-cli.d.mts +0 -3
  489. package/dist/types/npx-cli.d.mts.map +0 -1
  490. package/dist/types/pnpm-cli.d.mts +0 -3
  491. package/dist/types/pnpm-cli.d.mts.map +0 -1
  492. package/dist/types/sea/bootstrap.d.mts +0 -2
  493. package/dist/types/sea/bootstrap.d.mts.map +0 -1
  494. package/dist/types/sea/build-sea.d.mts +0 -27
  495. package/dist/types/sea/build-sea.d.mts.map +0 -1
  496. package/dist/types/shadow/common.d.mts +0 -23
  497. package/dist/types/shadow/common.d.mts.map +0 -1
  498. package/dist/types/shadow/npm/arborist/index.d.mts +0 -8
  499. package/dist/types/shadow/npm/arborist/index.d.mts.map +0 -1
  500. package/dist/types/shadow/npm/arborist/lib/arborist/index.d.mts +0 -35
  501. package/dist/types/shadow/npm/arborist/lib/arborist/index.d.mts.map +0 -1
  502. package/dist/types/shadow/npm/arborist/types.d.mts +0 -123
  503. package/dist/types/shadow/npm/arborist/types.d.mts.map +0 -1
  504. package/dist/types/shadow/npm/arborist-helpers.d.mts +0 -24
  505. package/dist/types/shadow/npm/arborist-helpers.d.mts.map +0 -1
  506. package/dist/types/shadow/npm/bin.d.mts +0 -5
  507. package/dist/types/shadow/npm/bin.d.mts.map +0 -1
  508. package/dist/types/shadow/npm/inject.d.mts +0 -2
  509. package/dist/types/shadow/npm/inject.d.mts.map +0 -1
  510. package/dist/types/shadow/npm/install.d.mts +0 -13
  511. package/dist/types/shadow/npm/install.d.mts.map +0 -1
  512. package/dist/types/shadow/npm/paths.d.mts +0 -6
  513. package/dist/types/shadow/npm/paths.d.mts.map +0 -1
  514. package/dist/types/shadow/npm-base.d.mts +0 -11
  515. package/dist/types/shadow/npm-base.d.mts.map +0 -1
  516. package/dist/types/shadow/npx/bin.d.mts +0 -5
  517. package/dist/types/shadow/npx/bin.d.mts.map +0 -1
  518. package/dist/types/shadow/pnpm/bin.d.mts +0 -10
  519. package/dist/types/shadow/pnpm/bin.d.mts.map +0 -1
  520. package/dist/types/shadow/stdio-ipc.d.mts +0 -7
  521. package/dist/types/shadow/stdio-ipc.d.mts.map +0 -1
  522. package/dist/types/shadow/yarn/bin.d.mts +0 -10
  523. package/dist/types/shadow/yarn/bin.d.mts.map +0 -1
  524. package/dist/types/test/json-output-validation.d.mts +0 -37
  525. package/dist/types/test/json-output-validation.d.mts.map +0 -1
  526. package/dist/types/test/mocks/socket-auth.d.mts +0 -88
  527. package/dist/types/test/mocks/socket-auth.d.mts.map +0 -1
  528. package/dist/types/types.d.mts +0 -29
  529. package/dist/types/types.d.mts.map +0 -1
  530. package/dist/types/utils/agent.d.mts +0 -12
  531. package/dist/types/utils/agent.d.mts.map +0 -1
  532. package/dist/types/utils/alert/artifact.d.mts +0 -21
  533. package/dist/types/utils/alert/artifact.d.mts.map +0 -1
  534. package/dist/types/utils/alert/fix.d.mts +0 -6
  535. package/dist/types/utils/alert/fix.d.mts.map +0 -1
  536. package/dist/types/utils/alert/severity.d.mts +0 -14
  537. package/dist/types/utils/alert/severity.d.mts.map +0 -1
  538. package/dist/types/utils/alerts-map.d.mts +0 -27
  539. package/dist/types/utils/alerts-map.d.mts.map +0 -1
  540. package/dist/types/utils/api.d.mts +0 -44
  541. package/dist/types/utils/api.d.mts.map +0 -1
  542. package/dist/types/utils/check-input.d.mts +0 -9
  543. package/dist/types/utils/check-input.d.mts.map +0 -1
  544. package/dist/types/utils/cmd.d.mts +0 -50
  545. package/dist/types/utils/cmd.d.mts.map +0 -1
  546. package/dist/types/utils/coana.d.mts +0 -2
  547. package/dist/types/utils/coana.d.mts.map +0 -1
  548. package/dist/types/utils/color-or-markdown.d.mts +0 -16
  549. package/dist/types/utils/color-or-markdown.d.mts.map +0 -1
  550. package/dist/types/utils/completion.d.mts +0 -11
  551. package/dist/types/utils/completion.d.mts.map +0 -1
  552. package/dist/types/utils/config.d.mts +0 -34
  553. package/dist/types/utils/config.d.mts.map +0 -1
  554. package/dist/types/utils/cve-to-ghsa.d.mts +0 -6
  555. package/dist/types/utils/cve-to-ghsa.d.mts.map +0 -1
  556. package/dist/types/utils/debug.d.mts +0 -45
  557. package/dist/types/utils/debug.d.mts.map +0 -1
  558. package/dist/types/utils/determine-org-slug.d.mts +0 -2
  559. package/dist/types/utils/determine-org-slug.d.mts.map +0 -1
  560. package/dist/types/utils/dlx-binary.d.mts +0 -58
  561. package/dist/types/utils/dlx-binary.d.mts.map +0 -1
  562. package/dist/types/utils/dlx-detection.d.mts +0 -29
  563. package/dist/types/utils/dlx-detection.d.mts.map +0 -1
  564. package/dist/types/utils/dlx.d.mts +0 -36
  565. package/dist/types/utils/dlx.d.mts.map +0 -1
  566. package/dist/types/utils/ecosystem.d.mts +0 -20
  567. package/dist/types/utils/ecosystem.d.mts.map +0 -1
  568. package/dist/types/utils/errors.d.mts +0 -62
  569. package/dist/types/utils/errors.d.mts.map +0 -1
  570. package/dist/types/utils/extract-names.d.mts +0 -15
  571. package/dist/types/utils/extract-names.d.mts.map +0 -1
  572. package/dist/types/utils/fail-msg-with-badge.d.mts +0 -2
  573. package/dist/types/utils/fail-msg-with-badge.d.mts.map +0 -1
  574. package/dist/types/utils/filter-config.d.mts +0 -5
  575. package/dist/types/utils/filter-config.d.mts.map +0 -1
  576. package/dist/types/utils/fs.d.mts +0 -8
  577. package/dist/types/utils/fs.d.mts.map +0 -1
  578. package/dist/types/utils/get-output-kind.d.mts +0 -3
  579. package/dist/types/utils/get-output-kind.d.mts.map +0 -1
  580. package/dist/types/utils/git.d.mts +0 -35
  581. package/dist/types/utils/git.d.mts.map +0 -1
  582. package/dist/types/utils/github.d.mts +0 -38
  583. package/dist/types/utils/github.d.mts.map +0 -1
  584. package/dist/types/utils/glob.d.mts +0 -15
  585. package/dist/types/utils/glob.d.mts.map +0 -1
  586. package/dist/types/utils/lockfile.d.mts +0 -2
  587. package/dist/types/utils/lockfile.d.mts.map +0 -1
  588. package/dist/types/utils/map-to-object.d.mts +0 -10
  589. package/dist/types/utils/map-to-object.d.mts.map +0 -1
  590. package/dist/types/utils/markdown.d.mts +0 -27
  591. package/dist/types/utils/markdown.d.mts.map +0 -1
  592. package/dist/types/utils/meow-with-subcommands.d.mts +0 -83
  593. package/dist/types/utils/meow-with-subcommands.d.mts.map +0 -1
  594. package/dist/types/utils/ms-at-home.d.mts +0 -2
  595. package/dist/types/utils/ms-at-home.d.mts.map +0 -1
  596. package/dist/types/utils/npm-config.d.mts +0 -14
  597. package/dist/types/utils/npm-config.d.mts.map +0 -1
  598. package/dist/types/utils/npm-package-arg.d.mts +0 -8
  599. package/dist/types/utils/npm-package-arg.d.mts.map +0 -1
  600. package/dist/types/utils/npm-paths.d.mts +0 -7
  601. package/dist/types/utils/npm-paths.d.mts.map +0 -1
  602. package/dist/types/utils/npm-spec.d.mts +0 -57
  603. package/dist/types/utils/npm-spec.d.mts.map +0 -1
  604. package/dist/types/utils/objects.d.mts +0 -3
  605. package/dist/types/utils/objects.d.mts.map +0 -1
  606. package/dist/types/utils/organization.d.mts +0 -5
  607. package/dist/types/utils/organization.d.mts.map +0 -1
  608. package/dist/types/utils/output-formatting.d.mts +0 -20
  609. package/dist/types/utils/output-formatting.d.mts.map +0 -1
  610. package/dist/types/utils/package-environment.d.mts +0 -57
  611. package/dist/types/utils/package-environment.d.mts.map +0 -1
  612. package/dist/types/utils/path-resolve.d.mts +0 -14
  613. package/dist/types/utils/path-resolve.d.mts.map +0 -1
  614. package/dist/types/utils/pnpm-paths.d.mts +0 -5
  615. package/dist/types/utils/pnpm-paths.d.mts.map +0 -1
  616. package/dist/types/utils/pnpm.d.mts +0 -11
  617. package/dist/types/utils/pnpm.d.mts.map +0 -1
  618. package/dist/types/utils/purl-to-ghsa.d.mts +0 -6
  619. package/dist/types/utils/purl-to-ghsa.d.mts.map +0 -1
  620. package/dist/types/utils/purl.d.mts +0 -71
  621. package/dist/types/utils/purl.d.mts.map +0 -1
  622. package/dist/types/utils/requirements.d.mts +0 -125
  623. package/dist/types/utils/requirements.d.mts.map +0 -1
  624. package/dist/types/utils/sdk.d.mts +0 -17
  625. package/dist/types/utils/sdk.d.mts.map +0 -1
  626. package/dist/types/utils/semver.d.mts +0 -7
  627. package/dist/types/utils/semver.d.mts.map +0 -1
  628. package/dist/types/utils/serialize-result-json.d.mts +0 -5
  629. package/dist/types/utils/serialize-result-json.d.mts.map +0 -1
  630. package/dist/types/utils/shadow-links.d.mts +0 -5
  631. package/dist/types/utils/shadow-links.d.mts.map +0 -1
  632. package/dist/types/utils/socket-json.d.mts +0 -59
  633. package/dist/types/utils/socket-json.d.mts.map +0 -1
  634. package/dist/types/utils/socket-package-alert.d.mts +0 -80
  635. package/dist/types/utils/socket-package-alert.d.mts.map +0 -1
  636. package/dist/types/utils/socket-url.d.mts +0 -8
  637. package/dist/types/utils/socket-url.d.mts.map +0 -1
  638. package/dist/types/utils/spec.d.mts +0 -5
  639. package/dist/types/utils/spec.d.mts.map +0 -1
  640. package/dist/types/utils/strings.d.mts +0 -14
  641. package/dist/types/utils/strings.d.mts.map +0 -1
  642. package/dist/types/utils/terminal-link.d.mts +0 -52
  643. package/dist/types/utils/terminal-link.d.mts.map +0 -1
  644. package/dist/types/utils/tildify.d.mts +0 -2
  645. package/dist/types/utils/tildify.d.mts.map +0 -1
  646. package/dist/types/utils/translations.d.mts +0 -617
  647. package/dist/types/utils/translations.d.mts.map +0 -1
  648. package/dist/types/utils/walk-nested-map.d.mts +0 -7
  649. package/dist/types/utils/walk-nested-map.d.mts.map +0 -1
  650. package/dist/types/utils/yarn-paths.d.mts +0 -5
  651. package/dist/types/utils/yarn-paths.d.mts.map +0 -1
  652. package/dist/types/utils/yarn-version.d.mts +0 -2
  653. package/dist/types/utils/yarn-version.d.mts.map +0 -1
  654. package/dist/types/yarn-cli.d.mts +0 -3
  655. package/dist/types/yarn-cli.d.mts.map +0 -1
  656. package/dist/utils.js +0 -6146
  657. package/dist/utils.js.map +0 -1
  658. package/dist/vendor.js +0 -162074
  659. package/dist/yarn-cli.js +0 -30
  660. package/dist/yarn-cli.js.map +0 -1
  661. package/external/@socketsecurity/registry/LICENSE +0 -21
  662. package/external/@socketsecurity/registry/README.md +0 -9
  663. package/external/@socketsecurity/registry/extensions.json +0 -28
  664. package/external/@socketsecurity/registry/external/@inquirer/confirm.js +0 -3165
  665. package/external/@socketsecurity/registry/external/@inquirer/input.js +0 -3202
  666. package/external/@socketsecurity/registry/external/@inquirer/password.js +0 -3307
  667. package/external/@socketsecurity/registry/external/@inquirer/search.js +0 -3519
  668. package/external/@socketsecurity/registry/external/@inquirer/select.js +0 -3655
  669. package/external/@socketsecurity/registry/external/@npmcli/package-json/index.js +0 -21406
  670. package/external/@socketsecurity/registry/external/@npmcli/package-json/lib/read-package.js +0 -183
  671. package/external/@socketsecurity/registry/external/@npmcli/package-json/lib/sort.js +0 -274
  672. package/external/@socketsecurity/registry/external/@npmcli/promise-spawn.js +0 -704
  673. package/external/@socketsecurity/registry/external/@socketregistry/is-unicode-supported.js +0 -54
  674. package/external/@socketsecurity/registry/external/@socketregistry/packageurl-js.js +0 -4516
  675. package/external/@socketsecurity/registry/external/@socketregistry/yocto-spinner.js +0 -453
  676. package/external/@socketsecurity/registry/external/@yarnpkg/extensions.js +0 -1406
  677. package/external/@socketsecurity/registry/external/browserslist.js +0 -20496
  678. package/external/@socketsecurity/registry/external/cacache.js +0 -16208
  679. package/external/@socketsecurity/registry/external/debug.js +0 -1163
  680. package/external/@socketsecurity/registry/external/fast-glob.js +0 -7994
  681. package/external/@socketsecurity/registry/external/fast-sort.js +0 -181
  682. package/external/@socketsecurity/registry/external/libnpmpack.js +0 -106271
  683. package/external/@socketsecurity/registry/external/make-fetch-happen.js +0 -38997
  684. package/external/@socketsecurity/registry/external/normalize-package-data.js +0 -5343
  685. package/external/@socketsecurity/registry/external/npm-package-arg.js +0 -5773
  686. package/external/@socketsecurity/registry/external/pacote.js +0 -74109
  687. package/external/@socketsecurity/registry/external/picomatch.js +0 -2307
  688. package/external/@socketsecurity/registry/external/semver.js +0 -2618
  689. package/external/@socketsecurity/registry/external/signal-exit.js +0 -336
  690. package/external/@socketsecurity/registry/external/spdx-correct.js +0 -1457
  691. package/external/@socketsecurity/registry/external/spdx-expression-parse.js +0 -1043
  692. package/external/@socketsecurity/registry/external/streaming-iterables.js +0 -326
  693. package/external/@socketsecurity/registry/external/validate-npm-package-name.js +0 -108
  694. package/external/@socketsecurity/registry/external/which.js +0 -405
  695. package/external/@socketsecurity/registry/external/yoctocolors-cjs.js +0 -101
  696. package/external/@socketsecurity/registry/index.js +0 -31
  697. package/external/@socketsecurity/registry/lib/agent.js +0 -390
  698. package/external/@socketsecurity/registry/lib/arrays.js +0 -89
  699. package/external/@socketsecurity/registry/lib/bin.js +0 -650
  700. package/external/@socketsecurity/registry/lib/constants/abort-controller.js +0 -15
  701. package/external/@socketsecurity/registry/lib/constants/abort-signal.js +0 -27
  702. package/external/@socketsecurity/registry/lib/constants/at-latest.js +0 -3
  703. package/external/@socketsecurity/registry/lib/constants/biome-json.js +0 -3
  704. package/external/@socketsecurity/registry/lib/constants/bun-lock.js +0 -3
  705. package/external/@socketsecurity/registry/lib/constants/bun-lockb.js +0 -3
  706. package/external/@socketsecurity/registry/lib/constants/bun.js +0 -3
  707. package/external/@socketsecurity/registry/lib/constants/ci.js +0 -3
  708. package/external/@socketsecurity/registry/lib/constants/column-limit.js +0 -3
  709. package/external/@socketsecurity/registry/lib/constants/copy-left-licenses.js +0 -27
  710. package/external/@socketsecurity/registry/lib/constants/darwin.js +0 -3
  711. package/external/@socketsecurity/registry/lib/constants/dot-git-dir.js +0 -3
  712. package/external/@socketsecurity/registry/lib/constants/dot-package-lock-json.js +0 -3
  713. package/external/@socketsecurity/registry/lib/constants/dot-socket-dir.js +0 -3
  714. package/external/@socketsecurity/registry/lib/constants/empty-file.js +0 -3
  715. package/external/@socketsecurity/registry/lib/constants/empty-value.js +0 -3
  716. package/external/@socketsecurity/registry/lib/constants/env.js +0 -59
  717. package/external/@socketsecurity/registry/lib/constants/eslint-config-js.js +0 -3
  718. package/external/@socketsecurity/registry/lib/constants/esnext.js +0 -3
  719. package/external/@socketsecurity/registry/lib/constants/exec-path.js +0 -3
  720. package/external/@socketsecurity/registry/lib/constants/ext-cjs.js +0 -3
  721. package/external/@socketsecurity/registry/lib/constants/ext-cmd.js +0 -3
  722. package/external/@socketsecurity/registry/lib/constants/ext-cts.js +0 -3
  723. package/external/@socketsecurity/registry/lib/constants/ext-dts.js +0 -3
  724. package/external/@socketsecurity/registry/lib/constants/ext-js.js +0 -3
  725. package/external/@socketsecurity/registry/lib/constants/ext-json.js +0 -3
  726. package/external/@socketsecurity/registry/lib/constants/ext-lock.js +0 -3
  727. package/external/@socketsecurity/registry/lib/constants/ext-lockb.js +0 -3
  728. package/external/@socketsecurity/registry/lib/constants/ext-md.js +0 -3
  729. package/external/@socketsecurity/registry/lib/constants/ext-mjs.js +0 -3
  730. package/external/@socketsecurity/registry/lib/constants/ext-mts.js +0 -3
  731. package/external/@socketsecurity/registry/lib/constants/ext-ps1.js +0 -3
  732. package/external/@socketsecurity/registry/lib/constants/ext-yaml.js +0 -3
  733. package/external/@socketsecurity/registry/lib/constants/ext-yml.js +0 -3
  734. package/external/@socketsecurity/registry/lib/constants/extensions-json.js +0 -3
  735. package/external/@socketsecurity/registry/lib/constants/extensions.js +0 -3
  736. package/external/@socketsecurity/registry/lib/constants/get-ipc.js +0 -10
  737. package/external/@socketsecurity/registry/lib/constants/gitignore.js +0 -3
  738. package/external/@socketsecurity/registry/lib/constants/index.js +0 -139
  739. package/external/@socketsecurity/registry/lib/constants/ipc-handler.js +0 -19
  740. package/external/@socketsecurity/registry/lib/constants/ipc-object.js +0 -6
  741. package/external/@socketsecurity/registry/lib/constants/ipc-promise.js +0 -47
  742. package/external/@socketsecurity/registry/lib/constants/ipc-target.js +0 -3
  743. package/external/@socketsecurity/registry/lib/constants/k-internals-symbol.js +0 -3
  744. package/external/@socketsecurity/registry/lib/constants/latest.js +0 -3
  745. package/external/@socketsecurity/registry/lib/constants/license-glob-recursive.js +0 -3
  746. package/external/@socketsecurity/registry/lib/constants/license-glob.js +0 -3
  747. package/external/@socketsecurity/registry/lib/constants/license-original-glob-recursive.js +0 -3
  748. package/external/@socketsecurity/registry/lib/constants/license-original-glob.js +0 -3
  749. package/external/@socketsecurity/registry/lib/constants/license-original.js +0 -3
  750. package/external/@socketsecurity/registry/lib/constants/license.js +0 -3
  751. package/external/@socketsecurity/registry/lib/constants/lifecycle-script-names.js +0 -18
  752. package/external/@socketsecurity/registry/lib/constants/loop-sentinel.js +0 -3
  753. package/external/@socketsecurity/registry/lib/constants/maintained-node-versions.js +0 -47
  754. package/external/@socketsecurity/registry/lib/constants/manifest-json.js +0 -3
  755. package/external/@socketsecurity/registry/lib/constants/mit.js +0 -3
  756. package/external/@socketsecurity/registry/lib/constants/node-auth-token.js +0 -3
  757. package/external/@socketsecurity/registry/lib/constants/node-debug-flags.js +0 -9
  758. package/external/@socketsecurity/registry/lib/constants/node-env.js +0 -3
  759. package/external/@socketsecurity/registry/lib/constants/node-harden-flags.js +0 -29
  760. package/external/@socketsecurity/registry/lib/constants/node-modules-glob-recursive.js +0 -3
  761. package/external/@socketsecurity/registry/lib/constants/node-modules.js +0 -3
  762. package/external/@socketsecurity/registry/lib/constants/node-no-warnings-flags.js +0 -16
  763. package/external/@socketsecurity/registry/lib/constants/node-version.js +0 -3
  764. package/external/@socketsecurity/registry/lib/constants/npm-exec-path.js +0 -5
  765. package/external/@socketsecurity/registry/lib/constants/npm-real-exec-path.js +0 -6
  766. package/external/@socketsecurity/registry/lib/constants/npm-shrinkwrap-json.js +0 -3
  767. package/external/@socketsecurity/registry/lib/constants/npm.js +0 -3
  768. package/external/@socketsecurity/registry/lib/constants/npx.js +0 -3
  769. package/external/@socketsecurity/registry/lib/constants/overrides.js +0 -3
  770. package/external/@socketsecurity/registry/lib/constants/package-default-node-range.js +0 -6
  771. package/external/@socketsecurity/registry/lib/constants/package-default-socket-categories.js +0 -3
  772. package/external/@socketsecurity/registry/lib/constants/package-default-version.js +0 -3
  773. package/external/@socketsecurity/registry/lib/constants/package-extensions.js +0 -47
  774. package/external/@socketsecurity/registry/lib/constants/package-json.js +0 -3
  775. package/external/@socketsecurity/registry/lib/constants/package-lock-json.js +0 -3
  776. package/external/@socketsecurity/registry/lib/constants/packument-cache.js +0 -3
  777. package/external/@socketsecurity/registry/lib/constants/pacote-cache-path.js +0 -9
  778. package/external/@socketsecurity/registry/lib/constants/pnpm-exec-path.js +0 -5
  779. package/external/@socketsecurity/registry/lib/constants/pnpm-lock-yaml.js +0 -3
  780. package/external/@socketsecurity/registry/lib/constants/pnpm.js +0 -3
  781. package/external/@socketsecurity/registry/lib/constants/pre-commit.js +0 -3
  782. package/external/@socketsecurity/registry/lib/constants/readme-glob-recursive.js +0 -3
  783. package/external/@socketsecurity/registry/lib/constants/readme-glob.js +0 -3
  784. package/external/@socketsecurity/registry/lib/constants/readme-md.js +0 -3
  785. package/external/@socketsecurity/registry/lib/constants/registry-scope-delimiter.js +0 -3
  786. package/external/@socketsecurity/registry/lib/constants/registry.js +0 -3
  787. package/external/@socketsecurity/registry/lib/constants/resolutions.js +0 -3
  788. package/external/@socketsecurity/registry/lib/constants/socket-github-org.js +0 -3
  789. package/external/@socketsecurity/registry/lib/constants/socket-ipc-handshake.js +0 -3
  790. package/external/@socketsecurity/registry/lib/constants/socket-override-scope.js +0 -3
  791. package/external/@socketsecurity/registry/lib/constants/socket-public-api-token.js +0 -3
  792. package/external/@socketsecurity/registry/lib/constants/socket-registry-npm-org.js +0 -3
  793. package/external/@socketsecurity/registry/lib/constants/socket-registry-package-name.js +0 -3
  794. package/external/@socketsecurity/registry/lib/constants/socket-registry-repo-name.js +0 -3
  795. package/external/@socketsecurity/registry/lib/constants/socket-registry-scope.js +0 -3
  796. package/external/@socketsecurity/registry/lib/constants/socket-security-scope.js +0 -3
  797. package/external/@socketsecurity/registry/lib/constants/spinner.js +0 -4
  798. package/external/@socketsecurity/registry/lib/constants/supports-node-compile-cache-api.js +0 -8
  799. package/external/@socketsecurity/registry/lib/constants/supports-node-compile-cache-env-var.js +0 -8
  800. package/external/@socketsecurity/registry/lib/constants/supports-node-disable-warning-flag.js +0 -8
  801. package/external/@socketsecurity/registry/lib/constants/supports-node-permission-flag.js +0 -8
  802. package/external/@socketsecurity/registry/lib/constants/supports-node-require-module.js +0 -3
  803. package/external/@socketsecurity/registry/lib/constants/supports-node-run.js +0 -8
  804. package/external/@socketsecurity/registry/lib/constants/supports-process-send.js +0 -5
  805. package/external/@socketsecurity/registry/lib/constants/ts-libs-available.js +0 -22
  806. package/external/@socketsecurity/registry/lib/constants/ts-types-available.js +0 -3
  807. package/external/@socketsecurity/registry/lib/constants/tsconfig-json.js +0 -3
  808. package/external/@socketsecurity/registry/lib/constants/undefined-token.js +0 -3
  809. package/external/@socketsecurity/registry/lib/constants/unknown-error.js +0 -3
  810. package/external/@socketsecurity/registry/lib/constants/unknown-value.js +0 -3
  811. package/external/@socketsecurity/registry/lib/constants/unlicenced.js +0 -3
  812. package/external/@socketsecurity/registry/lib/constants/unlicensed.js +0 -3
  813. package/external/@socketsecurity/registry/lib/constants/utf8.js +0 -3
  814. package/external/@socketsecurity/registry/lib/constants/vitest.js +0 -3
  815. package/external/@socketsecurity/registry/lib/constants/vlt-lock-json.js +0 -3
  816. package/external/@socketsecurity/registry/lib/constants/vlt.js +0 -3
  817. package/external/@socketsecurity/registry/lib/constants/win32.js +0 -3
  818. package/external/@socketsecurity/registry/lib/constants/yarn-berry.js +0 -3
  819. package/external/@socketsecurity/registry/lib/constants/yarn-classic.js +0 -3
  820. package/external/@socketsecurity/registry/lib/constants/yarn-exec-path.js +0 -5
  821. package/external/@socketsecurity/registry/lib/constants/yarn-lock.js +0 -3
  822. package/external/@socketsecurity/registry/lib/constants/yarn.js +0 -3
  823. package/external/@socketsecurity/registry/lib/debug.js +0 -264
  824. package/external/@socketsecurity/registry/lib/env.js +0 -62
  825. package/external/@socketsecurity/registry/lib/fs.js +0 -556
  826. package/external/@socketsecurity/registry/lib/functions.js +0 -20
  827. package/external/@socketsecurity/registry/lib/globs.js +0 -145
  828. package/external/@socketsecurity/registry/lib/json.js +0 -69
  829. package/external/@socketsecurity/registry/lib/logger.js +0 -534
  830. package/external/@socketsecurity/registry/lib/objects.js +0 -422
  831. package/external/@socketsecurity/registry/lib/packages.js +0 -1376
  832. package/external/@socketsecurity/registry/lib/path.js +0 -231
  833. package/external/@socketsecurity/registry/lib/promises.js +0 -286
  834. package/external/@socketsecurity/registry/lib/prompts.js +0 -63
  835. package/external/@socketsecurity/registry/lib/regexps.js +0 -23
  836. package/external/@socketsecurity/registry/lib/sorts.js +0 -70
  837. package/external/@socketsecurity/registry/lib/spawn.js +0 -252
  838. package/external/@socketsecurity/registry/lib/spinner.js +0 -205
  839. package/external/@socketsecurity/registry/lib/streams.js +0 -84
  840. package/external/@socketsecurity/registry/lib/strings.js +0 -235
  841. package/external/@socketsecurity/registry/lib/url.js +0 -68
  842. package/external/@socketsecurity/registry/lib/words.js +0 -45
  843. package/external/@socketsecurity/registry/manifest.json +0 -1875
  844. package/external/blessed/LICENSE +0 -20
  845. package/external/blessed/README.md +0 -2421
  846. package/external/blessed/lib/alias.js +0 -528
  847. package/external/blessed/lib/blessed.js +0 -34
  848. package/external/blessed/lib/colors.js +0 -532
  849. package/external/blessed/lib/events.js +0 -191
  850. package/external/blessed/lib/gpmclient.js +0 -223
  851. package/external/blessed/lib/helpers.js +0 -167
  852. package/external/blessed/lib/keys.js +0 -341
  853. package/external/blessed/lib/program.js +0 -4297
  854. package/external/blessed/lib/tput.js +0 -3020
  855. package/external/blessed/lib/unicode.js +0 -792
  856. package/external/blessed/lib/widget.js +0 -62
  857. package/external/blessed/lib/widgets/ansiimage.js +0 -169
  858. package/external/blessed/lib/widgets/bigtext.js +0 -161
  859. package/external/blessed/lib/widgets/box.js +0 -36
  860. package/external/blessed/lib/widgets/button.js +0 -64
  861. package/external/blessed/lib/widgets/checkbox.js +0 -93
  862. package/external/blessed/lib/widgets/element.js +0 -2572
  863. package/external/blessed/lib/widgets/filemanager.js +0 -214
  864. package/external/blessed/lib/widgets/form.js +0 -269
  865. package/external/blessed/lib/widgets/image.js +0 -63
  866. package/external/blessed/lib/widgets/input.js +0 -36
  867. package/external/blessed/lib/widgets/layout.js +0 -235
  868. package/external/blessed/lib/widgets/line.js +0 -58
  869. package/external/blessed/lib/widgets/list.js +0 -601
  870. package/external/blessed/lib/widgets/listbar.js +0 -413
  871. package/external/blessed/lib/widgets/listtable.js +0 -254
  872. package/external/blessed/lib/widgets/loading.js +0 -90
  873. package/external/blessed/lib/widgets/log.js +0 -85
  874. package/external/blessed/lib/widgets/message.js +0 -125
  875. package/external/blessed/lib/widgets/node.js +0 -284
  876. package/external/blessed/lib/widgets/overlayimage.js +0 -719
  877. package/external/blessed/lib/widgets/progressbar.js +0 -159
  878. package/external/blessed/lib/widgets/prompt.js +0 -122
  879. package/external/blessed/lib/widgets/question.js +0 -118
  880. package/external/blessed/lib/widgets/radiobutton.js +0 -63
  881. package/external/blessed/lib/widgets/radioset.js +0 -38
  882. package/external/blessed/lib/widgets/screen.js +0 -2300
  883. package/external/blessed/lib/widgets/scrollablebox.js +0 -391
  884. package/external/blessed/lib/widgets/scrollabletext.js +0 -37
  885. package/external/blessed/lib/widgets/table.js +0 -356
  886. package/external/blessed/lib/widgets/terminal.js +0 -414
  887. package/external/blessed/lib/widgets/text.js +0 -37
  888. package/external/blessed/lib/widgets/textarea.js +0 -344
  889. package/external/blessed/lib/widgets/textbox.js +0 -79
  890. package/external/blessed/lib/widgets/video.js +0 -128
  891. package/external/blessed/usr/fonts/AUTHORS +0 -1
  892. package/external/blessed/usr/fonts/LICENSE +0 -94
  893. package/external/blessed/usr/fonts/README +0 -340
  894. package/external/blessed/usr/fonts/ter-u14b.json +0 -17826
  895. package/external/blessed/usr/fonts/ter-u14n.json +0 -17826
  896. package/external/blessed/usr/linux +0 -0
  897. package/external/blessed/usr/windows-ansi +0 -0
  898. package/external/blessed/usr/xterm +0 -0
  899. package/external/blessed/usr/xterm-256color +0 -0
  900. package/external/blessed/usr/xterm.termcap +0 -243
  901. package/external/blessed/usr/xterm.terminfo +0 -1977
  902. package/external/blessed/vendor/tng.js +0 -1757
  903. package/external/blessed-contrib/LICENSE.md +0 -21
  904. package/external/blessed-contrib/lib/layout/grid.js +0 -409
  905. package/external/blessed-contrib/lib/widget/charts/bar.js +0 -8370
  906. package/external/blessed-contrib/lib/widget/charts/line.js +0 -17924
  907. package/external/blessed-contrib/lib/widget/table.js +0 -187
  908. package/shadow-bin/npm +0 -27
  909. package/shadow-bin/npx +0 -27
  910. package/shadow-bin/pnpm +0 -27
  911. package/shadow-bin/yarn +0 -27
  912. /package/{translations.json → data/alert-translations.json} +0 -0
  913. /package/{requirements.json → data/command-api-requirements.json} +0 -0
  914. /package/{dist → data}/socket-completion.bash +0 -0
@@ -1,4297 +0,0 @@
1
- 'use strict'
2
-
3
- /**
4
- * program.js - basic curses-like functionality for blessed.
5
- * Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
6
- * https://github.com/chjj/blessed
7
- */
8
-
9
- /**
10
- * Modules
11
- */
12
-
13
- var EventEmitter = require('events').EventEmitter
14
- , StringDecoder = require('string_decoder').StringDecoder
15
- , cp = require('child_process')
16
- , util = require('util')
17
- , fs = require('fs');
18
-
19
- var Tput = require('./tput')
20
- , colors = require('./colors')
21
- , slice = Array.prototype.slice;
22
-
23
- var nextTick = global.setImmediate || process.nextTick.bind(process);
24
-
25
- /**
26
- * Program
27
- */
28
-
29
- function Program(options) {
30
- var self = this;
31
-
32
- if (!(this instanceof Program)) {
33
- return new Program(options);
34
- }
35
-
36
- Program.bind(this);
37
-
38
- EventEmitter.call(this);
39
-
40
- if (!options || Object.getPrototypeOf(options) !== Object.prototype) {
41
- options = {
42
- input: arguments[0],
43
- output: arguments[1]
44
- };
45
- }
46
-
47
- this.options = options;
48
- this.input = options.input || process.stdin;
49
- this.output = options.output || process.stdout;
50
-
51
- options.log = options.log || options.dump;
52
- if (options.log) {
53
- this._logger = fs.createWriteStream(options.log);
54
- if (options.dump) this.setupDump();
55
- }
56
-
57
- this.zero = options.zero !== false;
58
- this.useBuffer = options.buffer;
59
-
60
- this.x = 0;
61
- this.y = 0;
62
- this.savedX = 0;
63
- this.savedY = 0;
64
-
65
- this.cols = this.output.columns || 1;
66
- this.rows = this.output.rows || 1;
67
-
68
- this.scrollTop = 0;
69
- this.scrollBottom = this.rows - 1;
70
-
71
- this._terminal = options.terminal
72
- || options.term
73
- || process.env.TERM
74
- || (process.platform === 'win32' ? 'windows-ansi' : 'xterm');
75
-
76
- this._terminal = this._terminal.toLowerCase();
77
-
78
- // OSX
79
- this.isOSXTerm = process.env.TERM_PROGRAM === 'Apple_Terminal';
80
- this.isiTerm2 = process.env.TERM_PROGRAM === 'iTerm.app'
81
- || !!process.env.ITERM_SESSION_ID;
82
-
83
- // VTE
84
- // NOTE: lxterminal does not provide an env variable to check for.
85
- // NOTE: gnome-terminal and sakura use a later version of VTE
86
- // which provides VTE_VERSION as well as supports SGR events.
87
- this.isXFCE = /xfce/i.test(process.env.COLORTERM);
88
- this.isTerminator = !!process.env.TERMINATOR_UUID;
89
- this.isLXDE = false;
90
- this.isVTE = !!process.env.VTE_VERSION
91
- || this.isXFCE
92
- || this.isTerminator
93
- || this.isLXDE;
94
-
95
- // xterm and rxvt - not accurate
96
- this.isRxvt = /rxvt/i.test(process.env.COLORTERM);
97
- this.isXterm = false;
98
-
99
- this.tmux = !!process.env.TMUX;
100
- this.tmuxVersion = (function() {
101
- if (!self.tmux) return 2;
102
- try {
103
- var version = cp.execFileSync('tmux', ['-V'], { encoding: 'utf8' });
104
- return +/^tmux ([\d.]+)/i.exec(version.trim().split('\n')[0])[1];
105
- } catch (e) {
106
- return 2;
107
- }
108
- })();
109
-
110
- this._buf = '';
111
- this._flush = this.flush.bind(this);
112
-
113
- if (options.tput !== false) {
114
- this.setupTput();
115
- }
116
-
117
- this.listen();
118
- }
119
-
120
- Program.global = null;
121
-
122
- Program.total = 0;
123
-
124
- Program.instances = [];
125
-
126
- Program.bind = function(program) {
127
- if (!Program.global) {
128
- Program.global = program;
129
- }
130
-
131
- if (!~Program.instances.indexOf(program)) {
132
- Program.instances.push(program);
133
- program.index = Program.total;
134
- Program.total++;
135
- }
136
-
137
- if (Program._bound) return;
138
- Program._bound = true;
139
-
140
- unshiftEvent(process, 'exit', Program._exitHandler = function() {
141
- Program.instances.forEach(function(program) {
142
- // Potentially reset window title on exit:
143
- // if (program._originalTitle) {
144
- // program.setTitle(program._originalTitle);
145
- // }
146
- // Ensure the buffer is flushed (it should
147
- // always be at this point, but who knows).
148
- program.flush();
149
- // Ensure _exiting is set (could technically
150
- // use process._exiting).
151
- program._exiting = true;
152
- });
153
- });
154
- };
155
-
156
- Object.setPrototypeOf(Program.prototype, EventEmitter.prototype);
157
-
158
- Program.prototype.type = 'program';
159
-
160
- Program.prototype.log = function() {
161
- return this._log('LOG', util.format.apply(util, arguments));
162
- };
163
-
164
- Program.prototype.debug = function() {
165
- if (!this.options.debug) return;
166
- return this._log('DEBUG', util.format.apply(util, arguments));
167
- };
168
-
169
- Program.prototype._log = function(pre, msg) {
170
- if (!this._logger) return;
171
- return this._logger.write(pre + ': ' + msg + '\n-\n');
172
- };
173
-
174
- Program.prototype.setupDump = function() {
175
- var self = this
176
- , write = this.output.write
177
- , decoder = new StringDecoder('utf8');
178
-
179
- function stringify(data) {
180
- return caret(data
181
- .replace(/\r/g, '\\r')
182
- .replace(/\n/g, '\\n')
183
- .replace(/\t/g, '\\t'))
184
- .replace(/[^ -~]/g, function(ch) {
185
- if (ch.charCodeAt(0) > 0xff) return ch;
186
- ch = ch.charCodeAt(0).toString(16);
187
- if (ch.length > 2) {
188
- if (ch.length < 4) ch = '0' + ch;
189
- return '\\u' + ch;
190
- }
191
- if (ch.length < 2) ch = '0' + ch;
192
- return '\\x' + ch;
193
- });
194
- }
195
-
196
- function caret(data) {
197
- return data.replace(/[\0\x80\x1b-\x1f\x7f\x01-\x1a]/g, function(ch) {
198
- switch (ch) {
199
- case '\0':
200
- case '\x80':
201
- ch = '@';
202
- break;
203
- case '\x1b':
204
- ch = '[';
205
- break;
206
- case '\x1c':
207
- ch = '\\';
208
- break;
209
- case '\x1d':
210
- ch = ']';
211
- break;
212
- case '\x1e':
213
- ch = '^';
214
- break;
215
- case '\x1f':
216
- ch = '_';
217
- break;
218
- case '\x7f':
219
- ch = '?';
220
- break;
221
- default:
222
- ch = ch.charCodeAt(0);
223
- // From ('A' - 64) to ('Z' - 64).
224
- if (ch >= 1 && ch <= 26) {
225
- ch = String.fromCharCode(ch + 64);
226
- } else {
227
- return String.fromCharCode(ch);
228
- }
229
- break;
230
- }
231
- return '^' + ch;
232
- });
233
- }
234
-
235
- this.input.on('data', function(data) {
236
- self._log('IN', stringify(decoder.write(data)));
237
- });
238
-
239
- this.output.write = function(data) {
240
- self._log('OUT', stringify(data));
241
- return write.apply(this, arguments);
242
- };
243
- };
244
-
245
- Program.prototype.setupTput = function() {
246
- if (this._tputSetup) return;
247
- this._tputSetup = true;
248
-
249
- var self = this
250
- , options = this.options
251
- , write = this._write.bind(this);
252
-
253
- var tput = this.tput = new Tput({
254
- terminal: this.terminal,
255
- padding: options.padding,
256
- extended: options.extended,
257
- printf: options.printf,
258
- termcap: options.termcap,
259
- forceUnicode: options.forceUnicode
260
- });
261
-
262
- if (tput.error) {
263
- nextTick(function() {
264
- self.emit('warning', tput.error.message);
265
- });
266
- }
267
-
268
- if (tput.padding) {
269
- nextTick(function() {
270
- self.emit('warning', 'Terminfo padding has been enabled.');
271
- });
272
- }
273
-
274
- this.put = function() {
275
- var args = slice.call(arguments)
276
- , cap = args.shift();
277
-
278
- if (tput[cap]) {
279
- return this._write(tput[cap].apply(tput, args));
280
- }
281
- };
282
-
283
- Object.keys(tput).forEach(function(key) {
284
- if (self[key] == null) {
285
- self[key] = tput[key];
286
- }
287
-
288
- if (typeof tput[key] !== 'function') {
289
- self.put[key] = tput[key];
290
- return;
291
- }
292
-
293
- if (tput.padding) {
294
- self.put[key] = function() {
295
- return tput._print(tput[key].apply(tput, arguments), write);
296
- };
297
- } else {
298
- self.put[key] = function() {
299
- return self._write(tput[key].apply(tput, arguments));
300
- };
301
- }
302
- });
303
- };
304
-
305
- Program.prototype.__defineGetter__('terminal', function() {
306
- return this._terminal;
307
- });
308
-
309
- Program.prototype.__defineSetter__('terminal', function(terminal) {
310
- this.setTerminal(terminal);
311
- return this.terminal;
312
- });
313
-
314
- Program.prototype.setTerminal = function(terminal) {
315
- this._terminal = terminal.toLowerCase();
316
- delete this._tputSetup;
317
- this.setupTput();
318
- };
319
-
320
- Program.prototype.has = function(name) {
321
- return this.tput
322
- ? this.tput.has(name)
323
- : false;
324
- };
325
-
326
- Program.prototype.term = function(is) {
327
- return this.terminal.indexOf(is) === 0;
328
- };
329
-
330
- Program.prototype.listen = function() {
331
- var self = this;
332
-
333
- // Potentially reset window title on exit:
334
- // if (!this.isRxvt) {
335
- // if (!this.isVTE) this.setTitleModeFeature(3);
336
- // this.manipulateWindow(21, function(err, data) {
337
- // if (err) return;
338
- // self._originalTitle = data.text;
339
- // });
340
- // }
341
-
342
- // Listen for keys/mouse on input
343
- if (!this.input._blessedInput) {
344
- this.input._blessedInput = 1;
345
- this._listenInput();
346
- } else {
347
- this.input._blessedInput++;
348
- }
349
-
350
- this.on('newListener', this._newHandler = function fn(type) {
351
- if (type === 'keypress' || type === 'mouse') {
352
- self.removeListener('newListener', fn);
353
- if (self.input.setRawMode && !self.input.isRaw) {
354
- self.input.setRawMode(true);
355
- self.input.resume();
356
- }
357
- }
358
- });
359
-
360
- this.on('newListener', function fn(type) {
361
- if (type === 'mouse') {
362
- self.removeListener('newListener', fn);
363
- self.bindMouse();
364
- }
365
- });
366
-
367
- // Listen for resize on output
368
- if (!this.output._blessedOutput) {
369
- this.output._blessedOutput = 1;
370
- this._listenOutput();
371
- } else {
372
- this.output._blessedOutput++;
373
- }
374
- };
375
-
376
- Program.prototype._listenInput = function() {
377
- var keys = require('./keys')
378
- , self = this;
379
-
380
- // Input
381
- this.input.on('keypress', this.input._keypressHandler = function(ch, key) {
382
- key = key || { ch: ch };
383
-
384
- if (key.name === 'undefined'
385
- && (key.code === '[M' || key.code === '[I' || key.code === '[O')) {
386
- // A mouse sequence. The `keys` module doesn't understand these.
387
- return;
388
- }
389
-
390
- if (key.name === 'undefined') {
391
- // Not sure what this is, but we should probably ignore it.
392
- return;
393
- }
394
-
395
- if (key.name === 'enter' && key.sequence === '\n') {
396
- key.name = 'linefeed';
397
- }
398
-
399
- if (key.name === 'return' && key.sequence === '\r') {
400
- self.input.emit('keypress', ch, merge({}, key, { name: 'enter' }));
401
- }
402
-
403
- var name = (key.ctrl ? 'C-' : '')
404
- + (key.meta ? 'M-' : '')
405
- + (key.shift && key.name ? 'S-' : '')
406
- + (key.name || ch);
407
-
408
- key.full = name;
409
-
410
- Program.instances.forEach(function(program) {
411
- if (program.input !== self.input) return;
412
- program.emit('keypress', ch, key);
413
- program.emit('key ' + name, ch, key);
414
- });
415
- });
416
-
417
- this.input.on('data', this.input._dataHandler = function(data) {
418
- Program.instances.forEach(function(program) {
419
- if (program.input !== self.input) return;
420
- program.emit('data', data);
421
- });
422
- });
423
-
424
- keys.emitKeypressEvents(this.input);
425
- };
426
-
427
- Program.prototype._listenOutput = function() {
428
- var self = this;
429
-
430
- if (!this.output.isTTY) {
431
- nextTick(function() {
432
- self.emit('warning', 'Output is not a TTY');
433
- });
434
- }
435
-
436
- // Output
437
- function resize() {
438
- Program.instances.forEach(function(program) {
439
- if (program.output !== self.output) return;
440
- program.cols = program.output.columns;
441
- program.rows = program.output.rows;
442
- program.emit('resize');
443
- });
444
- }
445
-
446
- this.output.on('resize', this.output._resizeHandler = function() {
447
- Program.instances.forEach(function(program) {
448
- if (program.output !== self.output) return;
449
- if (!program.options.resizeTimeout) {
450
- return resize();
451
- }
452
- if (program._resizeTimer) {
453
- clearTimeout(program._resizeTimer);
454
- delete program._resizeTimer;
455
- }
456
- var time = typeof program.options.resizeTimeout === 'number'
457
- ? program.options.resizeTimeout
458
- : 300;
459
- program._resizeTimer = setTimeout(resize, time);
460
- });
461
- });
462
- };
463
-
464
- Program.prototype.destroy = function() {
465
- var index = Program.instances.indexOf(this);
466
-
467
- if (~index) {
468
- Program.instances.splice(index, 1);
469
- Program.total--;
470
-
471
- this.flush();
472
- this._exiting = true;
473
-
474
- Program.global = Program.instances[0];
475
-
476
- if (Program.total === 0) {
477
- Program.global = null;
478
-
479
- process.removeListener('exit', Program._exitHandler);
480
- delete Program._exitHandler;
481
-
482
- delete Program._bound;
483
- }
484
-
485
- this.input._blessedInput--;
486
- this.output._blessedOutput--;
487
-
488
- if (this.input._blessedInput === 0) {
489
- this.input.removeListener('keypress', this.input._keypressHandler);
490
- this.input.removeListener('data', this.input._dataHandler);
491
- delete this.input._keypressHandler;
492
- delete this.input._dataHandler;
493
-
494
- if (this.input.setRawMode) {
495
- if (this.input.isRaw) {
496
- this.input.setRawMode(false);
497
- }
498
- if (!this.input.destroyed) {
499
- this.input.pause();
500
- }
501
- }
502
- }
503
-
504
- if (this.output._blessedOutput === 0) {
505
- this.output.removeListener('resize', this.output._resizeHandler);
506
- delete this.output._resizeHandler;
507
- }
508
-
509
- this.removeListener('newListener', this._newHandler);
510
- delete this._newHandler;
511
-
512
- this.destroyed = true;
513
- this.emit('destroy');
514
- }
515
- };
516
-
517
- Program.prototype.key = function(key, listener) {
518
- if (typeof key === 'string') key = key.split(/\s*,\s*/);
519
- key.forEach(function(key) {
520
- return this.on('key ' + key, listener);
521
- }, this);
522
- };
523
-
524
- Program.prototype.onceKey = function(key, listener) {
525
- if (typeof key === 'string') key = key.split(/\s*,\s*/);
526
- key.forEach(function(key) {
527
- return this.once('key ' + key, listener);
528
- }, this);
529
- };
530
-
531
- Program.prototype.unkey =
532
- Program.prototype.removeKey = function(key, listener) {
533
- if (typeof key === 'string') key = key.split(/\s*,\s*/);
534
- key.forEach(function(key) {
535
- return this.removeListener('key ' + key, listener);
536
- }, this);
537
- };
538
-
539
- // XTerm mouse events
540
- // http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#Mouse%20Tracking
541
- // To better understand these
542
- // the xterm code is very helpful:
543
- // Relevant files:
544
- // button.c, charproc.c, misc.c
545
- // Relevant functions in xterm/button.c:
546
- // BtnCode, EmitButtonCode, EditorButton, SendMousePosition
547
- // send a mouse event:
548
- // regular/utf8: ^[[M Cb Cx Cy
549
- // urxvt: ^[[ Cb ; Cx ; Cy M
550
- // sgr: ^[[ Cb ; Cx ; Cy M/m
551
- // vt300: ^[[ 24(1/3/5)~ [ Cx , Cy ] \r
552
- // locator: CSI P e ; P b ; P r ; P c ; P p & w
553
- // motion example of a left click:
554
- // ^[[M 3<^[[M@4<^[[M@5<^[[M@6<^[[M@7<^[[M#7<
555
- // mouseup, mousedown, mousewheel
556
- // left click: ^[[M 3<^[[M#3<
557
- // mousewheel up: ^[[M`3>
558
- Program.prototype.bindMouse = function() {
559
- if (this._boundMouse) return;
560
- this._boundMouse = true;
561
-
562
- var decoder = new StringDecoder('utf8')
563
- , self = this;
564
-
565
- this.on('data', function(data) {
566
- var text = decoder.write(data);
567
- if (!text) return;
568
- self._bindMouse(text, data);
569
- });
570
- };
571
-
572
- Program.prototype._bindMouse = function(s, buf) {
573
- var self = this
574
- , key
575
- , parts
576
- , b
577
- , x
578
- , y
579
- , mod
580
- , params
581
- , down
582
- , page
583
- , button;
584
-
585
- key = {
586
- name: undefined,
587
- ctrl: false,
588
- meta: false,
589
- shift: false
590
- };
591
-
592
- if (Buffer.isBuffer(s)) {
593
- if (s[0] > 127 && s[1] === undefined) {
594
- s[0] -= 128;
595
- s = '\x1b' + s.toString('utf-8');
596
- } else {
597
- s = s.toString('utf-8');
598
- }
599
- }
600
-
601
- // if (this.8bit) {
602
- // s = s.replace(/\233/g, '\x1b[');
603
- // buf = new Buffer(s, 'utf8');
604
- // }
605
-
606
- // XTerm / X10 for buggy VTE
607
- // VTE can only send unsigned chars and no unicode for coords. This limits
608
- // them to 0xff. However, normally the x10 protocol does not allow a byte
609
- // under 0x20, but since VTE can have the bytes overflow, we can consider
610
- // bytes below 0x20 to be up to 0xff + 0x20. This gives a limit of 287. Since
611
- // characters ranging from 223 to 248 confuse javascript's utf parser, we
612
- // need to parse the raw binary. We can detect whether the terminal is using
613
- // a bugged VTE version by examining the coordinates and seeing whether they
614
- // are a value they would never otherwise be with a properly implemented x10
615
- // protocol. This method of detecting VTE is only 99% reliable because we
616
- // can't check if the coords are 0x00 (255) since that is a valid x10 coord
617
- // technically.
618
- var bx = s.charCodeAt(4);
619
- var by = s.charCodeAt(5);
620
- if (buf[0] === 0x1b && buf[1] === 0x5b && buf[2] === 0x4d
621
- && (this.isVTE
622
- || bx >= 65533 || by >= 65533
623
- || (bx > 0x00 && bx < 0x20)
624
- || (by > 0x00 && by < 0x20)
625
- || (buf[4] > 223 && buf[4] < 248 && buf.length === 6)
626
- || (buf[5] > 223 && buf[5] < 248 && buf.length === 6))) {
627
- b = buf[3];
628
- x = buf[4];
629
- y = buf[5];
630
-
631
- // unsigned char overflow.
632
- if (x < 0x20) x += 0xff;
633
- if (y < 0x20) y += 0xff;
634
-
635
- // Convert the coordinates into a
636
- // properly formatted x10 utf8 sequence.
637
- s = '\x1b[M'
638
- + String.fromCharCode(b)
639
- + String.fromCharCode(x)
640
- + String.fromCharCode(y);
641
- }
642
-
643
- // XTerm / X10
644
- if (parts = /^\x1b\[M([\x00\u0020-\uffff]{3})/.exec(s)) {
645
- b = parts[1].charCodeAt(0);
646
- x = parts[1].charCodeAt(1);
647
- y = parts[1].charCodeAt(2);
648
-
649
- key.name = 'mouse';
650
- key.type = 'X10';
651
-
652
- key.raw = [b, x, y, parts[0]];
653
- key.buf = buf;
654
- key.x = x - 32;
655
- key.y = y - 32;
656
-
657
- if (this.zero) key.x--, key.y--;
658
-
659
- if (x === 0) key.x = 255;
660
- if (y === 0) key.y = 255;
661
-
662
- mod = b >> 2;
663
- key.shift = !!(mod & 1);
664
- key.meta = !!((mod >> 1) & 1);
665
- key.ctrl = !!((mod >> 2) & 1);
666
-
667
- b -= 32;
668
-
669
- if ((b >> 6) & 1) {
670
- key.action = b & 1 ? 'wheeldown' : 'wheelup';
671
- key.button = 'middle';
672
- } else if (b === 3) {
673
- // NOTE: x10 and urxvt have no way
674
- // of telling which button mouseup used.
675
- key.action = 'mouseup';
676
- key.button = this._lastButton || 'unknown';
677
- delete this._lastButton;
678
- } else {
679
- key.action = 'mousedown';
680
- button = b & 3;
681
- key.button =
682
- button === 0 ? 'left'
683
- : button === 1 ? 'middle'
684
- : button === 2 ? 'right'
685
- : 'unknown';
686
- this._lastButton = key.button;
687
- }
688
-
689
- // Probably a movement.
690
- // The *newer* VTE gets mouse movements comepletely wrong.
691
- // This presents a problem: older versions of VTE that get it right might
692
- // be confused by the second conditional in the if statement.
693
- // NOTE: Possibly just switch back to the if statement below.
694
- // none, shift, ctrl, alt
695
- // gnome: 32, 36, 48, 40
696
- // xterm: 35, _, 51, _
697
- // urxvt: 35, _, _, _
698
- // if (key.action === 'mousedown' && key.button === 'unknown') {
699
- if (b === 35 || b === 39 || b === 51 || b === 43
700
- || (this.isVTE && (b === 32 || b === 36 || b === 48 || b === 40))) {
701
- delete key.button;
702
- key.action = 'mousemove';
703
- }
704
-
705
- self.emit('mouse', key);
706
-
707
- return;
708
- }
709
-
710
- // URxvt
711
- if (parts = /^\x1b\[(\d+;\d+;\d+)M/.exec(s)) {
712
- params = parts[1].split(';');
713
- b = +params[0];
714
- x = +params[1];
715
- y = +params[2];
716
-
717
- key.name = 'mouse';
718
- key.type = 'urxvt';
719
-
720
- key.raw = [b, x, y, parts[0]];
721
- key.buf = buf;
722
- key.x = x;
723
- key.y = y;
724
-
725
- if (this.zero) key.x--, key.y--;
726
-
727
- mod = b >> 2;
728
- key.shift = !!(mod & 1);
729
- key.meta = !!((mod >> 1) & 1);
730
- key.ctrl = !!((mod >> 2) & 1);
731
-
732
- // XXX Bug in urxvt after wheelup/down on mousemove
733
- // NOTE: This may be different than 128/129 depending
734
- // on mod keys.
735
- if (b === 128 || b === 129) {
736
- b = 67;
737
- }
738
-
739
- b -= 32;
740
-
741
- if ((b >> 6) & 1) {
742
- key.action = b & 1 ? 'wheeldown' : 'wheelup';
743
- key.button = 'middle';
744
- } else if (b === 3) {
745
- // NOTE: x10 and urxvt have no way
746
- // of telling which button mouseup used.
747
- key.action = 'mouseup';
748
- key.button = this._lastButton || 'unknown';
749
- delete this._lastButton;
750
- } else {
751
- key.action = 'mousedown';
752
- button = b & 3;
753
- key.button =
754
- button === 0 ? 'left'
755
- : button === 1 ? 'middle'
756
- : button === 2 ? 'right'
757
- : 'unknown';
758
- // NOTE: 0/32 = mousemove, 32/64 = mousemove with left down
759
- // if ((b >> 1) === 32)
760
- this._lastButton = key.button;
761
- }
762
-
763
- // Probably a movement.
764
- // The *newer* VTE gets mouse movements comepletely wrong.
765
- // This presents a problem: older versions of VTE that get it right might
766
- // be confused by the second conditional in the if statement.
767
- // NOTE: Possibly just switch back to the if statement below.
768
- // none, shift, ctrl, alt
769
- // urxvt: 35, _, _, _
770
- // gnome: 32, 36, 48, 40
771
- // if (key.action === 'mousedown' && key.button === 'unknown') {
772
- if (b === 35 || b === 39 || b === 51 || b === 43
773
- || (this.isVTE && (b === 32 || b === 36 || b === 48 || b === 40))) {
774
- delete key.button;
775
- key.action = 'mousemove';
776
- }
777
-
778
- self.emit('mouse', key);
779
-
780
- return;
781
- }
782
-
783
- // SGR
784
- if (parts = /^\x1b\[<(\d+;\d+;\d+)([mM])/.exec(s)) {
785
- down = parts[2] === 'M';
786
- params = parts[1].split(';');
787
- b = +params[0];
788
- x = +params[1];
789
- y = +params[2];
790
-
791
- key.name = 'mouse';
792
- key.type = 'sgr';
793
-
794
- key.raw = [b, x, y, parts[0]];
795
- key.buf = buf;
796
- key.x = x;
797
- key.y = y;
798
-
799
- if (this.zero) key.x--, key.y--;
800
-
801
- mod = b >> 2;
802
- key.shift = !!(mod & 1);
803
- key.meta = !!((mod >> 1) & 1);
804
- key.ctrl = !!((mod >> 2) & 1);
805
-
806
- if ((b >> 6) & 1) {
807
- key.action = b & 1 ? 'wheeldown' : 'wheelup';
808
- key.button = 'middle';
809
- } else {
810
- key.action = down
811
- ? 'mousedown'
812
- : 'mouseup';
813
- button = b & 3;
814
- key.button =
815
- button === 0 ? 'left'
816
- : button === 1 ? 'middle'
817
- : button === 2 ? 'right'
818
- : 'unknown';
819
- }
820
-
821
- // Probably a movement.
822
- // The *newer* VTE gets mouse movements comepletely wrong.
823
- // This presents a problem: older versions of VTE that get it right might
824
- // be confused by the second conditional in the if statement.
825
- // NOTE: Possibly just switch back to the if statement below.
826
- // none, shift, ctrl, alt
827
- // xterm: 35, _, 51, _
828
- // gnome: 32, 36, 48, 40
829
- // if (key.action === 'mousedown' && key.button === 'unknown') {
830
- if (b === 35 || b === 39 || b === 51 || b === 43
831
- || (this.isVTE && (b === 32 || b === 36 || b === 48 || b === 40))) {
832
- delete key.button;
833
- key.action = 'mousemove';
834
- }
835
-
836
- self.emit('mouse', key);
837
-
838
- return;
839
- }
840
-
841
- // DEC
842
- // The xterm mouse documentation says there is a
843
- // `<` prefix, the DECRQLP says there is no prefix.
844
- if (parts = /^\x1b\[<(\d+;\d+;\d+;\d+)&w/.exec(s)) {
845
- params = parts[1].split(';');
846
- b = +params[0];
847
- x = +params[1];
848
- y = +params[2];
849
- page = +params[3];
850
-
851
- key.name = 'mouse';
852
- key.type = 'dec';
853
-
854
- key.raw = [b, x, y, parts[0]];
855
- key.buf = buf;
856
- key.x = x;
857
- key.y = y;
858
- key.page = page;
859
-
860
- if (this.zero) key.x--, key.y--;
861
-
862
- key.action = b === 3
863
- ? 'mouseup'
864
- : 'mousedown';
865
-
866
- key.button =
867
- b === 2 ? 'left'
868
- : b === 4 ? 'middle'
869
- : b === 6 ? 'right'
870
- : 'unknown';
871
-
872
- self.emit('mouse', key);
873
-
874
- return;
875
- }
876
-
877
- // vt300
878
- if (parts = /^\x1b\[24([0135])~\[(\d+),(\d+)\]\r/.exec(s)) {
879
- b = +parts[1];
880
- x = +parts[2];
881
- y = +parts[3];
882
-
883
- key.name = 'mouse';
884
- key.type = 'vt300';
885
-
886
- key.raw = [b, x, y, parts[0]];
887
- key.buf = buf;
888
- key.x = x;
889
- key.y = y;
890
-
891
- if (this.zero) key.x--, key.y--;
892
-
893
- key.action = 'mousedown';
894
- key.button =
895
- b === 1 ? 'left'
896
- : b === 2 ? 'middle'
897
- : b === 5 ? 'right'
898
- : 'unknown';
899
-
900
- self.emit('mouse', key);
901
-
902
- return;
903
- }
904
-
905
- if (parts = /^\x1b\[(O|I)/.exec(s)) {
906
- key.action = parts[1] === 'I'
907
- ? 'focus'
908
- : 'blur';
909
-
910
- self.emit('mouse', key);
911
- self.emit(key.action);
912
-
913
- return;
914
- }
915
- };
916
-
917
- // gpm support for linux vc
918
- Program.prototype.enableGpm = function() {
919
- var self = this;
920
- var gpmclient = require('./gpmclient');
921
-
922
- if (this.gpm) return;
923
-
924
- this.gpm = gpmclient();
925
-
926
- this.gpm.on('btndown', function(btn, modifier, x, y) {
927
- x--, y--;
928
-
929
- var key = {
930
- name: 'mouse',
931
- type: 'GPM',
932
- action: 'mousedown',
933
- button: self.gpm.ButtonName(btn),
934
- raw: [btn, modifier, x, y],
935
- x: x,
936
- y: y,
937
- shift: self.gpm.hasShiftKey(modifier),
938
- meta: self.gpm.hasMetaKey(modifier),
939
- ctrl: self.gpm.hasCtrlKey(modifier)
940
- };
941
-
942
- self.emit('mouse', key);
943
- });
944
-
945
- this.gpm.on('btnup', function(btn, modifier, x, y) {
946
- x--, y--;
947
-
948
- var key = {
949
- name: 'mouse',
950
- type: 'GPM',
951
- action: 'mouseup',
952
- button: self.gpm.ButtonName(btn),
953
- raw: [btn, modifier, x, y],
954
- x: x,
955
- y: y,
956
- shift: self.gpm.hasShiftKey(modifier),
957
- meta: self.gpm.hasMetaKey(modifier),
958
- ctrl: self.gpm.hasCtrlKey(modifier)
959
- };
960
-
961
- self.emit('mouse', key);
962
- });
963
-
964
- this.gpm.on('move', function(btn, modifier, x, y) {
965
- x--, y--;
966
-
967
- var key = {
968
- name: 'mouse',
969
- type: 'GPM',
970
- action: 'mousemove',
971
- button: self.gpm.ButtonName(btn),
972
- raw: [btn, modifier, x, y],
973
- x: x,
974
- y: y,
975
- shift: self.gpm.hasShiftKey(modifier),
976
- meta: self.gpm.hasMetaKey(modifier),
977
- ctrl: self.gpm.hasCtrlKey(modifier)
978
- };
979
-
980
- self.emit('mouse', key);
981
- });
982
-
983
- this.gpm.on('drag', function(btn, modifier, x, y) {
984
- x--, y--;
985
-
986
- var key = {
987
- name: 'mouse',
988
- type: 'GPM',
989
- action: 'mousemove',
990
- button: self.gpm.ButtonName(btn),
991
- raw: [btn, modifier, x, y],
992
- x: x,
993
- y: y,
994
- shift: self.gpm.hasShiftKey(modifier),
995
- meta: self.gpm.hasMetaKey(modifier),
996
- ctrl: self.gpm.hasCtrlKey(modifier)
997
- };
998
-
999
- self.emit('mouse', key);
1000
- });
1001
-
1002
- this.gpm.on('mousewheel', function(btn, modifier, x, y, dx, dy) {
1003
- var key = {
1004
- name: 'mouse',
1005
- type: 'GPM',
1006
- action: dy > 0 ? 'wheelup' : 'wheeldown',
1007
- button: self.gpm.ButtonName(btn),
1008
- raw: [btn, modifier, x, y, dx, dy],
1009
- x: x,
1010
- y: y,
1011
- shift: self.gpm.hasShiftKey(modifier),
1012
- meta: self.gpm.hasMetaKey(modifier),
1013
- ctrl: self.gpm.hasCtrlKey(modifier)
1014
- };
1015
-
1016
- self.emit('mouse', key);
1017
- });
1018
- };
1019
-
1020
- Program.prototype.disableGpm = function() {
1021
- if (this.gpm) {
1022
- this.gpm.stop();
1023
- delete this.gpm;
1024
- }
1025
- };
1026
-
1027
- // All possible responses from the terminal
1028
- Program.prototype.bindResponse = function() {
1029
- if (this._boundResponse) return;
1030
- this._boundResponse = true;
1031
-
1032
- var decoder = new StringDecoder('utf8')
1033
- , self = this;
1034
-
1035
- this.on('data', function(data) {
1036
- data = decoder.write(data);
1037
- if (!data) return;
1038
- self._bindResponse(data);
1039
- });
1040
- };
1041
-
1042
- Program.prototype._bindResponse = function(s) {
1043
- var out = {}
1044
- , parts;
1045
-
1046
- if (Buffer.isBuffer(s)) {
1047
- if (s[0] > 127 && s[1] === undefined) {
1048
- s[0] -= 128;
1049
- s = '\x1b' + s.toString('utf-8');
1050
- } else {
1051
- s = s.toString('utf-8');
1052
- }
1053
- }
1054
-
1055
- // CSI P s c
1056
- // Send Device Attributes (Primary DA).
1057
- // CSI > P s c
1058
- // Send Device Attributes (Secondary DA).
1059
- if (parts = /^\x1b\[(\?|>)(\d*(?:;\d*)*)c/.exec(s)) {
1060
- parts = parts[2].split(';').map(function(ch) {
1061
- return +ch || 0;
1062
- });
1063
-
1064
- out.event = 'device-attributes';
1065
- out.code = 'DA';
1066
-
1067
- if (parts[1] === '?') {
1068
- out.type = 'primary-attribute';
1069
- // VT100-style params:
1070
- if (parts[0] === 1 && parts[2] === 2) {
1071
- out.term = 'vt100';
1072
- out.advancedVideo = true;
1073
- } else if (parts[0] === 1 && parts[2] === 0) {
1074
- out.term = 'vt101';
1075
- } else if (parts[0] === 6) {
1076
- out.term = 'vt102';
1077
- } else if (parts[0] === 60
1078
- && parts[1] === 1 && parts[2] === 2
1079
- && parts[3] === 6 && parts[4] === 8
1080
- && parts[5] === 9 && parts[6] === 15) {
1081
- out.term = 'vt220';
1082
- } else {
1083
- // VT200-style params:
1084
- parts.forEach(function(attr) {
1085
- switch (attr) {
1086
- case 1:
1087
- out.cols132 = true;
1088
- break;
1089
- case 2:
1090
- out.printer = true;
1091
- break;
1092
- case 6:
1093
- out.selectiveErase = true;
1094
- break;
1095
- case 8:
1096
- out.userDefinedKeys = true;
1097
- break;
1098
- case 9:
1099
- out.nationalReplacementCharsets = true;
1100
- break;
1101
- case 15:
1102
- out.technicalCharacters = true;
1103
- break;
1104
- case 18:
1105
- out.userWindows = true;
1106
- break;
1107
- case 21:
1108
- out.horizontalScrolling = true;
1109
- break;
1110
- case 22:
1111
- out.ansiColor = true;
1112
- break;
1113
- case 29:
1114
- out.ansiTextLocator = true;
1115
- break;
1116
- }
1117
- });
1118
- }
1119
- } else {
1120
- out.type = 'secondary-attribute';
1121
- switch (parts[0]) {
1122
- case 0:
1123
- out.term = 'vt100';
1124
- break;
1125
- case 1:
1126
- out.term = 'vt220';
1127
- break;
1128
- case 2:
1129
- out.term = 'vt240';
1130
- break;
1131
- case 18:
1132
- out.term = 'vt330';
1133
- break;
1134
- case 19:
1135
- out.term = 'vt340';
1136
- break;
1137
- case 24:
1138
- out.term = 'vt320';
1139
- break;
1140
- case 41:
1141
- out.term = 'vt420';
1142
- break;
1143
- case 61:
1144
- out.term = 'vt510';
1145
- break;
1146
- case 64:
1147
- out.term = 'vt520';
1148
- break;
1149
- case 65:
1150
- out.term = 'vt525';
1151
- break;
1152
- }
1153
- out.firmwareVersion = parts[1];
1154
- out.romCartridgeRegistrationNumber = parts[2];
1155
- }
1156
-
1157
- // LEGACY
1158
- out.deviceAttributes = out;
1159
-
1160
- this.emit('response', out);
1161
- this.emit('response ' + out.event, out);
1162
-
1163
- return;
1164
- }
1165
-
1166
- // CSI Ps n Device Status Report (DSR).
1167
- // Ps = 5 -> Status Report. Result (``OK'') is
1168
- // CSI 0 n
1169
- // CSI ? Ps n
1170
- // Device Status Report (DSR, DEC-specific).
1171
- // Ps = 1 5 -> Report Printer status as CSI ? 1 0 n (ready).
1172
- // or CSI ? 1 1 n (not ready).
1173
- // Ps = 2 5 -> Report UDK status as CSI ? 2 0 n (unlocked)
1174
- // or CSI ? 2 1 n (locked).
1175
- // Ps = 2 6 -> Report Keyboard status as
1176
- // CSI ? 2 7 ; 1 ; 0 ; 0 n (North American).
1177
- // The last two parameters apply to VT400 & up, and denote key-
1178
- // board ready and LK01 respectively.
1179
- // Ps = 5 3 -> Report Locator status as
1180
- // CSI ? 5 3 n Locator available, if compiled-in, or
1181
- // CSI ? 5 0 n No Locator, if not.
1182
- if (parts = /^\x1b\[(\?)?(\d+)(?:;(\d+);(\d+);(\d+))?n/.exec(s)) {
1183
- out.event = 'device-status';
1184
- out.code = 'DSR';
1185
-
1186
- if (!parts[1] && parts[2] === '0' && !parts[3]) {
1187
- out.type = 'device-status';
1188
- out.status = 'OK';
1189
-
1190
- // LEGACY
1191
- out.deviceStatus = out.status;
1192
-
1193
- this.emit('response', out);
1194
- this.emit('response ' + out.event, out);
1195
-
1196
- return;
1197
- }
1198
-
1199
- if (parts[1] && (parts[2] === '10' || parts[2] === '11') && !parts[3]) {
1200
- out.type = 'printer-status';
1201
- out.status = parts[2] === '10'
1202
- ? 'ready'
1203
- : 'not ready';
1204
-
1205
- // LEGACY
1206
- out.printerStatus = out.status;
1207
-
1208
- this.emit('response', out);
1209
- this.emit('response ' + out.event, out);
1210
-
1211
- return;
1212
- }
1213
-
1214
- if (parts[1] && (parts[2] === '20' || parts[2] === '21') && !parts[3]) {
1215
- out.type = 'udk-status';
1216
- out.status = parts[2] === '20'
1217
- ? 'unlocked'
1218
- : 'locked';
1219
-
1220
- // LEGACY
1221
- out.UDKStatus = out.status;
1222
-
1223
- this.emit('response', out);
1224
- this.emit('response ' + out.event, out);
1225
-
1226
- return;
1227
- }
1228
-
1229
- if (parts[1]
1230
- && parts[2] === '27'
1231
- && parts[3] === '1'
1232
- && parts[4] === '0'
1233
- && parts[5] === '0') {
1234
- out.type = 'keyboard-status';
1235
- out.status = 'OK';
1236
-
1237
- // LEGACY
1238
- out.keyboardStatus = out.status;
1239
-
1240
- this.emit('response', out);
1241
- this.emit('response ' + out.event, out);
1242
-
1243
- return;
1244
- }
1245
-
1246
- if (parts[1] && (parts[2] === '53' || parts[2] === '50') && !parts[3]) {
1247
- out.type = 'locator-status';
1248
- out.status = parts[2] === '53'
1249
- ? 'available'
1250
- : 'unavailable';
1251
-
1252
- // LEGACY
1253
- out.locator = out.status;
1254
-
1255
- this.emit('response', out);
1256
- this.emit('response ' + out.event, out);
1257
-
1258
- return;
1259
- }
1260
-
1261
- out.type = 'error';
1262
- out.text = 'Unhandled: ' + JSON.stringify(parts);
1263
-
1264
- // LEGACY
1265
- out.error = out.text;
1266
-
1267
- this.emit('response', out);
1268
- this.emit('response ' + out.event, out);
1269
-
1270
- return;
1271
- }
1272
-
1273
- // CSI Ps n Device Status Report (DSR).
1274
- // Ps = 6 -> Report Cursor Position (CPR) [row;column].
1275
- // Result is
1276
- // CSI r ; c R
1277
- // CSI ? Ps n
1278
- // Device Status Report (DSR, DEC-specific).
1279
- // Ps = 6 -> Report Cursor Position (CPR) [row;column] as CSI
1280
- // ? r ; c R (assumes page is zero).
1281
- if (parts = /^\x1b\[(\?)?(\d+);(\d+)R/.exec(s)) {
1282
- out.event = 'device-status';
1283
- out.code = 'DSR';
1284
- out.type = 'cursor-status';
1285
-
1286
- out.status = {
1287
- x: +parts[3],
1288
- y: +parts[2],
1289
- page: !parts[1] ? undefined : 0
1290
- };
1291
-
1292
- out.x = out.status.x;
1293
- out.y = out.status.y;
1294
- out.page = out.status.page;
1295
-
1296
- // LEGACY
1297
- out.cursor = out.status;
1298
-
1299
- this.emit('response', out);
1300
- this.emit('response ' + out.event, out);
1301
-
1302
- return;
1303
- }
1304
-
1305
- // CSI Ps ; Ps ; Ps t
1306
- // Window manipulation (from dtterm, as well as extensions).
1307
- // These controls may be disabled using the allowWindowOps
1308
- // resource. Valid values for the first (and any additional
1309
- // parameters) are:
1310
- // Ps = 1 1 -> Report xterm window state. If the xterm window
1311
- // is open (non-iconified), it returns CSI 1 t . If the xterm
1312
- // window is iconified, it returns CSI 2 t .
1313
- // Ps = 1 3 -> Report xterm window position. Result is CSI 3
1314
- // ; x ; y t
1315
- // Ps = 1 4 -> Report xterm window in pixels. Result is CSI
1316
- // 4 ; height ; width t
1317
- // Ps = 1 8 -> Report the size of the text area in characters.
1318
- // Result is CSI 8 ; height ; width t
1319
- // Ps = 1 9 -> Report the size of the screen in characters.
1320
- // Result is CSI 9 ; height ; width t
1321
- if (parts = /^\x1b\[(\d+)(?:;(\d+);(\d+))?t/.exec(s)) {
1322
- out.event = 'window-manipulation';
1323
- out.code = '';
1324
-
1325
- if ((parts[1] === '1' || parts[1] === '2') && !parts[2]) {
1326
- out.type = 'window-state';
1327
- out.state = parts[1] === '1'
1328
- ? 'non-iconified'
1329
- : 'iconified';
1330
-
1331
- // LEGACY
1332
- out.windowState = out.state;
1333
-
1334
- this.emit('response', out);
1335
- this.emit('response ' + out.event, out);
1336
-
1337
- return;
1338
- }
1339
-
1340
- if (parts[1] === '3' && parts[2]) {
1341
- out.type = 'window-position';
1342
-
1343
- out.position = {
1344
- x: +parts[2],
1345
- y: +parts[3]
1346
- };
1347
- out.x = out.position.x;
1348
- out.y = out.position.y;
1349
-
1350
- // LEGACY
1351
- out.windowPosition = out.position;
1352
-
1353
- this.emit('response', out);
1354
- this.emit('response ' + out.event, out);
1355
-
1356
- return;
1357
- }
1358
-
1359
- if (parts[1] === '4' && parts[2]) {
1360
- out.type = 'window-size-pixels';
1361
- out.size = {
1362
- height: +parts[2],
1363
- width: +parts[3]
1364
- };
1365
- out.height = out.size.height;
1366
- out.width = out.size.width;
1367
-
1368
- // LEGACY
1369
- out.windowSizePixels = out.size;
1370
-
1371
- this.emit('response', out);
1372
- this.emit('response ' + out.event, out);
1373
-
1374
- return;
1375
- }
1376
-
1377
- if (parts[1] === '8' && parts[2]) {
1378
- out.type = 'textarea-size';
1379
- out.size = {
1380
- height: +parts[2],
1381
- width: +parts[3]
1382
- };
1383
- out.height = out.size.height;
1384
- out.width = out.size.width;
1385
-
1386
- // LEGACY
1387
- out.textAreaSizeCharacters = out.size;
1388
-
1389
- this.emit('response', out);
1390
- this.emit('response ' + out.event, out);
1391
-
1392
- return;
1393
- }
1394
-
1395
- if (parts[1] === '9' && parts[2]) {
1396
- out.type = 'screen-size';
1397
- out.size = {
1398
- height: +parts[2],
1399
- width: +parts[3]
1400
- };
1401
- out.height = out.size.height;
1402
- out.width = out.size.width;
1403
-
1404
- // LEGACY
1405
- out.screenSizeCharacters = out.size;
1406
-
1407
- this.emit('response', out);
1408
- this.emit('response ' + out.event, out);
1409
-
1410
- return;
1411
- }
1412
-
1413
- out.type = 'error';
1414
- out.text = 'Unhandled: ' + JSON.stringify(parts);
1415
-
1416
- // LEGACY
1417
- out.error = out.text;
1418
-
1419
- this.emit('response', out);
1420
- this.emit('response ' + out.event, out);
1421
-
1422
- return;
1423
- }
1424
-
1425
- // rxvt-unicode does not support window manipulation
1426
- // Result Normal: OSC l/L 0xEF 0xBF 0xBD
1427
- // Result ASCII: OSC l/L 0x1c (file separator)
1428
- // Result UTF8->ASCII: OSC l/L 0xFD
1429
- // Test with:
1430
- // echo -ne '\ePtmux;\e\e[>3t\e\\'
1431
- // sleep 2 && echo -ne '\ePtmux;\e\e[21t\e\\' & cat -v
1432
- // -
1433
- // echo -ne '\e[>3t'
1434
- // sleep 2 && echo -ne '\e[21t' & cat -v
1435
- if (parts = /^\x1b\](l|L)([^\x07\x1b]*)$/.exec(s)) {
1436
- parts[2] = 'rxvt';
1437
- s = '\x1b]' + parts[1] + parts[2] + '\x1b\\';
1438
- }
1439
-
1440
- // CSI Ps ; Ps ; Ps t
1441
- // Window manipulation (from dtterm, as well as extensions).
1442
- // These controls may be disabled using the allowWindowOps
1443
- // resource. Valid values for the first (and any additional
1444
- // parameters) are:
1445
- // Ps = 2 0 -> Report xterm window's icon label. Result is
1446
- // OSC L label ST
1447
- // Ps = 2 1 -> Report xterm window's title. Result is OSC l
1448
- // label ST
1449
- if (parts = /^\x1b\](l|L)([^\x07\x1b]*)(?:\x07|\x1b\\)/.exec(s)) {
1450
- out.event = 'window-manipulation';
1451
- out.code = '';
1452
-
1453
- if (parts[1] === 'L') {
1454
- out.type = 'window-icon-label';
1455
- out.text = parts[2];
1456
-
1457
- // LEGACY
1458
- out.windowIconLabel = out.text;
1459
-
1460
- this.emit('response', out);
1461
- this.emit('response ' + out.event, out);
1462
-
1463
- return;
1464
- }
1465
-
1466
- if (parts[1] === 'l') {
1467
- out.type = 'window-title';
1468
- out.text = parts[2];
1469
-
1470
- // LEGACY
1471
- out.windowTitle = out.text;
1472
-
1473
- this.emit('response', out);
1474
- this.emit('response ' + out.event, out);
1475
-
1476
- return;
1477
- }
1478
-
1479
- out.type = 'error';
1480
- out.text = 'Unhandled: ' + JSON.stringify(parts);
1481
-
1482
- // LEGACY
1483
- out.error = out.text;
1484
-
1485
- this.emit('response', out);
1486
- this.emit('response ' + out.event, out);
1487
-
1488
- return;
1489
- }
1490
-
1491
- // CSI Ps ' |
1492
- // Request Locator Position (DECRQLP).
1493
- // -> CSI Pe ; Pb ; Pr ; Pc ; Pp & w
1494
- // Parameters are [event;button;row;column;page].
1495
- // Valid values for the event:
1496
- // Pe = 0 -> locator unavailable - no other parameters sent.
1497
- // Pe = 1 -> request - xterm received a DECRQLP.
1498
- // Pe = 2 -> left button down.
1499
- // Pe = 3 -> left button up.
1500
- // Pe = 4 -> middle button down.
1501
- // Pe = 5 -> middle button up.
1502
- // Pe = 6 -> right button down.
1503
- // Pe = 7 -> right button up.
1504
- // Pe = 8 -> M4 button down.
1505
- // Pe = 9 -> M4 button up.
1506
- // Pe = 1 0 -> locator outside filter rectangle.
1507
- // ``button'' parameter is a bitmask indicating which buttons are
1508
- // pressed:
1509
- // Pb = 0 <- no buttons down.
1510
- // Pb & 1 <- right button down.
1511
- // Pb & 2 <- middle button down.
1512
- // Pb & 4 <- left button down.
1513
- // Pb & 8 <- M4 button down.
1514
- // ``row'' and ``column'' parameters are the coordinates of the
1515
- // locator position in the xterm window, encoded as ASCII deci-
1516
- // mal.
1517
- // The ``page'' parameter is not used by xterm, and will be omit-
1518
- // ted.
1519
- // NOTE:
1520
- // This is already implemented in the _bindMouse
1521
- // method, but it might make more sense here.
1522
- // The xterm mouse documentation says there is a
1523
- // `<` prefix, the DECRQLP says there is no prefix.
1524
- if (parts = /^\x1b\[(\d+(?:;\d+){4})&w/.exec(s)) {
1525
- parts = parts[1].split(';').map(function(ch) {
1526
- return +ch;
1527
- });
1528
-
1529
- out.event = 'locator-position';
1530
- out.code = 'DECRQLP';
1531
-
1532
- switch (parts[0]) {
1533
- case 0:
1534
- out.status = 'locator-unavailable';
1535
- break;
1536
- case 1:
1537
- out.status = 'request';
1538
- break;
1539
- case 2:
1540
- out.status = 'left-button-down';
1541
- break;
1542
- case 3:
1543
- out.status = 'left-button-up';
1544
- break;
1545
- case 4:
1546
- out.status = 'middle-button-down';
1547
- break;
1548
- case 5:
1549
- out.status = 'middle-button-up';
1550
- break;
1551
- case 6:
1552
- out.status = 'right-button-down';
1553
- break;
1554
- case 7:
1555
- out.status = 'right-button-up';
1556
- break;
1557
- case 8:
1558
- out.status = 'm4-button-down';
1559
- break;
1560
- case 9:
1561
- out.status = 'm4-button-up';
1562
- break;
1563
- case 10:
1564
- out.status = 'locator-outside';
1565
- break;
1566
- }
1567
-
1568
- out.mask = parts[1];
1569
- out.row = parts[2];
1570
- out.col = parts[3];
1571
- out.page = parts[4];
1572
-
1573
- // LEGACY
1574
- out.locatorPosition = out;
1575
-
1576
- this.emit('response', out);
1577
- this.emit('response ' + out.event, out);
1578
-
1579
- return;
1580
- }
1581
-
1582
- // OSC Ps ; Pt BEL
1583
- // OSC Ps ; Pt ST
1584
- // Set Text Parameters
1585
- if (parts = /^\x1b\](\d+);([^\x07\x1b]+)(?:\x07|\x1b\\)/.exec(s)) {
1586
- out.event = 'text-params';
1587
- out.code = 'Set Text Parameters';
1588
- out.ps = +s[1];
1589
- out.pt = s[2];
1590
- this.emit('response', out);
1591
- this.emit('response ' + out.event, out);
1592
- }
1593
- };
1594
-
1595
- Program.prototype.response = function(name, text, callback, noBypass) {
1596
- var self = this;
1597
-
1598
- if (arguments.length === 2) {
1599
- callback = text;
1600
- text = name;
1601
- name = null;
1602
- }
1603
-
1604
- if (!callback) {
1605
- callback = function() {};
1606
- }
1607
-
1608
- this.bindResponse();
1609
-
1610
- name = name
1611
- ? 'response ' + name
1612
- : 'response';
1613
-
1614
- var onresponse;
1615
-
1616
- this.once(name, onresponse = function(event) {
1617
- if (timeout) clearTimeout(timeout);
1618
- if (event.type === 'error') {
1619
- return callback(new Error(event.event + ': ' + event.text));
1620
- }
1621
- return callback(null, event);
1622
- });
1623
-
1624
- var timeout = setTimeout(function() {
1625
- self.removeListener(name, onresponse);
1626
- return callback(new Error('Timeout.'));
1627
- }, 2000);
1628
-
1629
- return noBypass
1630
- ? this._write(text)
1631
- : this._twrite(text);
1632
- };
1633
-
1634
- Program.prototype._owrite =
1635
- Program.prototype.write = function(text) {
1636
- if (!this.output.writable) return;
1637
- return this.output.write(text);
1638
- };
1639
-
1640
- Program.prototype._buffer = function(text) {
1641
- if (this._exiting) {
1642
- this.flush();
1643
- this._owrite(text);
1644
- return;
1645
- }
1646
-
1647
- if (this._buf) {
1648
- this._buf += text;
1649
- return;
1650
- }
1651
-
1652
- this._buf = text;
1653
-
1654
- nextTick(this._flush);
1655
-
1656
- return true;
1657
- };
1658
-
1659
- Program.prototype.flush = function() {
1660
- if (!this._buf) return;
1661
- this._owrite(this._buf);
1662
- this._buf = '';
1663
- };
1664
-
1665
- Program.prototype._write = function(text) {
1666
- if (this.ret) return text;
1667
- if (this.useBuffer) {
1668
- return this._buffer(text);
1669
- }
1670
- return this._owrite(text);
1671
- };
1672
-
1673
- // Example: `DCS tmux; ESC Pt ST`
1674
- // Real: `DCS tmux; ESC Pt ESC \`
1675
- Program.prototype._twrite = function(data) {
1676
- var self = this
1677
- , iterations = 0
1678
- , timer;
1679
-
1680
- if (this.tmux) {
1681
- // Replace all STs with BELs so they can be nested within the DCS code.
1682
- data = data.replace(/\x1b\\/g, '\x07');
1683
-
1684
- // Wrap in tmux forward DCS:
1685
- data = '\x1bPtmux;\x1b' + data + '\x1b\\';
1686
-
1687
- // If we've never even flushed yet, it means we're still in
1688
- // the normal buffer. Wait for alt screen buffer.
1689
- if (this.output.bytesWritten === 0) {
1690
- timer = setInterval(function() {
1691
- if (self.output.bytesWritten > 0 || ++iterations === 50) {
1692
- clearInterval(timer);
1693
- self.flush();
1694
- self._owrite(data);
1695
- }
1696
- }, 100);
1697
- return true;
1698
- }
1699
-
1700
- // NOTE: Flushing the buffer is required in some cases.
1701
- // The DCS code must be at the start of the output.
1702
- this.flush();
1703
-
1704
- // Write out raw now that the buffer is flushed.
1705
- return this._owrite(data);
1706
- }
1707
-
1708
- return this._write(data);
1709
- };
1710
-
1711
- Program.prototype.echo =
1712
- Program.prototype.print = function(text, attr) {
1713
- return attr
1714
- ? this._write(this.text(text, attr))
1715
- : this._write(text);
1716
- };
1717
-
1718
- Program.prototype._ncoords = function() {
1719
- if (this.x < 0) this.x = 0;
1720
- else if (this.x >= this.cols) this.x = this.cols - 1;
1721
- if (this.y < 0) this.y = 0;
1722
- else if (this.y >= this.rows) this.y = this.rows - 1;
1723
- };
1724
-
1725
- Program.prototype.setx = function(x) {
1726
- return this.cursorCharAbsolute(x);
1727
- // return this.charPosAbsolute(x);
1728
- };
1729
-
1730
- Program.prototype.sety = function(y) {
1731
- return this.linePosAbsolute(y);
1732
- };
1733
-
1734
- Program.prototype.move = function(x, y) {
1735
- return this.cursorPos(y, x);
1736
- };
1737
-
1738
- // TODO: Fix cud and cuu calls.
1739
- Program.prototype.omove = function(x, y) {
1740
- if (!this.zero) {
1741
- x = (x || 1) - 1;
1742
- y = (y || 1) - 1;
1743
- } else {
1744
- x = x || 0;
1745
- y = y || 0;
1746
- }
1747
- if (y === this.y && x === this.x) {
1748
- return;
1749
- }
1750
- if (y === this.y) {
1751
- if (x > this.x) {
1752
- this.cuf(x - this.x);
1753
- } else if (x < this.x) {
1754
- this.cub(this.x - x);
1755
- }
1756
- } else if (x === this.x) {
1757
- if (y > this.y) {
1758
- this.cud(y - this.y);
1759
- } else if (y < this.y) {
1760
- this.cuu(this.y - y);
1761
- }
1762
- } else {
1763
- if (!this.zero) x++, y++;
1764
- this.cup(y, x);
1765
- }
1766
- };
1767
-
1768
- Program.prototype.rsetx = function(x) {
1769
- // return this.HPositionRelative(x);
1770
- if (!x) return;
1771
- return x > 0
1772
- ? this.forward(x)
1773
- : this.back(-x);
1774
- };
1775
-
1776
- Program.prototype.rsety = function(y) {
1777
- // return this.VPositionRelative(y);
1778
- if (!y) return;
1779
- return y > 0
1780
- ? this.up(y)
1781
- : this.down(-y);
1782
- };
1783
-
1784
- Program.prototype.rmove = function(x, y) {
1785
- this.rsetx(x);
1786
- this.rsety(y);
1787
- };
1788
-
1789
- Program.prototype.simpleInsert = function(ch, i, attr) {
1790
- return this._write(this.repeat(ch, i), attr);
1791
- };
1792
-
1793
- Program.prototype.repeat = function(ch, i) {
1794
- if (!i || i < 0) i = 0;
1795
- return Array(i + 1).join(ch);
1796
- };
1797
-
1798
- Program.prototype.__defineGetter__('title', function() {
1799
- return this._title;
1800
- });
1801
-
1802
- Program.prototype.__defineSetter__('title', function(title) {
1803
- this.setTitle(title);
1804
- return this._title;
1805
- });
1806
-
1807
- // Specific to iTerm2, but I think it's really cool.
1808
- // Example:
1809
- // if (!screen.copyToClipboard(text)) {
1810
- // execClipboardProgram(text);
1811
- // }
1812
- Program.prototype.copyToClipboard = function(text) {
1813
- if (this.isiTerm2) {
1814
- this._twrite('\x1b]50;CopyToCliboard=' + text + '\x07');
1815
- return true;
1816
- }
1817
- return false;
1818
- };
1819
-
1820
- // Only XTerm and iTerm2. If you know of any others, post them.
1821
- Program.prototype.cursorShape = function(shape, blink) {
1822
- if (this.isiTerm2) {
1823
- switch (shape) {
1824
- case 'block':
1825
- if (!blink) {
1826
- this._twrite('\x1b]50;CursorShape=0;BlinkingCursorEnabled=0\x07');
1827
- } else {
1828
- this._twrite('\x1b]50;CursorShape=0;BlinkingCursorEnabled=1\x07');
1829
- }
1830
- break;
1831
- case 'underline':
1832
- if (!blink) {
1833
- // this._twrite('\x1b]50;CursorShape=n;BlinkingCursorEnabled=0\x07');
1834
- } else {
1835
- // this._twrite('\x1b]50;CursorShape=n;BlinkingCursorEnabled=1\x07');
1836
- }
1837
- break;
1838
- case 'line':
1839
- if (!blink) {
1840
- this._twrite('\x1b]50;CursorShape=1;BlinkingCursorEnabled=0\x07');
1841
- } else {
1842
- this._twrite('\x1b]50;CursorShape=1;BlinkingCursorEnabled=1\x07');
1843
- }
1844
- break;
1845
- }
1846
- return true;
1847
- } else if (this.term('xterm') || this.term('screen')) {
1848
- switch (shape) {
1849
- case 'block':
1850
- if (!blink) {
1851
- this._twrite('\x1b[0 q');
1852
- } else {
1853
- this._twrite('\x1b[1 q');
1854
- }
1855
- break;
1856
- case 'underline':
1857
- if (!blink) {
1858
- this._twrite('\x1b[2 q');
1859
- } else {
1860
- this._twrite('\x1b[3 q');
1861
- }
1862
- break;
1863
- case 'line':
1864
- if (!blink) {
1865
- this._twrite('\x1b[4 q');
1866
- } else {
1867
- this._twrite('\x1b[5 q');
1868
- }
1869
- break;
1870
- }
1871
- return true;
1872
- }
1873
- return false;
1874
- };
1875
-
1876
- Program.prototype.cursorColor = function(color) {
1877
- if (this.term('xterm') || this.term('rxvt') || this.term('screen')) {
1878
- this._twrite('\x1b]12;' + color + '\x07');
1879
- return true;
1880
- }
1881
- return false;
1882
- };
1883
-
1884
- Program.prototype.cursorReset =
1885
- Program.prototype.resetCursor = function() {
1886
- if (this.term('xterm') || this.term('rxvt') || this.term('screen')) {
1887
- // XXX
1888
- // return this.resetColors();
1889
- this._twrite('\x1b[0 q');
1890
- this._twrite('\x1b]112\x07');
1891
- // urxvt doesnt support OSC 112
1892
- this._twrite('\x1b]12;white\x07');
1893
- return true;
1894
- }
1895
- return false;
1896
- };
1897
-
1898
- Program.prototype.getTextParams = function(param, callback) {
1899
- return this.response('text-params', '\x1b]' + param + ';?\x07', function(err, data) {
1900
- if (err) return callback(err);
1901
- return callback(null, data.pt);
1902
- });
1903
- };
1904
-
1905
- Program.prototype.getCursorColor = function(callback) {
1906
- return this.getTextParams(12, callback);
1907
- };
1908
-
1909
- /**
1910
- * Normal
1911
- */
1912
-
1913
- //Program.prototype.pad =
1914
- Program.prototype.nul = function() {
1915
- //if (this.has('pad')) return this.put.pad();
1916
- return this._write('\x80');
1917
- };
1918
-
1919
- Program.prototype.bel =
1920
- Program.prototype.bell = function() {
1921
- if (this.has('bel')) return this.put.bel();
1922
- return this._write('\x07');
1923
- };
1924
-
1925
- Program.prototype.vtab = function() {
1926
- this.y++;
1927
- this._ncoords();
1928
- return this._write('\x0b');
1929
- };
1930
-
1931
- Program.prototype.ff =
1932
- Program.prototype.form = function() {
1933
- if (this.has('ff')) return this.put.ff();
1934
- return this._write('\x0c');
1935
- };
1936
-
1937
- Program.prototype.kbs =
1938
- Program.prototype.backspace = function() {
1939
- this.x--;
1940
- this._ncoords();
1941
- if (this.has('kbs')) return this.put.kbs();
1942
- return this._write('\x08');
1943
- };
1944
-
1945
- Program.prototype.ht =
1946
- Program.prototype.tab = function() {
1947
- this.x += 8;
1948
- this._ncoords();
1949
- if (this.has('ht')) return this.put.ht();
1950
- return this._write('\t');
1951
- };
1952
-
1953
- Program.prototype.shiftOut = function() {
1954
- // if (this.has('S2')) return this.put.S2();
1955
- return this._write('\x0e');
1956
- };
1957
-
1958
- Program.prototype.shiftIn = function() {
1959
- // if (this.has('S3')) return this.put.S3();
1960
- return this._write('\x0f');
1961
- };
1962
-
1963
- Program.prototype.cr =
1964
- Program.prototype.return = function() {
1965
- this.x = 0;
1966
- if (this.has('cr')) return this.put.cr();
1967
- return this._write('\r');
1968
- };
1969
-
1970
- Program.prototype.nel =
1971
- Program.prototype.newline =
1972
- Program.prototype.feed = function() {
1973
- if (this.tput && this.tput.bools.eat_newline_glitch && this.x >= this.cols) {
1974
- return;
1975
- }
1976
- this.x = 0;
1977
- this.y++;
1978
- this._ncoords();
1979
- if (this.has('nel')) return this.put.nel();
1980
- return this._write('\n');
1981
- };
1982
-
1983
- /**
1984
- * Esc
1985
- */
1986
-
1987
- // ESC D Index (IND is 0x84).
1988
- Program.prototype.ind =
1989
- Program.prototype.index = function() {
1990
- this.y++;
1991
- this._ncoords();
1992
- if (this.tput) return this.put.ind();
1993
- return this._write('\x1bD');
1994
- };
1995
-
1996
- // ESC M Reverse Index (RI is 0x8d).
1997
- Program.prototype.ri =
1998
- Program.prototype.reverse =
1999
- Program.prototype.reverseIndex = function() {
2000
- this.y--;
2001
- this._ncoords();
2002
- if (this.tput) return this.put.ri();
2003
- return this._write('\x1bM');
2004
- };
2005
-
2006
- // ESC E Next Line (NEL is 0x85).
2007
- Program.prototype.nextLine = function() {
2008
- this.y++;
2009
- this.x = 0;
2010
- this._ncoords();
2011
- if (this.has('nel')) return this.put.nel();
2012
- return this._write('\x1bE');
2013
- };
2014
-
2015
- // ESC c Full Reset (RIS).
2016
- Program.prototype.reset = function() {
2017
- this.x = this.y = 0;
2018
- if (this.has('rs1') || this.has('ris')) {
2019
- return this.has('rs1')
2020
- ? this.put.rs1()
2021
- : this.put.ris();
2022
- }
2023
- return this._write('\x1bc');
2024
- };
2025
-
2026
- // ESC H Tab Set (HTS is 0x88).
2027
- Program.prototype.tabSet = function() {
2028
- if (this.tput) return this.put.hts();
2029
- return this._write('\x1bH');
2030
- };
2031
-
2032
- // ESC 7 Save Cursor (DECSC).
2033
- Program.prototype.sc =
2034
- Program.prototype.saveCursor = function(key) {
2035
- if (key) return this.lsaveCursor(key);
2036
- this.savedX = this.x || 0;
2037
- this.savedY = this.y || 0;
2038
- if (this.tput) return this.put.sc();
2039
- return this._write('\x1b7');
2040
- };
2041
-
2042
- // ESC 8 Restore Cursor (DECRC).
2043
- Program.prototype.rc =
2044
- Program.prototype.restoreCursor = function(key, hide) {
2045
- if (key) return this.lrestoreCursor(key, hide);
2046
- this.x = this.savedX || 0;
2047
- this.y = this.savedY || 0;
2048
- if (this.tput) return this.put.rc();
2049
- return this._write('\x1b8');
2050
- };
2051
-
2052
- // Save Cursor Locally
2053
- Program.prototype.lsaveCursor = function(key) {
2054
- key = key || 'local';
2055
- this._saved = this._saved || {};
2056
- this._saved[key] = this._saved[key] || {};
2057
- this._saved[key].x = this.x;
2058
- this._saved[key].y = this.y;
2059
- this._saved[key].hidden = this.cursorHidden;
2060
- };
2061
-
2062
- // Restore Cursor Locally
2063
- Program.prototype.lrestoreCursor = function(key, hide) {
2064
- var pos;
2065
- key = key || 'local';
2066
- if (!this._saved || !this._saved[key]) return;
2067
- pos = this._saved[key];
2068
- //delete this._saved[key];
2069
- this.cup(pos.y, pos.x);
2070
- if (hide && pos.hidden !== this.cursorHidden) {
2071
- if (pos.hidden) {
2072
- this.hideCursor();
2073
- } else {
2074
- this.showCursor();
2075
- }
2076
- }
2077
- };
2078
-
2079
- // ESC # 3 DEC line height/width
2080
- Program.prototype.lineHeight = function() {
2081
- return this._write('\x1b#');
2082
- };
2083
-
2084
- // ESC (,),*,+,-,. Designate G0-G2 Character Set.
2085
- Program.prototype.charset = function(val, level) {
2086
- level = level || 0;
2087
-
2088
- // See also:
2089
- // acs_chars / acsc / ac
2090
- // enter_alt_charset_mode / smacs / as
2091
- // exit_alt_charset_mode / rmacs / ae
2092
- // enter_pc_charset_mode / smpch / S2
2093
- // exit_pc_charset_mode / rmpch / S3
2094
-
2095
- switch (level) {
2096
- case 0:
2097
- level = '(';
2098
- break;
2099
- case 1:
2100
- level = ')';
2101
- break;
2102
- case 2:
2103
- level = '*';
2104
- break;
2105
- case 3:
2106
- level = '+';
2107
- break;
2108
- }
2109
-
2110
- var name = typeof val === 'string'
2111
- ? val.toLowerCase()
2112
- : val;
2113
-
2114
- switch (name) {
2115
- case 'acs':
2116
- case 'scld': // DEC Special Character and Line Drawing Set.
2117
- if (this.tput) return this.put.smacs();
2118
- val = '0';
2119
- break;
2120
- case 'uk': // UK
2121
- val = 'A';
2122
- break;
2123
- case 'us': // United States (USASCII).
2124
- case 'usascii':
2125
- case 'ascii':
2126
- if (this.tput) return this.put.rmacs();
2127
- val = 'B';
2128
- break;
2129
- case 'dutch': // Dutch
2130
- val = '4';
2131
- break;
2132
- case 'finnish': // Finnish
2133
- val = 'C';
2134
- val = '5';
2135
- break;
2136
- case 'french': // French
2137
- val = 'R';
2138
- break;
2139
- case 'frenchcanadian': // FrenchCanadian
2140
- val = 'Q';
2141
- break;
2142
- case 'german': // German
2143
- val = 'K';
2144
- break;
2145
- case 'italian': // Italian
2146
- val = 'Y';
2147
- break;
2148
- case 'norwegiandanish': // NorwegianDanish
2149
- val = 'E';
2150
- val = '6';
2151
- break;
2152
- case 'spanish': // Spanish
2153
- val = 'Z';
2154
- break;
2155
- case 'swedish': // Swedish
2156
- val = 'H';
2157
- val = '7';
2158
- break;
2159
- case 'swiss': // Swiss
2160
- val = '=';
2161
- break;
2162
- case 'isolatin': // ISOLatin (actually /A)
2163
- val = '/A';
2164
- break;
2165
- default: // Default
2166
- if (this.tput) return this.put.rmacs();
2167
- val = 'B';
2168
- break;
2169
- }
2170
-
2171
- return this._write('\x1b(' + val);
2172
- };
2173
-
2174
- Program.prototype.enter_alt_charset_mode =
2175
- Program.prototype.as =
2176
- Program.prototype.smacs = function() {
2177
- return this.charset('acs');
2178
- };
2179
-
2180
- Program.prototype.exit_alt_charset_mode =
2181
- Program.prototype.ae =
2182
- Program.prototype.rmacs = function() {
2183
- return this.charset('ascii');
2184
- };
2185
-
2186
- // ESC N
2187
- // Single Shift Select of G2 Character Set
2188
- // ( SS2 is 0x8e). This affects next character only.
2189
- // ESC O
2190
- // Single Shift Select of G3 Character Set
2191
- // ( SS3 is 0x8f). This affects next character only.
2192
- // ESC n
2193
- // Invoke the G2 Character Set as GL (LS2).
2194
- // ESC o
2195
- // Invoke the G3 Character Set as GL (LS3).
2196
- // ESC |
2197
- // Invoke the G3 Character Set as GR (LS3R).
2198
- // ESC }
2199
- // Invoke the G2 Character Set as GR (LS2R).
2200
- // ESC ~
2201
- // Invoke the G1 Character Set as GR (LS1R).
2202
- Program.prototype.setG = function(val) {
2203
- // if (this.tput) return this.put.S2();
2204
- // if (this.tput) return this.put.S3();
2205
- switch (val) {
2206
- case 1:
2207
- val = '~'; // GR
2208
- break;
2209
- case 2:
2210
- val = 'n'; // GL
2211
- val = '}'; // GR
2212
- val = 'N'; // Next Char Only
2213
- break;
2214
- case 3:
2215
- val = 'o'; // GL
2216
- val = '|'; // GR
2217
- val = 'O'; // Next Char Only
2218
- break;
2219
- }
2220
- return this._write('\x1b' + val);
2221
- };
2222
-
2223
- /**
2224
- * OSC
2225
- */
2226
-
2227
- // OSC Ps ; Pt ST
2228
- // OSC Ps ; Pt BEL
2229
- // Set Text Parameters.
2230
- Program.prototype.setTitle = function(title) {
2231
- this._title = title;
2232
-
2233
- // if (this.term('screen')) {
2234
- // // Tmux pane
2235
- // // if (this.tmux) {
2236
- // // return this._write('\x1b]2;' + title + '\x1b\\');
2237
- // // }
2238
- // return this._write('\x1bk' + title + '\x1b\\');
2239
- // }
2240
-
2241
- return this._twrite('\x1b]0;' + title + '\x07');
2242
- };
2243
-
2244
- // OSC Ps ; Pt ST
2245
- // OSC Ps ; Pt BEL
2246
- // Reset colors
2247
- Program.prototype.resetColors = function(param) {
2248
- if (this.has('Cr')) {
2249
- return this.put.Cr(param);
2250
- }
2251
- return this._twrite('\x1b]112\x07');
2252
- //return this._twrite('\x1b]112;' + param + '\x07');
2253
- };
2254
-
2255
- // OSC Ps ; Pt ST
2256
- // OSC Ps ; Pt BEL
2257
- // Change dynamic colors
2258
- Program.prototype.dynamicColors = function(param) {
2259
- if (this.has('Cs')) {
2260
- return this.put.Cs(param);
2261
- }
2262
- return this._twrite('\x1b]12;' + param + '\x07');
2263
- };
2264
-
2265
- // OSC Ps ; Pt ST
2266
- // OSC Ps ; Pt BEL
2267
- // Sel data
2268
- Program.prototype.selData = function(a, b) {
2269
- if (this.has('Ms')) {
2270
- return this.put.Ms(a, b);
2271
- }
2272
- return this._twrite('\x1b]52;' + a + ';' + b + '\x07');
2273
- };
2274
-
2275
- /**
2276
- * CSI
2277
- */
2278
-
2279
- // CSI Ps A
2280
- // Cursor Up Ps Times (default = 1) (CUU).
2281
- Program.prototype.cuu =
2282
- Program.prototype.up =
2283
- Program.prototype.cursorUp = function(param) {
2284
- this.y -= param || 1;
2285
- this._ncoords();
2286
- if (this.tput) {
2287
- if (!this.tput.strings.parm_up_cursor) {
2288
- return this._write(this.repeat(this.tput.cuu1(), param));
2289
- }
2290
- return this.put.cuu(param);
2291
- }
2292
- return this._write('\x1b[' + (param || '') + 'A');
2293
- };
2294
-
2295
- // CSI Ps B
2296
- // Cursor Down Ps Times (default = 1) (CUD).
2297
- Program.prototype.cud =
2298
- Program.prototype.down =
2299
- Program.prototype.cursorDown = function(param) {
2300
- this.y += param || 1;
2301
- this._ncoords();
2302
- if (this.tput) {
2303
- if (!this.tput.strings.parm_down_cursor) {
2304
- return this._write(this.repeat(this.tput.cud1(), param));
2305
- }
2306
- return this.put.cud(param);
2307
- }
2308
- return this._write('\x1b[' + (param || '') + 'B');
2309
- };
2310
-
2311
- // CSI Ps C
2312
- // Cursor Forward Ps Times (default = 1) (CUF).
2313
- Program.prototype.cuf =
2314
- Program.prototype.right =
2315
- Program.prototype.forward =
2316
- Program.prototype.cursorForward = function(param) {
2317
- this.x += param || 1;
2318
- this._ncoords();
2319
- if (this.tput) {
2320
- if (!this.tput.strings.parm_right_cursor) {
2321
- return this._write(this.repeat(this.tput.cuf1(), param));
2322
- }
2323
- return this.put.cuf(param);
2324
- }
2325
- return this._write('\x1b[' + (param || '') + 'C');
2326
- };
2327
-
2328
- // CSI Ps D
2329
- // Cursor Backward Ps Times (default = 1) (CUB).
2330
- Program.prototype.cub =
2331
- Program.prototype.left =
2332
- Program.prototype.back =
2333
- Program.prototype.cursorBackward = function(param) {
2334
- this.x -= param || 1;
2335
- this._ncoords();
2336
- if (this.tput) {
2337
- if (!this.tput.strings.parm_left_cursor) {
2338
- return this._write(this.repeat(this.tput.cub1(), param));
2339
- }
2340
- return this.put.cub(param);
2341
- }
2342
- return this._write('\x1b[' + (param || '') + 'D');
2343
- };
2344
-
2345
- // CSI Ps ; Ps H
2346
- // Cursor Position [row;column] (default = [1,1]) (CUP).
2347
- Program.prototype.cup =
2348
- Program.prototype.pos =
2349
- Program.prototype.cursorPos = function(row, col) {
2350
- if (!this.zero) {
2351
- row = (row || 1) - 1;
2352
- col = (col || 1) - 1;
2353
- } else {
2354
- row = row || 0;
2355
- col = col || 0;
2356
- }
2357
- this.x = col;
2358
- this.y = row;
2359
- this._ncoords();
2360
- if (this.tput) return this.put.cup(row, col);
2361
- return this._write('\x1b[' + (row + 1) + ';' + (col + 1) + 'H');
2362
- };
2363
-
2364
- // CSI Ps J Erase in Display (ED).
2365
- // Ps = 0 -> Erase Below (default).
2366
- // Ps = 1 -> Erase Above.
2367
- // Ps = 2 -> Erase All.
2368
- // Ps = 3 -> Erase Saved Lines (xterm).
2369
- // CSI ? Ps J
2370
- // Erase in Display (DECSED).
2371
- // Ps = 0 -> Selective Erase Below (default).
2372
- // Ps = 1 -> Selective Erase Above.
2373
- // Ps = 2 -> Selective Erase All.
2374
- Program.prototype.ed =
2375
- Program.prototype.eraseInDisplay = function(param) {
2376
- if (this.tput) {
2377
- switch (param) {
2378
- case 'above':
2379
- param = 1;
2380
- break;
2381
- case 'all':
2382
- param = 2;
2383
- break;
2384
- case 'saved':
2385
- param = 3;
2386
- break;
2387
- case 'below':
2388
- default:
2389
- param = 0;
2390
- break;
2391
- }
2392
- // extended tput.E3 = ^[[3;J
2393
- return this.put.ed(param);
2394
- }
2395
- switch (param) {
2396
- case 'above':
2397
- return this._write('\X1b[1J');
2398
- case 'all':
2399
- return this._write('\x1b[2J');
2400
- case 'saved':
2401
- return this._write('\x1b[3J');
2402
- case 'below':
2403
- default:
2404
- return this._write('\x1b[J');
2405
- }
2406
- };
2407
-
2408
- Program.prototype.clear = function() {
2409
- this.x = 0;
2410
- this.y = 0;
2411
- if (this.tput) return this.put.clear();
2412
- return this._write('\x1b[H\x1b[J');
2413
- };
2414
-
2415
- // CSI Ps K Erase in Line (EL).
2416
- // Ps = 0 -> Erase to Right (default).
2417
- // Ps = 1 -> Erase to Left.
2418
- // Ps = 2 -> Erase All.
2419
- // CSI ? Ps K
2420
- // Erase in Line (DECSEL).
2421
- // Ps = 0 -> Selective Erase to Right (default).
2422
- // Ps = 1 -> Selective Erase to Left.
2423
- // Ps = 2 -> Selective Erase All.
2424
- Program.prototype.el =
2425
- Program.prototype.eraseInLine = function(param) {
2426
- if (this.tput) {
2427
- //if (this.tput.back_color_erase) ...
2428
- switch (param) {
2429
- case 'left':
2430
- param = 1;
2431
- break;
2432
- case 'all':
2433
- param = 2;
2434
- break;
2435
- case 'right':
2436
- default:
2437
- param = 0;
2438
- break;
2439
- }
2440
- return this.put.el(param);
2441
- }
2442
- switch (param) {
2443
- case 'left':
2444
- return this._write('\x1b[1K');
2445
- case 'all':
2446
- return this._write('\x1b[2K');
2447
- case 'right':
2448
- default:
2449
- return this._write('\x1b[K');
2450
- }
2451
- };
2452
-
2453
- // CSI Pm m Character Attributes (SGR).
2454
- // Ps = 0 -> Normal (default).
2455
- // Ps = 1 -> Bold.
2456
- // Ps = 4 -> Underlined.
2457
- // Ps = 5 -> Blink (appears as Bold).
2458
- // Ps = 7 -> Inverse.
2459
- // Ps = 8 -> Invisible, i.e., hidden (VT300).
2460
- // Ps = 2 2 -> Normal (neither bold nor faint).
2461
- // Ps = 2 4 -> Not underlined.
2462
- // Ps = 2 5 -> Steady (not blinking).
2463
- // Ps = 2 7 -> Positive (not inverse).
2464
- // Ps = 2 8 -> Visible, i.e., not hidden (VT300).
2465
- // Ps = 3 0 -> Set foreground color to Black.
2466
- // Ps = 3 1 -> Set foreground color to Red.
2467
- // Ps = 3 2 -> Set foreground color to Green.
2468
- // Ps = 3 3 -> Set foreground color to Yellow.
2469
- // Ps = 3 4 -> Set foreground color to Blue.
2470
- // Ps = 3 5 -> Set foreground color to Magenta.
2471
- // Ps = 3 6 -> Set foreground color to Cyan.
2472
- // Ps = 3 7 -> Set foreground color to White.
2473
- // Ps = 3 9 -> Set foreground color to default (original).
2474
- // Ps = 4 0 -> Set background color to Black.
2475
- // Ps = 4 1 -> Set background color to Red.
2476
- // Ps = 4 2 -> Set background color to Green.
2477
- // Ps = 4 3 -> Set background color to Yellow.
2478
- // Ps = 4 4 -> Set background color to Blue.
2479
- // Ps = 4 5 -> Set background color to Magenta.
2480
- // Ps = 4 6 -> Set background color to Cyan.
2481
- // Ps = 4 7 -> Set background color to White.
2482
- // Ps = 4 9 -> Set background color to default (original).
2483
-
2484
- // If 16-color support is compiled, the following apply. Assume
2485
- // that xterm's resources are set so that the ISO color codes are
2486
- // the first 8 of a set of 16. Then the aixterm colors are the
2487
- // bright versions of the ISO colors:
2488
- // Ps = 9 0 -> Set foreground color to Black.
2489
- // Ps = 9 1 -> Set foreground color to Red.
2490
- // Ps = 9 2 -> Set foreground color to Green.
2491
- // Ps = 9 3 -> Set foreground color to Yellow.
2492
- // Ps = 9 4 -> Set foreground color to Blue.
2493
- // Ps = 9 5 -> Set foreground color to Magenta.
2494
- // Ps = 9 6 -> Set foreground color to Cyan.
2495
- // Ps = 9 7 -> Set foreground color to White.
2496
- // Ps = 1 0 0 -> Set background color to Black.
2497
- // Ps = 1 0 1 -> Set background color to Red.
2498
- // Ps = 1 0 2 -> Set background color to Green.
2499
- // Ps = 1 0 3 -> Set background color to Yellow.
2500
- // Ps = 1 0 4 -> Set background color to Blue.
2501
- // Ps = 1 0 5 -> Set background color to Magenta.
2502
- // Ps = 1 0 6 -> Set background color to Cyan.
2503
- // Ps = 1 0 7 -> Set background color to White.
2504
-
2505
- // If xterm is compiled with the 16-color support disabled, it
2506
- // supports the following, from rxvt:
2507
- // Ps = 1 0 0 -> Set foreground and background color to
2508
- // default.
2509
-
2510
- // If 88- or 256-color support is compiled, the following apply.
2511
- // Ps = 3 8 ; 5 ; Ps -> Set foreground color to the second
2512
- // Ps.
2513
- // Ps = 4 8 ; 5 ; Ps -> Set background color to the second
2514
- // Ps.
2515
- Program.prototype.sgr =
2516
- Program.prototype.attr =
2517
- Program.prototype.charAttributes = function(param, val) {
2518
- return this._write(this._attr(param, val));
2519
- };
2520
-
2521
- Program.prototype.text = function(text, attr) {
2522
- return this._attr(attr, true) + text + this._attr(attr, false);
2523
- };
2524
-
2525
- // NOTE: sun-color may not allow multiple params for SGR.
2526
- Program.prototype._attr = function(param, val) {
2527
- var self = this
2528
- , parts
2529
- , color
2530
- , m;
2531
-
2532
- if (Array.isArray(param)) {
2533
- parts = param;
2534
- param = parts[0] || 'normal';
2535
- } else {
2536
- param = param || 'normal';
2537
- parts = param.split(/\s*[,;]\s*/);
2538
- }
2539
-
2540
- if (parts.length > 1) {
2541
- var used = {}
2542
- , out = [];
2543
-
2544
- parts.forEach(function(part) {
2545
- part = self._attr(part, val).slice(2, -1);
2546
- if (part === '') return;
2547
- if (used[part]) return;
2548
- used[part] = true;
2549
- out.push(part);
2550
- });
2551
-
2552
- return '\x1b[' + out.join(';') + 'm';
2553
- }
2554
-
2555
- if (param.indexOf('no ') === 0) {
2556
- param = param.substring(3);
2557
- val = false;
2558
- } else if (param.indexOf('!') === 0) {
2559
- param = param.substring(1);
2560
- val = false;
2561
- }
2562
-
2563
- switch (param) {
2564
- // attributes
2565
- case 'normal':
2566
- case 'default':
2567
- if (val === false) return '';
2568
- return '\x1b[m';
2569
- case 'bold':
2570
- return val === false
2571
- ? '\x1b[22m'
2572
- : '\x1b[1m';
2573
- case 'ul':
2574
- case 'underline':
2575
- case 'underlined':
2576
- return val === false
2577
- ? '\x1b[24m'
2578
- : '\x1b[4m';
2579
- case 'blink':
2580
- return val === false
2581
- ? '\x1b[25m'
2582
- : '\x1b[5m';
2583
- case 'inverse':
2584
- return val === false
2585
- ? '\x1b[27m'
2586
- : '\x1b[7m';
2587
- case 'invisible':
2588
- return val === false
2589
- ? '\x1b[28m'
2590
- : '\x1b[8m';
2591
-
2592
- // 8-color foreground
2593
- case 'black fg':
2594
- return val === false
2595
- ? '\x1b[39m'
2596
- : '\x1b[30m';
2597
- case 'red fg':
2598
- return val === false
2599
- ? '\x1b[39m'
2600
- : '\x1b[31m';
2601
- case 'green fg':
2602
- return val === false
2603
- ? '\x1b[39m'
2604
- : '\x1b[32m';
2605
- case 'yellow fg':
2606
- return val === false
2607
- ? '\x1b[39m'
2608
- : '\x1b[33m';
2609
- case 'blue fg':
2610
- return val === false
2611
- ? '\x1b[39m'
2612
- : '\x1b[34m';
2613
- case 'magenta fg':
2614
- return val === false
2615
- ? '\x1b[39m'
2616
- : '\x1b[35m';
2617
- case 'cyan fg':
2618
- return val === false
2619
- ? '\x1b[39m'
2620
- : '\x1b[36m';
2621
- case 'white fg':
2622
- case 'light grey fg':
2623
- case 'light gray fg':
2624
- case 'bright grey fg':
2625
- case 'bright gray fg':
2626
- return val === false
2627
- ? '\x1b[39m'
2628
- : '\x1b[37m';
2629
- case 'default fg':
2630
- if (val === false) return '';
2631
- return '\x1b[39m';
2632
-
2633
- // 8-color background
2634
- case 'black bg':
2635
- return val === false
2636
- ? '\x1b[49m'
2637
- : '\x1b[40m';
2638
- case 'red bg':
2639
- return val === false
2640
- ? '\x1b[49m'
2641
- : '\x1b[41m';
2642
- case 'green bg':
2643
- return val === false
2644
- ? '\x1b[49m'
2645
- : '\x1b[42m';
2646
- case 'yellow bg':
2647
- return val === false
2648
- ? '\x1b[49m'
2649
- : '\x1b[43m';
2650
- case 'blue bg':
2651
- return val === false
2652
- ? '\x1b[49m'
2653
- : '\x1b[44m';
2654
- case 'magenta bg':
2655
- return val === false
2656
- ? '\x1b[49m'
2657
- : '\x1b[45m';
2658
- case 'cyan bg':
2659
- return val === false
2660
- ? '\x1b[49m'
2661
- : '\x1b[46m';
2662
- case 'white bg':
2663
- case 'light grey bg':
2664
- case 'light gray bg':
2665
- case 'bright grey bg':
2666
- case 'bright gray bg':
2667
- return val === false
2668
- ? '\x1b[49m'
2669
- : '\x1b[47m';
2670
- case 'default bg':
2671
- if (val === false) return '';
2672
- return '\x1b[49m';
2673
-
2674
- // 16-color foreground
2675
- case 'light black fg':
2676
- case 'bright black fg':
2677
- case 'grey fg':
2678
- case 'gray fg':
2679
- return val === false
2680
- ? '\x1b[39m'
2681
- : '\x1b[90m';
2682
- case 'light red fg':
2683
- case 'bright red fg':
2684
- return val === false
2685
- ? '\x1b[39m'
2686
- : '\x1b[91m';
2687
- case 'light green fg':
2688
- case 'bright green fg':
2689
- return val === false
2690
- ? '\x1b[39m'
2691
- : '\x1b[92m';
2692
- case 'light yellow fg':
2693
- case 'bright yellow fg':
2694
- return val === false
2695
- ? '\x1b[39m'
2696
- : '\x1b[93m';
2697
- case 'light blue fg':
2698
- case 'bright blue fg':
2699
- return val === false
2700
- ? '\x1b[39m'
2701
- : '\x1b[94m';
2702
- case 'light magenta fg':
2703
- case 'bright magenta fg':
2704
- return val === false
2705
- ? '\x1b[39m'
2706
- : '\x1b[95m';
2707
- case 'light cyan fg':
2708
- case 'bright cyan fg':
2709
- return val === false
2710
- ? '\x1b[39m'
2711
- : '\x1b[96m';
2712
- case 'light white fg':
2713
- case 'bright white fg':
2714
- return val === false
2715
- ? '\x1b[39m'
2716
- : '\x1b[97m';
2717
-
2718
- // 16-color background
2719
- case 'light black bg':
2720
- case 'bright black bg':
2721
- case 'grey bg':
2722
- case 'gray bg':
2723
- return val === false
2724
- ? '\x1b[49m'
2725
- : '\x1b[100m';
2726
- case 'light red bg':
2727
- case 'bright red bg':
2728
- return val === false
2729
- ? '\x1b[49m'
2730
- : '\x1b[101m';
2731
- case 'light green bg':
2732
- case 'bright green bg':
2733
- return val === false
2734
- ? '\x1b[49m'
2735
- : '\x1b[102m';
2736
- case 'light yellow bg':
2737
- case 'bright yellow bg':
2738
- return val === false
2739
- ? '\x1b[49m'
2740
- : '\x1b[103m';
2741
- case 'light blue bg':
2742
- case 'bright blue bg':
2743
- return val === false
2744
- ? '\x1b[49m'
2745
- : '\x1b[104m';
2746
- case 'light magenta bg':
2747
- case 'bright magenta bg':
2748
- return val === false
2749
- ? '\x1b[49m'
2750
- : '\x1b[105m';
2751
- case 'light cyan bg':
2752
- case 'bright cyan bg':
2753
- return val === false
2754
- ? '\x1b[49m'
2755
- : '\x1b[106m';
2756
- case 'light white bg':
2757
- case 'bright white bg':
2758
- return val === false
2759
- ? '\x1b[49m'
2760
- : '\x1b[107m';
2761
-
2762
- // non-16-color rxvt default fg and bg
2763
- case 'default fg bg':
2764
- if (val === false) return '';
2765
- return this.term('rxvt')
2766
- ? '\x1b[100m'
2767
- : '\x1b[39;49m';
2768
-
2769
- default:
2770
- // 256-color fg and bg
2771
- if (param[0] === '#') {
2772
- param = param.replace(/#(?:[0-9a-f]{3}){1,2}/i, colors.match);
2773
- }
2774
-
2775
- m = /^(-?\d+) (fg|bg)$/.exec(param);
2776
- if (m) {
2777
- color = +m[1];
2778
-
2779
- if (val === false || color === -1) {
2780
- return this._attr('default ' + m[2]);
2781
- }
2782
-
2783
- color = colors.reduce(color, this.tput.colors);
2784
-
2785
- if (color < 16 || (this.tput && this.tput.colors <= 16)) {
2786
- if (m[2] === 'fg') {
2787
- if (color < 8) {
2788
- color += 30;
2789
- } else if (color < 16) {
2790
- color -= 8;
2791
- color += 90;
2792
- }
2793
- } else if (m[2] === 'bg') {
2794
- if (color < 8) {
2795
- color += 40;
2796
- } else if (color < 16) {
2797
- color -= 8;
2798
- color += 100;
2799
- }
2800
- }
2801
- return '\x1b[' + color + 'm';
2802
- }
2803
-
2804
- if (m[2] === 'fg') {
2805
- return '\x1b[38;5;' + color + 'm';
2806
- }
2807
-
2808
- if (m[2] === 'bg') {
2809
- return '\x1b[48;5;' + color + 'm';
2810
- }
2811
- }
2812
-
2813
- if (/^[\d;]*$/.test(param)) {
2814
- return '\x1b[' + param + 'm';
2815
- }
2816
-
2817
- return null;
2818
- }
2819
- };
2820
-
2821
- Program.prototype.fg =
2822
- Program.prototype.setForeground = function(color, val) {
2823
- color = color.split(/\s*[,;]\s*/).join(' fg, ') + ' fg';
2824
- return this.attr(color, val);
2825
- };
2826
-
2827
- Program.prototype.bg =
2828
- Program.prototype.setBackground = function(color, val) {
2829
- color = color.split(/\s*[,;]\s*/).join(' bg, ') + ' bg';
2830
- return this.attr(color, val);
2831
- };
2832
-
2833
- // CSI Ps n Device Status Report (DSR).
2834
- // Ps = 5 -> Status Report. Result (``OK'') is
2835
- // CSI 0 n
2836
- // Ps = 6 -> Report Cursor Position (CPR) [row;column].
2837
- // Result is
2838
- // CSI r ; c R
2839
- // CSI ? Ps n
2840
- // Device Status Report (DSR, DEC-specific).
2841
- // Ps = 6 -> Report Cursor Position (CPR) [row;column] as CSI
2842
- // ? r ; c R (assumes page is zero).
2843
- // Ps = 1 5 -> Report Printer status as CSI ? 1 0 n (ready).
2844
- // or CSI ? 1 1 n (not ready).
2845
- // Ps = 2 5 -> Report UDK status as CSI ? 2 0 n (unlocked)
2846
- // or CSI ? 2 1 n (locked).
2847
- // Ps = 2 6 -> Report Keyboard status as
2848
- // CSI ? 2 7 ; 1 ; 0 ; 0 n (North American).
2849
- // The last two parameters apply to VT400 & up, and denote key-
2850
- // board ready and LK01 respectively.
2851
- // Ps = 5 3 -> Report Locator status as
2852
- // CSI ? 5 3 n Locator available, if compiled-in, or
2853
- // CSI ? 5 0 n No Locator, if not.
2854
- Program.prototype.dsr =
2855
- Program.prototype.deviceStatus = function(param, callback, dec, noBypass) {
2856
- if (dec) {
2857
- return this.response('device-status',
2858
- '\x1b[?' + (param || '0') + 'n', callback, noBypass);
2859
- }
2860
- return this.response('device-status',
2861
- '\x1b[' + (param || '0') + 'n', callback, noBypass);
2862
- };
2863
-
2864
- Program.prototype.getCursor = function(callback) {
2865
- return this.deviceStatus(6, callback, false, true);
2866
- };
2867
-
2868
- Program.prototype.saveReportedCursor = function(callback) {
2869
- var self = this;
2870
- if (this.tput.strings.user7 === '\x1b[6n' || this.term('screen')) {
2871
- return this.getCursor(function(err, data) {
2872
- if (data) {
2873
- self._rx = data.status.x;
2874
- self._ry = data.status.y;
2875
- }
2876
- if (!callback) return;
2877
- return callback(err);
2878
- });
2879
- }
2880
- if (!callback) return;
2881
- return callback();
2882
- };
2883
-
2884
- Program.prototype.restoreReportedCursor = function() {
2885
- if (this._rx == null) return;
2886
- return this.cup(this._ry, this._rx);
2887
- // return this.nel();
2888
- };
2889
-
2890
- /**
2891
- * Additions
2892
- */
2893
-
2894
- // CSI Ps @
2895
- // Insert Ps (Blank) Character(s) (default = 1) (ICH).
2896
- Program.prototype.ich =
2897
- Program.prototype.insertChars = function(param) {
2898
- this.x += param || 1;
2899
- this._ncoords();
2900
- if (this.tput) return this.put.ich(param);
2901
- return this._write('\x1b[' + (param || 1) + '@');
2902
- };
2903
-
2904
- // CSI Ps E
2905
- // Cursor Next Line Ps Times (default = 1) (CNL).
2906
- // same as CSI Ps B ?
2907
- Program.prototype.cnl =
2908
- Program.prototype.cursorNextLine = function(param) {
2909
- this.y += param || 1;
2910
- this._ncoords();
2911
- return this._write('\x1b[' + (param || '') + 'E');
2912
- };
2913
-
2914
- // CSI Ps F
2915
- // Cursor Preceding Line Ps Times (default = 1) (CNL).
2916
- // reuse CSI Ps A ?
2917
- Program.prototype.cpl =
2918
- Program.prototype.cursorPrecedingLine = function(param) {
2919
- this.y -= param || 1;
2920
- this._ncoords();
2921
- return this._write('\x1b[' + (param || '') + 'F');
2922
- };
2923
-
2924
- // CSI Ps G
2925
- // Cursor Character Absolute [column] (default = [row,1]) (CHA).
2926
- Program.prototype.cha =
2927
- Program.prototype.cursorCharAbsolute = function(param) {
2928
- if (!this.zero) {
2929
- param = (param || 1) - 1;
2930
- } else {
2931
- param = param || 0;
2932
- }
2933
- this.x = param;
2934
- this.y = 0;
2935
- this._ncoords();
2936
- if (this.tput) return this.put.hpa(param);
2937
- return this._write('\x1b[' + (param + 1) + 'G');
2938
- };
2939
-
2940
- // CSI Ps L
2941
- // Insert Ps Line(s) (default = 1) (IL).
2942
- Program.prototype.il =
2943
- Program.prototype.insertLines = function(param) {
2944
- if (this.tput) return this.put.il(param);
2945
- return this._write('\x1b[' + (param || '') + 'L');
2946
- };
2947
-
2948
- // CSI Ps M
2949
- // Delete Ps Line(s) (default = 1) (DL).
2950
- Program.prototype.dl =
2951
- Program.prototype.deleteLines = function(param) {
2952
- if (this.tput) return this.put.dl(param);
2953
- return this._write('\x1b[' + (param || '') + 'M');
2954
- };
2955
-
2956
- // CSI Ps P
2957
- // Delete Ps Character(s) (default = 1) (DCH).
2958
- Program.prototype.dch =
2959
- Program.prototype.deleteChars = function(param) {
2960
- if (this.tput) return this.put.dch(param);
2961
- return this._write('\x1b[' + (param || '') + 'P');
2962
- };
2963
-
2964
- // CSI Ps X
2965
- // Erase Ps Character(s) (default = 1) (ECH).
2966
- Program.prototype.ech =
2967
- Program.prototype.eraseChars = function(param) {
2968
- if (this.tput) return this.put.ech(param);
2969
- return this._write('\x1b[' + (param || '') + 'X');
2970
- };
2971
-
2972
- // CSI Pm ` Character Position Absolute
2973
- // [column] (default = [row,1]) (HPA).
2974
- Program.prototype.hpa =
2975
- Program.prototype.charPosAbsolute = function(param) {
2976
- this.x = param || 0;
2977
- this._ncoords();
2978
- if (this.tput) {
2979
- return this.put.hpa.apply(this.put, arguments);
2980
- }
2981
- param = slice.call(arguments).join(';');
2982
- return this._write('\x1b[' + (param || '') + '`');
2983
- };
2984
-
2985
- // 141 61 a * HPR -
2986
- // Horizontal Position Relative
2987
- // reuse CSI Ps C ?
2988
- Program.prototype.hpr =
2989
- Program.prototype.HPositionRelative = function(param) {
2990
- if (this.tput) return this.cuf(param);
2991
- this.x += param || 1;
2992
- this._ncoords();
2993
- // Does not exist:
2994
- // if (this.tput) return this.put.hpr(param);
2995
- return this._write('\x1b[' + (param || '') + 'a');
2996
- };
2997
-
2998
- // CSI Ps c Send Device Attributes (Primary DA).
2999
- // Ps = 0 or omitted -> request attributes from terminal. The
3000
- // response depends on the decTerminalID resource setting.
3001
- // -> CSI ? 1 ; 2 c (``VT100 with Advanced Video Option'')
3002
- // -> CSI ? 1 ; 0 c (``VT101 with No Options'')
3003
- // -> CSI ? 6 c (``VT102'')
3004
- // -> CSI ? 6 0 ; 1 ; 2 ; 6 ; 8 ; 9 ; 1 5 ; c (``VT220'')
3005
- // The VT100-style response parameters do not mean anything by
3006
- // themselves. VT220 parameters do, telling the host what fea-
3007
- // tures the terminal supports:
3008
- // Ps = 1 -> 132-columns.
3009
- // Ps = 2 -> Printer.
3010
- // Ps = 6 -> Selective erase.
3011
- // Ps = 8 -> User-defined keys.
3012
- // Ps = 9 -> National replacement character sets.
3013
- // Ps = 1 5 -> Technical characters.
3014
- // Ps = 2 2 -> ANSI color, e.g., VT525.
3015
- // Ps = 2 9 -> ANSI text locator (i.e., DEC Locator mode).
3016
- // CSI > Ps c
3017
- // Send Device Attributes (Secondary DA).
3018
- // Ps = 0 or omitted -> request the terminal's identification
3019
- // code. The response depends on the decTerminalID resource set-
3020
- // ting. It should apply only to VT220 and up, but xterm extends
3021
- // this to VT100.
3022
- // -> CSI > Pp ; Pv ; Pc c
3023
- // where Pp denotes the terminal type
3024
- // Pp = 0 -> ``VT100''.
3025
- // Pp = 1 -> ``VT220''.
3026
- // and Pv is the firmware version (for xterm, this was originally
3027
- // the XFree86 patch number, starting with 95). In a DEC termi-
3028
- // nal, Pc indicates the ROM cartridge registration number and is
3029
- // always zero.
3030
- // More information:
3031
- // xterm/charproc.c - line 2012, for more information.
3032
- // vim responds with ^[[?0c or ^[[?1c after the terminal's response (?)
3033
- Program.prototype.da =
3034
- Program.prototype.sendDeviceAttributes = function(param, callback) {
3035
- return this.response('device-attributes',
3036
- '\x1b[' + (param || '') + 'c', callback);
3037
- };
3038
-
3039
- // CSI Pm d
3040
- // Line Position Absolute [row] (default = [1,column]) (VPA).
3041
- // NOTE: Can't find in terminfo, no idea why it has multiple params.
3042
- Program.prototype.vpa =
3043
- Program.prototype.linePosAbsolute = function(param) {
3044
- this.y = param || 1;
3045
- this._ncoords();
3046
- if (this.tput) {
3047
- return this.put.vpa.apply(this.put, arguments);
3048
- }
3049
- param = slice.call(arguments).join(';');
3050
- return this._write('\x1b[' + (param || '') + 'd');
3051
- };
3052
-
3053
- // 145 65 e * VPR - Vertical Position Relative
3054
- // reuse CSI Ps B ?
3055
- Program.prototype.vpr =
3056
- Program.prototype.VPositionRelative = function(param) {
3057
- if (this.tput) return this.cud(param);
3058
- this.y += param || 1;
3059
- this._ncoords();
3060
- // Does not exist:
3061
- // if (this.tput) return this.put.vpr(param);
3062
- return this._write('\x1b[' + (param || '') + 'e');
3063
- };
3064
-
3065
- // CSI Ps ; Ps f
3066
- // Horizontal and Vertical Position [row;column] (default =
3067
- // [1,1]) (HVP).
3068
- Program.prototype.hvp =
3069
- Program.prototype.HVPosition = function(row, col) {
3070
- if (!this.zero) {
3071
- row = (row || 1) - 1;
3072
- col = (col || 1) - 1;
3073
- } else {
3074
- row = row || 0;
3075
- col = col || 0;
3076
- }
3077
- this.y = row;
3078
- this.x = col;
3079
- this._ncoords();
3080
- // Does not exist (?):
3081
- // if (this.tput) return this.put.hvp(row, col);
3082
- if (this.tput) return this.put.cup(row, col);
3083
- return this._write('\x1b[' + (row + 1) + ';' + (col + 1) + 'f');
3084
- };
3085
-
3086
- // CSI Pm h Set Mode (SM).
3087
- // Ps = 2 -> Keyboard Action Mode (AM).
3088
- // Ps = 4 -> Insert Mode (IRM).
3089
- // Ps = 1 2 -> Send/receive (SRM).
3090
- // Ps = 2 0 -> Automatic Newline (LNM).
3091
- // CSI ? Pm h
3092
- // DEC Private Mode Set (DECSET).
3093
- // Ps = 1 -> Application Cursor Keys (DECCKM).
3094
- // Ps = 2 -> Designate USASCII for character sets G0-G3
3095
- // (DECANM), and set VT100 mode.
3096
- // Ps = 3 -> 132 Column Mode (DECCOLM).
3097
- // Ps = 4 -> Smooth (Slow) Scroll (DECSCLM).
3098
- // Ps = 5 -> Reverse Video (DECSCNM).
3099
- // Ps = 6 -> Origin Mode (DECOM).
3100
- // Ps = 7 -> Wraparound Mode (DECAWM).
3101
- // Ps = 8 -> Auto-repeat Keys (DECARM).
3102
- // Ps = 9 -> Send Mouse X & Y on button press. See the sec-
3103
- // tion Mouse Tracking.
3104
- // Ps = 1 0 -> Show toolbar (rxvt).
3105
- // Ps = 1 2 -> Start Blinking Cursor (att610).
3106
- // Ps = 1 8 -> Print form feed (DECPFF).
3107
- // Ps = 1 9 -> Set print extent to full screen (DECPEX).
3108
- // Ps = 2 5 -> Show Cursor (DECTCEM).
3109
- // Ps = 3 0 -> Show scrollbar (rxvt).
3110
- // Ps = 3 5 -> Enable font-shifting functions (rxvt).
3111
- // Ps = 3 8 -> Enter Tektronix Mode (DECTEK).
3112
- // Ps = 4 0 -> Allow 80 -> 132 Mode.
3113
- // Ps = 4 1 -> more(1) fix (see curses resource).
3114
- // Ps = 4 2 -> Enable Nation Replacement Character sets (DECN-
3115
- // RCM).
3116
- // Ps = 4 4 -> Turn On Margin Bell.
3117
- // Ps = 4 5 -> Reverse-wraparound Mode.
3118
- // Ps = 4 6 -> Start Logging. This is normally disabled by a
3119
- // compile-time option.
3120
- // Ps = 4 7 -> Use Alternate Screen Buffer. (This may be dis-
3121
- // abled by the titeInhibit resource).
3122
- // Ps = 6 6 -> Application keypad (DECNKM).
3123
- // Ps = 6 7 -> Backarrow key sends backspace (DECBKM).
3124
- // Ps = 1 0 0 0 -> Send Mouse X & Y on button press and
3125
- // release. See the section Mouse Tracking.
3126
- // Ps = 1 0 0 1 -> Use Hilite Mouse Tracking.
3127
- // Ps = 1 0 0 2 -> Use Cell Motion Mouse Tracking.
3128
- // Ps = 1 0 0 3 -> Use All Motion Mouse Tracking.
3129
- // Ps = 1 0 0 4 -> Send FocusIn/FocusOut events.
3130
- // Ps = 1 0 0 5 -> Enable Extended Mouse Mode.
3131
- // Ps = 1 0 1 0 -> Scroll to bottom on tty output (rxvt).
3132
- // Ps = 1 0 1 1 -> Scroll to bottom on key press (rxvt).
3133
- // Ps = 1 0 3 4 -> Interpret "meta" key, sets eighth bit.
3134
- // (enables the eightBitInput resource).
3135
- // Ps = 1 0 3 5 -> Enable special modifiers for Alt and Num-
3136
- // Lock keys. (This enables the numLock resource).
3137
- // Ps = 1 0 3 6 -> Send ESC when Meta modifies a key. (This
3138
- // enables the metaSendsEscape resource).
3139
- // Ps = 1 0 3 7 -> Send DEL from the editing-keypad Delete
3140
- // key.
3141
- // Ps = 1 0 3 9 -> Send ESC when Alt modifies a key. (This
3142
- // enables the altSendsEscape resource).
3143
- // Ps = 1 0 4 0 -> Keep selection even if not highlighted.
3144
- // (This enables the keepSelection resource).
3145
- // Ps = 1 0 4 1 -> Use the CLIPBOARD selection. (This enables
3146
- // the selectToClipboard resource).
3147
- // Ps = 1 0 4 2 -> Enable Urgency window manager hint when
3148
- // Control-G is received. (This enables the bellIsUrgent
3149
- // resource).
3150
- // Ps = 1 0 4 3 -> Enable raising of the window when Control-G
3151
- // is received. (enables the popOnBell resource).
3152
- // Ps = 1 0 4 7 -> Use Alternate Screen Buffer. (This may be
3153
- // disabled by the titeInhibit resource).
3154
- // Ps = 1 0 4 8 -> Save cursor as in DECSC. (This may be dis-
3155
- // abled by the titeInhibit resource).
3156
- // Ps = 1 0 4 9 -> Save cursor as in DECSC and use Alternate
3157
- // Screen Buffer, clearing it first. (This may be disabled by
3158
- // the titeInhibit resource). This combines the effects of the 1
3159
- // 0 4 7 and 1 0 4 8 modes. Use this with terminfo-based
3160
- // applications rather than the 4 7 mode.
3161
- // Ps = 1 0 5 0 -> Set terminfo/termcap function-key mode.
3162
- // Ps = 1 0 5 1 -> Set Sun function-key mode.
3163
- // Ps = 1 0 5 2 -> Set HP function-key mode.
3164
- // Ps = 1 0 5 3 -> Set SCO function-key mode.
3165
- // Ps = 1 0 6 0 -> Set legacy keyboard emulation (X11R6).
3166
- // Ps = 1 0 6 1 -> Set VT220 keyboard emulation.
3167
- // Ps = 2 0 0 4 -> Set bracketed paste mode.
3168
- // Modes:
3169
- // http://vt100.net/docs/vt220-rm/chapter4.html
3170
- Program.prototype.sm =
3171
- Program.prototype.setMode = function() {
3172
- var param = slice.call(arguments).join(';');
3173
- return this._write('\x1b[' + (param || '') + 'h');
3174
- };
3175
-
3176
- Program.prototype.decset = function() {
3177
- var param = slice.call(arguments).join(';');
3178
- return this.setMode('?' + param);
3179
- };
3180
-
3181
- Program.prototype.dectcem =
3182
- Program.prototype.cnorm =
3183
- Program.prototype.cvvis =
3184
- Program.prototype.showCursor = function() {
3185
- this.cursorHidden = false;
3186
- // NOTE: In xterm terminfo:
3187
- // cnorm stops blinking cursor
3188
- // cvvis starts blinking cursor
3189
- if (this.tput) return this.put.cnorm();
3190
- //if (this.tput) return this.put.cvvis();
3191
- // return this._write('\x1b[?12l\x1b[?25h'); // cursor_normal
3192
- // return this._write('\x1b[?12;25h'); // cursor_visible
3193
- return this.setMode('?25');
3194
- };
3195
-
3196
- Program.prototype.alternate =
3197
- Program.prototype.smcup =
3198
- Program.prototype.alternateBuffer = function() {
3199
- this.isAlt = true;
3200
- if (this.tput) return this.put.smcup();
3201
- if (this.term('vt') || this.term('linux')) return;
3202
- this.setMode('?47');
3203
- return this.setMode('?1049');
3204
- };
3205
-
3206
- // CSI Pm l Reset Mode (RM).
3207
- // Ps = 2 -> Keyboard Action Mode (AM).
3208
- // Ps = 4 -> Replace Mode (IRM).
3209
- // Ps = 1 2 -> Send/receive (SRM).
3210
- // Ps = 2 0 -> Normal Linefeed (LNM).
3211
- // CSI ? Pm l
3212
- // DEC Private Mode Reset (DECRST).
3213
- // Ps = 1 -> Normal Cursor Keys (DECCKM).
3214
- // Ps = 2 -> Designate VT52 mode (DECANM).
3215
- // Ps = 3 -> 80 Column Mode (DECCOLM).
3216
- // Ps = 4 -> Jump (Fast) Scroll (DECSCLM).
3217
- // Ps = 5 -> Normal Video (DECSCNM).
3218
- // Ps = 6 -> Normal Cursor Mode (DECOM).
3219
- // Ps = 7 -> No Wraparound Mode (DECAWM).
3220
- // Ps = 8 -> No Auto-repeat Keys (DECARM).
3221
- // Ps = 9 -> Don't send Mouse X & Y on button press.
3222
- // Ps = 1 0 -> Hide toolbar (rxvt).
3223
- // Ps = 1 2 -> Stop Blinking Cursor (att610).
3224
- // Ps = 1 8 -> Don't print form feed (DECPFF).
3225
- // Ps = 1 9 -> Limit print to scrolling region (DECPEX).
3226
- // Ps = 2 5 -> Hide Cursor (DECTCEM).
3227
- // Ps = 3 0 -> Don't show scrollbar (rxvt).
3228
- // Ps = 3 5 -> Disable font-shifting functions (rxvt).
3229
- // Ps = 4 0 -> Disallow 80 -> 132 Mode.
3230
- // Ps = 4 1 -> No more(1) fix (see curses resource).
3231
- // Ps = 4 2 -> Disable Nation Replacement Character sets (DEC-
3232
- // NRCM).
3233
- // Ps = 4 4 -> Turn Off Margin Bell.
3234
- // Ps = 4 5 -> No Reverse-wraparound Mode.
3235
- // Ps = 4 6 -> Stop Logging. (This is normally disabled by a
3236
- // compile-time option).
3237
- // Ps = 4 7 -> Use Normal Screen Buffer.
3238
- // Ps = 6 6 -> Numeric keypad (DECNKM).
3239
- // Ps = 6 7 -> Backarrow key sends delete (DECBKM).
3240
- // Ps = 1 0 0 0 -> Don't send Mouse X & Y on button press and
3241
- // release. See the section Mouse Tracking.
3242
- // Ps = 1 0 0 1 -> Don't use Hilite Mouse Tracking.
3243
- // Ps = 1 0 0 2 -> Don't use Cell Motion Mouse Tracking.
3244
- // Ps = 1 0 0 3 -> Don't use All Motion Mouse Tracking.
3245
- // Ps = 1 0 0 4 -> Don't send FocusIn/FocusOut events.
3246
- // Ps = 1 0 0 5 -> Disable Extended Mouse Mode.
3247
- // Ps = 1 0 1 0 -> Don't scroll to bottom on tty output
3248
- // (rxvt).
3249
- // Ps = 1 0 1 1 -> Don't scroll to bottom on key press (rxvt).
3250
- // Ps = 1 0 3 4 -> Don't interpret "meta" key. (This disables
3251
- // the eightBitInput resource).
3252
- // Ps = 1 0 3 5 -> Disable special modifiers for Alt and Num-
3253
- // Lock keys. (This disables the numLock resource).
3254
- // Ps = 1 0 3 6 -> Don't send ESC when Meta modifies a key.
3255
- // (This disables the metaSendsEscape resource).
3256
- // Ps = 1 0 3 7 -> Send VT220 Remove from the editing-keypad
3257
- // Delete key.
3258
- // Ps = 1 0 3 9 -> Don't send ESC when Alt modifies a key.
3259
- // (This disables the altSendsEscape resource).
3260
- // Ps = 1 0 4 0 -> Do not keep selection when not highlighted.
3261
- // (This disables the keepSelection resource).
3262
- // Ps = 1 0 4 1 -> Use the PRIMARY selection. (This disables
3263
- // the selectToClipboard resource).
3264
- // Ps = 1 0 4 2 -> Disable Urgency window manager hint when
3265
- // Control-G is received. (This disables the bellIsUrgent
3266
- // resource).
3267
- // Ps = 1 0 4 3 -> Disable raising of the window when Control-
3268
- // G is received. (This disables the popOnBell resource).
3269
- // Ps = 1 0 4 7 -> Use Normal Screen Buffer, clearing screen
3270
- // first if in the Alternate Screen. (This may be disabled by
3271
- // the titeInhibit resource).
3272
- // Ps = 1 0 4 8 -> Restore cursor as in DECRC. (This may be
3273
- // disabled by the titeInhibit resource).
3274
- // Ps = 1 0 4 9 -> Use Normal Screen Buffer and restore cursor
3275
- // as in DECRC. (This may be disabled by the titeInhibit
3276
- // resource). This combines the effects of the 1 0 4 7 and 1 0
3277
- // 4 8 modes. Use this with terminfo-based applications rather
3278
- // than the 4 7 mode.
3279
- // Ps = 1 0 5 0 -> Reset terminfo/termcap function-key mode.
3280
- // Ps = 1 0 5 1 -> Reset Sun function-key mode.
3281
- // Ps = 1 0 5 2 -> Reset HP function-key mode.
3282
- // Ps = 1 0 5 3 -> Reset SCO function-key mode.
3283
- // Ps = 1 0 6 0 -> Reset legacy keyboard emulation (X11R6).
3284
- // Ps = 1 0 6 1 -> Reset keyboard emulation to Sun/PC style.
3285
- // Ps = 2 0 0 4 -> Reset bracketed paste mode.
3286
- Program.prototype.rm =
3287
- Program.prototype.resetMode = function() {
3288
- var param = slice.call(arguments).join(';');
3289
- return this._write('\x1b[' + (param || '') + 'l');
3290
- };
3291
-
3292
- Program.prototype.decrst = function() {
3293
- var param = slice.call(arguments).join(';');
3294
- return this.resetMode('?' + param);
3295
- };
3296
-
3297
- Program.prototype.dectcemh =
3298
- Program.prototype.cursor_invisible =
3299
- Program.prototype.vi =
3300
- Program.prototype.civis =
3301
- Program.prototype.hideCursor = function() {
3302
- this.cursorHidden = true;
3303
- if (this.tput) return this.put.civis();
3304
- return this.resetMode('?25');
3305
- };
3306
-
3307
- Program.prototype.rmcup =
3308
- Program.prototype.normalBuffer = function() {
3309
- this.isAlt = false;
3310
- if (this.tput) return this.put.rmcup();
3311
- this.resetMode('?47');
3312
- return this.resetMode('?1049');
3313
- };
3314
-
3315
- Program.prototype.enableMouse = function() {
3316
- if (process.env.BLESSED_FORCE_MODES) {
3317
- var modes = process.env.BLESSED_FORCE_MODES.split(',');
3318
- var options = {};
3319
- for (var n = 0; n < modes.length; ++n) {
3320
- var pair = modes[n].split('=');
3321
- var v = pair[1] !== '0';
3322
- switch (pair[0].toUpperCase()) {
3323
- case 'SGRMOUSE':
3324
- options.sgrMouse = v;
3325
- break;
3326
- case 'UTFMOUSE':
3327
- options.utfMouse = v;
3328
- break;
3329
- case 'VT200MOUSE':
3330
- options.vt200Mouse = v;
3331
- break;
3332
- case 'URXVTMOUSE':
3333
- options.urxvtMouse = v;
3334
- break;
3335
- case 'X10MOUSE':
3336
- options.x10Mouse = v;
3337
- break;
3338
- case 'DECMOUSE':
3339
- options.decMouse = v;
3340
- break;
3341
- case 'PTERMMOUSE':
3342
- options.ptermMouse = v;
3343
- break;
3344
- case 'JSBTERMMOUSE':
3345
- options.jsbtermMouse = v;
3346
- break;
3347
- case 'VT200HILITE':
3348
- options.vt200Hilite = v;
3349
- break;
3350
- case 'GPMMOUSE':
3351
- options.gpmMouse = v;
3352
- break;
3353
- case 'CELLMOTION':
3354
- options.cellMotion = v;
3355
- break;
3356
- case 'ALLMOTION':
3357
- options.allMotion = v;
3358
- break;
3359
- case 'SENDFOCUS':
3360
- options.sendFocus = v;
3361
- break;
3362
- }
3363
- }
3364
- return this.setMouse(options, true);
3365
- }
3366
-
3367
- // NOTE:
3368
- // Cell Motion isn't normally need for anything below here, but we'll
3369
- // activate it for tmux (whether using it or not) in case our all-motion
3370
- // passthrough does not work. It can't hurt.
3371
-
3372
- if (this.term('rxvt-unicode')) {
3373
- return this.setMouse({
3374
- urxvtMouse: true,
3375
- cellMotion: true,
3376
- allMotion: true
3377
- }, true);
3378
- }
3379
-
3380
- // rxvt does not support the X10 UTF extensions
3381
- if (this.term('rxvt')) {
3382
- return this.setMouse({
3383
- vt200Mouse: true,
3384
- x10Mouse: true,
3385
- cellMotion: true,
3386
- allMotion: true
3387
- }, true);
3388
- }
3389
-
3390
- // libvte is broken. Older versions do not support the
3391
- // X10 UTF extension. However, later versions do support
3392
- // SGR/URXVT.
3393
- if (this.isVTE) {
3394
- return this.setMouse({
3395
- // NOTE: Could also use urxvtMouse here.
3396
- sgrMouse: true,
3397
- cellMotion: true,
3398
- allMotion: true
3399
- }, true);
3400
- }
3401
-
3402
- if (this.term('linux')) {
3403
- return this.setMouse({
3404
- vt200Mouse: true,
3405
- gpmMouse: true
3406
- }, true);
3407
- }
3408
-
3409
- if (this.term('xterm')
3410
- || this.term('screen')
3411
- || (this.tput && this.tput.strings.key_mouse)) {
3412
- return this.setMouse({
3413
- vt200Mouse: true,
3414
- utfMouse: true,
3415
- cellMotion: true,
3416
- allMotion: true
3417
- }, true);
3418
- }
3419
- };
3420
-
3421
- Program.prototype.disableMouse = function() {
3422
- if (!this._currentMouse) return;
3423
-
3424
- var obj = {};
3425
-
3426
- Object.keys(this._currentMouse).forEach(function(key) {
3427
- obj[key] = false;
3428
- });
3429
-
3430
- return this.setMouse(obj, false);
3431
- };
3432
-
3433
- // Set Mouse
3434
- Program.prototype.setMouse = function(opt, enable) {
3435
- if (opt.normalMouse != null) {
3436
- opt.vt200Mouse = opt.normalMouse;
3437
- opt.allMotion = opt.normalMouse;
3438
- }
3439
-
3440
- if (opt.hiliteTracking != null) {
3441
- opt.vt200Hilite = opt.hiliteTracking;
3442
- }
3443
-
3444
- if (enable === true) {
3445
- if (this._currentMouse) {
3446
- this.setMouse(opt);
3447
- Object.keys(opt).forEach(function(key) {
3448
- this._currentMouse[key] = opt[key];
3449
- }, this);
3450
- return;
3451
- }
3452
- this._currentMouse = opt;
3453
- this.mouseEnabled = true;
3454
- } else if (enable === false) {
3455
- delete this._currentMouse;
3456
- this.mouseEnabled = false;
3457
- }
3458
-
3459
- // Ps = 9 -> Send Mouse X & Y on button press. See the sec-
3460
- // tion Mouse Tracking.
3461
- // Ps = 9 -> Don't send Mouse X & Y on button press.
3462
- // x10 mouse
3463
- if (opt.x10Mouse != null) {
3464
- if (opt.x10Mouse) this.setMode('?9');
3465
- else this.resetMode('?9');
3466
- }
3467
-
3468
- // Ps = 1 0 0 0 -> Send Mouse X & Y on button press and
3469
- // release. See the section Mouse Tracking.
3470
- // Ps = 1 0 0 0 -> Don't send Mouse X & Y on button press and
3471
- // release. See the section Mouse Tracking.
3472
- // vt200 mouse
3473
- if (opt.vt200Mouse != null) {
3474
- if (opt.vt200Mouse) this.setMode('?1000');
3475
- else this.resetMode('?1000');
3476
- }
3477
-
3478
- // Ps = 1 0 0 1 -> Use Hilite Mouse Tracking.
3479
- // Ps = 1 0 0 1 -> Don't use Hilite Mouse Tracking.
3480
- if (opt.vt200Hilite != null) {
3481
- if (opt.vt200Hilite) this.setMode('?1001');
3482
- else this.resetMode('?1001');
3483
- }
3484
-
3485
- // Ps = 1 0 0 2 -> Use Cell Motion Mouse Tracking.
3486
- // Ps = 1 0 0 2 -> Don't use Cell Motion Mouse Tracking.
3487
- // button event mouse
3488
- if (opt.cellMotion != null) {
3489
- if (opt.cellMotion) this.setMode('?1002');
3490
- else this.resetMode('?1002');
3491
- }
3492
-
3493
- // Ps = 1 0 0 3 -> Use All Motion Mouse Tracking.
3494
- // Ps = 1 0 0 3 -> Don't use All Motion Mouse Tracking.
3495
- // any event mouse
3496
- if (opt.allMotion != null) {
3497
- // NOTE: Latest versions of tmux seem to only support cellMotion (not
3498
- // allMotion). We pass all motion through to the terminal.
3499
- if (this.tmux && this.tmuxVersion >= 2) {
3500
- if (opt.allMotion) this._twrite('\x1b[?1003h');
3501
- else this._twrite('\x1b[?1003l');
3502
- } else {
3503
- if (opt.allMotion) this.setMode('?1003');
3504
- else this.resetMode('?1003');
3505
- }
3506
- }
3507
-
3508
- // Ps = 1 0 0 4 -> Send FocusIn/FocusOut events.
3509
- // Ps = 1 0 0 4 -> Don't send FocusIn/FocusOut events.
3510
- if (opt.sendFocus != null) {
3511
- if (opt.sendFocus) this.setMode('?1004');
3512
- else this.resetMode('?1004');
3513
- }
3514
-
3515
- // Ps = 1 0 0 5 -> Enable Extended Mouse Mode.
3516
- // Ps = 1 0 0 5 -> Disable Extended Mouse Mode.
3517
- if (opt.utfMouse != null) {
3518
- if (opt.utfMouse) this.setMode('?1005');
3519
- else this.resetMode('?1005');
3520
- }
3521
-
3522
- // sgr mouse
3523
- if (opt.sgrMouse != null) {
3524
- if (opt.sgrMouse) this.setMode('?1006');
3525
- else this.resetMode('?1006');
3526
- }
3527
-
3528
- // urxvt mouse
3529
- if (opt.urxvtMouse != null) {
3530
- if (opt.urxvtMouse) this.setMode('?1015');
3531
- else this.resetMode('?1015');
3532
- }
3533
-
3534
- // dec mouse
3535
- if (opt.decMouse != null) {
3536
- if (opt.decMouse) this._write('\x1b[1;2\'z\x1b[1;3\'{');
3537
- else this._write('\x1b[\'z');
3538
- }
3539
-
3540
- // pterm mouse
3541
- if (opt.ptermMouse != null) {
3542
- if (opt.ptermMouse) this._write('\x1b[>1h\x1b[>6h\x1b[>7h\x1b[>1h\x1b[>9l');
3543
- else this._write('\x1b[>1l\x1b[>6l\x1b[>7l\x1b[>1l\x1b[>9h');
3544
- }
3545
-
3546
- // jsbterm mouse
3547
- if (opt.jsbtermMouse != null) {
3548
- // + = advanced mode
3549
- if (opt.jsbtermMouse) this._write('\x1b[0~ZwLMRK+1Q\x1b\\');
3550
- else this._write('\x1b[0~ZwQ\x1b\\');
3551
- }
3552
-
3553
- // gpm mouse
3554
- if (opt.gpmMouse != null) {
3555
- if (opt.gpmMouse) this.enableGpm();
3556
- else this.disableGpm();
3557
- }
3558
- };
3559
-
3560
- // CSI Ps ; Ps r
3561
- // Set Scrolling Region [top;bottom] (default = full size of win-
3562
- // dow) (DECSTBM).
3563
- // CSI ? Pm r
3564
- Program.prototype.decstbm =
3565
- Program.prototype.csr =
3566
- Program.prototype.setScrollRegion = function(top, bottom) {
3567
- if (!this.zero) {
3568
- top = (top || 1) - 1;
3569
- bottom = (bottom || this.rows) - 1;
3570
- } else {
3571
- top = top || 0;
3572
- bottom = bottom || (this.rows - 1);
3573
- }
3574
- this.scrollTop = top;
3575
- this.scrollBottom = bottom;
3576
- this.x = 0;
3577
- this.y = 0;
3578
- this._ncoords();
3579
- if (this.tput) return this.put.csr(top, bottom);
3580
- return this._write('\x1b[' + (top + 1) + ';' + (bottom + 1) + 'r');
3581
- };
3582
-
3583
- // CSI s
3584
- // Save cursor (ANSI.SYS).
3585
- Program.prototype.scA =
3586
- Program.prototype.saveCursorA = function() {
3587
- this.savedX = this.x;
3588
- this.savedY = this.y;
3589
- if (this.tput) return this.put.sc();
3590
- return this._write('\x1b[s');
3591
- };
3592
-
3593
- // CSI u
3594
- // Restore cursor (ANSI.SYS).
3595
- Program.prototype.rcA =
3596
- Program.prototype.restoreCursorA = function() {
3597
- this.x = this.savedX || 0;
3598
- this.y = this.savedY || 0;
3599
- if (this.tput) return this.put.rc();
3600
- return this._write('\x1b[u');
3601
- };
3602
-
3603
- /**
3604
- * Lesser Used
3605
- */
3606
-
3607
- // CSI Ps I
3608
- // Cursor Forward Tabulation Ps tab stops (default = 1) (CHT).
3609
- Program.prototype.cht =
3610
- Program.prototype.cursorForwardTab = function(param) {
3611
- this.x += 8;
3612
- this._ncoords();
3613
- if (this.tput) return this.put.tab(param);
3614
- return this._write('\x1b[' + (param || 1) + 'I');
3615
- };
3616
-
3617
- // CSI Ps S Scroll up Ps lines (default = 1) (SU).
3618
- Program.prototype.su =
3619
- Program.prototype.scrollUp = function(param) {
3620
- this.y -= param || 1;
3621
- this._ncoords();
3622
- if (this.tput) return this.put.parm_index(param);
3623
- return this._write('\x1b[' + (param || 1) + 'S');
3624
- };
3625
-
3626
- // CSI Ps T Scroll down Ps lines (default = 1) (SD).
3627
- Program.prototype.sd =
3628
- Program.prototype.scrollDown = function(param) {
3629
- this.y += param || 1;
3630
- this._ncoords();
3631
- if (this.tput) return this.put.parm_rindex(param);
3632
- return this._write('\x1b[' + (param || 1) + 'T');
3633
- };
3634
-
3635
- // CSI Ps ; Ps ; Ps ; Ps ; Ps T
3636
- // Initiate highlight mouse tracking. Parameters are
3637
- // [func;startx;starty;firstrow;lastrow]. See the section Mouse
3638
- // Tracking.
3639
- Program.prototype.initMouseTracking = function() {
3640
- return this._write('\x1b[' + slice.call(arguments).join(';') + 'T');
3641
- };
3642
-
3643
- // CSI > Ps; Ps T
3644
- // Reset one or more features of the title modes to the default
3645
- // value. Normally, "reset" disables the feature. It is possi-
3646
- // ble to disable the ability to reset features by compiling a
3647
- // different default for the title modes into xterm.
3648
- // Ps = 0 -> Do not set window/icon labels using hexadecimal.
3649
- // Ps = 1 -> Do not query window/icon labels using hexadeci-
3650
- // mal.
3651
- // Ps = 2 -> Do not set window/icon labels using UTF-8.
3652
- // Ps = 3 -> Do not query window/icon labels using UTF-8.
3653
- // (See discussion of "Title Modes").
3654
- Program.prototype.resetTitleModes = function() {
3655
- return this._write('\x1b[>' + slice.call(arguments).join(';') + 'T');
3656
- };
3657
-
3658
- // CSI Ps Z Cursor Backward Tabulation Ps tab stops (default = 1) (CBT).
3659
- Program.prototype.cbt =
3660
- Program.prototype.cursorBackwardTab = function(param) {
3661
- this.x -= 8;
3662
- this._ncoords();
3663
- if (this.tput) return this.put.cbt(param);
3664
- return this._write('\x1b[' + (param || 1) + 'Z');
3665
- };
3666
-
3667
- // CSI Ps b Repeat the preceding graphic character Ps times (REP).
3668
- Program.prototype.rep =
3669
- Program.prototype.repeatPrecedingCharacter = function(param) {
3670
- this.x += param || 1;
3671
- this._ncoords();
3672
- if (this.tput) return this.put.rep(param);
3673
- return this._write('\x1b[' + (param || 1) + 'b');
3674
- };
3675
-
3676
- // CSI Ps g Tab Clear (TBC).
3677
- // Ps = 0 -> Clear Current Column (default).
3678
- // Ps = 3 -> Clear All.
3679
- // Potentially:
3680
- // Ps = 2 -> Clear Stops on Line.
3681
- // http://vt100.net/annarbor/aaa-ug/section6.html
3682
- Program.prototype.tbc =
3683
- Program.prototype.tabClear = function(param) {
3684
- if (this.tput) return this.put.tbc(param);
3685
- return this._write('\x1b[' + (param || 0) + 'g');
3686
- };
3687
-
3688
- // CSI Pm i Media Copy (MC).
3689
- // Ps = 0 -> Print screen (default).
3690
- // Ps = 4 -> Turn off printer controller mode.
3691
- // Ps = 5 -> Turn on printer controller mode.
3692
- // CSI ? Pm i
3693
- // Media Copy (MC, DEC-specific).
3694
- // Ps = 1 -> Print line containing cursor.
3695
- // Ps = 4 -> Turn off autoprint mode.
3696
- // Ps = 5 -> Turn on autoprint mode.
3697
- // Ps = 1 0 -> Print composed display, ignores DECPEX.
3698
- // Ps = 1 1 -> Print all pages.
3699
- Program.prototype.mc =
3700
- Program.prototype.mediaCopy = function() {
3701
- return this._write('\x1b[' + slice.call(arguments).join(';') + 'i');
3702
- };
3703
-
3704
- Program.prototype.print_screen =
3705
- Program.prototype.ps =
3706
- Program.prototype.mc0 = function() {
3707
- if (this.tput) return this.put.mc0();
3708
- return this.mc('0');
3709
- };
3710
-
3711
- Program.prototype.prtr_on =
3712
- Program.prototype.po =
3713
- Program.prototype.mc5 = function() {
3714
- if (this.tput) return this.put.mc5();
3715
- return this.mc('5');
3716
- };
3717
-
3718
- Program.prototype.prtr_off =
3719
- Program.prototype.pf =
3720
- Program.prototype.mc4 = function() {
3721
- if (this.tput) return this.put.mc4();
3722
- return this.mc('4');
3723
- };
3724
-
3725
- Program.prototype.prtr_non =
3726
- Program.prototype.pO =
3727
- Program.prototype.mc5p = function() {
3728
- if (this.tput) return this.put.mc5p();
3729
- return this.mc('?5');
3730
- };
3731
-
3732
- // CSI > Ps; Ps m
3733
- // Set or reset resource-values used by xterm to decide whether
3734
- // to construct escape sequences holding information about the
3735
- // modifiers pressed with a given key. The first parameter iden-
3736
- // tifies the resource to set/reset. The second parameter is the
3737
- // value to assign to the resource. If the second parameter is
3738
- // omitted, the resource is reset to its initial value.
3739
- // Ps = 1 -> modifyCursorKeys.
3740
- // Ps = 2 -> modifyFunctionKeys.
3741
- // Ps = 4 -> modifyOtherKeys.
3742
- // If no parameters are given, all resources are reset to their
3743
- // initial values.
3744
- Program.prototype.setResources = function() {
3745
- return this._write('\x1b[>' + slice.call(arguments).join(';') + 'm');
3746
- };
3747
-
3748
- // CSI > Ps n
3749
- // Disable modifiers which may be enabled via the CSI > Ps; Ps m
3750
- // sequence. This corresponds to a resource value of "-1", which
3751
- // cannot be set with the other sequence. The parameter identi-
3752
- // fies the resource to be disabled:
3753
- // Ps = 1 -> modifyCursorKeys.
3754
- // Ps = 2 -> modifyFunctionKeys.
3755
- // Ps = 4 -> modifyOtherKeys.
3756
- // If the parameter is omitted, modifyFunctionKeys is disabled.
3757
- // When modifyFunctionKeys is disabled, xterm uses the modifier
3758
- // keys to make an extended sequence of functions rather than
3759
- // adding a parameter to each function key to denote the modi-
3760
- // fiers.
3761
- Program.prototype.disableModifiers = function(param) {
3762
- return this._write('\x1b[>' + (param || '') + 'n');
3763
- };
3764
-
3765
- // CSI > Ps p
3766
- // Set resource value pointerMode. This is used by xterm to
3767
- // decide whether to hide the pointer cursor as the user types.
3768
- // Valid values for the parameter:
3769
- // Ps = 0 -> never hide the pointer.
3770
- // Ps = 1 -> hide if the mouse tracking mode is not enabled.
3771
- // Ps = 2 -> always hide the pointer. If no parameter is
3772
- // given, xterm uses the default, which is 1 .
3773
- Program.prototype.setPointerMode = function(param) {
3774
- return this._write('\x1b[>' + (param || '') + 'p');
3775
- };
3776
-
3777
- // CSI ! p Soft terminal reset (DECSTR).
3778
- // http://vt100.net/docs/vt220-rm/table4-10.html
3779
- Program.prototype.decstr =
3780
- Program.prototype.rs2 =
3781
- Program.prototype.softReset = function() {
3782
- //if (this.tput) return this.put.init_2string();
3783
- //if (this.tput) return this.put.reset_2string();
3784
- if (this.tput) return this.put.rs2();
3785
- //return this._write('\x1b[!p');
3786
- //return this._write('\x1b[!p\x1b[?3;4l\x1b[4l\x1b>'); // init
3787
- return this._write('\x1b[!p\x1b[?3;4l\x1b[4l\x1b>'); // reset
3788
- };
3789
-
3790
- // CSI Ps$ p
3791
- // Request ANSI mode (DECRQM). For VT300 and up, reply is
3792
- // CSI Ps; Pm$ y
3793
- // where Ps is the mode number as in RM, and Pm is the mode
3794
- // value:
3795
- // 0 - not recognized
3796
- // 1 - set
3797
- // 2 - reset
3798
- // 3 - permanently set
3799
- // 4 - permanently reset
3800
- Program.prototype.decrqm =
3801
- Program.prototype.requestAnsiMode = function(param) {
3802
- return this._write('\x1b[' + (param || '') + '$p');
3803
- };
3804
-
3805
- // CSI ? Ps$ p
3806
- // Request DEC private mode (DECRQM). For VT300 and up, reply is
3807
- // CSI ? Ps; Pm$ p
3808
- // where Ps is the mode number as in DECSET, Pm is the mode value
3809
- // as in the ANSI DECRQM.
3810
- Program.prototype.decrqmp =
3811
- Program.prototype.requestPrivateMode = function(param) {
3812
- return this._write('\x1b[?' + (param || '') + '$p');
3813
- };
3814
-
3815
- // CSI Ps ; Ps " p
3816
- // Set conformance level (DECSCL). Valid values for the first
3817
- // parameter:
3818
- // Ps = 6 1 -> VT100.
3819
- // Ps = 6 2 -> VT200.
3820
- // Ps = 6 3 -> VT300.
3821
- // Valid values for the second parameter:
3822
- // Ps = 0 -> 8-bit controls.
3823
- // Ps = 1 -> 7-bit controls (always set for VT100).
3824
- // Ps = 2 -> 8-bit controls.
3825
- Program.prototype.decscl =
3826
- Program.prototype.setConformanceLevel = function() {
3827
- return this._write('\x1b[' + slice.call(arguments).join(';') + '"p');
3828
- };
3829
-
3830
- // CSI Ps q Load LEDs (DECLL).
3831
- // Ps = 0 -> Clear all LEDS (default).
3832
- // Ps = 1 -> Light Num Lock.
3833
- // Ps = 2 -> Light Caps Lock.
3834
- // Ps = 3 -> Light Scroll Lock.
3835
- // Ps = 2 1 -> Extinguish Num Lock.
3836
- // Ps = 2 2 -> Extinguish Caps Lock.
3837
- // Ps = 2 3 -> Extinguish Scroll Lock.
3838
- Program.prototype.decll =
3839
- Program.prototype.loadLEDs = function(param) {
3840
- return this._write('\x1b[' + (param || '') + 'q');
3841
- };
3842
-
3843
- // CSI Ps SP q
3844
- // Set cursor style (DECSCUSR, VT520).
3845
- // Ps = 0 -> blinking block.
3846
- // Ps = 1 -> blinking block (default).
3847
- // Ps = 2 -> steady block.
3848
- // Ps = 3 -> blinking underline.
3849
- // Ps = 4 -> steady underline.
3850
- Program.prototype.decscusr =
3851
- Program.prototype.setCursorStyle = function(param) {
3852
- switch (param) {
3853
- case 'blinking block':
3854
- param = 1;
3855
- break;
3856
- case 'block':
3857
- case 'steady block':
3858
- param = 2;
3859
- break;
3860
- case 'blinking underline':
3861
- param = 3;
3862
- break;
3863
- case 'underline':
3864
- case 'steady underline':
3865
- param = 4;
3866
- break;
3867
- case 'blinking bar':
3868
- param = 5;
3869
- break;
3870
- case 'bar':
3871
- case 'steady bar':
3872
- param = 6;
3873
- break;
3874
- }
3875
- if (param === 2 && this.has('Se')) {
3876
- return this.put.Se();
3877
- }
3878
- if (this.has('Ss')) {
3879
- return this.put.Ss(param);
3880
- }
3881
- return this._write('\x1b[' + (param || 1) + ' q');
3882
- };
3883
-
3884
- // CSI Ps " q
3885
- // Select character protection attribute (DECSCA). Valid values
3886
- // for the parameter:
3887
- // Ps = 0 -> DECSED and DECSEL can erase (default).
3888
- // Ps = 1 -> DECSED and DECSEL cannot erase.
3889
- // Ps = 2 -> DECSED and DECSEL can erase.
3890
- Program.prototype.decsca =
3891
- Program.prototype.setCharProtectionAttr = function(param) {
3892
- return this._write('\x1b[' + (param || 0) + '"q');
3893
- };
3894
-
3895
- // CSI ? Pm r
3896
- // Restore DEC Private Mode Values. The value of Ps previously
3897
- // saved is restored. Ps values are the same as for DECSET.
3898
- Program.prototype.restorePrivateValues = function() {
3899
- return this._write('\x1b[?' + slice.call(arguments).join(';') + 'r');
3900
- };
3901
-
3902
- // CSI Pt; Pl; Pb; Pr; Ps$ r
3903
- // Change Attributes in Rectangular Area (DECCARA), VT400 and up.
3904
- // Pt; Pl; Pb; Pr denotes the rectangle.
3905
- // Ps denotes the SGR attributes to change: 0, 1, 4, 5, 7.
3906
- // NOTE: xterm doesn't enable this code by default.
3907
- Program.prototype.deccara =
3908
- Program.prototype.setAttrInRectangle = function() {
3909
- return this._write('\x1b[' + slice.call(arguments).join(';') + '$r');
3910
- };
3911
-
3912
- // CSI ? Pm s
3913
- // Save DEC Private Mode Values. Ps values are the same as for
3914
- // DECSET.
3915
- Program.prototype.savePrivateValues = function() {
3916
- return this._write('\x1b[?' + slice.call(arguments).join(';') + 's');
3917
- };
3918
-
3919
- // CSI Ps ; Ps ; Ps t
3920
- // Window manipulation (from dtterm, as well as extensions).
3921
- // These controls may be disabled using the allowWindowOps
3922
- // resource. Valid values for the first (and any additional
3923
- // parameters) are:
3924
- // Ps = 1 -> De-iconify window.
3925
- // Ps = 2 -> Iconify window.
3926
- // Ps = 3 ; x ; y -> Move window to [x, y].
3927
- // Ps = 4 ; height ; width -> Resize the xterm window to
3928
- // height and width in pixels.
3929
- // Ps = 5 -> Raise the xterm window to the front of the stack-
3930
- // ing order.
3931
- // Ps = 6 -> Lower the xterm window to the bottom of the
3932
- // stacking order.
3933
- // Ps = 7 -> Refresh the xterm window.
3934
- // Ps = 8 ; height ; width -> Resize the text area to
3935
- // [height;width] in characters.
3936
- // Ps = 9 ; 0 -> Restore maximized window.
3937
- // Ps = 9 ; 1 -> Maximize window (i.e., resize to screen
3938
- // size).
3939
- // Ps = 1 0 ; 0 -> Undo full-screen mode.
3940
- // Ps = 1 0 ; 1 -> Change to full-screen.
3941
- // Ps = 1 1 -> Report xterm window state. If the xterm window
3942
- // is open (non-iconified), it returns CSI 1 t . If the xterm
3943
- // window is iconified, it returns CSI 2 t .
3944
- // Ps = 1 3 -> Report xterm window position. Result is CSI 3
3945
- // ; x ; y t
3946
- // Ps = 1 4 -> Report xterm window in pixels. Result is CSI
3947
- // 4 ; height ; width t
3948
- // Ps = 1 8 -> Report the size of the text area in characters.
3949
- // Result is CSI 8 ; height ; width t
3950
- // Ps = 1 9 -> Report the size of the screen in characters.
3951
- // Result is CSI 9 ; height ; width t
3952
- // Ps = 2 0 -> Report xterm window's icon label. Result is
3953
- // OSC L label ST
3954
- // Ps = 2 1 -> Report xterm window's title. Result is OSC l
3955
- // label ST
3956
- // Ps = 2 2 ; 0 -> Save xterm icon and window title on
3957
- // stack.
3958
- // Ps = 2 2 ; 1 -> Save xterm icon title on stack.
3959
- // Ps = 2 2 ; 2 -> Save xterm window title on stack.
3960
- // Ps = 2 3 ; 0 -> Restore xterm icon and window title from
3961
- // stack.
3962
- // Ps = 2 3 ; 1 -> Restore xterm icon title from stack.
3963
- // Ps = 2 3 ; 2 -> Restore xterm window title from stack.
3964
- // Ps >= 2 4 -> Resize to Ps lines (DECSLPP).
3965
- Program.prototype.manipulateWindow = function() {
3966
- var args = slice.call(arguments);
3967
-
3968
- var callback = typeof args[args.length - 1] === 'function'
3969
- ? args.pop()
3970
- : function() {};
3971
-
3972
- return this.response('window-manipulation',
3973
- '\x1b[' + args.join(';') + 't', callback);
3974
- };
3975
-
3976
- Program.prototype.getWindowSize = function(callback) {
3977
- return this.manipulateWindow(18, callback);
3978
- };
3979
-
3980
- // CSI Pt; Pl; Pb; Pr; Ps$ t
3981
- // Reverse Attributes in Rectangular Area (DECRARA), VT400 and
3982
- // up.
3983
- // Pt; Pl; Pb; Pr denotes the rectangle.
3984
- // Ps denotes the attributes to reverse, i.e., 1, 4, 5, 7.
3985
- // NOTE: xterm doesn't enable this code by default.
3986
- Program.prototype.decrara =
3987
- Program.prototype.reverseAttrInRectangle = function() {
3988
- return this._write('\x1b[' + slice.call(arguments).join(';') + '$t');
3989
- };
3990
-
3991
- // CSI > Ps; Ps t
3992
- // Set one or more features of the title modes. Each parameter
3993
- // enables a single feature.
3994
- // Ps = 0 -> Set window/icon labels using hexadecimal.
3995
- // Ps = 1 -> Query window/icon labels using hexadecimal.
3996
- // Ps = 2 -> Set window/icon labels using UTF-8.
3997
- // Ps = 3 -> Query window/icon labels using UTF-8. (See dis-
3998
- // cussion of "Title Modes")
3999
- // XXX VTE bizarelly echos this:
4000
- Program.prototype.setTitleModeFeature = function() {
4001
- return this._twrite('\x1b[>' + slice.call(arguments).join(';') + 't');
4002
- };
4003
-
4004
- // CSI Ps SP t
4005
- // Set warning-bell volume (DECSWBV, VT520).
4006
- // Ps = 0 or 1 -> off.
4007
- // Ps = 2 , 3 or 4 -> low.
4008
- // Ps = 5 , 6 , 7 , or 8 -> high.
4009
- Program.prototype.decswbv =
4010
- Program.prototype.setWarningBellVolume = function(param) {
4011
- return this._write('\x1b[' + (param || '') + ' t');
4012
- };
4013
-
4014
- // CSI Ps SP u
4015
- // Set margin-bell volume (DECSMBV, VT520).
4016
- // Ps = 1 -> off.
4017
- // Ps = 2 , 3 or 4 -> low.
4018
- // Ps = 0 , 5 , 6 , 7 , or 8 -> high.
4019
- Program.prototype.decsmbv =
4020
- Program.prototype.setMarginBellVolume = function(param) {
4021
- return this._write('\x1b[' + (param || '') + ' u');
4022
- };
4023
-
4024
- // CSI Pt; Pl; Pb; Pr; Pp; Pt; Pl; Pp$ v
4025
- // Copy Rectangular Area (DECCRA, VT400 and up).
4026
- // Pt; Pl; Pb; Pr denotes the rectangle.
4027
- // Pp denotes the source page.
4028
- // Pt; Pl denotes the target location.
4029
- // Pp denotes the target page.
4030
- // NOTE: xterm doesn't enable this code by default.
4031
- Program.prototype.deccra =
4032
- Program.prototype.copyRectangle = function() {
4033
- return this._write('\x1b[' + slice.call(arguments).join(';') + '$v');
4034
- };
4035
-
4036
- // CSI Pt ; Pl ; Pb ; Pr ' w
4037
- // Enable Filter Rectangle (DECEFR), VT420 and up.
4038
- // Parameters are [top;left;bottom;right].
4039
- // Defines the coordinates of a filter rectangle and activates
4040
- // it. Anytime the locator is detected outside of the filter
4041
- // rectangle, an outside rectangle event is generated and the
4042
- // rectangle is disabled. Filter rectangles are always treated
4043
- // as "one-shot" events. Any parameters that are omitted default
4044
- // to the current locator position. If all parameters are omit-
4045
- // ted, any locator motion will be reported. DECELR always can-
4046
- // cels any prevous rectangle definition.
4047
- Program.prototype.decefr =
4048
- Program.prototype.enableFilterRectangle = function() {
4049
- return this._write('\x1b[' + slice.call(arguments).join(';') + '\'w');
4050
- };
4051
-
4052
- // CSI Ps x Request Terminal Parameters (DECREQTPARM).
4053
- // if Ps is a "0" (default) or "1", and xterm is emulating VT100,
4054
- // the control sequence elicits a response of the same form whose
4055
- // parameters describe the terminal:
4056
- // Ps -> the given Ps incremented by 2.
4057
- // Pn = 1 <- no parity.
4058
- // Pn = 1 <- eight bits.
4059
- // Pn = 1 <- 2 8 transmit 38.4k baud.
4060
- // Pn = 1 <- 2 8 receive 38.4k baud.
4061
- // Pn = 1 <- clock multiplier.
4062
- // Pn = 0 <- STP flags.
4063
- Program.prototype.decreqtparm =
4064
- Program.prototype.requestParameters = function(param) {
4065
- return this._write('\x1b[' + (param || 0) + 'x');
4066
- };
4067
-
4068
- // CSI Ps x Select Attribute Change Extent (DECSACE).
4069
- // Ps = 0 -> from start to end position, wrapped.
4070
- // Ps = 1 -> from start to end position, wrapped.
4071
- // Ps = 2 -> rectangle (exact).
4072
- Program.prototype.decsace =
4073
- Program.prototype.selectChangeExtent = function(param) {
4074
- return this._write('\x1b[' + (param || 0) + 'x');
4075
- };
4076
-
4077
- // CSI Pc; Pt; Pl; Pb; Pr$ x
4078
- // Fill Rectangular Area (DECFRA), VT420 and up.
4079
- // Pc is the character to use.
4080
- // Pt; Pl; Pb; Pr denotes the rectangle.
4081
- // NOTE: xterm doesn't enable this code by default.
4082
- Program.prototype.decfra =
4083
- Program.prototype.fillRectangle = function() {
4084
- return this._write('\x1b[' + slice.call(arguments).join(';') + '$x');
4085
- };
4086
-
4087
- // CSI Ps ; Pu ' z
4088
- // Enable Locator Reporting (DECELR).
4089
- // Valid values for the first parameter:
4090
- // Ps = 0 -> Locator disabled (default).
4091
- // Ps = 1 -> Locator enabled.
4092
- // Ps = 2 -> Locator enabled for one report, then disabled.
4093
- // The second parameter specifies the coordinate unit for locator
4094
- // reports.
4095
- // Valid values for the second parameter:
4096
- // Pu = 0 <- or omitted -> default to character cells.
4097
- // Pu = 1 <- device physical pixels.
4098
- // Pu = 2 <- character cells.
4099
- Program.prototype.decelr =
4100
- Program.prototype.enableLocatorReporting = function() {
4101
- return this._write('\x1b[' + slice.call(arguments).join(';') + '\'z');
4102
- };
4103
-
4104
- // CSI Pt; Pl; Pb; Pr$ z
4105
- // Erase Rectangular Area (DECERA), VT400 and up.
4106
- // Pt; Pl; Pb; Pr denotes the rectangle.
4107
- // NOTE: xterm doesn't enable this code by default.
4108
- Program.prototype.decera =
4109
- Program.prototype.eraseRectangle = function() {
4110
- return this._write('\x1b[' + slice.call(arguments).join(';') + '$z');
4111
- };
4112
-
4113
- // CSI Pm ' {
4114
- // Select Locator Events (DECSLE).
4115
- // Valid values for the first (and any additional parameters)
4116
- // are:
4117
- // Ps = 0 -> only respond to explicit host requests (DECRQLP).
4118
- // (This is default). It also cancels any filter
4119
- // rectangle.
4120
- // Ps = 1 -> report button down transitions.
4121
- // Ps = 2 -> do not report button down transitions.
4122
- // Ps = 3 -> report button up transitions.
4123
- // Ps = 4 -> do not report button up transitions.
4124
- Program.prototype.decsle =
4125
- Program.prototype.setLocatorEvents = function() {
4126
- return this._write('\x1b[' + slice.call(arguments).join(';') + '\'{');
4127
- };
4128
-
4129
- // CSI Pt; Pl; Pb; Pr$ {
4130
- // Selective Erase Rectangular Area (DECSERA), VT400 and up.
4131
- // Pt; Pl; Pb; Pr denotes the rectangle.
4132
- Program.prototype.decsera =
4133
- Program.prototype.selectiveEraseRectangle = function() {
4134
- return this._write('\x1b[' + slice.call(arguments).join(';') + '${');
4135
- };
4136
-
4137
- // CSI Ps ' |
4138
- // Request Locator Position (DECRQLP).
4139
- // Valid values for the parameter are:
4140
- // Ps = 0 , 1 or omitted -> transmit a single DECLRP locator
4141
- // report.
4142
-
4143
- // If Locator Reporting has been enabled by a DECELR, xterm will
4144
- // respond with a DECLRP Locator Report. This report is also
4145
- // generated on button up and down events if they have been
4146
- // enabled with a DECSLE, or when the locator is detected outside
4147
- // of a filter rectangle, if filter rectangles have been enabled
4148
- // with a DECEFR.
4149
-
4150
- // -> CSI Pe ; Pb ; Pr ; Pc ; Pp & w
4151
-
4152
- // Parameters are [event;button;row;column;page].
4153
- // Valid values for the event:
4154
- // Pe = 0 -> locator unavailable - no other parameters sent.
4155
- // Pe = 1 -> request - xterm received a DECRQLP.
4156
- // Pe = 2 -> left button down.
4157
- // Pe = 3 -> left button up.
4158
- // Pe = 4 -> middle button down.
4159
- // Pe = 5 -> middle button up.
4160
- // Pe = 6 -> right button down.
4161
- // Pe = 7 -> right button up.
4162
- // Pe = 8 -> M4 button down.
4163
- // Pe = 9 -> M4 button up.
4164
- // Pe = 1 0 -> locator outside filter rectangle.
4165
- // ``button'' parameter is a bitmask indicating which buttons are
4166
- // pressed:
4167
- // Pb = 0 <- no buttons down.
4168
- // Pb & 1 <- right button down.
4169
- // Pb & 2 <- middle button down.
4170
- // Pb & 4 <- left button down.
4171
- // Pb & 8 <- M4 button down.
4172
- // ``row'' and ``column'' parameters are the coordinates of the
4173
- // locator position in the xterm window, encoded as ASCII deci-
4174
- // mal.
4175
- // The ``page'' parameter is not used by xterm, and will be omit-
4176
- // ted.
4177
- Program.prototype.decrqlp =
4178
- Program.prototype.req_mouse_pos =
4179
- Program.prototype.reqmp =
4180
- Program.prototype.requestLocatorPosition = function(param, callback) {
4181
- // See also:
4182
- // get_mouse / getm / Gm
4183
- // mouse_info / minfo / Mi
4184
- // Correct for tput?
4185
- if (this.has('req_mouse_pos')) {
4186
- var code = this.tput.req_mouse_pos(param);
4187
- return this.response('locator-position', code, callback);
4188
- }
4189
- return this.response('locator-position',
4190
- '\x1b[' + (param || '') + '\'|', callback);
4191
- };
4192
-
4193
- // CSI P m SP }
4194
- // Insert P s Column(s) (default = 1) (DECIC), VT420 and up.
4195
- // NOTE: xterm doesn't enable this code by default.
4196
- Program.prototype.decic =
4197
- Program.prototype.insertColumns = function() {
4198
- return this._write('\x1b[' + slice.call(arguments).join(';') + ' }');
4199
- };
4200
-
4201
- // CSI P m SP ~
4202
- // Delete P s Column(s) (default = 1) (DECDC), VT420 and up
4203
- // NOTE: xterm doesn't enable this code by default.
4204
- Program.prototype.decdc =
4205
- Program.prototype.deleteColumns = function() {
4206
- return this._write('\x1b[' + slice.call(arguments).join(';') + ' ~');
4207
- };
4208
-
4209
- Program.prototype.out = function(name) {
4210
- var args = Array.prototype.slice.call(arguments, 1);
4211
- this.ret = true;
4212
- var out = this[name].apply(this, args);
4213
- this.ret = false;
4214
- return out;
4215
- };
4216
-
4217
- Program.prototype.sigtstp = function(callback) {
4218
- var resume = this.pause();
4219
-
4220
- process.once('SIGCONT', function() {
4221
- resume();
4222
- if (callback) callback();
4223
- });
4224
-
4225
- process.kill(process.pid, 'SIGTSTP');
4226
- };
4227
-
4228
- Program.prototype.pause = function(callback) {
4229
- var self = this
4230
- , isAlt = this.isAlt
4231
- , mouseEnabled = this.mouseEnabled;
4232
-
4233
- this.lsaveCursor('pause');
4234
- //this.csr(0, screen.height - 1);
4235
- if (isAlt) this.normalBuffer();
4236
- this.showCursor();
4237
- if (mouseEnabled) this.disableMouse();
4238
-
4239
- var write = this.output.write;
4240
- this.output.write = function() {};
4241
- if (this.input.setRawMode) {
4242
- this.input.setRawMode(false);
4243
- }
4244
- this.input.pause();
4245
-
4246
- return this._resume = function() {
4247
- delete self._resume;
4248
-
4249
- if (self.input.setRawMode) {
4250
- self.input.setRawMode(true);
4251
- }
4252
- self.input.resume();
4253
- self.output.write = write;
4254
-
4255
- if (isAlt) self.alternateBuffer();
4256
- //self.csr(0, screen.height - 1);
4257
- if (mouseEnabled) self.enableMouse();
4258
- self.lrestoreCursor('pause', true);
4259
-
4260
- if (callback) callback();
4261
- };
4262
- };
4263
-
4264
- Program.prototype.resume = function() {
4265
- if (this._resume) return this._resume();
4266
- };
4267
-
4268
- /**
4269
- * Helpers
4270
- */
4271
-
4272
- // We could do this easier by just manipulating the _events object, or for
4273
- // older versions of node, manipulating the array returned by listeners(), but
4274
- // neither of these methods are guaranteed to work in future versions of node.
4275
- function unshiftEvent(obj, event, listener) {
4276
- var listeners = obj.listeners(event);
4277
- obj.removeAllListeners(event);
4278
- obj.on(event, listener);
4279
- listeners.forEach(function(listener) {
4280
- obj.on(event, listener);
4281
- });
4282
- }
4283
-
4284
- function merge(out) {
4285
- slice.call(arguments, 1).forEach(function(obj) {
4286
- Object.keys(obj).forEach(function(key) {
4287
- out[key] = obj[key];
4288
- });
4289
- });
4290
- return out;
4291
- }
4292
-
4293
- /**
4294
- * Expose
4295
- */
4296
-
4297
- module.exports = Program;