@socketsecurity/cli-with-sentry 0.15.11 → 0.15.12

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 (402) hide show
  1. package/bin/cli.js +6 -6
  2. package/dist/.config/tsconfig.dts.tsbuildinfo +1 -1
  3. package/dist/cli.js +5731 -6607
  4. package/dist/cli.js.map +1 -1
  5. package/dist/constants.js +274 -305
  6. package/dist/constants.js.map +1 -1
  7. package/dist/instrument-with-sentry.js +28 -34
  8. package/dist/instrument-with-sentry.js.map +1 -1
  9. package/dist/shadow-bin.js +96 -123
  10. package/dist/shadow-bin.js.map +1 -1
  11. package/dist/shadow-inject.js +470 -580
  12. package/dist/shadow-inject.js.map +1 -1
  13. package/dist/socket-completion.bash +221 -0
  14. package/dist/types/cli.d.mts +2 -2
  15. package/dist/types/commands/analytics/cmd-analytics.d.mts +9 -15
  16. package/dist/types/commands/analytics/fetch-org-analytics.d.mts +4 -6
  17. package/dist/types/commands/analytics/fetch-repo-analytics.d.mts +4 -7
  18. package/dist/types/commands/analytics/handle-analytics.d.mts +9 -15
  19. package/dist/types/commands/analytics/handle-analytics.d.mts.map +1 -1
  20. package/dist/types/commands/analytics/output-analytics.d.mts +26 -46
  21. package/dist/types/commands/analytics/output-analytics.d.mts.map +1 -1
  22. package/dist/types/commands/audit-log/cmd-audit-log.d.mts +9 -15
  23. package/dist/types/commands/audit-log/fetch-audit-log.d.mts +10 -16
  24. package/dist/types/commands/audit-log/fetch-audit-log.d.mts.map +1 -1
  25. package/dist/types/commands/audit-log/handle-audit-log.d.mts +9 -15
  26. package/dist/types/commands/audit-log/handle-audit-log.d.mts.map +1 -1
  27. package/dist/types/commands/audit-log/output-audit-log.d.mts +22 -47
  28. package/dist/types/commands/audit-log/output-audit-log.d.mts.map +1 -1
  29. package/dist/types/commands/cdxgen/cmd-cdxgen.d.mts +9 -15
  30. package/dist/types/commands/cdxgen/cmd-cdxgen.d.mts.map +1 -1
  31. package/dist/types/commands/cdxgen/handle-cdxgen.d.mts +4 -0
  32. package/dist/types/commands/cdxgen/handle-cdxgen.d.mts.map +1 -0
  33. package/dist/types/commands/ci/cmd-ci.d.mts +9 -15
  34. package/dist/types/commands/ci/fetch-default-org-slug.d.mts +3 -3
  35. package/dist/types/commands/ci/handle-ci.d.mts +2 -2
  36. package/dist/types/commands/config/cmd-config-auto.d.mts +9 -15
  37. package/dist/types/commands/config/cmd-config-get.d.mts +9 -15
  38. package/dist/types/commands/config/cmd-config-list.d.mts +9 -15
  39. package/dist/types/commands/config/cmd-config-set.d.mts +9 -15
  40. package/dist/types/commands/config/cmd-config-unset.d.mts +9 -15
  41. package/dist/types/commands/config/cmd-config.d.mts +3 -3
  42. package/dist/types/commands/config/discover-config-value.d.mts +3 -5
  43. package/dist/types/commands/config/discover-config-value.d.mts.map +1 -1
  44. package/dist/types/commands/config/handle-config-auto.d.mts +7 -10
  45. package/dist/types/commands/config/handle-config-auto.d.mts.map +1 -1
  46. package/dist/types/commands/config/handle-config-get.d.mts +7 -10
  47. package/dist/types/commands/config/handle-config-get.d.mts.map +1 -1
  48. package/dist/types/commands/config/handle-config-set.d.mts +8 -12
  49. package/dist/types/commands/config/handle-config-set.d.mts.map +1 -1
  50. package/dist/types/commands/config/handle-config-unset.d.mts +7 -10
  51. package/dist/types/commands/config/handle-config-unset.d.mts.map +1 -1
  52. package/dist/types/commands/config/output-config-auto.d.mts +4 -8
  53. package/dist/types/commands/config/output-config-get.d.mts +4 -8
  54. package/dist/types/commands/config/output-config-list.d.mts +6 -9
  55. package/dist/types/commands/config/output-config-list.d.mts.map +1 -1
  56. package/dist/types/commands/config/output-config-set.d.mts +3 -6
  57. package/dist/types/commands/config/output-config-unset.d.mts +3 -6
  58. package/dist/types/commands/dependencies/cmd-dependencies.d.mts +9 -15
  59. package/dist/types/commands/dependencies/fetch-dependencies.d.mts +7 -10
  60. package/dist/types/commands/dependencies/fetch-dependencies.d.mts.map +1 -1
  61. package/dist/types/commands/dependencies/handle-dependencies.d.mts +7 -11
  62. package/dist/types/commands/dependencies/handle-dependencies.d.mts.map +1 -1
  63. package/dist/types/commands/dependencies/output-dependencies.d.mts +8 -15
  64. package/dist/types/commands/dependencies/output-dependencies.d.mts.map +1 -1
  65. package/dist/types/commands/diff-scan/cmd-diff-scan-get.d.mts +9 -15
  66. package/dist/types/commands/diff-scan/cmd-diff-scan.d.mts +3 -3
  67. package/dist/types/commands/diff-scan/fetch-diff-scan.d.mts +8 -12
  68. package/dist/types/commands/diff-scan/fetch-diff-scan.d.mts.map +1 -1
  69. package/dist/types/commands/diff-scan/handle-diff-scan.d.mts +10 -17
  70. package/dist/types/commands/diff-scan/handle-diff-scan.d.mts.map +1 -1
  71. package/dist/types/commands/diff-scan/output-diff-scan.d.mts +8 -15
  72. package/dist/types/commands/diff-scan/output-diff-scan.d.mts.map +1 -1
  73. package/dist/types/commands/fix/cmd-fix.d.mts +9 -15
  74. package/dist/types/commands/fix/git.d.mts +14 -49
  75. package/dist/types/commands/fix/npm-fix.d.mts +4 -16
  76. package/dist/types/commands/fix/npm-fix.d.mts.map +1 -1
  77. package/dist/types/commands/fix/open-pr.d.mts +20 -46
  78. package/dist/types/commands/fix/open-pr.d.mts.map +1 -1
  79. package/dist/types/commands/fix/pnpm-fix.d.mts +4 -16
  80. package/dist/types/commands/fix/pnpm-fix.d.mts.map +1 -1
  81. package/dist/types/commands/fix/run-fix.d.mts +3 -3
  82. package/dist/types/commands/fix/shared.d.mts +9 -15
  83. package/dist/types/commands/fix/types.d.mts +16 -16
  84. package/dist/types/commands/info/cmd-info.d.mts +9 -15
  85. package/dist/types/commands/info/fetch-package-info.d.mts +3 -7
  86. package/dist/types/commands/info/handle-package-info.d.mts +15 -22
  87. package/dist/types/commands/info/handle-package-info.d.mts.map +1 -1
  88. package/dist/types/commands/info/output-package-info.d.mts +10 -18
  89. package/dist/types/commands/info/output-package-info.d.mts.map +1 -1
  90. package/dist/types/commands/install/cmd-install-completion.d.mts +10 -0
  91. package/dist/types/commands/install/cmd-install-completion.d.mts.map +1 -0
  92. package/dist/types/commands/install/cmd-install.d.mts +3 -0
  93. package/dist/types/commands/install/cmd-install.d.mts.map +1 -0
  94. package/dist/types/commands/install/handle-install-completion.d.mts +2 -0
  95. package/dist/types/commands/install/handle-install-completion.d.mts.map +1 -0
  96. package/dist/types/commands/install/output-install-completion.d.mts +12 -0
  97. package/dist/types/commands/install/output-install-completion.d.mts.map +1 -0
  98. package/dist/types/commands/install/setup-tab-completion.d.mts +13 -0
  99. package/dist/types/commands/install/setup-tab-completion.d.mts.map +1 -0
  100. package/dist/types/commands/login/apply-login.d.mts +2 -7
  101. package/dist/types/commands/login/attempt-login.d.mts +2 -5
  102. package/dist/types/commands/login/attempt-login.d.mts.map +1 -1
  103. package/dist/types/commands/login/cmd-login.d.mts +9 -15
  104. package/dist/types/commands/logout/apply-logout.d.mts +2 -2
  105. package/dist/types/commands/logout/attempt-logout.d.mts +2 -2
  106. package/dist/types/commands/logout/cmd-logout.d.mts +9 -15
  107. package/dist/types/commands/manifest/cmd-manifest-auto.d.mts +9 -15
  108. package/dist/types/commands/manifest/cmd-manifest-cdxgen.d.mts +10 -0
  109. package/dist/types/commands/manifest/cmd-manifest-cdxgen.d.mts.map +1 -0
  110. package/dist/types/commands/manifest/cmd-manifest-conda.d.mts +9 -15
  111. package/dist/types/commands/manifest/cmd-manifest-gradle.d.mts +9 -15
  112. package/dist/types/commands/manifest/cmd-manifest-kotlin.d.mts +9 -15
  113. package/dist/types/commands/manifest/cmd-manifest-scala.d.mts +9 -15
  114. package/dist/types/commands/manifest/cmd-manifest.d.mts +9 -15
  115. package/dist/types/commands/manifest/cmd-manifest.d.mts.map +1 -1
  116. package/dist/types/commands/manifest/convert-conda-to-requirements.d.mts +7 -15
  117. package/dist/types/commands/manifest/convert_gradle_to_maven.d.mts +2 -8
  118. package/dist/types/commands/manifest/convert_sbt_to_maven.d.mts +2 -8
  119. package/dist/types/commands/manifest/handle-manifest-conda.d.mts +3 -9
  120. package/dist/types/commands/manifest/output-requirements.d.mts +6 -10
  121. package/dist/types/commands/{cdxgen → manifest}/run-cdxgen.d.mts +2 -2
  122. package/dist/types/commands/manifest/run-cdxgen.d.mts.map +1 -0
  123. package/dist/types/commands/npm/cmd-npm.d.mts +9 -15
  124. package/dist/types/commands/npx/cmd-npx.d.mts +9 -15
  125. package/dist/types/commands/oops/cmd-oops.d.mts +9 -15
  126. package/dist/types/commands/optimize/add-overrides.d.mts +18 -22
  127. package/dist/types/commands/optimize/apply-optimization.d.mts +2 -6
  128. package/dist/types/commands/optimize/cmd-optimize.d.mts +9 -15
  129. package/dist/types/commands/optimize/deps-includes-by-agent.d.mts +4 -7
  130. package/dist/types/commands/optimize/get-dependency-entries.d.mts +3 -5
  131. package/dist/types/commands/optimize/get-overrides-by-agent.d.mts +8 -11
  132. package/dist/types/commands/optimize/lockfile-includes-by-agent.d.mts +3 -10
  133. package/dist/types/commands/optimize/ls-by-agent.d.mts +6 -13
  134. package/dist/types/commands/optimize/shared.d.mts +2 -2
  135. package/dist/types/commands/optimize/types.d.mts +7 -7
  136. package/dist/types/commands/optimize/update-lockfile.d.mts +9 -12
  137. package/dist/types/commands/optimize/update-manifest-by-agent.d.mts +5 -11
  138. package/dist/types/commands/organization/cmd-organization-list.d.mts +9 -15
  139. package/dist/types/commands/organization/cmd-organization-policy-license.d.mts +9 -15
  140. package/dist/types/commands/organization/cmd-organization-policy-security.d.mts +9 -15
  141. package/dist/types/commands/organization/cmd-organization-policy.d.mts +3 -3
  142. package/dist/types/commands/organization/cmd-organization-quota.d.mts +9 -15
  143. package/dist/types/commands/organization/cmd-organization.d.mts +3 -3
  144. package/dist/types/commands/organization/fetch-license-policy.d.mts +4 -6
  145. package/dist/types/commands/organization/fetch-organization-list.d.mts +4 -6
  146. package/dist/types/commands/organization/fetch-quota.d.mts +4 -6
  147. package/dist/types/commands/organization/fetch-security-policy.d.mts +4 -6
  148. package/dist/types/commands/organization/handle-license-policy.d.mts +3 -6
  149. package/dist/types/commands/organization/handle-organization-list.d.mts +3 -5
  150. package/dist/types/commands/organization/handle-quota.d.mts +3 -3
  151. package/dist/types/commands/organization/handle-security-policy.d.mts +3 -6
  152. package/dist/types/commands/organization/output-license-policy.d.mts +4 -7
  153. package/dist/types/commands/organization/output-organization-list.d.mts +4 -7
  154. package/dist/types/commands/organization/output-quota.d.mts +4 -7
  155. package/dist/types/commands/organization/output-security-policy.d.mts +4 -7
  156. package/dist/types/commands/package/cmd-package-score.d.mts +9 -15
  157. package/dist/types/commands/package/cmd-package-shallow.d.mts +16 -22
  158. package/dist/types/commands/package/cmd-package.d.mts +3 -3
  159. package/dist/types/commands/package/fetch-purl-deep-score.d.mts +49 -51
  160. package/dist/types/commands/package/fetch-purls-shallow-score.d.mts +4 -6
  161. package/dist/types/commands/package/handle-purl-deep-score.d.mts +3 -6
  162. package/dist/types/commands/package/handle-purls-shallow-score.d.mts +6 -9
  163. package/dist/types/commands/package/handle-purls-shallow-score.d.mts.map +1 -1
  164. package/dist/types/commands/package/output-purl-score.d.mts +4 -8
  165. package/dist/types/commands/package/output-purls-shallow-score.d.mts +4 -8
  166. package/dist/types/commands/package/parse-package-specifiers.d.mts +5 -8
  167. package/dist/types/commands/raw-npm/cmd-raw-npm.d.mts +9 -15
  168. package/dist/types/commands/raw-npm/run-raw-npm.d.mts +2 -4
  169. package/dist/types/commands/raw-npx/cmd-raw-npx.d.mts +9 -15
  170. package/dist/types/commands/raw-npx/run-raw-npx.d.mts +2 -4
  171. package/dist/types/commands/report/cmd-report-create.d.mts +9 -15
  172. package/dist/types/commands/report/cmd-report-view.d.mts +9 -15
  173. package/dist/types/commands/report/cmd-report.d.mts +3 -3
  174. package/dist/types/commands/repos/cmd-repos-create.d.mts +9 -15
  175. package/dist/types/commands/repos/cmd-repos-del.d.mts +9 -15
  176. package/dist/types/commands/repos/cmd-repos-list.d.mts +9 -15
  177. package/dist/types/commands/repos/cmd-repos-update.d.mts +9 -15
  178. package/dist/types/commands/repos/cmd-repos-view.d.mts +9 -15
  179. package/dist/types/commands/repos/cmd-repos.d.mts +3 -3
  180. package/dist/types/commands/repos/fetch-create-repo.d.mts +11 -18
  181. package/dist/types/commands/repos/fetch-create-repo.d.mts.map +1 -1
  182. package/dist/types/commands/repos/fetch-delete-repo.d.mts +4 -7
  183. package/dist/types/commands/repos/fetch-list-repos.d.mts +10 -16
  184. package/dist/types/commands/repos/fetch-list-repos.d.mts.map +1 -1
  185. package/dist/types/commands/repos/fetch-update-repo.d.mts +11 -18
  186. package/dist/types/commands/repos/fetch-update-repo.d.mts.map +1 -1
  187. package/dist/types/commands/repos/fetch-view-repo.d.mts +4 -7
  188. package/dist/types/commands/repos/handle-create-repo.d.mts +10 -20
  189. package/dist/types/commands/repos/handle-create-repo.d.mts.map +1 -1
  190. package/dist/types/commands/repos/handle-delete-repo.d.mts +3 -7
  191. package/dist/types/commands/repos/handle-list-repos.d.mts +10 -17
  192. package/dist/types/commands/repos/handle-list-repos.d.mts.map +1 -1
  193. package/dist/types/commands/repos/handle-update-repo.d.mts +10 -20
  194. package/dist/types/commands/repos/handle-update-repo.d.mts.map +1 -1
  195. package/dist/types/commands/repos/handle-view-repo.d.mts +3 -7
  196. package/dist/types/commands/repos/output-create-repo.d.mts +4 -8
  197. package/dist/types/commands/repos/output-delete-repo.d.mts +4 -8
  198. package/dist/types/commands/repos/output-list-repos.d.mts +4 -7
  199. package/dist/types/commands/repos/output-update-repo.d.mts +4 -8
  200. package/dist/types/commands/repos/output-view-repo.d.mts +4 -7
  201. package/dist/types/commands/scan/cmd-scan-create.d.mts +9 -15
  202. package/dist/types/commands/scan/cmd-scan-del.d.mts +9 -15
  203. package/dist/types/commands/scan/cmd-scan-diff.d.mts +9 -15
  204. package/dist/types/commands/scan/cmd-scan-list.d.mts +3 -3
  205. package/dist/types/commands/scan/cmd-scan-metadata.d.mts +3 -3
  206. package/dist/types/commands/scan/cmd-scan-report.d.mts +3 -3
  207. package/dist/types/commands/scan/cmd-scan-view.d.mts +3 -3
  208. package/dist/types/commands/scan/cmd-scan.d.mts +3 -3
  209. package/dist/types/commands/scan/fetch-create-org-full-scan.d.mts +11 -26
  210. package/dist/types/commands/scan/fetch-create-org-full-scan.d.mts.map +1 -1
  211. package/dist/types/commands/scan/fetch-delete-org-full-scan.d.mts +4 -7
  212. package/dist/types/commands/scan/fetch-diff-scan.d.mts +8 -12
  213. package/dist/types/commands/scan/fetch-diff-scan.d.mts.map +1 -1
  214. package/dist/types/commands/scan/fetch-list-scans.d.mts +13 -22
  215. package/dist/types/commands/scan/fetch-list-scans.d.mts.map +1 -1
  216. package/dist/types/commands/scan/fetch-report-data.d.mts +8 -14
  217. package/dist/types/commands/scan/fetch-scan-metadata.d.mts +4 -7
  218. package/dist/types/commands/scan/fetch-scan.d.mts +4 -7
  219. package/dist/types/commands/scan/fetch-supported-scan-file-names.d.mts +4 -6
  220. package/dist/types/commands/scan/generate-report.d.mts +36 -50
  221. package/dist/types/commands/scan/generate-report.d.mts.map +1 -1
  222. package/dist/types/commands/scan/handle-create-new-scan.d.mts +20 -37
  223. package/dist/types/commands/scan/handle-create-new-scan.d.mts.map +1 -1
  224. package/dist/types/commands/scan/handle-delete-scan.d.mts +3 -7
  225. package/dist/types/commands/scan/handle-diff-scan.d.mts +10 -17
  226. package/dist/types/commands/scan/handle-diff-scan.d.mts.map +1 -1
  227. package/dist/types/commands/scan/handle-list-scans.d.mts +13 -23
  228. package/dist/types/commands/scan/handle-list-scans.d.mts.map +1 -1
  229. package/dist/types/commands/scan/handle-scan-metadata.d.mts +3 -7
  230. package/dist/types/commands/scan/handle-scan-report.d.mts +12 -21
  231. package/dist/types/commands/scan/handle-scan-report.d.mts.map +1 -1
  232. package/dist/types/commands/scan/handle-scan-view.d.mts +3 -8
  233. package/dist/types/commands/scan/output-create-new-scan.d.mts +4 -8
  234. package/dist/types/commands/scan/output-delete-scan.d.mts +4 -7
  235. package/dist/types/commands/scan/output-diff-scan.d.mts +8 -15
  236. package/dist/types/commands/scan/output-diff-scan.d.mts.map +1 -1
  237. package/dist/types/commands/scan/output-list-scans.d.mts +4 -7
  238. package/dist/types/commands/scan/output-scan-metadata.d.mts +4 -8
  239. package/dist/types/commands/scan/output-scan-report.d.mts +20 -38
  240. package/dist/types/commands/scan/output-scan-report.d.mts.map +1 -1
  241. package/dist/types/commands/scan/output-scan-view.d.mts +4 -10
  242. package/dist/types/commands/scan/stream-scan.d.mts +2 -6
  243. package/dist/types/commands/scan/suggest-org-slug.d.mts +2 -2
  244. package/dist/types/commands/scan/suggest-repo-slug.d.mts +4 -4
  245. package/dist/types/commands/scan/suggest_branch_slug.d.mts +2 -4
  246. package/dist/types/commands/scan/suggest_target.d.mts +2 -2
  247. package/dist/types/commands/threat-feed/cmd-threat-feed.d.mts +9 -15
  248. package/dist/types/commands/threat-feed/fetch-threat-feed.d.mts +10 -16
  249. package/dist/types/commands/threat-feed/fetch-threat-feed.d.mts.map +1 -1
  250. package/dist/types/commands/threat-feed/handle-threat-feed.d.mts +10 -17
  251. package/dist/types/commands/threat-feed/handle-threat-feed.d.mts.map +1 -1
  252. package/dist/types/commands/threat-feed/output-threat-feed.d.mts +4 -7
  253. package/dist/types/commands/threat-feed/types.d.mts +12 -12
  254. package/dist/types/commands/uninstall/cmd-uninstall-completion.d.mts +9 -0
  255. package/dist/types/commands/uninstall/cmd-uninstall-completion.d.mts.map +1 -0
  256. package/dist/types/commands/uninstall/cmd-uninstall.d.mts +3 -0
  257. package/dist/types/commands/uninstall/cmd-uninstall.d.mts.map +1 -0
  258. package/dist/types/commands/uninstall/handle-uninstall-completion.d.mts +2 -0
  259. package/dist/types/commands/uninstall/handle-uninstall-completion.d.mts.map +1 -0
  260. package/dist/types/commands/uninstall/output-uninstall-completion.d.mts +6 -0
  261. package/dist/types/commands/uninstall/output-uninstall-completion.d.mts.map +1 -0
  262. package/dist/types/commands/uninstall/teardown-tab-completion.d.mts +6 -0
  263. package/dist/types/commands/uninstall/teardown-tab-completion.d.mts.map +1 -0
  264. package/dist/types/commands/wrapper/add-socket-wrapper.d.mts +2 -2
  265. package/dist/types/commands/wrapper/check-socket-wrapper-setup.d.mts +2 -2
  266. package/dist/types/commands/wrapper/cmd-wrapper.d.mts +9 -15
  267. package/dist/types/commands/wrapper/postinstall-wrapper.d.mts +2 -2
  268. package/dist/types/commands/wrapper/postinstall-wrapper.d.mts.map +1 -1
  269. package/dist/types/commands/wrapper/remove-socket-wrapper.d.mts +2 -2
  270. package/dist/types/constants.d.mts +125 -135
  271. package/dist/types/constants.d.mts.map +1 -1
  272. package/dist/types/flags.d.mts +14 -17
  273. package/dist/types/flags.d.mts.map +1 -1
  274. package/dist/types/instrument-with-sentry.d.mts +2 -2
  275. package/dist/types/shadow/npm/arborist/index.d.mts +2 -2
  276. package/dist/types/shadow/npm/arborist/lib/arborist/index.d.mts +19 -24
  277. package/dist/types/shadow/npm/arborist/lib/arborist/types.d.mts +43 -71
  278. package/dist/types/shadow/npm/arborist/lib/dep-valid.d.mts +3 -8
  279. package/dist/types/shadow/npm/arborist/lib/edge.d.mts +58 -71
  280. package/dist/types/shadow/npm/arborist/lib/node.d.mts +55 -91
  281. package/dist/types/shadow/npm/arborist/lib/override-set.d.mts +26 -32
  282. package/dist/types/shadow/npm/arborist-helpers.d.mts +33 -66
  283. package/dist/types/shadow/npm/arborist-helpers.d.mts.map +1 -1
  284. package/dist/types/shadow/npm/bin.d.mts +2 -5
  285. package/dist/types/shadow/npm/inject.d.mts +2 -2
  286. package/dist/types/shadow/npm/install.d.mts +11 -16
  287. package/dist/types/shadow/npm/link.d.mts +2 -5
  288. package/dist/types/shadow/npm/paths.d.mts +7 -7
  289. package/dist/types/shadow/npm/proc-log/index.d.mts +3 -6
  290. package/dist/types/types.d.mts +15 -17
  291. package/dist/types/utils/agent.d.mts +11 -14
  292. package/dist/types/utils/alert/artifact.d.mts +32 -50
  293. package/dist/types/utils/alert/fix.d.mts +5 -5
  294. package/dist/types/utils/alert/severity.d.mts +12 -24
  295. package/dist/types/utils/alerts-map.d.mts +23 -36
  296. package/dist/types/utils/api.d.mts +11 -34
  297. package/dist/types/utils/check-input.d.mts +9 -12
  298. package/dist/types/utils/cmd.d.mts +4 -4
  299. package/dist/types/utils/color-or-markdown.d.mts +14 -23
  300. package/dist/types/utils/color-or-markdown.d.mts.map +1 -1
  301. package/dist/types/utils/completion.d.mts +11 -0
  302. package/dist/types/utils/completion.d.mts.map +1 -0
  303. package/dist/types/utils/config.d.mts +22 -31
  304. package/dist/types/utils/config.d.mts.map +1 -1
  305. package/dist/types/utils/determine-org-slug.d.mts +2 -7
  306. package/dist/types/utils/errors.d.mts +12 -21
  307. package/dist/types/utils/fail-msg-with-badge.d.mts +2 -5
  308. package/dist/types/utils/fs.d.mts +21 -52
  309. package/dist/types/utils/get-output-kind.d.mts +3 -6
  310. package/dist/types/utils/glob.d.mts +13 -24
  311. package/dist/types/utils/map-to-object.d.mts +4 -6
  312. package/dist/types/utils/markdown.d.mts +4 -15
  313. package/dist/types/utils/meow-with-subcommands.d.mts +34 -46
  314. package/dist/types/utils/meow-with-subcommands.d.mts.map +1 -1
  315. package/dist/types/utils/npm-paths.d.mts +7 -7
  316. package/dist/types/utils/npm-paths.d.mts.map +1 -1
  317. package/dist/types/utils/objects.d.mts +3 -8
  318. package/dist/types/utils/output-formatting.d.mts +14 -24
  319. package/dist/types/utils/package-environment.d.mts +51 -72
  320. package/dist/types/utils/package-environment.d.mts.map +1 -1
  321. package/dist/types/utils/path-resolve.d.mts +9 -14
  322. package/dist/types/utils/pnpm.d.mts +9 -7
  323. package/dist/types/utils/pnpm.d.mts.map +1 -1
  324. package/dist/types/utils/sdk.d.mts +8 -12
  325. package/dist/types/utils/semver.d.mts +5 -17
  326. package/dist/types/utils/serialize-result-json.d.mts +3 -3
  327. package/dist/types/utils/socket-package-alert.d.mts +62 -81
  328. package/dist/types/utils/socket-url.d.mts +9 -15
  329. package/dist/types/utils/spec.d.mts +4 -7
  330. package/dist/types/utils/spec.d.mts.map +1 -1
  331. package/dist/types/utils/strings.d.mts +2 -5
  332. package/dist/types/utils/translations.d.mts +592 -592
  333. package/dist/types/utils/walk-nested-map.d.mts +7 -10
  334. package/dist/utils.js +1531 -1833
  335. package/dist/utils.js.map +1 -1
  336. package/dist/vendor.js +38333 -51605
  337. package/dist/vendor.js.map +1 -1
  338. package/external/@socketsecurity/registry/external/@npmcli/package-json/index.js +5 -8
  339. package/external/@socketsecurity/registry/external/@npmcli/promise-spawn.js +2 -4
  340. package/external/@socketsecurity/registry/external/cacache.js +1 -2
  341. package/external/@socketsecurity/registry/external/libnpmpack.js +36 -76
  342. package/external/@socketsecurity/registry/external/make-fetch-happen.js +31 -67
  343. package/external/@socketsecurity/registry/external/pacote.js +36 -76
  344. package/external/@socketsecurity/registry/external/tinyglobby.js +3 -6
  345. package/external/@socketsecurity/registry/external/which.js +2 -4
  346. package/external/@socketsecurity/registry/lib/logger.d.ts +3 -1
  347. package/external/@socketsecurity/registry/lib/logger.js +149 -69
  348. package/external/@socketsecurity/registry/package.json +2 -2
  349. package/external/blessed/lib/alias.js +475 -468
  350. package/external/blessed/lib/blessed.js +12 -12
  351. package/external/blessed/lib/colors.js +234 -194
  352. package/external/blessed/lib/events.js +64 -70
  353. package/external/blessed/lib/gpmclient.js +117 -141
  354. package/external/blessed/lib/helpers.js +89 -94
  355. package/external/blessed/lib/keys.js +169 -342
  356. package/external/blessed/lib/program.js +2130 -2365
  357. package/external/blessed/lib/tput.js +1183 -1276
  358. package/external/blessed/lib/unicode.js +400 -522
  359. package/external/blessed/lib/widget.js +14 -14
  360. package/external/blessed/lib/widgets/ansiimage.js +90 -96
  361. package/external/blessed/lib/widgets/bigtext.js +91 -102
  362. package/external/blessed/lib/widgets/box.js +8 -8
  363. package/external/blessed/lib/widgets/button.js +23 -23
  364. package/external/blessed/lib/widgets/checkbox.js +50 -54
  365. package/external/blessed/lib/widgets/element.js +1415 -1716
  366. package/external/blessed/lib/widgets/filemanager.js +107 -118
  367. package/external/blessed/lib/widgets/form.js +144 -178
  368. package/external/blessed/lib/widgets/image.js +26 -36
  369. package/external/blessed/lib/widgets/input.js +8 -8
  370. package/external/blessed/lib/widgets/layout.js +103 -119
  371. package/external/blessed/lib/widgets/line.js +17 -20
  372. package/external/blessed/lib/widgets/list.js +349 -402
  373. package/external/blessed/lib/widgets/listbar.js +265 -306
  374. package/external/blessed/lib/widgets/listtable.js +133 -146
  375. package/external/blessed/lib/widgets/loading.js +31 -31
  376. package/external/blessed/lib/widgets/log.js +41 -40
  377. package/external/blessed/lib/widgets/message.js +64 -86
  378. package/external/blessed/lib/widgets/node.js +175 -207
  379. package/external/blessed/lib/widgets/overlayimage.js +360 -437
  380. package/external/blessed/lib/widgets/progressbar.js +79 -88
  381. package/external/blessed/lib/widgets/prompt.js +54 -61
  382. package/external/blessed/lib/widgets/question.js +48 -61
  383. package/external/blessed/lib/widgets/radiobutton.js +26 -27
  384. package/external/blessed/lib/widgets/radioset.js +8 -8
  385. package/external/blessed/lib/widgets/screen.js +1186 -1375
  386. package/external/blessed/lib/widgets/scrollablebox.js +202 -228
  387. package/external/blessed/lib/widgets/scrollabletext.js +9 -9
  388. package/external/blessed/lib/widgets/table.js +187 -216
  389. package/external/blessed/lib/widgets/terminal.js +258 -298
  390. package/external/blessed/lib/widgets/text.js +9 -9
  391. package/external/blessed/lib/widgets/textarea.js +188 -222
  392. package/external/blessed/lib/widgets/textbox.js +34 -36
  393. package/external/blessed/lib/widgets/video.js +55 -59
  394. package/external/blessed/usr/fonts/ter-u14b.json +1 -1
  395. package/external/blessed/usr/fonts/ter-u14n.json +1 -1
  396. package/external/blessed/vendor/tng.js +1016 -1144
  397. package/external/blessed-contrib/lib/layout/grid.js +345 -377
  398. package/external/blessed-contrib/lib/widget/charts/bar.js +6612 -7139
  399. package/external/blessed-contrib/lib/widget/charts/line.js +16224 -23941
  400. package/external/blessed-contrib/lib/widget/table.js +78 -96
  401. package/package.json +8 -8
  402. package/dist/types/commands/cdxgen/run-cdxgen.d.mts.map +0 -1
@@ -10,52 +10,47 @@
10
10
  * Modules
11
11
  */
12
12
 
13
- const assert = require('assert')
13
+ var assert = require('assert');
14
14
 
15
- const colors = require('../colors'),
16
- unicode = require('../unicode')
15
+ var colors = require('../colors')
16
+ , unicode = require('../unicode');
17
17
 
18
- const nextTick = global.setImmediate || process.nextTick.bind(process)
18
+ var nextTick = global.setImmediate || process.nextTick.bind(process);
19
19
 
20
- const helpers = require('../helpers')
20
+ var helpers = require('../helpers');
21
21
 
22
- const Node = require('./node')
22
+ var Node = require('./node');
23
23
 
24
24
  /**
25
25
  * Element
26
26
  */
27
27
 
28
28
  function Element(options) {
29
- const self = this
29
+ var self = this;
30
30
 
31
31
  if (!(this instanceof Node)) {
32
- return new Element(options)
32
+ return new Element(options);
33
33
  }
34
34
 
35
- options = options || {}
35
+ options = options || {};
36
36
 
37
37
  // Workaround to get a `scrollable` option.
38
38
  if (options.scrollable && !this._ignore && this.type !== 'scrollable-box') {
39
- const ScrollableBox = require('./scrollablebox')
40
- Object.getOwnPropertyNames(ScrollableBox.prototype).forEach(function (key) {
41
- if (key === 'type') {
42
- return
43
- }
44
- Object.defineProperty(
45
- this,
46
- key,
47
- Object.getOwnPropertyDescriptor(ScrollableBox.prototype, key)
48
- )
49
- }, this)
50
- this._ignore = true
51
- ScrollableBox.call(this, options)
52
- delete this._ignore
53
- return this
39
+ var ScrollableBox = require('./scrollablebox');
40
+ Object.getOwnPropertyNames(ScrollableBox.prototype).forEach(function(key) {
41
+ if (key === 'type') return;
42
+ Object.defineProperty(this, key,
43
+ Object.getOwnPropertyDescriptor(ScrollableBox.prototype, key));
44
+ }, this);
45
+ this._ignore = true;
46
+ ScrollableBox.call(this, options);
47
+ delete this._ignore;
48
+ return this;
54
49
  }
55
50
 
56
- Node.call(this, options)
51
+ Node.call(this, options);
57
52
 
58
- this.name = options.name
53
+ this.name = options.name;
59
54
 
60
55
  options.position = options.position || {
61
56
  left: options.left,
@@ -64,49 +59,47 @@ function Element(options) {
64
59
  bottom: options.bottom,
65
60
  width: options.width,
66
61
  height: options.height
67
- }
62
+ };
68
63
 
69
- if (
70
- options.position.width === 'shrink' ||
71
- options.position.height === 'shrink'
72
- ) {
64
+ if (options.position.width === 'shrink'
65
+ || options.position.height === 'shrink') {
73
66
  if (options.position.width === 'shrink') {
74
- delete options.position.width
67
+ delete options.position.width;
75
68
  }
76
69
  if (options.position.height === 'shrink') {
77
- delete options.position.height
70
+ delete options.position.height;
78
71
  }
79
- options.shrink = true
72
+ options.shrink = true;
80
73
  }
81
74
 
82
- this.position = options.position
75
+ this.position = options.position;
83
76
 
84
- this.noOverflow = options.noOverflow
85
- this.dockBorders = options.dockBorders
86
- this.shadow = options.shadow
77
+ this.noOverflow = options.noOverflow;
78
+ this.dockBorders = options.dockBorders;
79
+ this.shadow = options.shadow;
87
80
 
88
- this.style = options.style
81
+ this.style = options.style;
89
82
 
90
83
  if (!this.style) {
91
- this.style = {}
92
- this.style.fg = options.fg
93
- this.style.bg = options.bg
94
- this.style.bold = options.bold
95
- this.style.underline = options.underline
96
- this.style.blink = options.blink
97
- this.style.inverse = options.inverse
98
- this.style.invisible = options.invisible
99
- this.style.transparent = options.transparent
100
- }
101
-
102
- this.hidden = options.hidden || false
103
- this.fixed = options.fixed || false
104
- this.align = options.align || 'left'
105
- this.valign = options.valign || 'top'
106
- this.wrap = options.wrap !== false
107
- this.shrink = options.shrink
108
- this.fixed = options.fixed
109
- this.ch = options.ch || ' '
84
+ this.style = {};
85
+ this.style.fg = options.fg;
86
+ this.style.bg = options.bg;
87
+ this.style.bold = options.bold;
88
+ this.style.underline = options.underline;
89
+ this.style.blink = options.blink;
90
+ this.style.inverse = options.inverse;
91
+ this.style.invisible = options.invisible;
92
+ this.style.transparent = options.transparent;
93
+ }
94
+
95
+ this.hidden = options.hidden || false;
96
+ this.fixed = options.fixed || false;
97
+ this.align = options.align || 'left';
98
+ this.valign = options.valign || 'top';
99
+ this.wrap = options.wrap !== false;
100
+ this.shrink = options.shrink;
101
+ this.fixed = options.fixed;
102
+ this.ch = options.ch || ' ';
110
103
 
111
104
  if (typeof options.padding === 'number' || !options.padding) {
112
105
  options.padding = {
@@ -114,7 +107,7 @@ function Element(options) {
114
107
  top: options.padding,
115
108
  right: options.padding,
116
109
  bottom: options.padding
117
- }
110
+ };
118
111
  }
119
112
 
120
113
  this.padding = {
@@ -122,600 +115,529 @@ function Element(options) {
122
115
  top: options.padding.top || 0,
123
116
  right: options.padding.right || 0,
124
117
  bottom: options.padding.bottom || 0
125
- }
118
+ };
126
119
 
127
- this.border = options.border
120
+ this.border = options.border;
128
121
  if (this.border) {
129
122
  if (typeof this.border === 'string') {
130
- this.border = { type: this.border }
123
+ this.border = { type: this.border };
131
124
  }
132
- this.border.type = this.border.type || 'bg'
133
- if (this.border.type === 'ascii') {
134
- this.border.type = 'line'
135
- }
136
- this.border.ch = this.border.ch || ' '
137
- this.style.border = this.style.border || this.border.style
125
+ this.border.type = this.border.type || 'bg';
126
+ if (this.border.type === 'ascii') this.border.type = 'line';
127
+ this.border.ch = this.border.ch || ' ';
128
+ this.style.border = this.style.border || this.border.style;
138
129
  if (!this.style.border) {
139
- this.style.border = {}
140
- this.style.border.fg = this.border.fg
141
- this.style.border.bg = this.border.bg
130
+ this.style.border = {};
131
+ this.style.border.fg = this.border.fg;
132
+ this.style.border.bg = this.border.bg;
142
133
  }
143
134
  //this.border.style = this.style.border;
144
- if (this.border.left == null) {
145
- this.border.left = true
146
- }
147
- if (this.border.top == null) {
148
- this.border.top = true
149
- }
150
- if (this.border.right == null) {
151
- this.border.right = true
152
- }
153
- if (this.border.bottom == null) {
154
- this.border.bottom = true
155
- }
135
+ if (this.border.left == null) this.border.left = true;
136
+ if (this.border.top == null) this.border.top = true;
137
+ if (this.border.right == null) this.border.right = true;
138
+ if (this.border.bottom == null) this.border.bottom = true;
156
139
  }
157
140
 
158
141
  // if (options.mouse || options.clickable) {
159
142
  if (options.clickable) {
160
- this.screen._listenMouse(this)
143
+ this.screen._listenMouse(this);
161
144
  }
162
145
 
163
146
  if (options.input || options.keyable) {
164
- this.screen._listenKeys(this)
147
+ this.screen._listenKeys(this);
165
148
  }
166
149
 
167
- this.parseTags = options.parseTags || options.tags
150
+ this.parseTags = options.parseTags || options.tags;
168
151
 
169
- this.setContent(options.content || '', true)
152
+ this.setContent(options.content || '', true);
170
153
 
171
154
  if (options.label) {
172
- this.setLabel(options.label)
155
+ this.setLabel(options.label);
173
156
  }
174
157
 
175
158
  if (options.hoverText) {
176
- this.setHover(options.hoverText)
159
+ this.setHover(options.hoverText);
177
160
  }
178
161
 
179
162
  // TODO: Possibly move this to Node for onScreenEvent('mouse', ...).
180
163
  this.on('newListener', function fn(type) {
181
164
  // type = type.split(' ').slice(1).join(' ');
182
- if (
183
- type === 'mouse' ||
184
- type === 'click' ||
185
- type === 'mouseover' ||
186
- type === 'mouseout' ||
187
- type === 'mousedown' ||
188
- type === 'mouseup' ||
189
- type === 'mousewheel' ||
190
- type === 'wheeldown' ||
191
- type === 'wheelup' ||
192
- type === 'mousemove'
193
- ) {
194
- self.screen._listenMouse(self)
165
+ if (type === 'mouse'
166
+ || type === 'click'
167
+ || type === 'mouseover'
168
+ || type === 'mouseout'
169
+ || type === 'mousedown'
170
+ || type === 'mouseup'
171
+ || type === 'mousewheel'
172
+ || type === 'wheeldown'
173
+ || type === 'wheelup'
174
+ || type === 'mousemove') {
175
+ self.screen._listenMouse(self);
195
176
  } else if (type === 'keypress' || type.indexOf('key ') === 0) {
196
- self.screen._listenKeys(self)
177
+ self.screen._listenKeys(self);
197
178
  }
198
- })
179
+ });
199
180
 
200
- this.on('resize', function () {
201
- self.parseContent()
202
- })
181
+ this.on('resize', function() {
182
+ self.parseContent();
183
+ });
203
184
 
204
- this.on('attach', function () {
205
- self.parseContent()
206
- })
185
+ this.on('attach', function() {
186
+ self.parseContent();
187
+ });
207
188
 
208
- this.on('detach', function () {
209
- delete self.lpos
210
- })
189
+ this.on('detach', function() {
190
+ delete self.lpos;
191
+ });
211
192
 
212
193
  if (options.hoverBg != null) {
213
- options.hoverEffects = options.hoverEffects || {}
214
- options.hoverEffects.bg = options.hoverBg
194
+ options.hoverEffects = options.hoverEffects || {};
195
+ options.hoverEffects.bg = options.hoverBg;
215
196
  }
216
197
 
217
198
  if (this.style.hover) {
218
- options.hoverEffects = this.style.hover
199
+ options.hoverEffects = this.style.hover;
219
200
  }
220
201
 
221
202
  if (this.style.focus) {
222
- options.focusEffects = this.style.focus
203
+ options.focusEffects = this.style.focus;
223
204
  }
224
205
 
225
206
  if (options.effects) {
226
- if (options.effects.hover) {
227
- options.hoverEffects = options.effects.hover
228
- }
229
- if (options.effects.focus) {
230
- options.focusEffects = options.effects.focus
231
- }
207
+ if (options.effects.hover) options.hoverEffects = options.effects.hover;
208
+ if (options.effects.focus) options.focusEffects = options.effects.focus;
232
209
  }
233
210
 
234
- ;[
235
- ['hoverEffects', 'mouseover', 'mouseout', '_htemp'],
236
- ['focusEffects', 'focus', 'blur', '_ftemp']
237
- ].forEach(function (props) {
238
- const pname = props[0],
239
- over = props[1],
240
- out = props[2],
241
- temp = props[3]
242
- self.screen.setEffects(self, self, over, out, self.options[pname], temp)
243
- })
211
+ [['hoverEffects', 'mouseover', 'mouseout', '_htemp'],
212
+ ['focusEffects', 'focus', 'blur', '_ftemp']].forEach(function(props) {
213
+ var pname = props[0], over = props[1], out = props[2], temp = props[3];
214
+ self.screen.setEffects(self, self, over, out, self.options[pname], temp);
215
+ });
244
216
 
245
217
  if (this.options.draggable) {
246
- this.draggable = true
218
+ this.draggable = true;
247
219
  }
248
220
 
249
221
  if (options.focused) {
250
- this.focus()
222
+ this.focus();
251
223
  }
252
224
  }
253
225
 
254
- Object.setPrototypeOf(Element.prototype, Node.prototype)
226
+ Object.setPrototypeOf(Element.prototype, Node.prototype);
255
227
 
256
- Element.prototype.type = 'element'
228
+ Element.prototype.type = 'element';
257
229
 
258
- Element.prototype.__defineGetter__('focused', function () {
259
- return this.screen.focused === this
260
- })
230
+ Element.prototype.__defineGetter__('focused', function() {
231
+ return this.screen.focused === this;
232
+ });
261
233
 
262
- Element.prototype.sattr = function (style, fg, bg) {
263
- let bold = style.bold,
264
- underline = style.underline,
265
- blink = style.blink,
266
- inverse = style.inverse,
267
- invisible = style.invisible
234
+ Element.prototype.sattr = function(style, fg, bg) {
235
+ var bold = style.bold
236
+ , underline = style.underline
237
+ , blink = style.blink
238
+ , inverse = style.inverse
239
+ , invisible = style.invisible;
268
240
 
269
241
  // if (arguments.length === 1) {
270
242
  if (fg == null && bg == null) {
271
- fg = style.fg
272
- bg = style.bg
243
+ fg = style.fg;
244
+ bg = style.bg;
273
245
  }
274
246
 
275
247
  // This used to be a loop, but I decided
276
248
  // to unroll it for performance's sake.
277
- if (typeof bold === 'function') {
278
- bold = bold(this)
279
- }
280
- if (typeof underline === 'function') {
281
- underline = underline(this)
282
- }
283
- if (typeof blink === 'function') {
284
- blink = blink(this)
285
- }
286
- if (typeof inverse === 'function') {
287
- inverse = inverse(this)
288
- }
289
- if (typeof invisible === 'function') {
290
- invisible = invisible(this)
291
- }
249
+ if (typeof bold === 'function') bold = bold(this);
250
+ if (typeof underline === 'function') underline = underline(this);
251
+ if (typeof blink === 'function') blink = blink(this);
252
+ if (typeof inverse === 'function') inverse = inverse(this);
253
+ if (typeof invisible === 'function') invisible = invisible(this);
292
254
 
293
- if (typeof fg === 'function') {
294
- fg = fg(this)
295
- }
296
- if (typeof bg === 'function') {
297
- bg = bg(this)
298
- }
255
+ if (typeof fg === 'function') fg = fg(this);
256
+ if (typeof bg === 'function') bg = bg(this);
299
257
 
300
258
  // return (this.uid << 24)
301
259
  // | ((this.dockBorders ? 32 : 0) << 18)
302
- return (
303
- ((invisible ? 16 : 0) << 18) |
304
- ((inverse ? 8 : 0) << 18) |
305
- ((blink ? 4 : 0) << 18) |
306
- ((underline ? 2 : 0) << 18) |
307
- ((bold ? 1 : 0) << 18) |
308
- (colors.convert(fg) << 9) |
309
- colors.convert(bg)
310
- )
311
- }
312
-
313
- Element.prototype.onScreenEvent = function (type, handler) {
314
- const listeners = (this._slisteners = this._slisteners || [])
315
- listeners.push({ type: type, handler: handler })
316
- this.screen.on(type, handler)
317
- }
318
-
319
- Element.prototype.onceScreenEvent = function (type, handler) {
320
- const listeners = (this._slisteners = this._slisteners || [])
321
- const entry = { type: type, handler: handler }
322
- listeners.push(entry)
323
- this.screen.once(type, function () {
324
- const i = listeners.indexOf(entry)
325
- if (~i) {
326
- listeners.splice(i, 1)
327
- }
328
- return handler.apply(this, arguments)
329
- })
330
- }
331
-
332
- Element.prototype.removeScreenEvent = function (type, handler) {
333
- const listeners = (this._slisteners = this._slisteners || [])
334
- for (let i = 0; i < listeners.length; i++) {
335
- const listener = listeners[i]
260
+ return ((invisible ? 16 : 0) << 18)
261
+ | ((inverse ? 8 : 0) << 18)
262
+ | ((blink ? 4 : 0) << 18)
263
+ | ((underline ? 2 : 0) << 18)
264
+ | ((bold ? 1 : 0) << 18)
265
+ | (colors.convert(fg) << 9)
266
+ | colors.convert(bg);
267
+ };
268
+
269
+ Element.prototype.onScreenEvent = function(type, handler) {
270
+ var listeners = this._slisteners = this._slisteners || [];
271
+ listeners.push({ type: type, handler: handler });
272
+ this.screen.on(type, handler);
273
+ };
274
+
275
+ Element.prototype.onceScreenEvent = function(type, handler) {
276
+ var listeners = this._slisteners = this._slisteners || [];
277
+ var entry = { type: type, handler: handler };
278
+ listeners.push(entry);
279
+ this.screen.once(type, function() {
280
+ var i = listeners.indexOf(entry);
281
+ if (~i) listeners.splice(i, 1);
282
+ return handler.apply(this, arguments);
283
+ });
284
+ };
285
+
286
+ Element.prototype.removeScreenEvent = function(type, handler) {
287
+ var listeners = this._slisteners = this._slisteners || [];
288
+ for (var i = 0; i < listeners.length; i++) {
289
+ var listener = listeners[i];
336
290
  if (listener.type === type && listener.handler === handler) {
337
- listeners.splice(i, 1)
291
+ listeners.splice(i, 1);
338
292
  if (this._slisteners.length === 0) {
339
- delete this._slisteners
293
+ delete this._slisteners;
340
294
  }
341
- break
295
+ break;
342
296
  }
343
297
  }
344
- this.screen.removeListener(type, handler)
345
- }
298
+ this.screen.removeListener(type, handler);
299
+ };
346
300
 
347
- Element.prototype.free = function () {
348
- const listeners = (this._slisteners = this._slisteners || [])
349
- for (let i = 0; i < listeners.length; i++) {
350
- const listener = listeners[i]
351
- this.screen.removeListener(listener.type, listener.handler)
301
+ Element.prototype.free = function() {
302
+ var listeners = this._slisteners = this._slisteners || [];
303
+ for (var i = 0; i < listeners.length; i++) {
304
+ var listener = listeners[i];
305
+ this.screen.removeListener(listener.type, listener.handler);
352
306
  }
353
- delete this._slisteners
354
- }
307
+ delete this._slisteners;
308
+ };
355
309
 
356
- Element.prototype.hide = function () {
357
- if (this.hidden) {
358
- return
359
- }
360
- this.clearPos()
361
- this.hidden = true
362
- this.emit('hide')
310
+ Element.prototype.hide = function() {
311
+ if (this.hidden) return;
312
+ this.clearPos();
313
+ this.hidden = true;
314
+ this.emit('hide');
363
315
  if (this.screen.focused === this) {
364
- this.screen.rewindFocus()
365
- }
366
- }
367
-
368
- Element.prototype.show = function () {
369
- if (!this.hidden) {
370
- return
371
- }
372
- this.hidden = false
373
- this.emit('show')
374
- }
375
-
376
- Element.prototype.toggle = function () {
377
- return this.hidden ? this.show() : this.hide()
378
- }
379
-
380
- Element.prototype.focus = function () {
381
- return (this.screen.focused = this)
382
- }
383
-
384
- Element.prototype.setContent = function (content, noClear, noTags) {
385
- if (!noClear) {
386
- this.clearPos()
387
- }
388
- this.content = content || ''
389
- this.parseContent(noTags)
390
- this.emit('set content')
391
- }
392
-
393
- Element.prototype.getContent = function () {
394
- if (!this._clines) {
395
- return ''
396
- }
397
- return this._clines.fake.join('\n')
398
- }
399
-
400
- Element.prototype.setText = function (content, noClear) {
401
- content = content || ''
402
- content = content.replace(/\x1b\[[\d;]*m/g, '')
403
- return this.setContent(content, noClear, true)
404
- }
405
-
406
- Element.prototype.getText = function () {
407
- return this.getContent().replace(/\x1b\[[\d;]*m/g, '')
408
- }
409
-
410
- Element.prototype.parseContent = function (noTags) {
411
- if (this.detached) {
412
- return false
413
- }
414
-
415
- const width = this.width - this.iwidth
416
- if (
417
- this._clines == null ||
418
- this._clines.width !== width ||
419
- this._clines.content !== this.content
420
- ) {
421
- let content = this.content
316
+ this.screen.rewindFocus();
317
+ }
318
+ };
319
+
320
+ Element.prototype.show = function() {
321
+ if (!this.hidden) return;
322
+ this.hidden = false;
323
+ this.emit('show');
324
+ };
325
+
326
+ Element.prototype.toggle = function() {
327
+ return this.hidden ? this.show() : this.hide();
328
+ };
329
+
330
+ Element.prototype.focus = function() {
331
+ return this.screen.focused = this;
332
+ };
333
+
334
+ Element.prototype.setContent = function(content, noClear, noTags) {
335
+ if (!noClear) this.clearPos();
336
+ this.content = content || '';
337
+ this.parseContent(noTags);
338
+ this.emit('set content');
339
+ };
340
+
341
+ Element.prototype.getContent = function() {
342
+ if (!this._clines) return '';
343
+ return this._clines.fake.join('\n');
344
+ };
345
+
346
+ Element.prototype.setText = function(content, noClear) {
347
+ content = content || '';
348
+ content = content.replace(/\x1b\[[\d;]*m/g, '');
349
+ return this.setContent(content, noClear, true);
350
+ };
351
+
352
+ Element.prototype.getText = function() {
353
+ return this.getContent().replace(/\x1b\[[\d;]*m/g, '');
354
+ };
355
+
356
+ Element.prototype.parseContent = function(noTags) {
357
+ if (this.detached) return false;
358
+
359
+ var width = this.width - this.iwidth;
360
+ if (this._clines == null
361
+ || this._clines.width !== width
362
+ || this._clines.content !== this.content) {
363
+ var content = this.content;
422
364
 
423
365
  content = content
424
366
  .replace(/[\x00-\x08\x0b-\x0c\x0e-\x1a\x1c-\x1f\x7f]/g, '')
425
367
  .replace(/\x1b(?!\[[\d;]*m)/g, '')
426
368
  .replace(/\r\n|\r/g, '\n')
427
- .replace(/\t/g, this.screen.tabc)
369
+ .replace(/\t/g, this.screen.tabc);
428
370
 
429
371
  if (this.screen.fullUnicode) {
430
372
  // double-width chars will eat the next char after render. create a
431
373
  // blank character after it so it doesn't eat the real next char.
432
- content = content.replace(unicode.chars.all, '$1\x03')
374
+ content = content.replace(unicode.chars.all, '$1\x03');
433
375
  // iTerm2 cannot render combining characters properly.
434
376
  if (this.screen.program.isiTerm2) {
435
- content = content.replace(unicode.chars.combining, '')
377
+ content = content.replace(unicode.chars.combining, '');
436
378
  }
437
379
  } else {
438
380
  // no double-width: replace them with question-marks.
439
- content = content.replace(unicode.chars.all, '??')
381
+ content = content.replace(unicode.chars.all, '??');
440
382
  // delete combining characters since they're 0-width anyway.
441
383
  // NOTE: We could drop this, the non-surrogates would get changed to ? by
442
384
  // the unicode filter, and surrogates changed to ? by the surrogate
443
385
  // regex. however, the user might expect them to be 0-width.
444
386
  // NOTE: Might be better for performance to drop!
445
- content = content.replace(unicode.chars.combining, '')
387
+ content = content.replace(unicode.chars.combining, '');
446
388
  // no surrogate pairs: replace them with question-marks.
447
- content = content.replace(unicode.chars.surrogate, '?')
389
+ content = content.replace(unicode.chars.surrogate, '?');
448
390
  // XXX Deduplicate code here:
449
391
  // content = helpers.dropUnicode(content);
450
392
  }
451
393
 
452
394
  if (!noTags) {
453
- content = this._parseTags(content)
395
+ content = this._parseTags(content);
454
396
  }
455
397
 
456
- this._clines = this._wrapContent(content, width)
457
- this._clines.width = width
458
- this._clines.content = this.content
459
- this._clines.attr = this._parseAttr(this._clines)
460
- this._clines.ci = []
461
- this._clines.reduce(
462
- function (total, line) {
463
- this._clines.ci.push(total)
464
- return total + line.length + 1
465
- }.bind(this),
466
- 0
467
- )
398
+ this._clines = this._wrapContent(content, width);
399
+ this._clines.width = width;
400
+ this._clines.content = this.content;
401
+ this._clines.attr = this._parseAttr(this._clines);
402
+ this._clines.ci = [];
403
+ this._clines.reduce(function(total, line) {
404
+ this._clines.ci.push(total);
405
+ return total + line.length + 1;
406
+ }.bind(this), 0);
468
407
 
469
- this._pcontent = this._clines.join('\n')
470
- this.emit('parsed content')
408
+ this._pcontent = this._clines.join('\n');
409
+ this.emit('parsed content');
471
410
 
472
- return true
411
+ return true;
473
412
  }
474
413
 
475
414
  // Need to calculate this every time because the default fg/bg may change.
476
- this._clines.attr = this._parseAttr(this._clines) || this._clines.attr
415
+ this._clines.attr = this._parseAttr(this._clines) || this._clines.attr;
477
416
 
478
- return false
479
- }
417
+ return false;
418
+ };
480
419
 
481
420
  // Convert `{red-fg}foo{/red-fg}` to `\x1b[31mfoo\x1b[39m`.
482
- Element.prototype._parseTags = function (text) {
483
- if (!this.parseTags) {
484
- return text
485
- }
486
- if (!/{\/?[\w\-,;!#]*}/.test(text)) {
487
- return text
488
- }
489
-
490
- let program = this.screen.program,
491
- out = '',
492
- state,
493
- bg = [],
494
- fg = [],
495
- flag = [],
496
- cap,
497
- slash,
498
- param,
499
- attr,
500
- esc
421
+ Element.prototype._parseTags = function(text) {
422
+ if (!this.parseTags) return text;
423
+ if (!/{\/?[\w\-,;!#]*}/.test(text)) return text;
424
+
425
+ var program = this.screen.program
426
+ , out = ''
427
+ , state
428
+ , bg = []
429
+ , fg = []
430
+ , flag = []
431
+ , cap
432
+ , slash
433
+ , param
434
+ , attr
435
+ , esc;
501
436
 
502
437
  for (;;) {
503
438
  if (!esc && (cap = /^{escape}/.exec(text))) {
504
- text = text.substring(cap[0].length)
505
- esc = true
506
- continue
439
+ text = text.substring(cap[0].length);
440
+ esc = true;
441
+ continue;
507
442
  }
508
443
 
509
444
  if (esc && (cap = /^([\s\S]+?){\/escape}/.exec(text))) {
510
- text = text.substring(cap[0].length)
511
- out += cap[1]
512
- esc = false
513
- continue
445
+ text = text.substring(cap[0].length);
446
+ out += cap[1];
447
+ esc = false;
448
+ continue;
514
449
  }
515
450
 
516
451
  if (esc) {
517
452
  // throw new Error('Unterminated escape tag.');
518
- out += text
519
- break
453
+ out += text;
454
+ break;
520
455
  }
521
456
 
522
- if ((cap = /^{(\/?)([\w\-,;!#]*)}/.exec(text))) {
523
- text = text.substring(cap[0].length)
524
- slash = cap[1] === '/'
525
- param = cap[2].replace(/-/g, ' ')
457
+ if (cap = /^{(\/?)([\w\-,;!#]*)}/.exec(text)) {
458
+ text = text.substring(cap[0].length);
459
+ slash = cap[1] === '/';
460
+ param = cap[2].replace(/-/g, ' ');
526
461
 
527
462
  if (param === 'open') {
528
- out += '{'
529
- continue
463
+ out += '{';
464
+ continue;
530
465
  } else if (param === 'close') {
531
- out += '}'
532
- continue
466
+ out += '}';
467
+ continue;
533
468
  }
534
469
 
535
- if (param.slice(-3) === ' bg') {
536
- state = bg
537
- } else if (param.slice(-3) === ' fg') {
538
- state = fg
539
- } else {
540
- state = flag
541
- }
470
+ if (param.slice(-3) === ' bg') state = bg;
471
+ else if (param.slice(-3) === ' fg') state = fg;
472
+ else state = flag;
542
473
 
543
474
  if (slash) {
544
475
  if (!param) {
545
- out += program._attr('normal')
546
- bg.length = 0
547
- fg.length = 0
548
- flag.length = 0
476
+ out += program._attr('normal');
477
+ bg.length = 0;
478
+ fg.length = 0;
479
+ flag.length = 0;
549
480
  } else {
550
- attr = program._attr(param, false)
481
+ attr = program._attr(param, false);
551
482
  if (attr == null) {
552
- out += cap[0]
483
+ out += cap[0];
553
484
  } else {
554
485
  // if (param !== state[state.length - 1]) {
555
486
  // throw new Error('Misnested tags.');
556
487
  // }
557
- state.pop()
488
+ state.pop();
558
489
  if (state.length) {
559
- out += program._attr(state[state.length - 1])
490
+ out += program._attr(state[state.length - 1]);
560
491
  } else {
561
- out += attr
492
+ out += attr;
562
493
  }
563
494
  }
564
495
  }
565
496
  } else {
566
497
  if (!param) {
567
- out += cap[0]
498
+ out += cap[0];
568
499
  } else {
569
- attr = program._attr(param)
500
+ attr = program._attr(param);
570
501
  if (attr == null) {
571
- out += cap[0]
502
+ out += cap[0];
572
503
  } else {
573
- state.push(param)
574
- out += attr
504
+ state.push(param);
505
+ out += attr;
575
506
  }
576
507
  }
577
508
  }
578
509
 
579
- continue
510
+ continue;
580
511
  }
581
512
 
582
- if ((cap = /^[\s\S]+?(?={\/?[\w\-,;!#]*})/.exec(text))) {
583
- text = text.substring(cap[0].length)
584
- out += cap[0]
585
- continue
513
+ if (cap = /^[\s\S]+?(?={\/?[\w\-,;!#]*})/.exec(text)) {
514
+ text = text.substring(cap[0].length);
515
+ out += cap[0];
516
+ continue;
586
517
  }
587
518
 
588
- out += text
589
- break
519
+ out += text;
520
+ break;
590
521
  }
591
522
 
592
- return out
593
- }
523
+ return out;
524
+ };
594
525
 
595
- Element.prototype._parseAttr = function (lines) {
596
- let dattr = this.sattr(this.style),
597
- attr = dattr,
598
- attrs = [],
599
- line,
600
- i,
601
- j,
602
- c
526
+ Element.prototype._parseAttr = function(lines) {
527
+ var dattr = this.sattr(this.style)
528
+ , attr = dattr
529
+ , attrs = []
530
+ , line
531
+ , i
532
+ , j
533
+ , c;
603
534
 
604
535
  if (lines[0].attr === attr) {
605
- return
536
+ return;
606
537
  }
607
538
 
608
539
  for (j = 0; j < lines.length; j++) {
609
- line = lines[j]
610
- attrs[j] = attr
540
+ line = lines[j];
541
+ attrs[j] = attr;
611
542
  for (i = 0; i < line.length; i++) {
612
543
  if (line[i] === '\x1b') {
613
- if ((c = /^\x1b\[[\d;]*m/.exec(line.substring(i)))) {
614
- attr = this.screen.attrCode(c[0], attr, dattr)
615
- i += c[0].length - 1
544
+ if (c = /^\x1b\[[\d;]*m/.exec(line.substring(i))) {
545
+ attr = this.screen.attrCode(c[0], attr, dattr);
546
+ i += c[0].length - 1;
616
547
  }
617
548
  }
618
549
  }
619
550
  }
620
551
 
621
- return attrs
622
- }
552
+ return attrs;
553
+ };
623
554
 
624
- Element.prototype._align = function (line, width, align) {
625
- if (!align) {
626
- return line
627
- }
555
+ Element.prototype._align = function(line, width, align) {
556
+ if (!align) return line;
628
557
  //if (!align && !~line.indexOf('{|}')) return line;
629
558
 
630
- let cline = line.replace(/\x1b\[[\d;]*m/g, ''),
631
- len = cline.length,
632
- s = width - len
559
+ var cline = line.replace(/\x1b\[[\d;]*m/g, '')
560
+ , len = cline.length
561
+ , s = width - len;
633
562
 
634
563
  if (this.shrink) {
635
- s = 0
564
+ s = 0;
636
565
  }
637
566
 
638
- if (len === 0) {
639
- return line
640
- }
641
- if (s < 0) {
642
- return line
643
- }
567
+ if (len === 0) return line;
568
+ if (s < 0) return line;
644
569
 
645
570
  if (align === 'center') {
646
- s = Array(((s / 2) | 0) + 1).join(' ')
647
- return s + line + s
571
+ s = Array(((s / 2) | 0) + 1).join(' ');
572
+ return s + line + s;
648
573
  } else if (align === 'right') {
649
- s = Array(s + 1).join(' ')
650
- return s + line
574
+ s = Array(s + 1).join(' ');
575
+ return s + line;
651
576
  } else if (this.parseTags && ~line.indexOf('{|}')) {
652
- const parts = line.split('{|}')
653
- const cparts = cline.split('{|}')
654
- s = Math.max(width - cparts[0].length - cparts[1].length, 0)
655
- s = Array(s + 1).join(' ')
656
- return parts[0] + s + parts[1]
657
- }
658
-
659
- return line
660
- }
661
-
662
- Element.prototype._wrapContent = function (content, width) {
663
- let tags = this.parseTags,
664
- state = this.align,
665
- wrap = this.wrap,
666
- margin = 0,
667
- rtof = [],
668
- ftor = [],
669
- out = [],
670
- no = 0,
671
- line,
672
- align,
673
- cap,
674
- total,
675
- i,
676
- part,
677
- j,
678
- lines,
679
- rest
680
-
681
- lines = content.split('\n')
577
+ var parts = line.split('{|}');
578
+ var cparts = cline.split('{|}');
579
+ s = Math.max(width - cparts[0].length - cparts[1].length, 0);
580
+ s = Array(s + 1).join(' ');
581
+ return parts[0] + s + parts[1];
582
+ }
583
+
584
+ return line;
585
+ };
586
+
587
+ Element.prototype._wrapContent = function(content, width) {
588
+ var tags = this.parseTags
589
+ , state = this.align
590
+ , wrap = this.wrap
591
+ , margin = 0
592
+ , rtof = []
593
+ , ftor = []
594
+ , out = []
595
+ , no = 0
596
+ , line
597
+ , align
598
+ , cap
599
+ , total
600
+ , i
601
+ , part
602
+ , j
603
+ , lines
604
+ , rest;
605
+
606
+ lines = content.split('\n');
682
607
 
683
608
  if (!content) {
684
- out.push(content)
685
- out.rtof = [0]
686
- out.ftor = [[0]]
687
- out.fake = lines
688
- out.real = out
689
- out.mwidth = 0
690
- return out
609
+ out.push(content);
610
+ out.rtof = [0];
611
+ out.ftor = [[0]];
612
+ out.fake = lines;
613
+ out.real = out;
614
+ out.mwidth = 0;
615
+ return out;
691
616
  }
692
617
 
693
- if (this.scrollbar) {
694
- margin++
695
- }
696
- if (this.type === 'textarea') {
697
- margin++
698
- }
699
- if (width > margin) {
700
- width -= margin
701
- }
618
+ if (this.scrollbar) margin++;
619
+ if (this.type === 'textarea') margin++;
620
+ if (width > margin) width -= margin;
702
621
 
703
- main: for (; no < lines.length; no++) {
704
- line = lines[no]
705
- align = state
622
+ main:
623
+ for (; no < lines.length; no++) {
624
+ line = lines[no];
625
+ align = state;
706
626
 
707
- ftor.push([])
627
+ ftor.push([]);
708
628
 
709
629
  // Handle alignment tags.
710
630
  if (tags) {
711
- if ((cap = /^{(left|center|right)}/.exec(line))) {
712
- line = line.substring(cap[0].length)
713
- align = state = cap[1] !== 'left' ? cap[1] : null
714
- }
715
- if ((cap = /{\/(left|center|right)}$/.exec(line))) {
716
- line = line.slice(0, -cap[0].length)
631
+ if (cap = /^{(left|center|right)}/.exec(line)) {
632
+ line = line.substring(cap[0].length);
633
+ align = state = cap[1] !== 'left'
634
+ ? cap[1]
635
+ : null;
636
+ }
637
+ if (cap = /{\/(left|center|right)}$/.exec(line)) {
638
+ line = line.slice(0, -cap[0].length);
717
639
  //state = null;
718
- state = this.align
640
+ state = this.align;
719
641
  }
720
642
  }
721
643
 
@@ -724,31 +646,27 @@ Element.prototype._wrapContent = function (content, width) {
724
646
  // Measure the real width of the string.
725
647
  for (i = 0, total = 0; i < line.length; i++) {
726
648
  while (line[i] === '\x1b') {
727
- while (line[i] && line[i++] !== 'm') {}
728
- }
729
- if (!line[i]) {
730
- break
649
+ while (line[i] && line[i++] !== 'm');
731
650
  }
651
+ if (!line[i]) break;
732
652
  if (++total === width) {
733
653
  // If we're not wrapping the text, we have to finish up the rest of
734
654
  // the control sequences before cutting off the line.
735
- i++
655
+ i++;
736
656
  if (!wrap) {
737
- rest = line.substring(i).match(/\x1b\[[^m]*m/g)
738
- rest = rest ? rest.join('') : ''
739
- out.push(this._align(line.substring(0, i) + rest, width, align))
740
- ftor[no].push(out.length - 1)
741
- rtof.push(no)
742
- continue main
657
+ rest = line.substring(i).match(/\x1b\[[^m]*m/g);
658
+ rest = rest ? rest.join('') : '';
659
+ out.push(this._align(line.substring(0, i) + rest, width, align));
660
+ ftor[no].push(out.length - 1);
661
+ rtof.push(no);
662
+ continue main;
743
663
  }
744
664
  if (!this.screen.fullUnicode) {
745
665
  // Try to find a space to break on.
746
666
  if (i !== line.length) {
747
- j = i
748
- while (j > i - 10 && j > 0 && line[--j] !== ' ') {}
749
- if (line[j] === ' ') {
750
- i = j + 1
751
- }
667
+ j = i;
668
+ while (j > i - 10 && j > 0 && line[--j] !== ' ');
669
+ if (line[j] === ' ') i = j + 1;
752
670
  }
753
671
  } else {
754
672
  // Try to find a character to break on.
@@ -758,304 +676,263 @@ Element.prototype._wrapContent = function (content, width) {
758
676
  // counts on wrapping (experimental):
759
677
  // NOTE: Could optimize this by putting
760
678
  // it in the parent for loop.
761
- if (unicode.isSurrogate(line, i)) {
762
- i--
763
- }
764
- for (let s = 0, n = 0; n < i; n++) {
765
- if (unicode.isSurrogate(line, n)) {
766
- s++, n++
767
- }
679
+ if (unicode.isSurrogate(line, i)) i--;
680
+ for (var s = 0, n = 0; n < i; n++) {
681
+ if (unicode.isSurrogate(line, n)) s++, n++;
768
682
  }
769
- i += s
683
+ i += s;
770
684
  // </XXX>
771
- j = i
685
+ j = i;
772
686
  // Break _past_ space.
773
687
  // Break _past_ double-width chars.
774
688
  // Break _past_ surrogate pairs.
775
689
  // Break _past_ combining chars.
776
690
  while (j > i - 10 && j > 0) {
777
- j--
778
- if (
779
- line[j] === ' ' ||
780
- line[j] === '\x03' ||
781
- (unicode.isSurrogate(line, j - 1) &&
782
- line[j + 1] !== '\x03') ||
783
- unicode.isCombining(line, j)
784
- ) {
785
- break
691
+ j--;
692
+ if (line[j] === ' '
693
+ || line[j] === '\x03'
694
+ || (unicode.isSurrogate(line, j - 1) && line[j + 1] !== '\x03')
695
+ || unicode.isCombining(line, j)) {
696
+ break;
786
697
  }
787
698
  }
788
- if (
789
- line[j] === ' ' ||
790
- line[j] === '\x03' ||
791
- (unicode.isSurrogate(line, j - 1) && line[j + 1] !== '\x03') ||
792
- unicode.isCombining(line, j)
793
- ) {
794
- i = j + 1
699
+ if (line[j] === ' '
700
+ || line[j] === '\x03'
701
+ || (unicode.isSurrogate(line, j - 1) && line[j + 1] !== '\x03')
702
+ || unicode.isCombining(line, j)) {
703
+ i = j + 1;
795
704
  }
796
705
  }
797
706
  }
798
- break
707
+ break;
799
708
  }
800
709
  }
801
710
 
802
- part = line.substring(0, i)
803
- line = line.substring(i)
711
+ part = line.substring(0, i);
712
+ line = line.substring(i);
804
713
 
805
- out.push(this._align(part, width, align))
806
- ftor[no].push(out.length - 1)
807
- rtof.push(no)
714
+ out.push(this._align(part, width, align));
715
+ ftor[no].push(out.length - 1);
716
+ rtof.push(no);
808
717
 
809
718
  // Make sure we didn't wrap the line to the very end, otherwise
810
719
  // we get a pointless empty line after a newline.
811
- if (line === '') {
812
- continue main
813
- }
720
+ if (line === '') continue main;
814
721
 
815
722
  // If only an escape code got cut off, at it to `part`.
816
- if (/^(?:\x1b[[\d;]*m)+$/.test(line)) {
817
- out[out.length - 1] += line
818
- continue main
723
+ if (/^(?:\x1b[\[\d;]*m)+$/.test(line)) {
724
+ out[out.length - 1] += line;
725
+ continue main;
819
726
  }
820
727
  }
821
728
 
822
- out.push(this._align(line, width, align))
823
- ftor[no].push(out.length - 1)
824
- rtof.push(no)
729
+ out.push(this._align(line, width, align));
730
+ ftor[no].push(out.length - 1);
731
+ rtof.push(no);
825
732
  }
826
733
 
827
- out.rtof = rtof
828
- out.ftor = ftor
829
- out.fake = lines
830
- out.real = out
734
+ out.rtof = rtof;
735
+ out.ftor = ftor;
736
+ out.fake = lines;
737
+ out.real = out;
831
738
 
832
- out.mwidth = out.reduce(function (current, line) {
833
- line = line.replace(/\x1b\[[\d;]*m/g, '')
834
- return line.length > current ? line.length : current
835
- }, 0)
739
+ out.mwidth = out.reduce(function(current, line) {
740
+ line = line.replace(/\x1b\[[\d;]*m/g, '');
741
+ return line.length > current
742
+ ? line.length
743
+ : current;
744
+ }, 0);
836
745
 
837
- return out
838
- }
746
+ return out;
747
+ };
839
748
 
840
- Element.prototype.__defineGetter__('visible', function () {
841
- let el = this
749
+ Element.prototype.__defineGetter__('visible', function() {
750
+ var el = this;
842
751
  do {
843
- if (el.detached) {
844
- return false
845
- }
846
- if (el.hidden) {
847
- return false
848
- }
752
+ if (el.detached) return false;
753
+ if (el.hidden) return false;
849
754
  // if (!el.lpos) return false;
850
755
  // if (el.position.width === 0 || el.position.height === 0) return false;
851
- } while ((el = el.parent))
852
- return true
853
- })
756
+ } while (el = el.parent);
757
+ return true;
758
+ });
854
759
 
855
- Element.prototype.__defineGetter__('_detached', function () {
856
- let el = this
760
+ Element.prototype.__defineGetter__('_detached', function() {
761
+ var el = this;
857
762
  do {
858
- if (el.type === 'screen') {
859
- return false
860
- }
861
- if (!el.parent) {
862
- return true
863
- }
864
- } while ((el = el.parent))
865
- return false
866
- })
763
+ if (el.type === 'screen') return false;
764
+ if (!el.parent) return true;
765
+ } while (el = el.parent);
766
+ return false;
767
+ });
867
768
 
868
- Element.prototype.enableMouse = function () {
869
- this.screen._listenMouse(this)
870
- }
769
+ Element.prototype.enableMouse = function() {
770
+ this.screen._listenMouse(this);
771
+ };
871
772
 
872
- Element.prototype.enableKeys = function () {
873
- this.screen._listenKeys(this)
874
- }
773
+ Element.prototype.enableKeys = function() {
774
+ this.screen._listenKeys(this);
775
+ };
875
776
 
876
- Element.prototype.enableInput = function () {
877
- this.screen._listenMouse(this)
878
- this.screen._listenKeys(this)
879
- }
777
+ Element.prototype.enableInput = function() {
778
+ this.screen._listenMouse(this);
779
+ this.screen._listenKeys(this);
780
+ };
880
781
 
881
- Element.prototype.__defineGetter__('draggable', function () {
882
- return this._draggable === true
883
- })
782
+ Element.prototype.__defineGetter__('draggable', function() {
783
+ return this._draggable === true;
784
+ });
884
785
 
885
- Element.prototype.__defineSetter__('draggable', function (draggable) {
886
- return draggable ? this.enableDrag(draggable) : this.disableDrag()
887
- })
786
+ Element.prototype.__defineSetter__('draggable', function(draggable) {
787
+ return draggable ? this.enableDrag(draggable) : this.disableDrag();
788
+ });
888
789
 
889
- Element.prototype.enableDrag = function (verify) {
890
- const self = this
790
+ Element.prototype.enableDrag = function(verify) {
791
+ var self = this;
891
792
 
892
- if (this._draggable) {
893
- return true
894
- }
793
+ if (this._draggable) return true;
895
794
 
896
795
  if (typeof verify !== 'function') {
897
- verify = function () {
898
- return true
899
- }
796
+ verify = function() { return true; };
900
797
  }
901
798
 
902
- this.enableMouse()
799
+ this.enableMouse();
903
800
 
904
- this.on(
905
- 'mousedown',
906
- (this._dragMD = function (data) {
907
- if (self.screen._dragging) {
908
- return
909
- }
910
- if (!verify(data)) {
911
- return
912
- }
913
- self.screen._dragging = self
914
- self._drag = {
915
- x: data.x - self.aleft,
916
- y: data.y - self.atop
917
- }
918
- self.setFront()
919
- })
920
- )
921
-
922
- this.onScreenEvent(
923
- 'mouse',
924
- (this._dragM = function (data) {
925
- if (self.screen._dragging !== self) {
926
- return
927
- }
801
+ this.on('mousedown', this._dragMD = function(data) {
802
+ if (self.screen._dragging) return;
803
+ if (!verify(data)) return;
804
+ self.screen._dragging = self;
805
+ self._drag = {
806
+ x: data.x - self.aleft,
807
+ y: data.y - self.atop
808
+ };
809
+ self.setFront();
810
+ });
928
811
 
929
- if (data.action !== 'mousedown' && data.action !== 'mousemove') {
930
- delete self.screen._dragging
931
- delete self._drag
932
- return
933
- }
812
+ this.onScreenEvent('mouse', this._dragM = function(data) {
813
+ if (self.screen._dragging !== self) return;
934
814
 
935
- // This can happen in edge cases where the user is
936
- // already dragging and element when it is detached.
937
- if (!self.parent) {
938
- return
939
- }
815
+ if (data.action !== 'mousedown' && data.action !== 'mousemove') {
816
+ delete self.screen._dragging;
817
+ delete self._drag;
818
+ return;
819
+ }
940
820
 
941
- const ox = self._drag.x,
942
- oy = self._drag.y,
943
- px = self.parent.aleft,
944
- py = self.parent.atop,
945
- x = data.x - px - ox,
946
- y = data.y - py - oy
821
+ // This can happen in edge cases where the user is
822
+ // already dragging and element when it is detached.
823
+ if (!self.parent) return;
947
824
 
948
- if (self.position.right != null) {
949
- if (self.position.left != null) {
950
- self.width = '100%-' + (self.parent.width - self.width)
951
- }
952
- self.position.right = null
825
+ var ox = self._drag.x
826
+ , oy = self._drag.y
827
+ , px = self.parent.aleft
828
+ , py = self.parent.atop
829
+ , x = data.x - px - ox
830
+ , y = data.y - py - oy;
831
+
832
+ if (self.position.right != null) {
833
+ if (self.position.left != null) {
834
+ self.width = '100%-' + (self.parent.width - self.width);
953
835
  }
836
+ self.position.right = null;
837
+ }
954
838
 
955
- if (self.position.bottom != null) {
956
- if (self.position.top != null) {
957
- self.height = '100%-' + (self.parent.height - self.height)
958
- }
959
- self.position.bottom = null
839
+ if (self.position.bottom != null) {
840
+ if (self.position.top != null) {
841
+ self.height = '100%-' + (self.parent.height - self.height);
960
842
  }
843
+ self.position.bottom = null;
844
+ }
961
845
 
962
- self.rleft = x
963
- self.rtop = y
846
+ self.rleft = x;
847
+ self.rtop = y;
964
848
 
965
- self.screen.render()
966
- })
967
- )
849
+ self.screen.render();
850
+ });
968
851
 
969
- return (this._draggable = true)
970
- }
852
+ return this._draggable = true;
853
+ };
971
854
 
972
- Element.prototype.disableDrag = function () {
973
- if (!this._draggable) {
974
- return false
975
- }
976
- delete this.screen._dragging
977
- delete this._drag
978
- this.removeListener('mousedown', this._dragMD)
979
- this.removeScreenEvent('mouse', this._dragM)
980
- return (this._draggable = false)
981
- }
855
+ Element.prototype.disableDrag = function() {
856
+ if (!this._draggable) return false;
857
+ delete this.screen._dragging;
858
+ delete this._drag;
859
+ this.removeListener('mousedown', this._dragMD);
860
+ this.removeScreenEvent('mouse', this._dragM);
861
+ return this._draggable = false;
862
+ };
982
863
 
983
- Element.prototype.key = function () {
984
- return this.screen.program.key.apply(this, arguments)
985
- }
864
+ Element.prototype.key = function() {
865
+ return this.screen.program.key.apply(this, arguments);
866
+ };
986
867
 
987
- Element.prototype.onceKey = function () {
988
- return this.screen.program.onceKey.apply(this, arguments)
989
- }
868
+ Element.prototype.onceKey = function() {
869
+ return this.screen.program.onceKey.apply(this, arguments);
870
+ };
990
871
 
991
- Element.prototype.unkey = Element.prototype.removeKey = function () {
992
- return this.screen.program.unkey.apply(this, arguments)
993
- }
872
+ Element.prototype.unkey =
873
+ Element.prototype.removeKey = function() {
874
+ return this.screen.program.unkey.apply(this, arguments);
875
+ };
994
876
 
995
- Element.prototype.setIndex = function (index) {
996
- if (!this.parent) {
997
- return
998
- }
877
+ Element.prototype.setIndex = function(index) {
878
+ if (!this.parent) return;
999
879
 
1000
880
  if (index < 0) {
1001
- index = this.parent.children.length + index
881
+ index = this.parent.children.length + index;
1002
882
  }
1003
883
 
1004
- index = Math.max(index, 0)
1005
- index = Math.min(index, this.parent.children.length - 1)
884
+ index = Math.max(index, 0);
885
+ index = Math.min(index, this.parent.children.length - 1);
1006
886
 
1007
- const i = this.parent.children.indexOf(this)
1008
- if (!~i) {
1009
- return
1010
- }
887
+ var i = this.parent.children.indexOf(this);
888
+ if (!~i) return;
1011
889
 
1012
- const item = this.parent.children.splice(i, 1)[0]
1013
- this.parent.children.splice(index, 0, item)
1014
- }
890
+ var item = this.parent.children.splice(i, 1)[0];
891
+ this.parent.children.splice(index, 0, item);
892
+ };
1015
893
 
1016
- Element.prototype.setFront = function () {
1017
- return this.setIndex(-1)
1018
- }
894
+ Element.prototype.setFront = function() {
895
+ return this.setIndex(-1);
896
+ };
1019
897
 
1020
- Element.prototype.setBack = function () {
1021
- return this.setIndex(0)
1022
- }
898
+ Element.prototype.setBack = function() {
899
+ return this.setIndex(0);
900
+ };
1023
901
 
1024
- Element.prototype.clearPos = function (get, override) {
1025
- if (this.detached) {
1026
- return
1027
- }
1028
- const lpos = this._getCoords(get)
1029
- if (!lpos) {
1030
- return
1031
- }
1032
- this.screen.clearRegion(lpos.xi, lpos.xl, lpos.yi, lpos.yl, override)
1033
- }
902
+ Element.prototype.clearPos = function(get, override) {
903
+ if (this.detached) return;
904
+ var lpos = this._getCoords(get);
905
+ if (!lpos) return;
906
+ this.screen.clearRegion(
907
+ lpos.xi, lpos.xl,
908
+ lpos.yi, lpos.yl,
909
+ override);
910
+ };
1034
911
 
1035
- Element.prototype.setLabel = function (options) {
1036
- const self = this
1037
- const Box = require('./box')
912
+ Element.prototype.setLabel = function(options) {
913
+ var self = this;
914
+ var Box = require('./box');
1038
915
 
1039
916
  if (typeof options === 'string') {
1040
- options = { text: options }
917
+ options = { text: options };
1041
918
  }
1042
919
 
1043
920
  if (this._label) {
1044
- this._label.setContent(options.text)
921
+ this._label.setContent(options.text);
1045
922
  if (options.side !== 'right') {
1046
- this._label.rleft = 2 + (this.border ? -1 : 0)
1047
- this._label.position.right = undefined
923
+ this._label.rleft = 2 + (this.border ? -1 : 0);
924
+ this._label.position.right = undefined;
1048
925
  if (!this.screen.autoPadding) {
1049
- this._label.rleft = 2
926
+ this._label.rleft = 2;
1050
927
  }
1051
928
  } else {
1052
- this._label.rright = 2 + (this.border ? -1 : 0)
1053
- this._label.position.left = undefined
929
+ this._label.rright = 2 + (this.border ? -1 : 0);
930
+ this._label.position.left = undefined;
1054
931
  if (!this.screen.autoPadding) {
1055
- this._label.rright = 2
932
+ this._label.rright = 2;
1056
933
  }
1057
934
  }
1058
- return
935
+ return;
1059
936
  }
1060
937
 
1061
938
  this._label = new Box({
@@ -1066,80 +943,70 @@ Element.prototype.setLabel = function (options) {
1066
943
  tags: this.parseTags,
1067
944
  shrink: true,
1068
945
  style: this.style.label
1069
- })
946
+ });
1070
947
 
1071
948
  if (options.side !== 'right') {
1072
- this._label.rleft = 2 - this.ileft
949
+ this._label.rleft = 2 - this.ileft;
1073
950
  } else {
1074
- this._label.rright = 2 - this.iright
951
+ this._label.rright = 2 - this.iright;
1075
952
  }
1076
953
 
1077
- this._label._isLabel = true
954
+ this._label._isLabel = true;
1078
955
 
1079
956
  if (!this.screen.autoPadding) {
1080
957
  if (options.side !== 'right') {
1081
- this._label.rleft = 2
958
+ this._label.rleft = 2;
1082
959
  } else {
1083
- this._label.rright = 2
960
+ this._label.rright = 2;
1084
961
  }
1085
- this._label.rtop = 0
962
+ this._label.rtop = 0;
1086
963
  }
1087
964
 
1088
- const reposition = function () {
1089
- self._label.rtop = (self.childBase || 0) - self.itop
965
+ var reposition = function() {
966
+ self._label.rtop = (self.childBase || 0) - self.itop;
1090
967
  if (!self.screen.autoPadding) {
1091
- self._label.rtop = self.childBase || 0
1092
- }
1093
- self.screen.render()
1094
- }
1095
-
1096
- this.on(
1097
- 'scroll',
1098
- (this._labelScroll = function () {
1099
- reposition()
1100
- })
1101
- )
1102
-
1103
- this.on(
1104
- 'resize',
1105
- (this._labelResize = function () {
1106
- nextTick(function () {
1107
- reposition()
1108
- })
1109
- })
1110
- )
1111
- }
1112
-
1113
- Element.prototype.removeLabel = function () {
1114
- if (!this._label) {
1115
- return
1116
- }
1117
- this.removeListener('scroll', this._labelScroll)
1118
- this.removeListener('resize', this._labelResize)
1119
- this._label.detach()
1120
- delete this._labelScroll
1121
- delete this._labelResize
1122
- delete this._label
1123
- }
1124
-
1125
- Element.prototype.setHover = function (options) {
968
+ self._label.rtop = (self.childBase || 0);
969
+ }
970
+ self.screen.render();
971
+ };
972
+
973
+ this.on('scroll', this._labelScroll = function() {
974
+ reposition();
975
+ });
976
+
977
+ this.on('resize', this._labelResize = function() {
978
+ nextTick(function() {
979
+ reposition();
980
+ });
981
+ });
982
+ };
983
+
984
+ Element.prototype.removeLabel = function() {
985
+ if (!this._label) return;
986
+ this.removeListener('scroll', this._labelScroll);
987
+ this.removeListener('resize', this._labelResize);
988
+ this._label.detach();
989
+ delete this._labelScroll;
990
+ delete this._labelResize;
991
+ delete this._label;
992
+ };
993
+
994
+ Element.prototype.setHover = function(options) {
1126
995
  if (typeof options === 'string') {
1127
- options = { text: options }
996
+ options = { text: options };
1128
997
  }
1129
998
 
1130
- this._hoverOptions = options
1131
- this.enableMouse()
1132
- this.screen._initHover()
1133
- }
999
+ this._hoverOptions = options;
1000
+ this.enableMouse();
1001
+ this.screen._initHover();
1002
+ };
1134
1003
 
1135
- Element.prototype.removeHover = function () {
1136
- delete this._hoverOptions
1137
- if (!this.screen._hoverText || this.screen._hoverText.detached) {
1138
- return
1139
- }
1140
- this.screen._hoverText.detach()
1141
- this.screen.render()
1142
- }
1004
+ Element.prototype.removeHover = function() {
1005
+ delete this._hoverOptions;
1006
+ if (!this.screen._hoverText || this.screen._hoverText.detached) return;
1007
+ this.screen._hoverText.detach();
1008
+ this.screen.render();
1009
+ };
1143
1010
 
1144
1011
  /**
1145
1012
  * Positioning
@@ -1160,45 +1027,41 @@ Element.prototype.removeHover = function () {
1160
1027
  // position (since that might be wrong because
1161
1028
  // it doesn't handle content shrinkage).
1162
1029
 
1163
- Element.prototype._getPos = function () {
1164
- const pos = this.lpos
1030
+ Element.prototype._getPos = function() {
1031
+ var pos = this.lpos;
1165
1032
 
1166
- assert.ok(pos)
1033
+ assert.ok(pos);
1167
1034
 
1168
- if (pos.aleft != null) {
1169
- return pos
1170
- }
1035
+ if (pos.aleft != null) return pos;
1171
1036
 
1172
- pos.aleft = pos.xi
1173
- pos.atop = pos.yi
1174
- pos.aright = this.screen.cols - pos.xl
1175
- pos.abottom = this.screen.rows - pos.yl
1176
- pos.width = pos.xl - pos.xi
1177
- pos.height = pos.yl - pos.yi
1037
+ pos.aleft = pos.xi;
1038
+ pos.atop = pos.yi;
1039
+ pos.aright = this.screen.cols - pos.xl;
1040
+ pos.abottom = this.screen.rows - pos.yl;
1041
+ pos.width = pos.xl - pos.xi;
1042
+ pos.height = pos.yl - pos.yi;
1178
1043
 
1179
- return pos
1180
- }
1044
+ return pos;
1045
+ };
1181
1046
 
1182
1047
  /**
1183
1048
  * Position Getters
1184
1049
  */
1185
1050
 
1186
- Element.prototype._getWidth = function (get) {
1187
- let parent = get ? this.parent._getPos() : this.parent,
1188
- width = this.position.width,
1189
- left,
1190
- expr
1051
+ Element.prototype._getWidth = function(get) {
1052
+ var parent = get ? this.parent._getPos() : this.parent
1053
+ , width = this.position.width
1054
+ , left
1055
+ , expr;
1191
1056
 
1192
1057
  if (typeof width === 'string') {
1193
- if (width === 'half') {
1194
- width = '50%'
1195
- }
1196
- expr = width.split(/(?=\+|-)/)
1197
- width = expr[0]
1198
- width = +width.slice(0, -1) / 100
1199
- width = (parent.width * width) | 0
1200
- width += +(expr[1] || 0)
1201
- return width
1058
+ if (width === 'half') width = '50%';
1059
+ expr = width.split(/(?=\+|-)/);
1060
+ width = expr[0];
1061
+ width = +width.slice(0, -1) / 100;
1062
+ width = parent.width * width | 0;
1063
+ width += +(expr[1] || 0);
1064
+ return width;
1202
1065
  }
1203
1066
 
1204
1067
  // This is for if the element is being streched or shrunken.
@@ -1208,52 +1071,46 @@ Element.prototype._getWidth = function (get) {
1208
1071
  // decided by the width the element, so it needs to be
1209
1072
  // calculated here.
1210
1073
  if (width == null) {
1211
- left = this.position.left || 0
1074
+ left = this.position.left || 0;
1212
1075
  if (typeof left === 'string') {
1213
- if (left === 'center') {
1214
- left = '50%'
1215
- }
1216
- expr = left.split(/(?=\+|-)/)
1217
- left = expr[0]
1218
- left = +left.slice(0, -1) / 100
1219
- left = (parent.width * left) | 0
1220
- left += +(expr[1] || 0)
1221
- }
1222
- width = parent.width - (this.position.right || 0) - left
1076
+ if (left === 'center') left = '50%';
1077
+ expr = left.split(/(?=\+|-)/);
1078
+ left = expr[0];
1079
+ left = +left.slice(0, -1) / 100;
1080
+ left = parent.width * left | 0;
1081
+ left += +(expr[1] || 0);
1082
+ }
1083
+ width = parent.width - (this.position.right || 0) - left;
1223
1084
  if (this.screen.autoPadding) {
1224
- if (
1225
- (this.position.left != null || this.position.right == null) &&
1226
- this.position.left !== 'center'
1227
- ) {
1228
- width -= this.parent.ileft
1085
+ if ((this.position.left != null || this.position.right == null)
1086
+ && this.position.left !== 'center') {
1087
+ width -= this.parent.ileft;
1229
1088
  }
1230
- width -= this.parent.iright
1089
+ width -= this.parent.iright;
1231
1090
  }
1232
1091
  }
1233
1092
 
1234
- return width
1235
- }
1093
+ return width;
1094
+ };
1236
1095
 
1237
- Element.prototype.__defineGetter__('width', function () {
1238
- return this._getWidth(false)
1239
- })
1096
+ Element.prototype.__defineGetter__('width', function() {
1097
+ return this._getWidth(false);
1098
+ });
1240
1099
 
1241
- Element.prototype._getHeight = function (get) {
1242
- let parent = get ? this.parent._getPos() : this.parent,
1243
- height = this.position.height,
1244
- top,
1245
- expr
1100
+ Element.prototype._getHeight = function(get) {
1101
+ var parent = get ? this.parent._getPos() : this.parent
1102
+ , height = this.position.height
1103
+ , top
1104
+ , expr;
1246
1105
 
1247
1106
  if (typeof height === 'string') {
1248
- if (height === 'half') {
1249
- height = '50%'
1250
- }
1251
- expr = height.split(/(?=\+|-)/)
1252
- height = expr[0]
1253
- height = +height.slice(0, -1) / 100
1254
- height = (parent.height * height) | 0
1255
- height += +(expr[1] || 0)
1256
- return height
1107
+ if (height === 'half') height = '50%';
1108
+ expr = height.split(/(?=\+|-)/);
1109
+ height = expr[0];
1110
+ height = +height.slice(0, -1) / 100;
1111
+ height = parent.height * height | 0;
1112
+ height += +(expr[1] || 0);
1113
+ return height;
1257
1114
  }
1258
1115
 
1259
1116
  // This is for if the element is being streched or shrunken.
@@ -1263,179 +1120,170 @@ Element.prototype._getHeight = function (get) {
1263
1120
  // decided by the width the element, so it needs to be
1264
1121
  // calculated here.
1265
1122
  if (height == null) {
1266
- top = this.position.top || 0
1123
+ top = this.position.top || 0;
1267
1124
  if (typeof top === 'string') {
1268
- if (top === 'center') {
1269
- top = '50%'
1270
- }
1271
- expr = top.split(/(?=\+|-)/)
1272
- top = expr[0]
1273
- top = +top.slice(0, -1) / 100
1274
- top = (parent.height * top) | 0
1275
- top += +(expr[1] || 0)
1276
- }
1277
- height = parent.height - (this.position.bottom || 0) - top
1125
+ if (top === 'center') top = '50%';
1126
+ expr = top.split(/(?=\+|-)/);
1127
+ top = expr[0];
1128
+ top = +top.slice(0, -1) / 100;
1129
+ top = parent.height * top | 0;
1130
+ top += +(expr[1] || 0);
1131
+ }
1132
+ height = parent.height - (this.position.bottom || 0) - top;
1278
1133
  if (this.screen.autoPadding) {
1279
- if (
1280
- (this.position.top != null || this.position.bottom == null) &&
1281
- this.position.top !== 'center'
1282
- ) {
1283
- height -= this.parent.itop
1134
+ if ((this.position.top != null
1135
+ || this.position.bottom == null)
1136
+ && this.position.top !== 'center') {
1137
+ height -= this.parent.itop;
1284
1138
  }
1285
- height -= this.parent.ibottom
1139
+ height -= this.parent.ibottom;
1286
1140
  }
1287
1141
  }
1288
1142
 
1289
- return height
1290
- }
1143
+ return height;
1144
+ };
1291
1145
 
1292
- Element.prototype.__defineGetter__('height', function () {
1293
- return this._getHeight(false)
1294
- })
1146
+ Element.prototype.__defineGetter__('height', function() {
1147
+ return this._getHeight(false);
1148
+ });
1295
1149
 
1296
- Element.prototype._getLeft = function (get) {
1297
- let parent = get ? this.parent._getPos() : this.parent,
1298
- left = this.position.left || 0,
1299
- expr
1150
+ Element.prototype._getLeft = function(get) {
1151
+ var parent = get ? this.parent._getPos() : this.parent
1152
+ , left = this.position.left || 0
1153
+ , expr;
1300
1154
 
1301
1155
  if (typeof left === 'string') {
1302
- if (left === 'center') {
1303
- left = '50%'
1304
- }
1305
- expr = left.split(/(?=\+|-)/)
1306
- left = expr[0]
1307
- left = +left.slice(0, -1) / 100
1308
- left = (parent.width * left) | 0
1309
- left += +(expr[1] || 0)
1156
+ if (left === 'center') left = '50%';
1157
+ expr = left.split(/(?=\+|-)/);
1158
+ left = expr[0];
1159
+ left = +left.slice(0, -1) / 100;
1160
+ left = parent.width * left | 0;
1161
+ left += +(expr[1] || 0);
1310
1162
  if (this.position.left === 'center') {
1311
- left -= (this._getWidth(get) / 2) | 0
1163
+ left -= this._getWidth(get) / 2 | 0;
1312
1164
  }
1313
1165
  }
1314
1166
 
1315
1167
  if (this.position.left == null && this.position.right != null) {
1316
- return this.screen.cols - this._getWidth(get) - this._getRight(get)
1168
+ return this.screen.cols - this._getWidth(get) - this._getRight(get);
1317
1169
  }
1318
1170
 
1319
1171
  if (this.screen.autoPadding) {
1320
- if (
1321
- (this.position.left != null || this.position.right == null) &&
1322
- this.position.left !== 'center'
1323
- ) {
1324
- left += this.parent.ileft
1172
+ if ((this.position.left != null
1173
+ || this.position.right == null)
1174
+ && this.position.left !== 'center') {
1175
+ left += this.parent.ileft;
1325
1176
  }
1326
1177
  }
1327
1178
 
1328
- return (parent.aleft || 0) + left
1329
- }
1179
+ return (parent.aleft || 0) + left;
1180
+ };
1330
1181
 
1331
- Element.prototype.__defineGetter__('aleft', function () {
1332
- return this._getLeft(false)
1333
- })
1182
+ Element.prototype.__defineGetter__('aleft', function() {
1183
+ return this._getLeft(false);
1184
+ });
1334
1185
 
1335
- Element.prototype._getRight = function (get) {
1336
- let parent = get ? this.parent._getPos() : this.parent,
1337
- right
1186
+ Element.prototype._getRight = function(get) {
1187
+ var parent = get ? this.parent._getPos() : this.parent
1188
+ , right;
1338
1189
 
1339
1190
  if (this.position.right == null && this.position.left != null) {
1340
- right = this.screen.cols - (this._getLeft(get) + this._getWidth(get))
1191
+ right = this.screen.cols - (this._getLeft(get) + this._getWidth(get));
1341
1192
  if (this.screen.autoPadding) {
1342
- right += this.parent.iright
1193
+ right += this.parent.iright;
1343
1194
  }
1344
- return right
1195
+ return right;
1345
1196
  }
1346
1197
 
1347
- right = (parent.aright || 0) + (this.position.right || 0)
1198
+ right = (parent.aright || 0) + (this.position.right || 0);
1348
1199
 
1349
1200
  if (this.screen.autoPadding) {
1350
- right += this.parent.iright
1201
+ right += this.parent.iright;
1351
1202
  }
1352
1203
 
1353
- return right
1354
- }
1204
+ return right;
1205
+ };
1355
1206
 
1356
- Element.prototype.__defineGetter__('aright', function () {
1357
- return this._getRight(false)
1358
- })
1207
+ Element.prototype.__defineGetter__('aright', function() {
1208
+ return this._getRight(false);
1209
+ });
1359
1210
 
1360
- Element.prototype._getTop = function (get) {
1361
- let parent = get ? this.parent._getPos() : this.parent,
1362
- top = this.position.top || 0,
1363
- expr
1211
+ Element.prototype._getTop = function(get) {
1212
+ var parent = get ? this.parent._getPos() : this.parent
1213
+ , top = this.position.top || 0
1214
+ , expr;
1364
1215
 
1365
1216
  if (typeof top === 'string') {
1366
- if (top === 'center') {
1367
- top = '50%'
1368
- }
1369
- expr = top.split(/(?=\+|-)/)
1370
- top = expr[0]
1371
- top = +top.slice(0, -1) / 100
1372
- top = (parent.height * top) | 0
1373
- top += +(expr[1] || 0)
1217
+ if (top === 'center') top = '50%';
1218
+ expr = top.split(/(?=\+|-)/);
1219
+ top = expr[0];
1220
+ top = +top.slice(0, -1) / 100;
1221
+ top = parent.height * top | 0;
1222
+ top += +(expr[1] || 0);
1374
1223
  if (this.position.top === 'center') {
1375
- top -= (this._getHeight(get) / 2) | 0
1224
+ top -= this._getHeight(get) / 2 | 0;
1376
1225
  }
1377
1226
  }
1378
1227
 
1379
1228
  if (this.position.top == null && this.position.bottom != null) {
1380
- return this.screen.rows - this._getHeight(get) - this._getBottom(get)
1229
+ return this.screen.rows - this._getHeight(get) - this._getBottom(get);
1381
1230
  }
1382
1231
 
1383
1232
  if (this.screen.autoPadding) {
1384
- if (
1385
- (this.position.top != null || this.position.bottom == null) &&
1386
- this.position.top !== 'center'
1387
- ) {
1388
- top += this.parent.itop
1233
+ if ((this.position.top != null
1234
+ || this.position.bottom == null)
1235
+ && this.position.top !== 'center') {
1236
+ top += this.parent.itop;
1389
1237
  }
1390
1238
  }
1391
1239
 
1392
- return (parent.atop || 0) + top
1393
- }
1240
+ return (parent.atop || 0) + top;
1241
+ };
1394
1242
 
1395
- Element.prototype.__defineGetter__('atop', function () {
1396
- return this._getTop(false)
1397
- })
1243
+ Element.prototype.__defineGetter__('atop', function() {
1244
+ return this._getTop(false);
1245
+ });
1398
1246
 
1399
- Element.prototype._getBottom = function (get) {
1400
- let parent = get ? this.parent._getPos() : this.parent,
1401
- bottom
1247
+ Element.prototype._getBottom = function(get) {
1248
+ var parent = get ? this.parent._getPos() : this.parent
1249
+ , bottom;
1402
1250
 
1403
1251
  if (this.position.bottom == null && this.position.top != null) {
1404
- bottom = this.screen.rows - (this._getTop(get) + this._getHeight(get))
1252
+ bottom = this.screen.rows - (this._getTop(get) + this._getHeight(get));
1405
1253
  if (this.screen.autoPadding) {
1406
- bottom += this.parent.ibottom
1254
+ bottom += this.parent.ibottom;
1407
1255
  }
1408
- return bottom
1256
+ return bottom;
1409
1257
  }
1410
1258
 
1411
- bottom = (parent.abottom || 0) + (this.position.bottom || 0)
1259
+ bottom = (parent.abottom || 0) + (this.position.bottom || 0);
1412
1260
 
1413
1261
  if (this.screen.autoPadding) {
1414
- bottom += this.parent.ibottom
1262
+ bottom += this.parent.ibottom;
1415
1263
  }
1416
1264
 
1417
- return bottom
1418
- }
1265
+ return bottom;
1266
+ };
1419
1267
 
1420
- Element.prototype.__defineGetter__('abottom', function () {
1421
- return this._getBottom(false)
1422
- })
1268
+ Element.prototype.__defineGetter__('abottom', function() {
1269
+ return this._getBottom(false);
1270
+ });
1423
1271
 
1424
- Element.prototype.__defineGetter__('rleft', function () {
1425
- return this.aleft - this.parent.aleft
1426
- })
1272
+ Element.prototype.__defineGetter__('rleft', function() {
1273
+ return this.aleft - this.parent.aleft;
1274
+ });
1427
1275
 
1428
- Element.prototype.__defineGetter__('rright', function () {
1429
- return this.aright - this.parent.aright
1430
- })
1276
+ Element.prototype.__defineGetter__('rright', function() {
1277
+ return this.aright - this.parent.aright;
1278
+ });
1431
1279
 
1432
- Element.prototype.__defineGetter__('rtop', function () {
1433
- return this.atop - this.parent.atop
1434
- })
1280
+ Element.prototype.__defineGetter__('rtop', function() {
1281
+ return this.atop - this.parent.atop;
1282
+ });
1435
1283
 
1436
- Element.prototype.__defineGetter__('rbottom', function () {
1437
- return this.abottom - this.parent.abottom
1438
- })
1284
+ Element.prototype.__defineGetter__('rbottom', function() {
1285
+ return this.abottom - this.parent.abottom;
1286
+ });
1439
1287
 
1440
1288
  /**
1441
1289
  * Position Setters
@@ -1446,257 +1294,217 @@ Element.prototype.__defineGetter__('rbottom', function () {
1446
1294
  // If position.bottom is null, we could simply set top instead.
1447
1295
  // But it wouldn't replicate bottom behavior appropriately if
1448
1296
  // the parent was resized, etc.
1449
- Element.prototype.__defineSetter__('width', function (val) {
1450
- if (this.position.width === val) {
1451
- return
1452
- }
1453
- if (/^\d+$/.test(val)) {
1454
- val = +val
1455
- }
1456
- this.emit('resize')
1457
- this.clearPos()
1458
- return (this.position.width = val)
1459
- })
1460
-
1461
- Element.prototype.__defineSetter__('height', function (val) {
1462
- if (this.position.height === val) {
1463
- return
1464
- }
1465
- if (/^\d+$/.test(val)) {
1466
- val = +val
1467
- }
1468
- this.emit('resize')
1469
- this.clearPos()
1470
- return (this.position.height = val)
1471
- })
1472
-
1473
- Element.prototype.__defineSetter__('aleft', function (val) {
1474
- let expr
1297
+ Element.prototype.__defineSetter__('width', function(val) {
1298
+ if (this.position.width === val) return;
1299
+ if (/^\d+$/.test(val)) val = +val;
1300
+ this.emit('resize');
1301
+ this.clearPos();
1302
+ return this.position.width = val;
1303
+ });
1304
+
1305
+ Element.prototype.__defineSetter__('height', function(val) {
1306
+ if (this.position.height === val) return;
1307
+ if (/^\d+$/.test(val)) val = +val;
1308
+ this.emit('resize');
1309
+ this.clearPos();
1310
+ return this.position.height = val;
1311
+ });
1312
+
1313
+ Element.prototype.__defineSetter__('aleft', function(val) {
1314
+ var expr;
1475
1315
  if (typeof val === 'string') {
1476
1316
  if (val === 'center') {
1477
- val = (this.screen.width / 2) | 0
1478
- val -= (this.width / 2) | 0
1317
+ val = this.screen.width / 2 | 0;
1318
+ val -= this.width / 2 | 0;
1479
1319
  } else {
1480
- expr = val.split(/(?=\+|-)/)
1481
- val = expr[0]
1482
- val = +val.slice(0, -1) / 100
1483
- val = (this.screen.width * val) | 0
1484
- val += +(expr[1] || 0)
1485
- }
1486
- }
1487
- val -= this.parent.aleft
1488
- if (this.position.left === val) {
1489
- return
1490
- }
1491
- this.emit('move')
1492
- this.clearPos()
1493
- return (this.position.left = val)
1494
- })
1495
-
1496
- Element.prototype.__defineSetter__('aright', function (val) {
1497
- val -= this.parent.aright
1498
- if (this.position.right === val) {
1499
- return
1500
- }
1501
- this.emit('move')
1502
- this.clearPos()
1503
- return (this.position.right = val)
1504
- })
1505
-
1506
- Element.prototype.__defineSetter__('atop', function (val) {
1507
- let expr
1320
+ expr = val.split(/(?=\+|-)/);
1321
+ val = expr[0];
1322
+ val = +val.slice(0, -1) / 100;
1323
+ val = this.screen.width * val | 0;
1324
+ val += +(expr[1] || 0);
1325
+ }
1326
+ }
1327
+ val -= this.parent.aleft;
1328
+ if (this.position.left === val) return;
1329
+ this.emit('move');
1330
+ this.clearPos();
1331
+ return this.position.left = val;
1332
+ });
1333
+
1334
+ Element.prototype.__defineSetter__('aright', function(val) {
1335
+ val -= this.parent.aright;
1336
+ if (this.position.right === val) return;
1337
+ this.emit('move');
1338
+ this.clearPos();
1339
+ return this.position.right = val;
1340
+ });
1341
+
1342
+ Element.prototype.__defineSetter__('atop', function(val) {
1343
+ var expr;
1508
1344
  if (typeof val === 'string') {
1509
1345
  if (val === 'center') {
1510
- val = (this.screen.height / 2) | 0
1511
- val -= (this.height / 2) | 0
1346
+ val = this.screen.height / 2 | 0;
1347
+ val -= this.height / 2 | 0;
1512
1348
  } else {
1513
- expr = val.split(/(?=\+|-)/)
1514
- val = expr[0]
1515
- val = +val.slice(0, -1) / 100
1516
- val = (this.screen.height * val) | 0
1517
- val += +(expr[1] || 0)
1518
- }
1519
- }
1520
- val -= this.parent.atop
1521
- if (this.position.top === val) {
1522
- return
1523
- }
1524
- this.emit('move')
1525
- this.clearPos()
1526
- return (this.position.top = val)
1527
- })
1528
-
1529
- Element.prototype.__defineSetter__('abottom', function (val) {
1530
- val -= this.parent.abottom
1531
- if (this.position.bottom === val) {
1532
- return
1533
- }
1534
- this.emit('move')
1535
- this.clearPos()
1536
- return (this.position.bottom = val)
1537
- })
1538
-
1539
- Element.prototype.__defineSetter__('rleft', function (val) {
1540
- if (this.position.left === val) {
1541
- return
1542
- }
1543
- if (/^\d+$/.test(val)) {
1544
- val = +val
1545
- }
1546
- this.emit('move')
1547
- this.clearPos()
1548
- return (this.position.left = val)
1549
- })
1550
-
1551
- Element.prototype.__defineSetter__('rright', function (val) {
1552
- if (this.position.right === val) {
1553
- return
1554
- }
1555
- this.emit('move')
1556
- this.clearPos()
1557
- return (this.position.right = val)
1558
- })
1559
-
1560
- Element.prototype.__defineSetter__('rtop', function (val) {
1561
- if (this.position.top === val) {
1562
- return
1563
- }
1564
- if (/^\d+$/.test(val)) {
1565
- val = +val
1566
- }
1567
- this.emit('move')
1568
- this.clearPos()
1569
- return (this.position.top = val)
1570
- })
1571
-
1572
- Element.prototype.__defineSetter__('rbottom', function (val) {
1573
- if (this.position.bottom === val) {
1574
- return
1575
- }
1576
- this.emit('move')
1577
- this.clearPos()
1578
- return (this.position.bottom = val)
1579
- })
1580
-
1581
- Element.prototype.__defineGetter__('ileft', function () {
1582
- return (this.border ? 1 : 0) + this.padding.left
1349
+ expr = val.split(/(?=\+|-)/);
1350
+ val = expr[0];
1351
+ val = +val.slice(0, -1) / 100;
1352
+ val = this.screen.height * val | 0;
1353
+ val += +(expr[1] || 0);
1354
+ }
1355
+ }
1356
+ val -= this.parent.atop;
1357
+ if (this.position.top === val) return;
1358
+ this.emit('move');
1359
+ this.clearPos();
1360
+ return this.position.top = val;
1361
+ });
1362
+
1363
+ Element.prototype.__defineSetter__('abottom', function(val) {
1364
+ val -= this.parent.abottom;
1365
+ if (this.position.bottom === val) return;
1366
+ this.emit('move');
1367
+ this.clearPos();
1368
+ return this.position.bottom = val;
1369
+ });
1370
+
1371
+ Element.prototype.__defineSetter__('rleft', function(val) {
1372
+ if (this.position.left === val) return;
1373
+ if (/^\d+$/.test(val)) val = +val;
1374
+ this.emit('move');
1375
+ this.clearPos();
1376
+ return this.position.left = val;
1377
+ });
1378
+
1379
+ Element.prototype.__defineSetter__('rright', function(val) {
1380
+ if (this.position.right === val) return;
1381
+ this.emit('move');
1382
+ this.clearPos();
1383
+ return this.position.right = val;
1384
+ });
1385
+
1386
+ Element.prototype.__defineSetter__('rtop', function(val) {
1387
+ if (this.position.top === val) return;
1388
+ if (/^\d+$/.test(val)) val = +val;
1389
+ this.emit('move');
1390
+ this.clearPos();
1391
+ return this.position.top = val;
1392
+ });
1393
+
1394
+ Element.prototype.__defineSetter__('rbottom', function(val) {
1395
+ if (this.position.bottom === val) return;
1396
+ this.emit('move');
1397
+ this.clearPos();
1398
+ return this.position.bottom = val;
1399
+ });
1400
+
1401
+ Element.prototype.__defineGetter__('ileft', function() {
1402
+ return (this.border ? 1 : 0) + this.padding.left;
1583
1403
  // return (this.border && this.border.left ? 1 : 0) + this.padding.left;
1584
- })
1404
+ });
1585
1405
 
1586
- Element.prototype.__defineGetter__('itop', function () {
1587
- return (this.border ? 1 : 0) + this.padding.top
1406
+ Element.prototype.__defineGetter__('itop', function() {
1407
+ return (this.border ? 1 : 0) + this.padding.top;
1588
1408
  // return (this.border && this.border.top ? 1 : 0) + this.padding.top;
1589
- })
1409
+ });
1590
1410
 
1591
- Element.prototype.__defineGetter__('iright', function () {
1592
- return (this.border ? 1 : 0) + this.padding.right
1411
+ Element.prototype.__defineGetter__('iright', function() {
1412
+ return (this.border ? 1 : 0) + this.padding.right;
1593
1413
  // return (this.border && this.border.right ? 1 : 0) + this.padding.right;
1594
- })
1414
+ });
1595
1415
 
1596
- Element.prototype.__defineGetter__('ibottom', function () {
1597
- return (this.border ? 1 : 0) + this.padding.bottom
1416
+ Element.prototype.__defineGetter__('ibottom', function() {
1417
+ return (this.border ? 1 : 0) + this.padding.bottom;
1598
1418
  // return (this.border && this.border.bottom ? 1 : 0) + this.padding.bottom;
1599
- })
1419
+ });
1600
1420
 
1601
- Element.prototype.__defineGetter__('iwidth', function () {
1421
+ Element.prototype.__defineGetter__('iwidth', function() {
1602
1422
  // return (this.border
1603
1423
  // ? ((this.border.left ? 1 : 0) + (this.border.right ? 1 : 0)) : 0)
1604
1424
  // + this.padding.left + this.padding.right;
1605
- return (this.border ? 2 : 0) + this.padding.left + this.padding.right
1606
- })
1425
+ return (this.border ? 2 : 0) + this.padding.left + this.padding.right;
1426
+ });
1607
1427
 
1608
- Element.prototype.__defineGetter__('iheight', function () {
1428
+ Element.prototype.__defineGetter__('iheight', function() {
1609
1429
  // return (this.border
1610
1430
  // ? ((this.border.top ? 1 : 0) + (this.border.bottom ? 1 : 0)) : 0)
1611
1431
  // + this.padding.top + this.padding.bottom;
1612
- return (this.border ? 2 : 0) + this.padding.top + this.padding.bottom
1613
- })
1614
-
1615
- Element.prototype.__defineGetter__('tpadding', function () {
1616
- return (
1617
- this.padding.left +
1618
- this.padding.top +
1619
- this.padding.right +
1620
- this.padding.bottom
1621
- )
1622
- })
1432
+ return (this.border ? 2 : 0) + this.padding.top + this.padding.bottom;
1433
+ });
1434
+
1435
+ Element.prototype.__defineGetter__('tpadding', function() {
1436
+ return this.padding.left + this.padding.top
1437
+ + this.padding.right + this.padding.bottom;
1438
+ });
1623
1439
 
1624
1440
  /**
1625
1441
  * Relative coordinates as default properties
1626
1442
  */
1627
1443
 
1628
- Element.prototype.__defineGetter__('left', function () {
1629
- return this.rleft
1630
- })
1444
+ Element.prototype.__defineGetter__('left', function() {
1445
+ return this.rleft;
1446
+ });
1631
1447
 
1632
- Element.prototype.__defineGetter__('right', function () {
1633
- return this.rright
1634
- })
1448
+ Element.prototype.__defineGetter__('right', function() {
1449
+ return this.rright;
1450
+ });
1635
1451
 
1636
- Element.prototype.__defineGetter__('top', function () {
1637
- return this.rtop
1638
- })
1452
+ Element.prototype.__defineGetter__('top', function() {
1453
+ return this.rtop;
1454
+ });
1639
1455
 
1640
- Element.prototype.__defineGetter__('bottom', function () {
1641
- return this.rbottom
1642
- })
1456
+ Element.prototype.__defineGetter__('bottom', function() {
1457
+ return this.rbottom;
1458
+ });
1643
1459
 
1644
- Element.prototype.__defineSetter__('left', function (val) {
1645
- return (this.rleft = val)
1646
- })
1460
+ Element.prototype.__defineSetter__('left', function(val) {
1461
+ return this.rleft = val;
1462
+ });
1647
1463
 
1648
- Element.prototype.__defineSetter__('right', function (val) {
1649
- return (this.rright = val)
1650
- })
1464
+ Element.prototype.__defineSetter__('right', function(val) {
1465
+ return this.rright = val;
1466
+ });
1651
1467
 
1652
- Element.prototype.__defineSetter__('top', function (val) {
1653
- return (this.rtop = val)
1654
- })
1468
+ Element.prototype.__defineSetter__('top', function(val) {
1469
+ return this.rtop = val;
1470
+ });
1655
1471
 
1656
- Element.prototype.__defineSetter__('bottom', function (val) {
1657
- return (this.rbottom = val)
1658
- })
1472
+ Element.prototype.__defineSetter__('bottom', function(val) {
1473
+ return this.rbottom = val;
1474
+ });
1659
1475
 
1660
1476
  /**
1661
1477
  * Rendering - here be dragons
1662
1478
  */
1663
1479
 
1664
- Element.prototype._getShrinkBox = function (xi, xl, yi, yl, get) {
1480
+ Element.prototype._getShrinkBox = function(xi, xl, yi, yl, get) {
1665
1481
  if (!this.children.length) {
1666
- return { xi: xi, xl: xi + 1, yi: yi, yl: yi + 1 }
1482
+ return { xi: xi, xl: xi + 1, yi: yi, yl: yi + 1 };
1667
1483
  }
1668
1484
 
1669
- let i,
1670
- el,
1671
- ret,
1672
- mxi = xi,
1673
- mxl = xi + 1,
1674
- myi = yi,
1675
- myl = yi + 1
1485
+ var i, el, ret, mxi = xi, mxl = xi + 1, myi = yi, myl = yi + 1;
1676
1486
 
1677
1487
  // This is a chicken and egg problem. We need to determine how the children
1678
1488
  // will render in order to determine how this element renders, but it in
1679
1489
  // order to figure out how the children will render, they need to know
1680
1490
  // exactly how their parent renders, so, we can give them what we have so
1681
1491
  // far.
1682
- let _lpos
1492
+ var _lpos;
1683
1493
  if (get) {
1684
- _lpos = this.lpos
1685
- this.lpos = { xi: xi, xl: xl, yi: yi, yl: yl }
1494
+ _lpos = this.lpos;
1495
+ this.lpos = { xi: xi, xl: xl, yi: yi, yl: yl };
1686
1496
  //this.shrink = false;
1687
1497
  }
1688
1498
 
1689
1499
  for (i = 0; i < this.children.length; i++) {
1690
- el = this.children[i]
1500
+ el = this.children[i];
1691
1501
 
1692
- ret = el._getCoords(get)
1502
+ ret = el._getCoords(get);
1693
1503
 
1694
1504
  // Or just (seemed to work, but probably not good):
1695
1505
  // ret = el.lpos || this.lpos;
1696
1506
 
1697
- if (!ret) {
1698
- continue
1699
- }
1507
+ if (!ret) continue;
1700
1508
 
1701
1509
  // Since the parent element is shrunk, and the child elements think it's
1702
1510
  // going to take up as much space as possible, an element anchored to the
@@ -1705,216 +1513,202 @@ Element.prototype._getShrinkBox = function (xi, xl, yi, yl, get) {
1705
1513
  // element.
1706
1514
  // if (get) {
1707
1515
  if (el.position.left == null && el.position.right != null) {
1708
- ret.xl = xi + (ret.xl - ret.xi)
1709
- ret.xi = xi
1516
+ ret.xl = xi + (ret.xl - ret.xi);
1517
+ ret.xi = xi;
1710
1518
  if (this.screen.autoPadding) {
1711
1519
  // Maybe just do this no matter what.
1712
- ret.xl += this.ileft
1713
- ret.xi += this.ileft
1520
+ ret.xl += this.ileft;
1521
+ ret.xi += this.ileft;
1714
1522
  }
1715
1523
  }
1716
1524
  if (el.position.top == null && el.position.bottom != null) {
1717
- ret.yl = yi + (ret.yl - ret.yi)
1718
- ret.yi = yi
1525
+ ret.yl = yi + (ret.yl - ret.yi);
1526
+ ret.yi = yi;
1719
1527
  if (this.screen.autoPadding) {
1720
1528
  // Maybe just do this no matter what.
1721
- ret.yl += this.itop
1722
- ret.yi += this.itop
1529
+ ret.yl += this.itop;
1530
+ ret.yi += this.itop;
1723
1531
  }
1724
1532
  }
1725
1533
 
1726
- if (ret.xi < mxi) {
1727
- mxi = ret.xi
1728
- }
1729
- if (ret.xl > mxl) {
1730
- mxl = ret.xl
1731
- }
1732
- if (ret.yi < myi) {
1733
- myi = ret.yi
1734
- }
1735
- if (ret.yl > myl) {
1736
- myl = ret.yl
1737
- }
1534
+ if (ret.xi < mxi) mxi = ret.xi;
1535
+ if (ret.xl > mxl) mxl = ret.xl;
1536
+ if (ret.yi < myi) myi = ret.yi;
1537
+ if (ret.yl > myl) myl = ret.yl;
1738
1538
  }
1739
1539
 
1740
1540
  if (get) {
1741
- this.lpos = _lpos
1541
+ this.lpos = _lpos;
1742
1542
  //this.shrink = true;
1743
1543
  }
1744
1544
 
1745
- if (
1746
- this.position.width == null &&
1747
- (this.position.left == null || this.position.right == null)
1748
- ) {
1545
+ if (this.position.width == null
1546
+ && (this.position.left == null
1547
+ || this.position.right == null)) {
1749
1548
  if (this.position.left == null && this.position.right != null) {
1750
- xi = xl - (mxl - mxi)
1549
+ xi = xl - (mxl - mxi);
1751
1550
  if (!this.screen.autoPadding) {
1752
- xi -= this.padding.left + this.padding.right
1551
+ xi -= this.padding.left + this.padding.right;
1753
1552
  } else {
1754
- xi -= this.ileft
1553
+ xi -= this.ileft;
1755
1554
  }
1756
1555
  } else {
1757
- xl = mxl
1556
+ xl = mxl;
1758
1557
  if (!this.screen.autoPadding) {
1759
- xl += this.padding.left + this.padding.right
1558
+ xl += this.padding.left + this.padding.right;
1760
1559
  // XXX Temporary workaround until we decide to make autoPadding default.
1761
1560
  // See widget-listtable.js for an example of why this is necessary.
1762
1561
  // XXX Maybe just to this for all this being that this would affect
1763
1562
  // width shrunken normal shrunken lists as well.
1764
1563
  // if (this._isList) {
1765
1564
  if (this.type === 'list-table') {
1766
- xl -= this.padding.left + this.padding.right
1767
- xl += this.iright
1565
+ xl -= this.padding.left + this.padding.right;
1566
+ xl += this.iright;
1768
1567
  }
1769
1568
  } else {
1770
1569
  //xl += this.padding.right;
1771
- xl += this.iright
1570
+ xl += this.iright;
1772
1571
  }
1773
1572
  }
1774
1573
  }
1775
1574
 
1776
- if (
1777
- this.position.height == null &&
1778
- (this.position.top == null || this.position.bottom == null) &&
1779
- (!this.scrollable || this._isList)
1780
- ) {
1575
+ if (this.position.height == null
1576
+ && (this.position.top == null
1577
+ || this.position.bottom == null)
1578
+ && (!this.scrollable || this._isList)) {
1781
1579
  // NOTE: Lists get special treatment if they are shrunken - assume they
1782
1580
  // want all list items showing. This is one case we can calculate the
1783
1581
  // height based on items/boxes.
1784
1582
  if (this._isList) {
1785
- myi = 0 - this.itop
1786
- myl = this.items.length + this.ibottom
1583
+ myi = 0 - this.itop;
1584
+ myl = this.items.length + this.ibottom;
1787
1585
  }
1788
1586
  if (this.position.top == null && this.position.bottom != null) {
1789
- yi = yl - (myl - myi)
1587
+ yi = yl - (myl - myi);
1790
1588
  if (!this.screen.autoPadding) {
1791
- yi -= this.padding.top + this.padding.bottom
1589
+ yi -= this.padding.top + this.padding.bottom;
1792
1590
  } else {
1793
- yi -= this.itop
1591
+ yi -= this.itop;
1794
1592
  }
1795
1593
  } else {
1796
- yl = myl
1594
+ yl = myl;
1797
1595
  if (!this.screen.autoPadding) {
1798
- yl += this.padding.top + this.padding.bottom
1596
+ yl += this.padding.top + this.padding.bottom;
1799
1597
  } else {
1800
- yl += this.ibottom
1598
+ yl += this.ibottom;
1801
1599
  }
1802
1600
  }
1803
1601
  }
1804
1602
 
1805
- return { xi: xi, xl: xl, yi: yi, yl: yl }
1806
- }
1603
+ return { xi: xi, xl: xl, yi: yi, yl: yl };
1604
+ };
1807
1605
 
1808
- Element.prototype._getShrinkContent = function (xi, xl, yi, yl) {
1809
- const h = this._clines.length,
1810
- w = this._clines.mwidth || 1
1606
+ Element.prototype._getShrinkContent = function(xi, xl, yi, yl) {
1607
+ var h = this._clines.length
1608
+ , w = this._clines.mwidth || 1;
1811
1609
 
1812
- if (
1813
- this.position.width == null &&
1814
- (this.position.left == null || this.position.right == null)
1815
- ) {
1610
+ if (this.position.width == null
1611
+ && (this.position.left == null
1612
+ || this.position.right == null)) {
1816
1613
  if (this.position.left == null && this.position.right != null) {
1817
- xi = xl - w - this.iwidth
1614
+ xi = xl - w - this.iwidth;
1818
1615
  } else {
1819
- xl = xi + w + this.iwidth
1616
+ xl = xi + w + this.iwidth;
1820
1617
  }
1821
1618
  }
1822
1619
 
1823
- if (
1824
- this.position.height == null &&
1825
- (this.position.top == null || this.position.bottom == null) &&
1826
- (!this.scrollable || this._isList)
1827
- ) {
1620
+ if (this.position.height == null
1621
+ && (this.position.top == null
1622
+ || this.position.bottom == null)
1623
+ && (!this.scrollable || this._isList)) {
1828
1624
  if (this.position.top == null && this.position.bottom != null) {
1829
- yi = yl - h - this.iheight
1625
+ yi = yl - h - this.iheight;
1830
1626
  } else {
1831
- yl = yi + h + this.iheight
1627
+ yl = yi + h + this.iheight;
1832
1628
  }
1833
1629
  }
1834
1630
 
1835
- return { xi: xi, xl: xl, yi: yi, yl: yl }
1836
- }
1631
+ return { xi: xi, xl: xl, yi: yi, yl: yl };
1632
+ };
1837
1633
 
1838
- Element.prototype._getShrink = function (xi, xl, yi, yl, get) {
1839
- let shrinkBox = this._getShrinkBox(xi, xl, yi, yl, get),
1840
- shrinkContent = this._getShrinkContent(xi, xl, yi, yl, get),
1841
- xll = xl,
1842
- yll = yl
1634
+ Element.prototype._getShrink = function(xi, xl, yi, yl, get) {
1635
+ var shrinkBox = this._getShrinkBox(xi, xl, yi, yl, get)
1636
+ , shrinkContent = this._getShrinkContent(xi, xl, yi, yl, get)
1637
+ , xll = xl
1638
+ , yll = yl;
1843
1639
 
1844
1640
  // Figure out which one is bigger and use it.
1845
1641
  if (shrinkBox.xl - shrinkBox.xi > shrinkContent.xl - shrinkContent.xi) {
1846
- xi = shrinkBox.xi
1847
- xl = shrinkBox.xl
1642
+ xi = shrinkBox.xi;
1643
+ xl = shrinkBox.xl;
1848
1644
  } else {
1849
- xi = shrinkContent.xi
1850
- xl = shrinkContent.xl
1645
+ xi = shrinkContent.xi;
1646
+ xl = shrinkContent.xl;
1851
1647
  }
1852
1648
 
1853
1649
  if (shrinkBox.yl - shrinkBox.yi > shrinkContent.yl - shrinkContent.yi) {
1854
- yi = shrinkBox.yi
1855
- yl = shrinkBox.yl
1650
+ yi = shrinkBox.yi;
1651
+ yl = shrinkBox.yl;
1856
1652
  } else {
1857
- yi = shrinkContent.yi
1858
- yl = shrinkContent.yl
1653
+ yi = shrinkContent.yi;
1654
+ yl = shrinkContent.yl;
1859
1655
  }
1860
1656
 
1861
1657
  // Recenter shrunken elements.
1862
1658
  if (xl < xll && this.position.left === 'center') {
1863
- xll = ((xll - xl) / 2) | 0
1864
- xi += xll
1865
- xl += xll
1659
+ xll = (xll - xl) / 2 | 0;
1660
+ xi += xll;
1661
+ xl += xll;
1866
1662
  }
1867
1663
 
1868
1664
  if (yl < yll && this.position.top === 'center') {
1869
- yll = ((yll - yl) / 2) | 0
1870
- yi += yll
1871
- yl += yll
1665
+ yll = (yll - yl) / 2 | 0;
1666
+ yi += yll;
1667
+ yl += yll;
1872
1668
  }
1873
1669
 
1874
- return { xi: xi, xl: xl, yi: yi, yl: yl }
1875
- }
1670
+ return { xi: xi, xl: xl, yi: yi, yl: yl };
1671
+ };
1876
1672
 
1877
- Element.prototype._getCoords = function (get, noscroll) {
1878
- if (this.hidden) {
1879
- return
1880
- }
1673
+ Element.prototype._getCoords = function(get, noscroll) {
1674
+ if (this.hidden) return;
1881
1675
 
1882
1676
  // if (this.parent._rendering) {
1883
1677
  // get = true;
1884
1678
  // }
1885
1679
 
1886
- let xi = this._getLeft(get),
1887
- xl = xi + this._getWidth(get),
1888
- yi = this._getTop(get),
1889
- yl = yi + this._getHeight(get),
1890
- base = this.childBase || 0,
1891
- el = this,
1892
- fixed = this.fixed,
1893
- coords,
1894
- v,
1895
- noleft,
1896
- noright,
1897
- notop,
1898
- nobot,
1899
- ppos,
1900
- b
1680
+ var xi = this._getLeft(get)
1681
+ , xl = xi + this._getWidth(get)
1682
+ , yi = this._getTop(get)
1683
+ , yl = yi + this._getHeight(get)
1684
+ , base = this.childBase || 0
1685
+ , el = this
1686
+ , fixed = this.fixed
1687
+ , coords
1688
+ , v
1689
+ , noleft
1690
+ , noright
1691
+ , notop
1692
+ , nobot
1693
+ , ppos
1694
+ , b;
1901
1695
 
1902
1696
  // Attempt to shrink the element base on the
1903
1697
  // size of the content and child elements.
1904
1698
  if (this.shrink) {
1905
- coords = this._getShrink(xi, xl, yi, yl, get)
1906
- ;(xi = coords.xi), (xl = coords.xl)
1907
- ;(yi = coords.yi), (yl = coords.yl)
1699
+ coords = this._getShrink(xi, xl, yi, yl, get);
1700
+ xi = coords.xi, xl = coords.xl;
1701
+ yi = coords.yi, yl = coords.yl;
1908
1702
  }
1909
1703
 
1910
1704
  // Find a scrollable ancestor if we have one.
1911
- while ((el = el.parent)) {
1705
+ while (el = el.parent) {
1912
1706
  if (el.scrollable) {
1913
1707
  if (fixed) {
1914
- fixed = false
1915
- continue
1708
+ fixed = false;
1709
+ continue;
1916
1710
  }
1917
- break
1711
+ break;
1918
1712
  }
1919
1713
  }
1920
1714
 
@@ -1928,9 +1722,9 @@ Element.prototype._getCoords = function (get, noscroll) {
1928
1722
  // See: $ node test/widget-shrink-fail.js
1929
1723
  // var thisparent = this.parent;
1930
1724
 
1931
- const thisparent = el
1725
+ var thisparent = el;
1932
1726
  if (el && !noscroll) {
1933
- ppos = thisparent.lpos
1727
+ ppos = thisparent.lpos;
1934
1728
 
1935
1729
  // The shrink option can cause a stack overflow
1936
1730
  // by calling _getCoords on the child again.
@@ -1938,17 +1732,15 @@ Element.prototype._getCoords = function (get, noscroll) {
1938
1732
  // ppos = thisparent._getCoords();
1939
1733
  // }
1940
1734
 
1941
- if (!ppos) {
1942
- return
1943
- }
1735
+ if (!ppos) return;
1944
1736
 
1945
1737
  // TODO: Figure out how to fix base (and cbase to only
1946
1738
  // take into account the *parent's* padding.
1947
1739
 
1948
- yi -= ppos.base
1949
- yl -= ppos.base
1740
+ yi -= ppos.base;
1741
+ yl -= ppos.base;
1950
1742
 
1951
- b = thisparent.border ? 1 : 0
1743
+ b = thisparent.border ? 1 : 0;
1952
1744
 
1953
1745
  // XXX
1954
1746
  // Fixes non-`fixed` labels to work with scrolling (they're ON the border):
@@ -1957,90 +1749,70 @@ Element.prototype._getCoords = function (get, noscroll) {
1957
1749
  // || this.position.top < 0
1958
1750
  // || this.position.bottom < 0) {
1959
1751
  if (this._isLabel) {
1960
- b = 0
1752
+ b = 0;
1961
1753
  }
1962
1754
 
1963
1755
  if (yi < ppos.yi + b) {
1964
1756
  if (yl - 1 < ppos.yi + b) {
1965
1757
  // Is above.
1966
- return
1758
+ return;
1967
1759
  } else {
1968
1760
  // Is partially covered above.
1969
- notop = true
1970
- v = ppos.yi - yi
1971
- if (this.border) {
1972
- v--
1973
- }
1974
- if (thisparent.border) {
1975
- v++
1976
- }
1977
- base += v
1978
- yi += v
1761
+ notop = true;
1762
+ v = ppos.yi - yi;
1763
+ if (this.border) v--;
1764
+ if (thisparent.border) v++;
1765
+ base += v;
1766
+ yi += v;
1979
1767
  }
1980
1768
  } else if (yl > ppos.yl - b) {
1981
1769
  if (yi > ppos.yl - 1 - b) {
1982
1770
  // Is below.
1983
- return
1771
+ return;
1984
1772
  } else {
1985
1773
  // Is partially covered below.
1986
- nobot = true
1987
- v = yl - ppos.yl
1988
- if (this.border) {
1989
- v--
1990
- }
1991
- if (thisparent.border) {
1992
- v++
1993
- }
1994
- yl -= v
1774
+ nobot = true;
1775
+ v = yl - ppos.yl;
1776
+ if (this.border) v--;
1777
+ if (thisparent.border) v++;
1778
+ yl -= v;
1995
1779
  }
1996
1780
  }
1997
1781
 
1998
1782
  // Shouldn't be necessary.
1999
1783
  // assert.ok(yi < yl);
2000
- if (yi >= yl) {
2001
- return
2002
- }
1784
+ if (yi >= yl) return;
2003
1785
 
2004
1786
  // Could allow overlapping stuff in scrolling elements
2005
1787
  // if we cleared the pending buffer before every draw.
2006
1788
  if (xi < el.lpos.xi) {
2007
- xi = el.lpos.xi
2008
- noleft = true
2009
- if (this.border) {
2010
- xi--
2011
- }
2012
- if (thisparent.border) {
2013
- xi++
2014
- }
1789
+ xi = el.lpos.xi;
1790
+ noleft = true;
1791
+ if (this.border) xi--;
1792
+ if (thisparent.border) xi++;
2015
1793
  }
2016
1794
  if (xl > el.lpos.xl) {
2017
- xl = el.lpos.xl
2018
- noright = true
2019
- if (this.border) {
2020
- xl++
2021
- }
2022
- if (thisparent.border) {
2023
- xl--
2024
- }
1795
+ xl = el.lpos.xl;
1796
+ noright = true;
1797
+ if (this.border) xl++;
1798
+ if (thisparent.border) xl--;
2025
1799
  }
2026
1800
  //if (xi > xl) return;
2027
- if (xi >= xl) {
2028
- return
2029
- }
1801
+ if (xi >= xl) return;
2030
1802
  }
2031
1803
 
2032
1804
  if (this.noOverflow && this.parent.lpos) {
2033
1805
  if (xi < this.parent.lpos.xi + this.parent.ileft) {
2034
- xi = this.parent.lpos.xi + this.parent.ileft
1806
+ xi = this.parent.lpos.xi + this.parent.ileft;
2035
1807
  }
2036
1808
  if (xl > this.parent.lpos.xl - this.parent.iright) {
2037
- xl = this.parent.lpos.xl - this.parent.iright
1809
+ xl = this.parent.lpos.xl - this.parent.iright;
2038
1810
  }
2039
1811
  if (yi < this.parent.lpos.yi + this.parent.itop) {
2040
- yi = this.parent.lpos.yi + this.parent.itop
1812
+ yi = this.parent.lpos.yi + this.parent.itop;
2041
1813
  }
2042
1814
  if (yl > this.parent.lpos.yl - this.parent.ibottom) {
2043
- yl = this.parent.lpos.yl - this.parent.ibottom
1815
+ yl = this.parent.lpos.yl - this.parent.ibottom;
2044
1816
  }
2045
1817
  }
2046
1818
 
@@ -2060,48 +1832,48 @@ Element.prototype._getCoords = function (get, noscroll) {
2060
1832
  notop: notop,
2061
1833
  nobot: nobot,
2062
1834
  renders: this.screen.renders
2063
- }
2064
- }
1835
+ };
1836
+ };
2065
1837
 
2066
- Element.prototype.render = function () {
2067
- this._emit('prerender')
1838
+ Element.prototype.render = function() {
1839
+ this._emit('prerender');
2068
1840
 
2069
- this.parseContent()
1841
+ this.parseContent();
2070
1842
 
2071
- const coords = this._getCoords(true)
1843
+ var coords = this._getCoords(true);
2072
1844
  if (!coords) {
2073
- delete this.lpos
2074
- return
1845
+ delete this.lpos;
1846
+ return;
2075
1847
  }
2076
1848
 
2077
1849
  if (coords.xl - coords.xi <= 0) {
2078
- coords.xl = Math.max(coords.xl, coords.xi)
2079
- return
1850
+ coords.xl = Math.max(coords.xl, coords.xi);
1851
+ return;
2080
1852
  }
2081
1853
 
2082
1854
  if (coords.yl - coords.yi <= 0) {
2083
- coords.yl = Math.max(coords.yl, coords.yi)
2084
- return
2085
- }
2086
-
2087
- let lines = this.screen.lines,
2088
- xi = coords.xi,
2089
- xl = coords.xl,
2090
- yi = coords.yi,
2091
- yl = coords.yl,
2092
- x,
2093
- y,
2094
- cell,
2095
- attr,
2096
- ch,
2097
- content = this._pcontent,
2098
- ci = this._clines.ci[coords.base],
2099
- battr,
2100
- dattr,
2101
- c,
2102
- visible,
2103
- i,
2104
- bch = this.ch
1855
+ coords.yl = Math.max(coords.yl, coords.yi);
1856
+ return;
1857
+ }
1858
+
1859
+ var lines = this.screen.lines
1860
+ , xi = coords.xi
1861
+ , xl = coords.xl
1862
+ , yi = coords.yi
1863
+ , yl = coords.yl
1864
+ , x
1865
+ , y
1866
+ , cell
1867
+ , attr
1868
+ , ch
1869
+ , content = this._pcontent
1870
+ , ci = this._clines.ci[coords.base]
1871
+ , battr
1872
+ , dattr
1873
+ , c
1874
+ , visible
1875
+ , i
1876
+ , bch = this.ch;
2105
1877
 
2106
1878
  // Clip content if it's off the edge of the screen
2107
1879
  // if (xi + this.ileft < 0 || yi + this.itop < 0) {
@@ -2129,14 +1901,14 @@ Element.prototype.render = function () {
2129
1901
  // }
2130
1902
 
2131
1903
  if (coords.base >= this._clines.ci.length) {
2132
- ci = this._pcontent.length
1904
+ ci = this._pcontent.length;
2133
1905
  }
2134
1906
 
2135
- this.lpos = coords
1907
+ this.lpos = coords;
2136
1908
 
2137
1909
  if (this.border && this.border.type === 'line') {
2138
- this.screen._borderStops[coords.yi] = true
2139
- this.screen._borderStops[coords.yl - 1] = true
1910
+ this.screen._borderStops[coords.yi] = true;
1911
+ this.screen._borderStops[coords.yl - 1] = true;
2140
1912
  // if (!this.screen._borderStops[coords.yi]) {
2141
1913
  // this.screen._borderStops[coords.yi] = { xi: coords.xi, xl: coords.xl };
2142
1914
  // } else {
@@ -2150,18 +1922,16 @@ Element.prototype.render = function () {
2150
1922
  // this.screen._borderStops[coords.yl - 1] = this.screen._borderStops[coords.yi];
2151
1923
  }
2152
1924
 
2153
- dattr = this.sattr(this.style)
2154
- attr = dattr
1925
+ dattr = this.sattr(this.style);
1926
+ attr = dattr;
2155
1927
 
2156
1928
  // If we're in a scrollable text box, check to
2157
1929
  // see which attributes this line starts with.
2158
1930
  if (ci > 0) {
2159
- attr = this._clines.attr[Math.min(coords.base, this._clines.length - 1)]
1931
+ attr = this._clines.attr[Math.min(coords.base, this._clines.length - 1)];
2160
1932
  }
2161
1933
 
2162
- if (this.border) {
2163
- xi++, xl--, yi++, yl--
2164
- }
1934
+ if (this.border) xi++, xl--, yi++, yl--;
2165
1935
 
2166
1936
  // If we have padding/valign, that means the
2167
1937
  // content-drawing loop will skip a few cells/lines.
@@ -2170,39 +1940,35 @@ Element.prototype.render = function () {
2170
1940
  if (this.tpadding || (this.valign && this.valign !== 'top')) {
2171
1941
  if (this.style.transparent) {
2172
1942
  for (y = Math.max(yi, 0); y < yl; y++) {
2173
- if (!lines[y]) {
2174
- break
2175
- }
1943
+ if (!lines[y]) break;
2176
1944
  for (x = Math.max(xi, 0); x < xl; x++) {
2177
- if (!lines[y][x]) {
2178
- break
2179
- }
2180
- lines[y][x][0] = colors.blend(attr, lines[y][x][0])
1945
+ if (!lines[y][x]) break;
1946
+ lines[y][x][0] = colors.blend(attr, lines[y][x][0]);
2181
1947
  // lines[y][x][1] = bch;
2182
- lines[y].dirty = true
1948
+ lines[y].dirty = true;
2183
1949
  }
2184
1950
  }
2185
1951
  } else {
2186
- this.screen.fillRegion(dattr, bch, xi, xl, yi, yl)
1952
+ this.screen.fillRegion(dattr, bch, xi, xl, yi, yl);
2187
1953
  }
2188
1954
  }
2189
1955
 
2190
1956
  if (this.tpadding) {
2191
- ;(xi += this.padding.left), (xl -= this.padding.right)
2192
- ;(yi += this.padding.top), (yl -= this.padding.bottom)
1957
+ xi += this.padding.left, xl -= this.padding.right;
1958
+ yi += this.padding.top, yl -= this.padding.bottom;
2193
1959
  }
2194
1960
 
2195
1961
  // Determine where to place the text if it's vertically aligned.
2196
1962
  if (this.valign === 'middle' || this.valign === 'bottom') {
2197
- visible = yl - yi
1963
+ visible = yl - yi;
2198
1964
  if (this._clines.length < visible) {
2199
1965
  if (this.valign === 'middle') {
2200
- visible = (visible / 2) | 0
2201
- visible -= (this._clines.length / 2) | 0
1966
+ visible = visible / 2 | 0;
1967
+ visible -= this._clines.length / 2 | 0;
2202
1968
  } else if (this.valign === 'bottom') {
2203
- visible -= this._clines.length
1969
+ visible -= this._clines.length;
2204
1970
  }
2205
- ci -= visible * (xl - xi)
1971
+ ci -= visible * (xl - xi);
2206
1972
  }
2207
1973
  }
2208
1974
 
@@ -2210,22 +1976,22 @@ Element.prototype.render = function () {
2210
1976
  for (y = yi; y < yl; y++) {
2211
1977
  if (!lines[y]) {
2212
1978
  if (y >= this.screen.height || yl < this.ibottom) {
2213
- break
1979
+ break;
2214
1980
  } else {
2215
- continue
1981
+ continue;
2216
1982
  }
2217
1983
  }
2218
1984
  for (x = xi; x < xl; x++) {
2219
- cell = lines[y][x]
1985
+ cell = lines[y][x];
2220
1986
  if (!cell) {
2221
1987
  if (x >= this.screen.width || xl < this.iright) {
2222
- break
1988
+ break;
2223
1989
  } else {
2224
- continue
1990
+ continue;
2225
1991
  }
2226
1992
  }
2227
1993
 
2228
- ch = content[ci++] || bch
1994
+ ch = content[ci++] || bch;
2229
1995
 
2230
1996
  // if (!content[ci] && !coords._contentEnd) {
2231
1997
  // coords._contentEnd = { x: x - xi, y: y - yi };
@@ -2233,102 +1999,89 @@ Element.prototype.render = function () {
2233
1999
 
2234
2000
  // Handle escape codes.
2235
2001
  while (ch === '\x1b') {
2236
- if ((c = /^\x1b\[[\d;]*m/.exec(content.substring(ci - 1)))) {
2237
- ci += c[0].length - 1
2238
- attr = this.screen.attrCode(c[0], attr, dattr)
2002
+ if (c = /^\x1b\[[\d;]*m/.exec(content.substring(ci - 1))) {
2003
+ ci += c[0].length - 1;
2004
+ attr = this.screen.attrCode(c[0], attr, dattr);
2239
2005
  // Ignore foreground changes for selected items.
2240
- if (
2241
- this.parent._isList &&
2242
- this.parent.interactive &&
2243
- this.parent.items[this.parent.selected] === this &&
2244
- this.parent.options.invertSelected !== false
2245
- ) {
2246
- attr = (attr & ~(0x1ff << 9)) | (dattr & (0x1ff << 9))
2006
+ if (this.parent._isList && this.parent.interactive
2007
+ && this.parent.items[this.parent.selected] === this
2008
+ && this.parent.options.invertSelected !== false) {
2009
+ attr = (attr & ~(0x1ff << 9)) | (dattr & (0x1ff << 9));
2247
2010
  }
2248
- ch = content[ci] || bch
2249
- ci++
2011
+ ch = content[ci] || bch;
2012
+ ci++;
2250
2013
  } else {
2251
- break
2014
+ break;
2252
2015
  }
2253
2016
  }
2254
2017
 
2255
2018
  // Handle newlines.
2256
- if (ch === '\t') {
2257
- ch = bch
2258
- }
2019
+ if (ch === '\t') ch = bch;
2259
2020
  if (ch === '\n') {
2260
2021
  // If we're on the first cell and we find a newline and the last cell
2261
2022
  // of the last line was not a newline, let's just treat this like the
2262
2023
  // newline was already "counted".
2263
2024
  if (x === xi && y !== yi && content[ci - 2] !== '\n') {
2264
- x--
2265
- continue
2025
+ x--;
2026
+ continue;
2266
2027
  }
2267
2028
  // We could use fillRegion here, name the
2268
2029
  // outer loop, and continue to it instead.
2269
- ch = bch
2030
+ ch = bch;
2270
2031
  for (; x < xl; x++) {
2271
- cell = lines[y][x]
2272
- if (!cell) {
2273
- break
2274
- }
2032
+ cell = lines[y][x];
2033
+ if (!cell) break;
2275
2034
  if (this.style.transparent) {
2276
- lines[y][x][0] = colors.blend(attr, lines[y][x][0])
2277
- if (content[ci]) {
2278
- lines[y][x][1] = ch
2279
- }
2280
- lines[y].dirty = true
2035
+ lines[y][x][0] = colors.blend(attr, lines[y][x][0]);
2036
+ if (content[ci]) lines[y][x][1] = ch;
2037
+ lines[y].dirty = true;
2281
2038
  } else {
2282
2039
  if (attr !== cell[0] || ch !== cell[1]) {
2283
- lines[y][x][0] = attr
2284
- lines[y][x][1] = ch
2285
- lines[y].dirty = true
2040
+ lines[y][x][0] = attr;
2041
+ lines[y][x][1] = ch;
2042
+ lines[y].dirty = true;
2286
2043
  }
2287
2044
  }
2288
2045
  }
2289
- continue
2046
+ continue;
2290
2047
  }
2291
2048
 
2292
2049
  if (this.screen.fullUnicode && content[ci - 1]) {
2293
- const point = unicode.codePointAt(content, ci - 1)
2050
+ var point = unicode.codePointAt(content, ci - 1);
2294
2051
  // Handle combining chars:
2295
2052
  // Make sure they get in the same cell and are counted as 0.
2296
2053
  if (unicode.combining[point]) {
2297
2054
  if (point > 0x00ffff) {
2298
- ch = content[ci - 1] + content[ci]
2299
- ci++
2055
+ ch = content[ci - 1] + content[ci];
2056
+ ci++;
2300
2057
  }
2301
2058
  if (x - 1 >= xi) {
2302
- lines[y][x - 1][1] += ch
2059
+ lines[y][x - 1][1] += ch;
2303
2060
  } else if (y - 1 >= yi) {
2304
- lines[y - 1][xl - 1][1] += ch
2061
+ lines[y - 1][xl - 1][1] += ch;
2305
2062
  }
2306
- x--
2307
- continue
2063
+ x--;
2064
+ continue;
2308
2065
  }
2309
2066
  // Handle surrogate pairs:
2310
2067
  // Make sure we put surrogate pair chars in one cell.
2311
2068
  if (point > 0x00ffff) {
2312
- ch = content[ci - 1] + content[ci]
2313
- ci++
2069
+ ch = content[ci - 1] + content[ci];
2070
+ ci++;
2314
2071
  }
2315
2072
  }
2316
2073
 
2317
- if (this._noFill) {
2318
- continue
2319
- }
2074
+ if (this._noFill) continue;
2320
2075
 
2321
2076
  if (this.style.transparent) {
2322
- lines[y][x][0] = colors.blend(attr, lines[y][x][0])
2323
- if (content[ci]) {
2324
- lines[y][x][1] = ch
2325
- }
2326
- lines[y].dirty = true
2077
+ lines[y][x][0] = colors.blend(attr, lines[y][x][0]);
2078
+ if (content[ci]) lines[y][x][1] = ch;
2079
+ lines[y].dirty = true;
2327
2080
  } else {
2328
2081
  if (attr !== cell[0] || ch !== cell[1]) {
2329
- lines[y][x][0] = attr
2330
- lines[y][x][1] = ch
2331
- lines[y].dirty = true
2082
+ lines[y][x][0] = attr;
2083
+ lines[y][x][1] = ch;
2084
+ lines[y].dirty = true;
2332
2085
  }
2333
2086
  }
2334
2087
  }
@@ -2339,535 +2092,481 @@ Element.prototype.render = function () {
2339
2092
  if (this.scrollbar) {
2340
2093
  // XXX
2341
2094
  // i = this.getScrollHeight();
2342
- i = Math.max(this._clines.length, this._scrollBottom())
2095
+ i = Math.max(this._clines.length, this._scrollBottom());
2343
2096
  }
2344
- if (coords.notop || coords.nobot) {
2345
- i = -Infinity
2346
- }
2347
- if (this.scrollbar && yl - yi < i) {
2348
- x = xl - 1
2349
- if (this.scrollbar.ignoreBorder && this.border) {
2350
- x++
2351
- }
2097
+ if (coords.notop || coords.nobot) i = -Infinity;
2098
+ if (this.scrollbar && (yl - yi) < i) {
2099
+ x = xl - 1;
2100
+ if (this.scrollbar.ignoreBorder && this.border) x++;
2352
2101
  if (this.alwaysScroll) {
2353
- y = this.childBase / (i - (yl - yi))
2102
+ y = this.childBase / (i - (yl - yi));
2354
2103
  } else {
2355
- y = (this.childBase + this.childOffset) / (i - 1)
2104
+ y = (this.childBase + this.childOffset) / (i - 1);
2356
2105
  }
2357
- y = yi + (((yl - yi) * y) | 0)
2358
- if (y >= yl) {
2359
- y = yl - 1
2360
- }
2361
- cell = lines[y] && lines[y][x]
2106
+ y = yi + ((yl - yi) * y | 0);
2107
+ if (y >= yl) y = yl - 1;
2108
+ cell = lines[y] && lines[y][x];
2362
2109
  if (cell) {
2363
2110
  if (this.track) {
2364
- ch = this.track.ch || ' '
2365
- attr = this.sattr(
2366
- this.style.track,
2111
+ ch = this.track.ch || ' ';
2112
+ attr = this.sattr(this.style.track,
2367
2113
  this.style.track.fg || this.style.fg,
2368
- this.style.track.bg || this.style.bg
2369
- )
2370
- this.screen.fillRegion(attr, ch, x, x + 1, yi, yl)
2114
+ this.style.track.bg || this.style.bg);
2115
+ this.screen.fillRegion(attr, ch, x, x + 1, yi, yl);
2371
2116
  }
2372
- ch = this.scrollbar.ch || ' '
2373
- attr = this.sattr(
2374
- this.style.scrollbar,
2117
+ ch = this.scrollbar.ch || ' ';
2118
+ attr = this.sattr(this.style.scrollbar,
2375
2119
  this.style.scrollbar.fg || this.style.fg,
2376
- this.style.scrollbar.bg || this.style.bg
2377
- )
2120
+ this.style.scrollbar.bg || this.style.bg);
2378
2121
  if (attr !== cell[0] || ch !== cell[1]) {
2379
- lines[y][x][0] = attr
2380
- lines[y][x][1] = ch
2381
- lines[y].dirty = true
2122
+ lines[y][x][0] = attr;
2123
+ lines[y][x][1] = ch;
2124
+ lines[y].dirty = true;
2382
2125
  }
2383
2126
  }
2384
2127
  }
2385
2128
 
2386
- if (this.border) {
2387
- xi--, xl++, yi--, yl++
2388
- }
2129
+ if (this.border) xi--, xl++, yi--, yl++;
2389
2130
 
2390
2131
  if (this.tpadding) {
2391
- ;(xi -= this.padding.left), (xl += this.padding.right)
2392
- ;(yi -= this.padding.top), (yl += this.padding.bottom)
2132
+ xi -= this.padding.left, xl += this.padding.right;
2133
+ yi -= this.padding.top, yl += this.padding.bottom;
2393
2134
  }
2394
2135
 
2395
2136
  // Draw the border.
2396
2137
  if (this.border) {
2397
- battr = this.sattr(this.style.border)
2398
- y = yi
2399
- if (coords.notop) {
2400
- y = -1
2401
- }
2138
+ battr = this.sattr(this.style.border);
2139
+ y = yi;
2140
+ if (coords.notop) y = -1;
2402
2141
  for (x = xi; x < xl; x++) {
2403
- if (!lines[y]) {
2404
- break
2405
- }
2406
- if (coords.noleft && x === xi) {
2407
- continue
2408
- }
2409
- if (coords.noright && x === xl - 1) {
2410
- continue
2411
- }
2412
- cell = lines[y][x]
2413
- if (!cell) {
2414
- continue
2415
- }
2142
+ if (!lines[y]) break;
2143
+ if (coords.noleft && x === xi) continue;
2144
+ if (coords.noright && x === xl - 1) continue;
2145
+ cell = lines[y][x];
2146
+ if (!cell) continue;
2416
2147
  if (this.border.type === 'line') {
2417
2148
  if (x === xi) {
2418
- ch = '\u250c' // '┌'
2149
+ ch = '\u250c'; // '┌'
2419
2150
  if (!this.border.left) {
2420
2151
  if (this.border.top) {
2421
- ch = '\u2500' // '─'
2152
+ ch = '\u2500'; // '─'
2422
2153
  } else {
2423
- continue
2154
+ continue;
2424
2155
  }
2425
2156
  } else {
2426
2157
  if (!this.border.top) {
2427
- ch = '\u2502' // '│'
2158
+ ch = '\u2502'; // '│'
2428
2159
  }
2429
2160
  }
2430
2161
  } else if (x === xl - 1) {
2431
- ch = '\u2510' // '┐'
2162
+ ch = '\u2510'; // '┐'
2432
2163
  if (!this.border.right) {
2433
2164
  if (this.border.top) {
2434
- ch = '\u2500' // '─'
2165
+ ch = '\u2500'; // '─'
2435
2166
  } else {
2436
- continue
2167
+ continue;
2437
2168
  }
2438
2169
  } else {
2439
2170
  if (!this.border.top) {
2440
- ch = '\u2502' // '│'
2171
+ ch = '\u2502'; // '│'
2441
2172
  }
2442
2173
  }
2443
2174
  } else {
2444
- ch = '\u2500' // '─'
2175
+ ch = '\u2500'; // '─'
2445
2176
  }
2446
2177
  } else if (this.border.type === 'bg') {
2447
- ch = this.border.ch
2178
+ ch = this.border.ch;
2448
2179
  }
2449
2180
  if (!this.border.top && x !== xi && x !== xl - 1) {
2450
- ch = ' '
2181
+ ch = ' ';
2451
2182
  if (dattr !== cell[0] || ch !== cell[1]) {
2452
- lines[y][x][0] = dattr
2453
- lines[y][x][1] = ch
2454
- lines[y].dirty = true
2455
- continue
2183
+ lines[y][x][0] = dattr;
2184
+ lines[y][x][1] = ch;
2185
+ lines[y].dirty = true;
2186
+ continue;
2456
2187
  }
2457
2188
  }
2458
2189
  if (battr !== cell[0] || ch !== cell[1]) {
2459
- lines[y][x][0] = battr
2460
- lines[y][x][1] = ch
2461
- lines[y].dirty = true
2190
+ lines[y][x][0] = battr;
2191
+ lines[y][x][1] = ch;
2192
+ lines[y].dirty = true;
2462
2193
  }
2463
2194
  }
2464
- y = yi + 1
2195
+ y = yi + 1;
2465
2196
  for (; y < yl - 1; y++) {
2466
- if (!lines[y]) {
2467
- continue
2468
- }
2469
- cell = lines[y][xi]
2197
+ if (!lines[y]) continue;
2198
+ cell = lines[y][xi];
2470
2199
  if (cell) {
2471
2200
  if (this.border.left) {
2472
2201
  if (this.border.type === 'line') {
2473
- ch = '\u2502' // '│'
2202
+ ch = '\u2502'; // '│'
2474
2203
  } else if (this.border.type === 'bg') {
2475
- ch = this.border.ch
2204
+ ch = this.border.ch;
2476
2205
  }
2477
- if (!coords.noleft) {
2478
- if (battr !== cell[0] || ch !== cell[1]) {
2479
- lines[y][xi][0] = battr
2480
- lines[y][xi][1] = ch
2481
- lines[y].dirty = true
2482
- }
2206
+ if (!coords.noleft)
2207
+ if (battr !== cell[0] || ch !== cell[1]) {
2208
+ lines[y][xi][0] = battr;
2209
+ lines[y][xi][1] = ch;
2210
+ lines[y].dirty = true;
2483
2211
  }
2484
2212
  } else {
2485
- ch = ' '
2213
+ ch = ' ';
2486
2214
  if (dattr !== cell[0] || ch !== cell[1]) {
2487
- lines[y][xi][0] = dattr
2488
- lines[y][xi][1] = ch
2489
- lines[y].dirty = true
2215
+ lines[y][xi][0] = dattr;
2216
+ lines[y][xi][1] = ch;
2217
+ lines[y].dirty = true;
2490
2218
  }
2491
2219
  }
2492
2220
  }
2493
- cell = lines[y][xl - 1]
2221
+ cell = lines[y][xl - 1];
2494
2222
  if (cell) {
2495
2223
  if (this.border.right) {
2496
2224
  if (this.border.type === 'line') {
2497
- ch = '\u2502' // '│'
2225
+ ch = '\u2502'; // '│'
2498
2226
  } else if (this.border.type === 'bg') {
2499
- ch = this.border.ch
2227
+ ch = this.border.ch;
2500
2228
  }
2501
- if (!coords.noright) {
2502
- if (battr !== cell[0] || ch !== cell[1]) {
2503
- lines[y][xl - 1][0] = battr
2504
- lines[y][xl - 1][1] = ch
2505
- lines[y].dirty = true
2506
- }
2229
+ if (!coords.noright)
2230
+ if (battr !== cell[0] || ch !== cell[1]) {
2231
+ lines[y][xl - 1][0] = battr;
2232
+ lines[y][xl - 1][1] = ch;
2233
+ lines[y].dirty = true;
2507
2234
  }
2508
2235
  } else {
2509
- ch = ' '
2236
+ ch = ' ';
2510
2237
  if (dattr !== cell[0] || ch !== cell[1]) {
2511
- lines[y][xl - 1][0] = dattr
2512
- lines[y][xl - 1][1] = ch
2513
- lines[y].dirty = true
2238
+ lines[y][xl - 1][0] = dattr;
2239
+ lines[y][xl - 1][1] = ch;
2240
+ lines[y].dirty = true;
2514
2241
  }
2515
2242
  }
2516
2243
  }
2517
2244
  }
2518
- y = yl - 1
2519
- if (coords.nobot) {
2520
- y = -1
2521
- }
2245
+ y = yl - 1;
2246
+ if (coords.nobot) y = -1;
2522
2247
  for (x = xi; x < xl; x++) {
2523
- if (!lines[y]) {
2524
- break
2525
- }
2526
- if (coords.noleft && x === xi) {
2527
- continue
2528
- }
2529
- if (coords.noright && x === xl - 1) {
2530
- continue
2531
- }
2532
- cell = lines[y][x]
2533
- if (!cell) {
2534
- continue
2535
- }
2248
+ if (!lines[y]) break;
2249
+ if (coords.noleft && x === xi) continue;
2250
+ if (coords.noright && x === xl - 1) continue;
2251
+ cell = lines[y][x];
2252
+ if (!cell) continue;
2536
2253
  if (this.border.type === 'line') {
2537
2254
  if (x === xi) {
2538
- ch = '\u2514' // '└'
2255
+ ch = '\u2514'; // '└'
2539
2256
  if (!this.border.left) {
2540
2257
  if (this.border.bottom) {
2541
- ch = '\u2500' // '─'
2258
+ ch = '\u2500'; // '─'
2542
2259
  } else {
2543
- continue
2260
+ continue;
2544
2261
  }
2545
2262
  } else {
2546
2263
  if (!this.border.bottom) {
2547
- ch = '\u2502' // '│'
2264
+ ch = '\u2502'; // '│'
2548
2265
  }
2549
2266
  }
2550
2267
  } else if (x === xl - 1) {
2551
- ch = '\u2518' // '┘'
2268
+ ch = '\u2518'; // '┘'
2552
2269
  if (!this.border.right) {
2553
2270
  if (this.border.bottom) {
2554
- ch = '\u2500' // '─'
2271
+ ch = '\u2500'; // '─'
2555
2272
  } else {
2556
- continue
2273
+ continue;
2557
2274
  }
2558
2275
  } else {
2559
2276
  if (!this.border.bottom) {
2560
- ch = '\u2502' // '│'
2277
+ ch = '\u2502'; // '│'
2561
2278
  }
2562
2279
  }
2563
2280
  } else {
2564
- ch = '\u2500' // '─'
2281
+ ch = '\u2500'; // '─'
2565
2282
  }
2566
2283
  } else if (this.border.type === 'bg') {
2567
- ch = this.border.ch
2284
+ ch = this.border.ch;
2568
2285
  }
2569
2286
  if (!this.border.bottom && x !== xi && x !== xl - 1) {
2570
- ch = ' '
2287
+ ch = ' ';
2571
2288
  if (dattr !== cell[0] || ch !== cell[1]) {
2572
- lines[y][x][0] = dattr
2573
- lines[y][x][1] = ch
2574
- lines[y].dirty = true
2289
+ lines[y][x][0] = dattr;
2290
+ lines[y][x][1] = ch;
2291
+ lines[y].dirty = true;
2575
2292
  }
2576
- continue
2293
+ continue;
2577
2294
  }
2578
2295
  if (battr !== cell[0] || ch !== cell[1]) {
2579
- lines[y][x][0] = battr
2580
- lines[y][x][1] = ch
2581
- lines[y].dirty = true
2296
+ lines[y][x][0] = battr;
2297
+ lines[y][x][1] = ch;
2298
+ lines[y].dirty = true;
2582
2299
  }
2583
2300
  }
2584
2301
  }
2585
2302
 
2586
2303
  if (this.shadow) {
2587
2304
  // right
2588
- y = Math.max(yi + 1, 0)
2305
+ y = Math.max(yi + 1, 0);
2589
2306
  for (; y < yl + 1; y++) {
2590
- if (!lines[y]) {
2591
- break
2592
- }
2593
- x = xl
2307
+ if (!lines[y]) break;
2308
+ x = xl;
2594
2309
  for (; x < xl + 2; x++) {
2595
- if (!lines[y][x]) {
2596
- break
2597
- }
2310
+ if (!lines[y][x]) break;
2598
2311
  // lines[y][x][0] = colors.blend(this.dattr, lines[y][x][0]);
2599
- lines[y][x][0] = colors.blend(lines[y][x][0])
2600
- lines[y].dirty = true
2312
+ lines[y][x][0] = colors.blend(lines[y][x][0]);
2313
+ lines[y].dirty = true;
2601
2314
  }
2602
2315
  }
2603
2316
  // bottom
2604
- y = yl
2317
+ y = yl;
2605
2318
  for (; y < yl + 1; y++) {
2606
- if (!lines[y]) {
2607
- break
2608
- }
2319
+ if (!lines[y]) break;
2609
2320
  for (x = Math.max(xi + 1, 0); x < xl; x++) {
2610
- if (!lines[y][x]) {
2611
- break
2612
- }
2321
+ if (!lines[y][x]) break;
2613
2322
  // lines[y][x][0] = colors.blend(this.dattr, lines[y][x][0]);
2614
- lines[y][x][0] = colors.blend(lines[y][x][0])
2615
- lines[y].dirty = true
2323
+ lines[y][x][0] = colors.blend(lines[y][x][0]);
2324
+ lines[y].dirty = true;
2616
2325
  }
2617
2326
  }
2618
2327
  }
2619
2328
 
2620
- this.children.forEach(function (el) {
2329
+ this.children.forEach(function(el) {
2621
2330
  if (el.screen._ci !== -1) {
2622
- el.index = el.screen._ci++
2331
+ el.index = el.screen._ci++;
2623
2332
  }
2624
2333
  // if (el.screen._rendering) {
2625
2334
  // el._rendering = true;
2626
2335
  // }
2627
- el.render()
2336
+ el.render();
2628
2337
  // if (el.screen._rendering) {
2629
2338
  // el._rendering = false;
2630
2339
  // }
2631
- })
2340
+ });
2632
2341
 
2633
- this._emit('render', [coords])
2342
+ this._emit('render', [coords]);
2634
2343
 
2635
- return coords
2636
- }
2344
+ return coords;
2345
+ };
2637
2346
 
2638
- Element.prototype._render = Element.prototype.render
2347
+ Element.prototype._render = Element.prototype.render;
2639
2348
 
2640
2349
  /**
2641
2350
  * Content Methods
2642
2351
  */
2643
2352
 
2644
- Element.prototype.insertLine = function (i, line) {
2645
- if (typeof line === 'string') {
2646
- line = line.split('\n')
2647
- }
2353
+ Element.prototype.insertLine = function(i, line) {
2354
+ if (typeof line === 'string') line = line.split('\n');
2648
2355
 
2649
2356
  if (i !== i || i == null) {
2650
- i = this._clines.ftor.length
2357
+ i = this._clines.ftor.length;
2651
2358
  }
2652
2359
 
2653
- i = Math.max(i, 0)
2360
+ i = Math.max(i, 0);
2654
2361
 
2655
2362
  while (this._clines.fake.length < i) {
2656
- this._clines.fake.push('')
2657
- this._clines.ftor.push([this._clines.push('') - 1])
2658
- this._clines.rtof(this._clines.fake.length - 1)
2363
+ this._clines.fake.push('');
2364
+ this._clines.ftor.push([this._clines.push('') - 1]);
2365
+ this._clines.rtof(this._clines.fake.length - 1);
2659
2366
  }
2660
2367
 
2661
2368
  // NOTE: Could possibly compare the first and last ftor line numbers to see
2662
2369
  // if they're the same, or if they fit in the visible region entirely.
2663
- let start = this._clines.length,
2664
- diff,
2665
- real
2370
+ var start = this._clines.length
2371
+ , diff
2372
+ , real;
2666
2373
 
2667
2374
  if (i >= this._clines.ftor.length) {
2668
- real = this._clines.ftor[this._clines.ftor.length - 1]
2669
- real = real[real.length - 1] + 1
2375
+ real = this._clines.ftor[this._clines.ftor.length - 1];
2376
+ real = real[real.length - 1] + 1;
2670
2377
  } else {
2671
- real = this._clines.ftor[i][0]
2378
+ real = this._clines.ftor[i][0];
2672
2379
  }
2673
2380
 
2674
- for (let j = 0; j < line.length; j++) {
2675
- this._clines.fake.splice(i + j, 0, line[j])
2381
+ for (var j = 0; j < line.length; j++) {
2382
+ this._clines.fake.splice(i + j, 0, line[j]);
2676
2383
  }
2677
2384
 
2678
- this.setContent(this._clines.fake.join('\n'), true)
2385
+ this.setContent(this._clines.fake.join('\n'), true);
2679
2386
 
2680
- diff = this._clines.length - start
2387
+ diff = this._clines.length - start;
2681
2388
 
2682
2389
  if (diff > 0) {
2683
- const pos = this._getCoords()
2684
- if (!pos) {
2685
- return
2686
- }
2390
+ var pos = this._getCoords();
2391
+ if (!pos) return;
2687
2392
 
2688
- const height = pos.yl - pos.yi - this.iheight,
2689
- base = this.childBase || 0,
2690
- visible = real >= base && real - base < height
2393
+ var height = pos.yl - pos.yi - this.iheight
2394
+ , base = this.childBase || 0
2395
+ , visible = real >= base && real - base < height;
2691
2396
 
2692
2397
  if (pos && visible && this.screen.cleanSides(this)) {
2693
- this.screen.insertLine(
2694
- diff,
2398
+ this.screen.insertLine(diff,
2695
2399
  pos.yi + this.itop + real - base,
2696
2400
  pos.yi,
2697
- pos.yl - this.ibottom - 1
2698
- )
2401
+ pos.yl - this.ibottom - 1);
2699
2402
  }
2700
2403
  }
2701
- }
2404
+ };
2702
2405
 
2703
- Element.prototype.deleteLine = function (i, n) {
2704
- n = n || 1
2406
+ Element.prototype.deleteLine = function(i, n) {
2407
+ n = n || 1;
2705
2408
 
2706
2409
  if (i !== i || i == null) {
2707
- i = this._clines.ftor.length - 1
2410
+ i = this._clines.ftor.length - 1;
2708
2411
  }
2709
2412
 
2710
- i = Math.max(i, 0)
2711
- i = Math.min(i, this._clines.ftor.length - 1)
2413
+ i = Math.max(i, 0);
2414
+ i = Math.min(i, this._clines.ftor.length - 1);
2712
2415
 
2713
2416
  // NOTE: Could possibly compare the first and last ftor line numbers to see
2714
2417
  // if they're the same, or if they fit in the visible region entirely.
2715
- let start = this._clines.length,
2716
- diff,
2717
- real = this._clines.ftor[i][0]
2418
+ var start = this._clines.length
2419
+ , diff
2420
+ , real = this._clines.ftor[i][0];
2718
2421
 
2719
2422
  while (n--) {
2720
- this._clines.fake.splice(i, 1)
2423
+ this._clines.fake.splice(i, 1);
2721
2424
  }
2722
2425
 
2723
- this.setContent(this._clines.fake.join('\n'), true)
2426
+ this.setContent(this._clines.fake.join('\n'), true);
2724
2427
 
2725
- diff = start - this._clines.length
2428
+ diff = start - this._clines.length;
2726
2429
 
2727
2430
  // XXX clearPos() without diff statement?
2728
- let height = 0
2431
+ var height = 0;
2729
2432
 
2730
2433
  if (diff > 0) {
2731
- const pos = this._getCoords()
2732
- if (!pos) {
2733
- return
2734
- }
2434
+ var pos = this._getCoords();
2435
+ if (!pos) return;
2735
2436
 
2736
- height = pos.yl - pos.yi - this.iheight
2437
+ height = pos.yl - pos.yi - this.iheight;
2737
2438
 
2738
- const base = this.childBase || 0,
2739
- visible = real >= base && real - base < height
2439
+ var base = this.childBase || 0
2440
+ , visible = real >= base && real - base < height;
2740
2441
 
2741
2442
  if (pos && visible && this.screen.cleanSides(this)) {
2742
- this.screen.deleteLine(
2743
- diff,
2443
+ this.screen.deleteLine(diff,
2744
2444
  pos.yi + this.itop + real - base,
2745
2445
  pos.yi,
2746
- pos.yl - this.ibottom - 1
2747
- )
2446
+ pos.yl - this.ibottom - 1);
2748
2447
  }
2749
2448
  }
2750
2449
 
2751
2450
  if (this._clines.length < height) {
2752
- this.clearPos()
2451
+ this.clearPos();
2753
2452
  }
2754
- }
2453
+ };
2755
2454
 
2756
- Element.prototype.insertTop = function (line) {
2757
- const fake = this._clines.rtof[this.childBase || 0]
2758
- return this.insertLine(fake, line)
2759
- }
2455
+ Element.prototype.insertTop = function(line) {
2456
+ var fake = this._clines.rtof[this.childBase || 0];
2457
+ return this.insertLine(fake, line);
2458
+ };
2760
2459
 
2761
- Element.prototype.insertBottom = function (line) {
2762
- const h = (this.childBase || 0) + this.height - this.iheight,
2763
- i = Math.min(h, this._clines.length),
2764
- fake = this._clines.rtof[i - 1] + 1
2460
+ Element.prototype.insertBottom = function(line) {
2461
+ var h = (this.childBase || 0) + this.height - this.iheight
2462
+ , i = Math.min(h, this._clines.length)
2463
+ , fake = this._clines.rtof[i - 1] + 1;
2765
2464
 
2766
- return this.insertLine(fake, line)
2767
- }
2465
+ return this.insertLine(fake, line);
2466
+ };
2768
2467
 
2769
- Element.prototype.deleteTop = function (n) {
2770
- const fake = this._clines.rtof[this.childBase || 0]
2771
- return this.deleteLine(fake, n)
2772
- }
2468
+ Element.prototype.deleteTop = function(n) {
2469
+ var fake = this._clines.rtof[this.childBase || 0];
2470
+ return this.deleteLine(fake, n);
2471
+ };
2773
2472
 
2774
- Element.prototype.deleteBottom = function (n) {
2775
- const h = (this.childBase || 0) + this.height - 1 - this.iheight,
2776
- i = Math.min(h, this._clines.length - 1),
2777
- fake = this._clines.rtof[i]
2473
+ Element.prototype.deleteBottom = function(n) {
2474
+ var h = (this.childBase || 0) + this.height - 1 - this.iheight
2475
+ , i = Math.min(h, this._clines.length - 1)
2476
+ , fake = this._clines.rtof[i];
2778
2477
 
2779
- n = n || 1
2478
+ n = n || 1;
2780
2479
 
2781
- return this.deleteLine(fake - (n - 1), n)
2782
- }
2480
+ return this.deleteLine(fake - (n - 1), n);
2481
+ };
2783
2482
 
2784
- Element.prototype.setLine = function (i, line) {
2785
- i = Math.max(i, 0)
2483
+ Element.prototype.setLine = function(i, line) {
2484
+ i = Math.max(i, 0);
2786
2485
  while (this._clines.fake.length < i) {
2787
- this._clines.fake.push('')
2788
- }
2789
- this._clines.fake[i] = line
2790
- return this.setContent(this._clines.fake.join('\n'), true)
2791
- }
2792
-
2793
- Element.prototype.setBaseLine = function (i, line) {
2794
- const fake = this._clines.rtof[this.childBase || 0]
2795
- return this.setLine(fake + i, line)
2796
- }
2797
-
2798
- Element.prototype.getLine = function (i) {
2799
- i = Math.max(i, 0)
2800
- i = Math.min(i, this._clines.fake.length - 1)
2801
- return this._clines.fake[i]
2802
- }
2803
-
2804
- Element.prototype.getBaseLine = function (i) {
2805
- const fake = this._clines.rtof[this.childBase || 0]
2806
- return this.getLine(fake + i)
2807
- }
2808
-
2809
- Element.prototype.clearLine = function (i) {
2810
- i = Math.min(i, this._clines.fake.length - 1)
2811
- return this.setLine(i, '')
2812
- }
2813
-
2814
- Element.prototype.clearBaseLine = function (i) {
2815
- const fake = this._clines.rtof[this.childBase || 0]
2816
- return this.clearLine(fake + i)
2817
- }
2818
-
2819
- Element.prototype.unshiftLine = function (line) {
2820
- return this.insertLine(0, line)
2821
- }
2822
-
2823
- Element.prototype.shiftLine = function (n) {
2824
- return this.deleteLine(0, n)
2825
- }
2826
-
2827
- Element.prototype.pushLine = function (line) {
2828
- if (!this.content) {
2829
- return this.setLine(0, line)
2830
- }
2831
- return this.insertLine(this._clines.fake.length, line)
2832
- }
2833
-
2834
- Element.prototype.popLine = function (n) {
2835
- return this.deleteLine(this._clines.fake.length - 1, n)
2836
- }
2837
-
2838
- Element.prototype.getLines = function () {
2839
- return this._clines.fake.slice()
2840
- }
2841
-
2842
- Element.prototype.getScreenLines = function () {
2843
- return this._clines.slice()
2844
- }
2845
-
2846
- Element.prototype.strWidth = function (text) {
2847
- text = this.parseTags ? helpers.stripTags(text) : text
2486
+ this._clines.fake.push('');
2487
+ }
2488
+ this._clines.fake[i] = line;
2489
+ return this.setContent(this._clines.fake.join('\n'), true);
2490
+ };
2491
+
2492
+ Element.prototype.setBaseLine = function(i, line) {
2493
+ var fake = this._clines.rtof[this.childBase || 0];
2494
+ return this.setLine(fake + i, line);
2495
+ };
2496
+
2497
+ Element.prototype.getLine = function(i) {
2498
+ i = Math.max(i, 0);
2499
+ i = Math.min(i, this._clines.fake.length - 1);
2500
+ return this._clines.fake[i];
2501
+ };
2502
+
2503
+ Element.prototype.getBaseLine = function(i) {
2504
+ var fake = this._clines.rtof[this.childBase || 0];
2505
+ return this.getLine(fake + i);
2506
+ };
2507
+
2508
+ Element.prototype.clearLine = function(i) {
2509
+ i = Math.min(i, this._clines.fake.length - 1);
2510
+ return this.setLine(i, '');
2511
+ };
2512
+
2513
+ Element.prototype.clearBaseLine = function(i) {
2514
+ var fake = this._clines.rtof[this.childBase || 0];
2515
+ return this.clearLine(fake + i);
2516
+ };
2517
+
2518
+ Element.prototype.unshiftLine = function(line) {
2519
+ return this.insertLine(0, line);
2520
+ };
2521
+
2522
+ Element.prototype.shiftLine = function(n) {
2523
+ return this.deleteLine(0, n);
2524
+ };
2525
+
2526
+ Element.prototype.pushLine = function(line) {
2527
+ if (!this.content) return this.setLine(0, line);
2528
+ return this.insertLine(this._clines.fake.length, line);
2529
+ };
2530
+
2531
+ Element.prototype.popLine = function(n) {
2532
+ return this.deleteLine(this._clines.fake.length - 1, n);
2533
+ };
2534
+
2535
+ Element.prototype.getLines = function() {
2536
+ return this._clines.fake.slice();
2537
+ };
2538
+
2539
+ Element.prototype.getScreenLines = function() {
2540
+ return this._clines.slice();
2541
+ };
2542
+
2543
+ Element.prototype.strWidth = function(text) {
2544
+ text = this.parseTags
2545
+ ? helpers.stripTags(text)
2546
+ : text;
2848
2547
  return this.screen.fullUnicode
2849
2548
  ? unicode.strWidth(text)
2850
- : helpers.dropUnicode(text).length
2851
- }
2549
+ : helpers.dropUnicode(text).length;
2550
+ };
2852
2551
 
2853
- Element.prototype.screenshot = function (xi, xl, yi, yl) {
2854
- xi = this.lpos.xi + this.ileft + (xi || 0)
2552
+ Element.prototype.screenshot = function(xi, xl, yi, yl) {
2553
+ xi = this.lpos.xi + this.ileft + (xi || 0);
2855
2554
  if (xl != null) {
2856
- xl = this.lpos.xi + this.ileft + (xl || 0)
2555
+ xl = this.lpos.xi + this.ileft + (xl || 0);
2857
2556
  } else {
2858
- xl = this.lpos.xl - this.iright
2557
+ xl = this.lpos.xl - this.iright;
2859
2558
  }
2860
- yi = this.lpos.yi + this.itop + (yi || 0)
2559
+ yi = this.lpos.yi + this.itop + (yi || 0);
2861
2560
  if (yl != null) {
2862
- yl = this.lpos.yi + this.itop + (yl || 0)
2561
+ yl = this.lpos.yi + this.itop + (yl || 0);
2863
2562
  } else {
2864
- yl = this.lpos.yl - this.ibottom
2563
+ yl = this.lpos.yl - this.ibottom;
2865
2564
  }
2866
- return this.screen.screenshot(xi, xl, yi, yl)
2867
- }
2565
+ return this.screen.screenshot(xi, xl, yi, yl);
2566
+ };
2868
2567
 
2869
2568
  /**
2870
2569
  * Expose
2871
2570
  */
2872
2571
 
2873
- module.exports = Element
2572
+ module.exports = Element;