wtt-connect 0.2.18 → 0.2.20

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 (319) hide show
  1. package/package.json +2 -5
  2. package/src/adapters/codex.js +144 -2
  3. package/src/runner.js +258 -0
  4. package/src/store.js +6 -0
  5. package/src/terminal-session.js +12 -1
  6. package/node_modules/node-addon-api/LICENSE.md +0 -9
  7. package/node_modules/node-addon-api/README.md +0 -319
  8. package/node_modules/node-addon-api/common.gypi +0 -20
  9. package/node_modules/node-addon-api/except.gypi +0 -25
  10. package/node_modules/node-addon-api/index.js +0 -12
  11. package/node_modules/node-addon-api/napi-inl.deprecated.h +0 -186
  12. package/node_modules/node-addon-api/napi-inl.h +0 -6607
  13. package/node_modules/node-addon-api/napi.h +0 -3201
  14. package/node_modules/node-addon-api/node_addon_api.gyp +0 -32
  15. package/node_modules/node-addon-api/node_api.gyp +0 -9
  16. package/node_modules/node-addon-api/noexcept.gypi +0 -26
  17. package/node_modules/node-addon-api/nothing.c +0 -0
  18. package/node_modules/node-addon-api/package-support.json +0 -21
  19. package/node_modules/node-addon-api/package.json +0 -480
  20. package/node_modules/node-addon-api/tools/README.md +0 -73
  21. package/node_modules/node-addon-api/tools/check-napi.js +0 -99
  22. package/node_modules/node-addon-api/tools/clang-format.js +0 -71
  23. package/node_modules/node-addon-api/tools/conversion.js +0 -301
  24. package/node_modules/node-addon-api/tools/eslint-format.js +0 -79
  25. package/node_modules/node-pty/LICENSE +0 -69
  26. package/node_modules/node-pty/README.md +0 -165
  27. package/node_modules/node-pty/binding.gyp +0 -111
  28. package/node_modules/node-pty/build/Makefile +0 -369
  29. package/node_modules/node-pty/build/Release/pty.node +0 -0
  30. package/node_modules/node-pty/build/binding.Makefile +0 -6
  31. package/node_modules/node-pty/build/config.gypi +0 -503
  32. package/node_modules/node-pty/build/pty.target.mk +0 -168
  33. package/node_modules/node-pty/deps/.editorconfig +0 -2
  34. package/node_modules/node-pty/deps/winpty/.drone.yml +0 -17
  35. package/node_modules/node-pty/deps/winpty/.gitattributes +0 -19
  36. package/node_modules/node-pty/deps/winpty/LICENSE +0 -21
  37. package/node_modules/node-pty/deps/winpty/Makefile +0 -166
  38. package/node_modules/node-pty/deps/winpty/README.md +0 -151
  39. package/node_modules/node-pty/deps/winpty/RELEASES.md +0 -280
  40. package/node_modules/node-pty/deps/winpty/VERSION.txt +0 -1
  41. package/node_modules/node-pty/deps/winpty/configure +0 -167
  42. package/node_modules/node-pty/deps/winpty/misc/BufferResizeTests.cc +0 -90
  43. package/node_modules/node-pty/deps/winpty/misc/ChangeScreenBuffer.cc +0 -53
  44. package/node_modules/node-pty/deps/winpty/misc/ClearConsole.cc +0 -72
  45. package/node_modules/node-pty/deps/winpty/misc/ConinMode.cc +0 -117
  46. package/node_modules/node-pty/deps/winpty/misc/ConinMode.ps1 +0 -116
  47. package/node_modules/node-pty/deps/winpty/misc/ConoutMode.cc +0 -113
  48. package/node_modules/node-pty/deps/winpty/misc/DebugClient.py +0 -42
  49. package/node_modules/node-pty/deps/winpty/misc/DebugServer.py +0 -63
  50. package/node_modules/node-pty/deps/winpty/misc/DumpLines.py +0 -5
  51. package/node_modules/node-pty/deps/winpty/misc/EnableExtendedFlags.txt +0 -46
  52. package/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/CP437-Consolas.txt +0 -528
  53. package/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/CP437-Lucida.txt +0 -633
  54. package/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/CP932.txt +0 -630
  55. package/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/CP936.txt +0 -630
  56. package/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/CP949.txt +0 -630
  57. package/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/CP950.txt +0 -630
  58. package/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/MinimumWindowWidths.txt +0 -16
  59. package/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/Results.txt +0 -4
  60. package/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/Windows10SetFontBugginess.txt +0 -144
  61. package/node_modules/node-pty/deps/winpty/misc/FontSurvey.cc +0 -100
  62. package/node_modules/node-pty/deps/winpty/misc/FormatChar.h +0 -21
  63. package/node_modules/node-pty/deps/winpty/misc/FreezePerfTest.cc +0 -62
  64. package/node_modules/node-pty/deps/winpty/misc/GetCh.cc +0 -20
  65. package/node_modules/node-pty/deps/winpty/misc/GetConsolePos.cc +0 -41
  66. package/node_modules/node-pty/deps/winpty/misc/GetFont.cc +0 -261
  67. package/node_modules/node-pty/deps/winpty/misc/IdentifyConsoleWindow.ps1 +0 -51
  68. package/node_modules/node-pty/deps/winpty/misc/IsNewConsole.cc +0 -87
  69. package/node_modules/node-pty/deps/winpty/misc/MouseInputNotes.txt +0 -90
  70. package/node_modules/node-pty/deps/winpty/misc/MoveConsoleWindow.cc +0 -34
  71. package/node_modules/node-pty/deps/winpty/misc/Notes.txt +0 -219
  72. package/node_modules/node-pty/deps/winpty/misc/OSVersion.cc +0 -27
  73. package/node_modules/node-pty/deps/winpty/misc/ScreenBufferFreezeInactive.cc +0 -101
  74. package/node_modules/node-pty/deps/winpty/misc/ScreenBufferTest.cc +0 -671
  75. package/node_modules/node-pty/deps/winpty/misc/ScreenBufferTest2.cc +0 -151
  76. package/node_modules/node-pty/deps/winpty/misc/SelectAllTest.cc +0 -45
  77. package/node_modules/node-pty/deps/winpty/misc/SetBufferSize.cc +0 -32
  78. package/node_modules/node-pty/deps/winpty/misc/SetCursorPos.cc +0 -10
  79. package/node_modules/node-pty/deps/winpty/misc/SetFont.cc +0 -145
  80. package/node_modules/node-pty/deps/winpty/misc/SetWindowRect.cc +0 -36
  81. package/node_modules/node-pty/deps/winpty/misc/ShowArgv.cc +0 -12
  82. package/node_modules/node-pty/deps/winpty/misc/ShowConsoleInput.cc +0 -40
  83. package/node_modules/node-pty/deps/winpty/misc/Spew.py +0 -5
  84. package/node_modules/node-pty/deps/winpty/misc/TestUtil.cc +0 -172
  85. package/node_modules/node-pty/deps/winpty/misc/UnicodeDoubleWidthTest.cc +0 -102
  86. package/node_modules/node-pty/deps/winpty/misc/UnicodeWideTest1.cc +0 -246
  87. package/node_modules/node-pty/deps/winpty/misc/UnicodeWideTest2.cc +0 -130
  88. package/node_modules/node-pty/deps/winpty/misc/UnixEcho.cc +0 -89
  89. package/node_modules/node-pty/deps/winpty/misc/Utf16Echo.cc +0 -46
  90. package/node_modules/node-pty/deps/winpty/misc/VeryLargeRead.cc +0 -122
  91. package/node_modules/node-pty/deps/winpty/misc/VkEscapeTest.cc +0 -56
  92. package/node_modules/node-pty/deps/winpty/misc/Win10ResizeWhileFrozen.cc +0 -52
  93. package/node_modules/node-pty/deps/winpty/misc/Win10WrapTest1.cc +0 -57
  94. package/node_modules/node-pty/deps/winpty/misc/Win10WrapTest2.cc +0 -30
  95. package/node_modules/node-pty/deps/winpty/misc/Win32Echo1.cc +0 -26
  96. package/node_modules/node-pty/deps/winpty/misc/Win32Echo2.cc +0 -19
  97. package/node_modules/node-pty/deps/winpty/misc/Win32Test1.cc +0 -46
  98. package/node_modules/node-pty/deps/winpty/misc/Win32Test2.cc +0 -70
  99. package/node_modules/node-pty/deps/winpty/misc/Win32Test3.cc +0 -78
  100. package/node_modules/node-pty/deps/winpty/misc/Win32Write1.cc +0 -44
  101. package/node_modules/node-pty/deps/winpty/misc/WindowsBugCrashReader.cc +0 -27
  102. package/node_modules/node-pty/deps/winpty/misc/WriteConsole.cc +0 -106
  103. package/node_modules/node-pty/deps/winpty/misc/build32.sh +0 -9
  104. package/node_modules/node-pty/deps/winpty/misc/build64.sh +0 -9
  105. package/node_modules/node-pty/deps/winpty/misc/color-test.sh +0 -212
  106. package/node_modules/node-pty/deps/winpty/misc/font-notes.txt +0 -300
  107. package/node_modules/node-pty/deps/winpty/misc/winbug-15048.cc +0 -201
  108. package/node_modules/node-pty/deps/winpty/ship/build-pty4j-libpty.bat +0 -36
  109. package/node_modules/node-pty/deps/winpty/ship/common_ship.py +0 -53
  110. package/node_modules/node-pty/deps/winpty/ship/make_msvc_package.py +0 -165
  111. package/node_modules/node-pty/deps/winpty/ship/ship.py +0 -108
  112. package/node_modules/node-pty/deps/winpty/src/agent/Agent.cc +0 -613
  113. package/node_modules/node-pty/deps/winpty/src/agent/Agent.h +0 -103
  114. package/node_modules/node-pty/deps/winpty/src/agent/AgentCreateDesktop.cc +0 -84
  115. package/node_modules/node-pty/deps/winpty/src/agent/AgentCreateDesktop.h +0 -28
  116. package/node_modules/node-pty/deps/winpty/src/agent/ConsoleFont.cc +0 -632
  117. package/node_modules/node-pty/deps/winpty/src/agent/ConsoleFont.h +0 -28
  118. package/node_modules/node-pty/deps/winpty/src/agent/ConsoleInput.cc +0 -852
  119. package/node_modules/node-pty/deps/winpty/src/agent/ConsoleInput.h +0 -109
  120. package/node_modules/node-pty/deps/winpty/src/agent/ConsoleInputReencoding.cc +0 -121
  121. package/node_modules/node-pty/deps/winpty/src/agent/ConsoleInputReencoding.h +0 -36
  122. package/node_modules/node-pty/deps/winpty/src/agent/ConsoleLine.cc +0 -152
  123. package/node_modules/node-pty/deps/winpty/src/agent/ConsoleLine.h +0 -41
  124. package/node_modules/node-pty/deps/winpty/src/agent/Coord.h +0 -87
  125. package/node_modules/node-pty/deps/winpty/src/agent/DebugShowInput.cc +0 -239
  126. package/node_modules/node-pty/deps/winpty/src/agent/DebugShowInput.h +0 -32
  127. package/node_modules/node-pty/deps/winpty/src/agent/DefaultInputMap.cc +0 -422
  128. package/node_modules/node-pty/deps/winpty/src/agent/DefaultInputMap.h +0 -28
  129. package/node_modules/node-pty/deps/winpty/src/agent/DsrSender.h +0 -30
  130. package/node_modules/node-pty/deps/winpty/src/agent/EventLoop.cc +0 -99
  131. package/node_modules/node-pty/deps/winpty/src/agent/EventLoop.h +0 -47
  132. package/node_modules/node-pty/deps/winpty/src/agent/InputMap.cc +0 -246
  133. package/node_modules/node-pty/deps/winpty/src/agent/InputMap.h +0 -114
  134. package/node_modules/node-pty/deps/winpty/src/agent/LargeConsoleRead.cc +0 -71
  135. package/node_modules/node-pty/deps/winpty/src/agent/LargeConsoleRead.h +0 -68
  136. package/node_modules/node-pty/deps/winpty/src/agent/NamedPipe.cc +0 -378
  137. package/node_modules/node-pty/deps/winpty/src/agent/NamedPipe.h +0 -125
  138. package/node_modules/node-pty/deps/winpty/src/agent/Scraper.cc +0 -699
  139. package/node_modules/node-pty/deps/winpty/src/agent/Scraper.h +0 -103
  140. package/node_modules/node-pty/deps/winpty/src/agent/SimplePool.h +0 -75
  141. package/node_modules/node-pty/deps/winpty/src/agent/SmallRect.h +0 -143
  142. package/node_modules/node-pty/deps/winpty/src/agent/Terminal.cc +0 -535
  143. package/node_modules/node-pty/deps/winpty/src/agent/Terminal.h +0 -69
  144. package/node_modules/node-pty/deps/winpty/src/agent/UnicodeEncoding.h +0 -157
  145. package/node_modules/node-pty/deps/winpty/src/agent/UnicodeEncodingTest.cc +0 -189
  146. package/node_modules/node-pty/deps/winpty/src/agent/Win32Console.cc +0 -107
  147. package/node_modules/node-pty/deps/winpty/src/agent/Win32Console.h +0 -67
  148. package/node_modules/node-pty/deps/winpty/src/agent/Win32ConsoleBuffer.cc +0 -193
  149. package/node_modules/node-pty/deps/winpty/src/agent/Win32ConsoleBuffer.h +0 -99
  150. package/node_modules/node-pty/deps/winpty/src/agent/main.cc +0 -114
  151. package/node_modules/node-pty/deps/winpty/src/agent/subdir.mk +0 -61
  152. package/node_modules/node-pty/deps/winpty/src/configurations.gypi +0 -60
  153. package/node_modules/node-pty/deps/winpty/src/debugserver/DebugServer.cc +0 -117
  154. package/node_modules/node-pty/deps/winpty/src/debugserver/subdir.mk +0 -41
  155. package/node_modules/node-pty/deps/winpty/src/include/winpty.h +0 -242
  156. package/node_modules/node-pty/deps/winpty/src/include/winpty_constants.h +0 -131
  157. package/node_modules/node-pty/deps/winpty/src/libwinpty/AgentLocation.cc +0 -75
  158. package/node_modules/node-pty/deps/winpty/src/libwinpty/AgentLocation.h +0 -28
  159. package/node_modules/node-pty/deps/winpty/src/libwinpty/LibWinptyException.h +0 -54
  160. package/node_modules/node-pty/deps/winpty/src/libwinpty/WinptyInternal.h +0 -72
  161. package/node_modules/node-pty/deps/winpty/src/libwinpty/subdir.mk +0 -46
  162. package/node_modules/node-pty/deps/winpty/src/libwinpty/winpty.cc +0 -970
  163. package/node_modules/node-pty/deps/winpty/src/shared/AgentMsg.h +0 -38
  164. package/node_modules/node-pty/deps/winpty/src/shared/BackgroundDesktop.cc +0 -122
  165. package/node_modules/node-pty/deps/winpty/src/shared/BackgroundDesktop.h +0 -73
  166. package/node_modules/node-pty/deps/winpty/src/shared/Buffer.cc +0 -103
  167. package/node_modules/node-pty/deps/winpty/src/shared/Buffer.h +0 -102
  168. package/node_modules/node-pty/deps/winpty/src/shared/DebugClient.cc +0 -187
  169. package/node_modules/node-pty/deps/winpty/src/shared/DebugClient.h +0 -38
  170. package/node_modules/node-pty/deps/winpty/src/shared/GenRandom.cc +0 -138
  171. package/node_modules/node-pty/deps/winpty/src/shared/GenRandom.h +0 -55
  172. package/node_modules/node-pty/deps/winpty/src/shared/GetCommitHash.bat +0 -13
  173. package/node_modules/node-pty/deps/winpty/src/shared/Mutex.h +0 -54
  174. package/node_modules/node-pty/deps/winpty/src/shared/OsModule.h +0 -63
  175. package/node_modules/node-pty/deps/winpty/src/shared/OwnedHandle.cc +0 -36
  176. package/node_modules/node-pty/deps/winpty/src/shared/OwnedHandle.h +0 -45
  177. package/node_modules/node-pty/deps/winpty/src/shared/PrecompiledHeader.h +0 -43
  178. package/node_modules/node-pty/deps/winpty/src/shared/StringBuilder.h +0 -227
  179. package/node_modules/node-pty/deps/winpty/src/shared/StringBuilderTest.cc +0 -114
  180. package/node_modules/node-pty/deps/winpty/src/shared/StringUtil.cc +0 -55
  181. package/node_modules/node-pty/deps/winpty/src/shared/StringUtil.h +0 -80
  182. package/node_modules/node-pty/deps/winpty/src/shared/TimeMeasurement.h +0 -63
  183. package/node_modules/node-pty/deps/winpty/src/shared/UnixCtrlChars.h +0 -45
  184. package/node_modules/node-pty/deps/winpty/src/shared/UpdateGenVersion.bat +0 -20
  185. package/node_modules/node-pty/deps/winpty/src/shared/WindowsSecurity.cc +0 -460
  186. package/node_modules/node-pty/deps/winpty/src/shared/WindowsSecurity.h +0 -104
  187. package/node_modules/node-pty/deps/winpty/src/shared/WindowsVersion.cc +0 -252
  188. package/node_modules/node-pty/deps/winpty/src/shared/WindowsVersion.h +0 -29
  189. package/node_modules/node-pty/deps/winpty/src/shared/WinptyAssert.cc +0 -55
  190. package/node_modules/node-pty/deps/winpty/src/shared/WinptyAssert.h +0 -64
  191. package/node_modules/node-pty/deps/winpty/src/shared/WinptyException.cc +0 -57
  192. package/node_modules/node-pty/deps/winpty/src/shared/WinptyException.h +0 -43
  193. package/node_modules/node-pty/deps/winpty/src/shared/WinptyVersion.cc +0 -42
  194. package/node_modules/node-pty/deps/winpty/src/shared/WinptyVersion.h +0 -27
  195. package/node_modules/node-pty/deps/winpty/src/shared/winpty_snprintf.h +0 -99
  196. package/node_modules/node-pty/deps/winpty/src/subdir.mk +0 -5
  197. package/node_modules/node-pty/deps/winpty/src/tests/subdir.mk +0 -28
  198. package/node_modules/node-pty/deps/winpty/src/tests/trivial_test.cc +0 -158
  199. package/node_modules/node-pty/deps/winpty/src/unix-adapter/InputHandler.cc +0 -114
  200. package/node_modules/node-pty/deps/winpty/src/unix-adapter/InputHandler.h +0 -56
  201. package/node_modules/node-pty/deps/winpty/src/unix-adapter/OutputHandler.cc +0 -80
  202. package/node_modules/node-pty/deps/winpty/src/unix-adapter/OutputHandler.h +0 -53
  203. package/node_modules/node-pty/deps/winpty/src/unix-adapter/Util.cc +0 -86
  204. package/node_modules/node-pty/deps/winpty/src/unix-adapter/Util.h +0 -31
  205. package/node_modules/node-pty/deps/winpty/src/unix-adapter/WakeupFd.cc +0 -70
  206. package/node_modules/node-pty/deps/winpty/src/unix-adapter/WakeupFd.h +0 -42
  207. package/node_modules/node-pty/deps/winpty/src/unix-adapter/main.cc +0 -729
  208. package/node_modules/node-pty/deps/winpty/src/unix-adapter/subdir.mk +0 -41
  209. package/node_modules/node-pty/deps/winpty/src/winpty.gyp +0 -234
  210. package/node_modules/node-pty/deps/winpty/vcbuild.bat +0 -83
  211. package/node_modules/node-pty/lib/conpty_console_list_agent.js +0 -16
  212. package/node_modules/node-pty/lib/conpty_console_list_agent.js.map +0 -1
  213. package/node_modules/node-pty/lib/eventEmitter2.js +0 -47
  214. package/node_modules/node-pty/lib/eventEmitter2.js.map +0 -1
  215. package/node_modules/node-pty/lib/eventEmitter2.test.js +0 -30
  216. package/node_modules/node-pty/lib/eventEmitter2.test.js.map +0 -1
  217. package/node_modules/node-pty/lib/index.js +0 -52
  218. package/node_modules/node-pty/lib/index.js.map +0 -1
  219. package/node_modules/node-pty/lib/interfaces.js +0 -7
  220. package/node_modules/node-pty/lib/interfaces.js.map +0 -1
  221. package/node_modules/node-pty/lib/shared/conout.js +0 -11
  222. package/node_modules/node-pty/lib/shared/conout.js.map +0 -1
  223. package/node_modules/node-pty/lib/terminal.js +0 -190
  224. package/node_modules/node-pty/lib/terminal.js.map +0 -1
  225. package/node_modules/node-pty/lib/terminal.test.js +0 -139
  226. package/node_modules/node-pty/lib/terminal.test.js.map +0 -1
  227. package/node_modules/node-pty/lib/testUtils.test.js +0 -28
  228. package/node_modules/node-pty/lib/testUtils.test.js.map +0 -1
  229. package/node_modules/node-pty/lib/types.js +0 -7
  230. package/node_modules/node-pty/lib/types.js.map +0 -1
  231. package/node_modules/node-pty/lib/unixTerminal.js +0 -346
  232. package/node_modules/node-pty/lib/unixTerminal.js.map +0 -1
  233. package/node_modules/node-pty/lib/unixTerminal.test.js +0 -351
  234. package/node_modules/node-pty/lib/unixTerminal.test.js.map +0 -1
  235. package/node_modules/node-pty/lib/utils.js +0 -39
  236. package/node_modules/node-pty/lib/utils.js.map +0 -1
  237. package/node_modules/node-pty/lib/windowsConoutConnection.js +0 -125
  238. package/node_modules/node-pty/lib/windowsConoutConnection.js.map +0 -1
  239. package/node_modules/node-pty/lib/windowsPtyAgent.js +0 -320
  240. package/node_modules/node-pty/lib/windowsPtyAgent.js.map +0 -1
  241. package/node_modules/node-pty/lib/windowsPtyAgent.test.js +0 -90
  242. package/node_modules/node-pty/lib/windowsPtyAgent.test.js.map +0 -1
  243. package/node_modules/node-pty/lib/windowsTerminal.js +0 -199
  244. package/node_modules/node-pty/lib/windowsTerminal.js.map +0 -1
  245. package/node_modules/node-pty/lib/windowsTerminal.test.js +0 -219
  246. package/node_modules/node-pty/lib/windowsTerminal.test.js.map +0 -1
  247. package/node_modules/node-pty/lib/worker/conoutSocketWorker.js +0 -22
  248. package/node_modules/node-pty/lib/worker/conoutSocketWorker.js.map +0 -1
  249. package/node_modules/node-pty/node-addon-api/node_addon_api.Makefile +0 -6
  250. package/node_modules/node-pty/node-addon-api/node_addon_api.target.mk +0 -106
  251. package/node_modules/node-pty/node-addon-api/node_addon_api_except.target.mk +0 -110
  252. package/node_modules/node-pty/node-addon-api/node_addon_api_maybe.target.mk +0 -106
  253. package/node_modules/node-pty/package.json +0 -64
  254. package/node_modules/node-pty/prebuilds/darwin-arm64/pty.node +0 -0
  255. package/node_modules/node-pty/prebuilds/darwin-arm64/spawn-helper +0 -0
  256. package/node_modules/node-pty/prebuilds/darwin-x64/pty.node +0 -0
  257. package/node_modules/node-pty/prebuilds/darwin-x64/spawn-helper +0 -0
  258. package/node_modules/node-pty/prebuilds/win32-arm64/conpty/OpenConsole.exe +0 -0
  259. package/node_modules/node-pty/prebuilds/win32-arm64/conpty/conpty.dll +0 -0
  260. package/node_modules/node-pty/prebuilds/win32-arm64/conpty.node +0 -0
  261. package/node_modules/node-pty/prebuilds/win32-arm64/conpty.pdb +0 -0
  262. package/node_modules/node-pty/prebuilds/win32-arm64/conpty_console_list.node +0 -0
  263. package/node_modules/node-pty/prebuilds/win32-arm64/conpty_console_list.pdb +0 -0
  264. package/node_modules/node-pty/prebuilds/win32-arm64/pty.node +0 -0
  265. package/node_modules/node-pty/prebuilds/win32-arm64/pty.pdb +0 -0
  266. package/node_modules/node-pty/prebuilds/win32-arm64/winpty-agent.exe +0 -0
  267. package/node_modules/node-pty/prebuilds/win32-arm64/winpty-agent.pdb +0 -0
  268. package/node_modules/node-pty/prebuilds/win32-arm64/winpty.dll +0 -0
  269. package/node_modules/node-pty/prebuilds/win32-arm64/winpty.pdb +0 -0
  270. package/node_modules/node-pty/prebuilds/win32-x64/conpty/OpenConsole.exe +0 -0
  271. package/node_modules/node-pty/prebuilds/win32-x64/conpty/conpty.dll +0 -0
  272. package/node_modules/node-pty/prebuilds/win32-x64/conpty.node +0 -0
  273. package/node_modules/node-pty/prebuilds/win32-x64/conpty.pdb +0 -0
  274. package/node_modules/node-pty/prebuilds/win32-x64/conpty_console_list.node +0 -0
  275. package/node_modules/node-pty/prebuilds/win32-x64/conpty_console_list.pdb +0 -0
  276. package/node_modules/node-pty/prebuilds/win32-x64/pty.node +0 -0
  277. package/node_modules/node-pty/prebuilds/win32-x64/pty.pdb +0 -0
  278. package/node_modules/node-pty/prebuilds/win32-x64/winpty-agent.exe +0 -0
  279. package/node_modules/node-pty/prebuilds/win32-x64/winpty-agent.pdb +0 -0
  280. package/node_modules/node-pty/prebuilds/win32-x64/winpty.dll +0 -0
  281. package/node_modules/node-pty/prebuilds/win32-x64/winpty.pdb +0 -0
  282. package/node_modules/node-pty/scripts/gen-compile-commands.js +0 -8
  283. package/node_modules/node-pty/scripts/increment-version.js +0 -54
  284. package/node_modules/node-pty/scripts/post-install.js +0 -80
  285. package/node_modules/node-pty/scripts/prebuild.js +0 -34
  286. package/node_modules/node-pty/src/conpty_console_list_agent.ts +0 -15
  287. package/node_modules/node-pty/src/eventEmitter2.test.ts +0 -30
  288. package/node_modules/node-pty/src/eventEmitter2.ts +0 -48
  289. package/node_modules/node-pty/src/index.ts +0 -52
  290. package/node_modules/node-pty/src/interfaces.ts +0 -130
  291. package/node_modules/node-pty/src/native.d.ts +0 -54
  292. package/node_modules/node-pty/src/shared/conout.ts +0 -15
  293. package/node_modules/node-pty/src/terminal.test.ts +0 -119
  294. package/node_modules/node-pty/src/terminal.ts +0 -211
  295. package/node_modules/node-pty/src/testUtils.test.ts +0 -23
  296. package/node_modules/node-pty/src/tsconfig.json +0 -22
  297. package/node_modules/node-pty/src/types.ts +0 -15
  298. package/node_modules/node-pty/src/unix/pty.cc +0 -799
  299. package/node_modules/node-pty/src/unix/spawn-helper.cc +0 -23
  300. package/node_modules/node-pty/src/unixTerminal.test.ts +0 -367
  301. package/node_modules/node-pty/src/unixTerminal.ts +0 -388
  302. package/node_modules/node-pty/src/utils.ts +0 -29
  303. package/node_modules/node-pty/src/win/conpty.cc +0 -583
  304. package/node_modules/node-pty/src/win/conpty.h +0 -41
  305. package/node_modules/node-pty/src/win/conpty_console_list.cc +0 -44
  306. package/node_modules/node-pty/src/win/path_util.cc +0 -95
  307. package/node_modules/node-pty/src/win/path_util.h +0 -26
  308. package/node_modules/node-pty/src/win/winpty.cc +0 -333
  309. package/node_modules/node-pty/src/windowsConoutConnection.ts +0 -82
  310. package/node_modules/node-pty/src/windowsPtyAgent.test.ts +0 -94
  311. package/node_modules/node-pty/src/windowsPtyAgent.ts +0 -321
  312. package/node_modules/node-pty/src/windowsTerminal.test.ts +0 -229
  313. package/node_modules/node-pty/src/windowsTerminal.ts +0 -203
  314. package/node_modules/node-pty/src/worker/conoutSocketWorker.ts +0 -22
  315. package/node_modules/node-pty/third_party/conpty/1.23.251008001/win10-arm64/OpenConsole.exe +0 -0
  316. package/node_modules/node-pty/third_party/conpty/1.23.251008001/win10-arm64/conpty.dll +0 -0
  317. package/node_modules/node-pty/third_party/conpty/1.23.251008001/win10-x64/OpenConsole.exe +0 -0
  318. package/node_modules/node-pty/third_party/conpty/1.23.251008001/win10-x64/conpty.dll +0 -0
  319. package/node_modules/node-pty/typings/node-pty.d.ts +0 -211
@@ -1,699 +0,0 @@
1
- // Copyright (c) 2011-2016 Ryan Prichard
2
- //
3
- // Permission is hereby granted, free of charge, to any person obtaining a copy
4
- // of this software and associated documentation files (the "Software"), to
5
- // deal in the Software without restriction, including without limitation the
6
- // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
- // sell copies of the Software, and to permit persons to whom the Software is
8
- // furnished to do so, subject to the following conditions:
9
- //
10
- // The above copyright notice and this permission notice shall be included in
11
- // all copies or substantial portions of the Software.
12
- //
13
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
- // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19
- // IN THE SOFTWARE.
20
-
21
- #include "Scraper.h"
22
-
23
- #include <windows.h>
24
-
25
- #include <stdint.h>
26
-
27
- #include <algorithm>
28
- #include <utility>
29
-
30
- #include "../shared/WinptyAssert.h"
31
- #include "../shared/winpty_snprintf.h"
32
-
33
- #include "ConsoleFont.h"
34
- #include "Win32Console.h"
35
- #include "Win32ConsoleBuffer.h"
36
-
37
- namespace {
38
-
39
- template <typename T>
40
- T constrained(T min, T val, T max) {
41
- ASSERT(min <= max);
42
- return std::min(std::max(min, val), max);
43
- }
44
-
45
- } // anonymous namespace
46
-
47
- Scraper::Scraper(
48
- Win32Console &console,
49
- Win32ConsoleBuffer &buffer,
50
- std::unique_ptr<Terminal> terminal,
51
- Coord initialSize) :
52
- m_console(console),
53
- m_terminal(std::move(terminal)),
54
- m_ptySize(initialSize)
55
- {
56
- m_consoleBuffer = &buffer;
57
-
58
- resetConsoleTracking(Terminal::OmitClear, buffer.windowRect().top());
59
-
60
- m_bufferData.resize(BUFFER_LINE_COUNT);
61
-
62
- // Setup the initial screen buffer and window size.
63
- //
64
- // Use SetConsoleWindowInfo to shrink the console window as much as
65
- // possible -- to a 1x1 cell at the top-left. This call always succeeds.
66
- // Prior to the new Windows 10 console, it also actually resizes the GUI
67
- // window to 1x1 cell. Nevertheless, even though the GUI window can
68
- // therefore be narrower than its minimum, calling
69
- // SetConsoleScreenBufferSize with a 1x1 size still fails.
70
- //
71
- // While the small font intends to support large buffers, a user could
72
- // still hit a limit imposed by their monitor width, so cap the new window
73
- // size to GetLargestConsoleWindowSize().
74
- setSmallFont(buffer.conout(), initialSize.X, m_console.isNewW10());
75
- buffer.moveWindow(SmallRect(0, 0, 1, 1));
76
- buffer.resizeBufferRange(Coord(initialSize.X, BUFFER_LINE_COUNT));
77
- const auto largest = GetLargestConsoleWindowSize(buffer.conout());
78
- buffer.moveWindow(SmallRect(
79
- 0, 0,
80
- std::min(initialSize.X, largest.X),
81
- std::min(initialSize.Y, largest.Y)));
82
- buffer.setCursorPosition(Coord(0, 0));
83
-
84
- // For the sake of the color translation heuristic, set the console color
85
- // to LtGray-on-Black.
86
- buffer.setTextAttribute(Win32ConsoleBuffer::kDefaultAttributes);
87
- buffer.clearAllLines(m_consoleBuffer->bufferInfo());
88
-
89
- m_consoleBuffer = nullptr;
90
- }
91
-
92
- Scraper::~Scraper()
93
- {
94
- }
95
-
96
- // Whether or not the agent is frozen on entry, it will be frozen on exit.
97
- void Scraper::resizeWindow(Win32ConsoleBuffer &buffer,
98
- Coord newSize,
99
- ConsoleScreenBufferInfo &finalInfoOut)
100
- {
101
- m_consoleBuffer = &buffer;
102
- m_ptySize = newSize;
103
- syncConsoleContentAndSize(true, finalInfoOut);
104
- m_consoleBuffer = nullptr;
105
- }
106
-
107
- // This function may freeze the agent, but it will not unfreeze it.
108
- void Scraper::scrapeBuffer(Win32ConsoleBuffer &buffer,
109
- ConsoleScreenBufferInfo &finalInfoOut)
110
- {
111
- m_consoleBuffer = &buffer;
112
- syncConsoleContentAndSize(false, finalInfoOut);
113
- m_consoleBuffer = nullptr;
114
- }
115
-
116
- void Scraper::resetConsoleTracking(
117
- Terminal::SendClearFlag sendClear, int64_t scrapedLineCount)
118
- {
119
- for (ConsoleLine &line : m_bufferData) {
120
- line.reset();
121
- }
122
- m_syncRow = -1;
123
- m_scrapedLineCount = scrapedLineCount;
124
- m_scrolledCount = 0;
125
- m_maxBufferedLine = -1;
126
- m_dirtyWindowTop = -1;
127
- m_dirtyLineCount = 0;
128
- m_terminal->reset(sendClear, m_scrapedLineCount);
129
- }
130
-
131
- // Detect window movement. If the window moves down (presumably as a
132
- // result of scrolling), then assume that all screen buffer lines down to
133
- // the bottom of the window are dirty.
134
- void Scraper::markEntireWindowDirty(const SmallRect &windowRect)
135
- {
136
- m_dirtyLineCount = std::max(m_dirtyLineCount,
137
- windowRect.top() + windowRect.height());
138
- }
139
-
140
- // Scan the screen buffer and advance the dirty line count when we find
141
- // non-empty lines.
142
- void Scraper::scanForDirtyLines(const SmallRect &windowRect)
143
- {
144
- const int w = m_readBuffer.rect().width();
145
- ASSERT(m_dirtyLineCount >= 1);
146
- const CHAR_INFO *const prevLine =
147
- m_readBuffer.lineData(m_dirtyLineCount - 1);
148
- WORD prevLineAttr = prevLine[w - 1].Attributes;
149
- const int stopLine = windowRect.top() + windowRect.height();
150
-
151
- for (int line = m_dirtyLineCount; line < stopLine; ++line) {
152
- const CHAR_INFO *lineData = m_readBuffer.lineData(line);
153
- for (int col = 0; col < w; ++col) {
154
- const WORD colAttr = lineData[col].Attributes;
155
- if (lineData[col].Char.UnicodeChar != L' ' ||
156
- colAttr != prevLineAttr) {
157
- m_dirtyLineCount = line + 1;
158
- break;
159
- }
160
- }
161
- prevLineAttr = lineData[w - 1].Attributes;
162
- }
163
- }
164
-
165
- // Clear lines in the line buffer. The `firstRow` parameter is in
166
- // screen-buffer coordinates.
167
- void Scraper::clearBufferLines(
168
- const int firstRow,
169
- const int count)
170
- {
171
- ASSERT(!m_directMode);
172
- for (int row = firstRow; row < firstRow + count; ++row) {
173
- const int64_t bufLine = row + m_scrolledCount;
174
- m_maxBufferedLine = std::max(m_maxBufferedLine, bufLine);
175
- m_bufferData[bufLine % BUFFER_LINE_COUNT].blank(
176
- Win32ConsoleBuffer::kDefaultAttributes);
177
- }
178
- }
179
-
180
- static bool cursorInWindow(const ConsoleScreenBufferInfo &info)
181
- {
182
- return info.dwCursorPosition.Y >= info.srWindow.Top &&
183
- info.dwCursorPosition.Y <= info.srWindow.Bottom;
184
- }
185
-
186
- void Scraper::resizeImpl(const ConsoleScreenBufferInfo &origInfo)
187
- {
188
- ASSERT(m_console.frozen());
189
- const int cols = m_ptySize.X;
190
- const int rows = m_ptySize.Y;
191
- Coord finalBufferSize;
192
-
193
- {
194
- //
195
- // To accommodate Windows 10, erase all lines up to the top of the
196
- // visible window. It's hard to tell whether this is strictly
197
- // necessary. It ensures that the sync marker won't move downward,
198
- // and it ensures that we won't repeat lines that have already scrolled
199
- // up into the scrollback.
200
- //
201
- // It *is* possible for these blank lines to reappear in the visible
202
- // window (e.g. if the window is made taller), but because we blanked
203
- // the lines in the line buffer, we still don't output them again.
204
- //
205
- const Coord origBufferSize = origInfo.bufferSize();
206
- const SmallRect origWindowRect = origInfo.windowRect();
207
-
208
- if (m_directMode) {
209
- for (ConsoleLine &line : m_bufferData) {
210
- line.reset();
211
- }
212
- } else {
213
- m_consoleBuffer->clearLines(0, origWindowRect.Top, origInfo);
214
- clearBufferLines(0, origWindowRect.Top);
215
- if (m_syncRow != -1) {
216
- createSyncMarker(std::min(
217
- m_syncRow,
218
- BUFFER_LINE_COUNT - rows
219
- - SYNC_MARKER_LEN
220
- - SYNC_MARKER_MARGIN));
221
- }
222
- }
223
-
224
- finalBufferSize = Coord(
225
- cols,
226
- // If there was previously no scrollback (e.g. a full-screen app
227
- // in direct mode) and we're reducing the window height, then
228
- // reduce the console buffer's height too.
229
- (origWindowRect.height() == origBufferSize.Y)
230
- ? rows
231
- : std::max<int>(rows, origBufferSize.Y));
232
-
233
- // Reset the console font size. We need to do this before shrinking
234
- // the window, because we might need to make the font bigger to permit
235
- // a smaller window width. Making the font smaller could expand the
236
- // screen buffer, which would hang the conhost process in the
237
- // Windows 10 (10240 build) if the console selection is in progress, so
238
- // unfreeze it first.
239
- m_console.setFrozen(false);
240
- setSmallFont(m_consoleBuffer->conout(), cols, m_console.isNewW10());
241
- }
242
-
243
- // We try to make the font small enough so that the entire screen buffer
244
- // fits on the monitor, but it can't be guaranteed.
245
- const auto largest =
246
- GetLargestConsoleWindowSize(m_consoleBuffer->conout());
247
- const short visibleCols = std::min<short>(cols, largest.X);
248
- const short visibleRows = std::min<short>(rows, largest.Y);
249
-
250
- {
251
- // Make the window small enough. We want the console frozen during
252
- // this step so we don't accidentally move the window above the cursor.
253
- m_console.setFrozen(true);
254
- const auto info = m_consoleBuffer->bufferInfo();
255
- const auto &bufferSize = info.dwSize;
256
- const int tmpWindowWidth = std::min(bufferSize.X, visibleCols);
257
- const int tmpWindowHeight = std::min(bufferSize.Y, visibleRows);
258
- SmallRect tmpWindowRect(
259
- 0,
260
- std::min<int>(bufferSize.Y - tmpWindowHeight,
261
- info.windowRect().Top),
262
- tmpWindowWidth,
263
- tmpWindowHeight);
264
- if (cursorInWindow(info)) {
265
- tmpWindowRect = tmpWindowRect.ensureLineIncluded(
266
- info.cursorPosition().Y);
267
- }
268
- m_consoleBuffer->moveWindow(tmpWindowRect);
269
- }
270
-
271
- {
272
- // Resize the buffer to the final desired size.
273
- m_console.setFrozen(false);
274
- m_consoleBuffer->resizeBufferRange(finalBufferSize);
275
- }
276
-
277
- {
278
- // Expand the window to its full size.
279
- m_console.setFrozen(true);
280
- const ConsoleScreenBufferInfo info = m_consoleBuffer->bufferInfo();
281
-
282
- SmallRect finalWindowRect(
283
- 0,
284
- std::min<int>(info.bufferSize().Y - visibleRows,
285
- info.windowRect().Top),
286
- visibleCols,
287
- visibleRows);
288
-
289
- //
290
- // Once a line in the screen buffer is "dirty", it should stay visible
291
- // in the console window, so that we continue to update its content in
292
- // the terminal. This code is particularly (only?) necessary on
293
- // Windows 10, where making the buffer wider can rewrap lines and move
294
- // the console window upward.
295
- //
296
- if (!m_directMode && m_dirtyLineCount > finalWindowRect.Bottom + 1) {
297
- // In theory, we avoid ensureLineIncluded, because, a massive
298
- // amount of output could have occurred while the console was
299
- // unfrozen, so that the *top* of the window is now below the
300
- // dirtiest tracked line.
301
- finalWindowRect = SmallRect(
302
- 0, m_dirtyLineCount - visibleRows,
303
- visibleCols, visibleRows);
304
- }
305
-
306
- // Highest priority constraint: ensure that the cursor remains visible.
307
- if (cursorInWindow(info)) {
308
- finalWindowRect = finalWindowRect.ensureLineIncluded(
309
- info.cursorPosition().Y);
310
- }
311
-
312
- m_consoleBuffer->moveWindow(finalWindowRect);
313
- m_dirtyWindowTop = finalWindowRect.Top;
314
- }
315
-
316
- ASSERT(m_console.frozen());
317
- }
318
-
319
- void Scraper::syncConsoleContentAndSize(
320
- bool forceResize,
321
- ConsoleScreenBufferInfo &finalInfoOut)
322
- {
323
- // We'll try to avoid freezing the console by reading large chunks (or
324
- // all!) of the screen buffer without otherwise attempting to synchronize
325
- // with the console application. We can only do this on Windows 10 and up
326
- // because:
327
- // - Prior to Windows 8, the size of a ReadConsoleOutputW call was limited
328
- // by the ~32KB RPC buffer.
329
- // - Prior to Windows 10, an out-of-range read region crashes the caller.
330
- // (See misc/WindowsBugCrashReader.cc.)
331
- //
332
- if (!m_console.isNewW10() || forceResize) {
333
- m_console.setFrozen(true);
334
- }
335
-
336
- const ConsoleScreenBufferInfo info = m_consoleBuffer->bufferInfo();
337
- bool cursorVisible = true;
338
- CONSOLE_CURSOR_INFO cursorInfo = {};
339
- if (!GetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursorInfo)) {
340
- trace("GetConsoleCursorInfo failed");
341
- } else {
342
- cursorVisible = cursorInfo.bVisible != 0;
343
- }
344
-
345
- // If an app resizes the buffer height, then we enter "direct mode", where
346
- // we stop trying to track incremental console changes.
347
- const bool newDirectMode = (info.bufferSize().Y != BUFFER_LINE_COUNT);
348
- if (newDirectMode != m_directMode) {
349
- trace("Entering %s mode", newDirectMode ? "direct" : "scrolling");
350
- resetConsoleTracking(Terminal::SendClear,
351
- newDirectMode ? 0 : info.windowRect().top());
352
- m_directMode = newDirectMode;
353
-
354
- // When we switch from direct->scrolling mode, make sure the console is
355
- // the right size.
356
- if (!m_directMode) {
357
- m_console.setFrozen(true);
358
- forceResize = true;
359
- }
360
- }
361
-
362
- if (m_directMode) {
363
- // In direct-mode, resizing the console redraws the terminal, so do it
364
- // before scraping.
365
- if (forceResize) {
366
- resizeImpl(info);
367
- }
368
- directScrapeOutput(info, cursorVisible);
369
- } else {
370
- if (!m_console.frozen()) {
371
- if (!scrollingScrapeOutput(info, cursorVisible, true)) {
372
- m_console.setFrozen(true);
373
- }
374
- }
375
- if (m_console.frozen()) {
376
- scrollingScrapeOutput(info, cursorVisible, false);
377
- }
378
- // In scrolling mode, we want to scrape before resizing, because we'll
379
- // erase everything in the console buffer up to the top of the console
380
- // window.
381
- if (forceResize) {
382
- resizeImpl(info);
383
- }
384
- }
385
-
386
- finalInfoOut = forceResize ? m_consoleBuffer->bufferInfo() : info;
387
- }
388
-
389
- // Try to match Windows' behavior w.r.t. to the LVB attribute flags. In some
390
- // situations, Windows ignores the LVB flags on a character cell because of
391
- // backwards compatibility -- apparently some programs set the flags without
392
- // intending to enable reverse-video or underscores.
393
- //
394
- // [rprichard 2017-01-15] I haven't actually noticed any old programs that need
395
- // this treatment -- the motivation for this function comes from the MSDN
396
- // documentation for SetConsoleMode and ENABLE_LVB_GRID_WORLDWIDE.
397
- WORD Scraper::attributesMask()
398
- {
399
- const auto WINPTY_ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x4u;
400
- const auto WINPTY_ENABLE_LVB_GRID_WORLDWIDE = 0x10u;
401
- const auto WINPTY_COMMON_LVB_REVERSE_VIDEO = 0x4000u;
402
- const auto WINPTY_COMMON_LVB_UNDERSCORE = 0x8000u;
403
-
404
- const auto cp = GetConsoleOutputCP();
405
- const auto isCjk = (cp == 932 || cp == 936 || cp == 949 || cp == 950);
406
-
407
- const DWORD outputMode = [this]{
408
- ASSERT(this->m_consoleBuffer != nullptr);
409
- DWORD mode = 0;
410
- if (!GetConsoleMode(this->m_consoleBuffer->conout(), &mode)) {
411
- mode = 0;
412
- }
413
- return mode;
414
- }();
415
- const bool hasEnableLvbGridWorldwide =
416
- (outputMode & WINPTY_ENABLE_LVB_GRID_WORLDWIDE) != 0;
417
- const bool hasEnableVtProcessing =
418
- (outputMode & WINPTY_ENABLE_VIRTUAL_TERMINAL_PROCESSING) != 0;
419
-
420
- // The new Windows 10 console (as of 14393) seems to respect
421
- // COMMON_LVB_REVERSE_VIDEO even in CP437 w/o the other enabling modes, so
422
- // try to match that behavior.
423
- const auto isReverseSupported =
424
- isCjk || hasEnableLvbGridWorldwide || hasEnableVtProcessing || m_console.isNewW10();
425
- const auto isUnderscoreSupported =
426
- isCjk || hasEnableLvbGridWorldwide || hasEnableVtProcessing;
427
-
428
- WORD mask = ~0;
429
- if (!isReverseSupported) { mask &= ~WINPTY_COMMON_LVB_REVERSE_VIDEO; }
430
- if (!isUnderscoreSupported) { mask &= ~WINPTY_COMMON_LVB_UNDERSCORE; }
431
- return mask;
432
- }
433
-
434
- void Scraper::directScrapeOutput(const ConsoleScreenBufferInfo &info,
435
- bool consoleCursorVisible)
436
- {
437
- const SmallRect windowRect = info.windowRect();
438
-
439
- const SmallRect scrapeRect(
440
- windowRect.left(), windowRect.top(),
441
- std::min<SHORT>(std::min(windowRect.width(), m_ptySize.X),
442
- MAX_CONSOLE_WIDTH),
443
- std::min<SHORT>(std::min(windowRect.height(), m_ptySize.Y),
444
- BUFFER_LINE_COUNT));
445
- const int w = scrapeRect.width();
446
- const int h = scrapeRect.height();
447
-
448
- const Coord cursor = info.cursorPosition();
449
- const bool showTerminalCursor =
450
- consoleCursorVisible && scrapeRect.contains(cursor);
451
- const int cursorColumn = !showTerminalCursor ? -1 : cursor.X - scrapeRect.Left;
452
- const int cursorLine = !showTerminalCursor ? -1 : cursor.Y - scrapeRect.Top;
453
-
454
- if (!showTerminalCursor) {
455
- m_terminal->hideTerminalCursor();
456
- }
457
-
458
- largeConsoleRead(m_readBuffer, *m_consoleBuffer, scrapeRect, attributesMask());
459
-
460
- for (int line = 0; line < h; ++line) {
461
- const CHAR_INFO *const curLine =
462
- m_readBuffer.lineData(scrapeRect.top() + line);
463
- ConsoleLine &bufLine = m_bufferData[line];
464
- if (bufLine.detectChangeAndSetLine(curLine, w)) {
465
- const int lineCursorColumn =
466
- line == cursorLine ? cursorColumn : -1;
467
- m_terminal->sendLine(line, curLine, w, lineCursorColumn);
468
- }
469
- }
470
-
471
- if (showTerminalCursor) {
472
- m_terminal->showTerminalCursor(cursorColumn, cursorLine);
473
- }
474
- }
475
-
476
- bool Scraper::scrollingScrapeOutput(const ConsoleScreenBufferInfo &info,
477
- bool consoleCursorVisible,
478
- bool tentative)
479
- {
480
- const Coord cursor = info.cursorPosition();
481
- const SmallRect windowRect = info.windowRect();
482
-
483
- if (m_syncRow != -1) {
484
- // If a synchronizing marker was placed into the history, look for it
485
- // and adjust the scroll count.
486
- const int markerRow = findSyncMarker();
487
- if (markerRow == -1) {
488
- if (tentative) {
489
- // I *think* it's possible to keep going, but it's simple to
490
- // bail out.
491
- return false;
492
- }
493
- // Something has happened. Reset the terminal.
494
- trace("Sync marker has disappeared -- resetting the terminal"
495
- " (m_syncCounter=%u)",
496
- m_syncCounter);
497
- resetConsoleTracking(Terminal::SendClear, windowRect.top());
498
- } else if (markerRow != m_syncRow) {
499
- ASSERT(markerRow < m_syncRow);
500
- m_scrolledCount += (m_syncRow - markerRow);
501
- m_syncRow = markerRow;
502
- // If the buffer has scrolled, then the entire window is dirty.
503
- markEntireWindowDirty(windowRect);
504
- }
505
- }
506
-
507
- // Creating a new sync row requires clearing part of the console buffer, so
508
- // avoid doing it if there's already a sync row that's good enough.
509
- const int newSyncRow =
510
- static_cast<int>(windowRect.top()) - SYNC_MARKER_LEN - SYNC_MARKER_MARGIN;
511
- const bool shouldCreateSyncRow =
512
- newSyncRow >= m_syncRow + SYNC_MARKER_LEN + SYNC_MARKER_MARGIN;
513
- if (tentative && shouldCreateSyncRow) {
514
- // It's difficult even in principle to put down a new marker if the
515
- // console can scroll an arbitrarily amount while we're writing.
516
- return false;
517
- }
518
-
519
- // Update the dirty line count:
520
- // - If the window has moved, the entire window is dirty.
521
- // - Everything up to the cursor is dirty.
522
- // - All lines above the window are dirty.
523
- // - Any non-blank lines are dirty.
524
- if (m_dirtyWindowTop != -1) {
525
- if (windowRect.top() > m_dirtyWindowTop) {
526
- // The window has moved down, presumably as a result of scrolling.
527
- markEntireWindowDirty(windowRect);
528
- } else if (windowRect.top() < m_dirtyWindowTop) {
529
- if (tentative) {
530
- // I *think* it's possible to keep going, but it's simple to
531
- // bail out.
532
- return false;
533
- }
534
- // The window has moved upward. This is generally not expected to
535
- // happen, but the CMD/PowerShell CLS command will move the window
536
- // to the top as part of clearing everything else in the console.
537
- trace("Window moved upward -- resetting the terminal"
538
- " (m_syncCounter=%u)",
539
- m_syncCounter);
540
- resetConsoleTracking(Terminal::SendClear, windowRect.top());
541
- }
542
- }
543
- m_dirtyWindowTop = windowRect.top();
544
- m_dirtyLineCount = std::max(m_dirtyLineCount, cursor.Y + 1);
545
- m_dirtyLineCount = std::max(m_dirtyLineCount, (int)windowRect.top());
546
-
547
- // There will be at least one dirty line, because there is a cursor.
548
- ASSERT(m_dirtyLineCount >= 1);
549
-
550
- // The first line to scrape, in virtual line coordinates.
551
- const int64_t firstVirtLine = std::min(m_scrapedLineCount,
552
- windowRect.top() + m_scrolledCount);
553
-
554
- // Read all the data we will need from the console. Start reading with the
555
- // first line to scrape, but adjust the the read area upward to account for
556
- // scanForDirtyLines' need to read the previous attribute. Read to the
557
- // bottom of the window. (It's not clear to me whether the
558
- // m_dirtyLineCount adjustment here is strictly necessary. It isn't
559
- // necessary so long as the cursor is inside the current window.)
560
- const int firstReadLine = std::min<int>(firstVirtLine - m_scrolledCount,
561
- m_dirtyLineCount - 1);
562
- const int stopReadLine = std::max(windowRect.top() + windowRect.height(),
563
- m_dirtyLineCount);
564
- ASSERT(firstReadLine >= 0 && stopReadLine > firstReadLine);
565
- largeConsoleRead(m_readBuffer,
566
- *m_consoleBuffer,
567
- SmallRect(0, firstReadLine,
568
- std::min<SHORT>(info.bufferSize().X,
569
- MAX_CONSOLE_WIDTH),
570
- stopReadLine - firstReadLine),
571
- attributesMask());
572
-
573
- // If we're scraping the buffer without freezing it, we have to query the
574
- // buffer position data separately from the buffer content, so the two
575
- // could easily be out-of-sync. If they *are* out-of-sync, abort the
576
- // scrape operation and restart it frozen. (We may have updated the
577
- // dirty-line high-water-mark, but that should be OK.)
578
- if (tentative) {
579
- const auto infoCheck = m_consoleBuffer->bufferInfo();
580
- if (info.bufferSize() != infoCheck.bufferSize() ||
581
- info.windowRect() != infoCheck.windowRect() ||
582
- info.cursorPosition() != infoCheck.cursorPosition()) {
583
- return false;
584
- }
585
- if (m_syncRow != -1 && m_syncRow != findSyncMarker()) {
586
- return false;
587
- }
588
- }
589
-
590
- if (shouldCreateSyncRow) {
591
- ASSERT(!tentative);
592
- createSyncMarker(newSyncRow);
593
- }
594
-
595
- // At this point, we're finished interacting (reading or writing) the
596
- // console, and we just need to convert our collected data into terminal
597
- // output.
598
-
599
- scanForDirtyLines(windowRect);
600
-
601
- // Note that it's possible for all the lines on the current window to
602
- // be non-dirty.
603
-
604
- // The line to stop scraping at, in virtual line coordinates.
605
- const int64_t stopVirtLine =
606
- std::min(m_dirtyLineCount, windowRect.top() + windowRect.height()) +
607
- m_scrolledCount;
608
-
609
- const bool showTerminalCursor =
610
- consoleCursorVisible && windowRect.contains(cursor);
611
- const int64_t cursorLine = !showTerminalCursor ? -1 : cursor.Y + m_scrolledCount;
612
- const int cursorColumn = !showTerminalCursor ? -1 : cursor.X;
613
-
614
- if (!showTerminalCursor) {
615
- m_terminal->hideTerminalCursor();
616
- }
617
-
618
- bool sawModifiedLine = false;
619
-
620
- const int w = m_readBuffer.rect().width();
621
- for (int64_t line = firstVirtLine; line < stopVirtLine; ++line) {
622
- const CHAR_INFO *curLine =
623
- m_readBuffer.lineData(line - m_scrolledCount);
624
- ConsoleLine &bufLine = m_bufferData[line % BUFFER_LINE_COUNT];
625
- if (line > m_maxBufferedLine) {
626
- m_maxBufferedLine = line;
627
- sawModifiedLine = true;
628
- }
629
- if (sawModifiedLine) {
630
- bufLine.setLine(curLine, w);
631
- } else {
632
- sawModifiedLine = bufLine.detectChangeAndSetLine(curLine, w);
633
- }
634
- if (sawModifiedLine) {
635
- const int lineCursorColumn =
636
- line == cursorLine ? cursorColumn : -1;
637
- m_terminal->sendLine(line, curLine, w, lineCursorColumn);
638
- }
639
- }
640
-
641
- m_scrapedLineCount = windowRect.top() + m_scrolledCount;
642
-
643
- if (showTerminalCursor) {
644
- m_terminal->showTerminalCursor(cursorColumn, cursorLine);
645
- }
646
-
647
- return true;
648
- }
649
-
650
- void Scraper::syncMarkerText(CHAR_INFO (&output)[SYNC_MARKER_LEN])
651
- {
652
- // XXX: The marker text generated here could easily collide with ordinary
653
- // console output. Does it make sense to try to avoid the collision?
654
- char str[SYNC_MARKER_LEN + 1];
655
- winpty_snprintf(str, "S*Y*N*C*%08x", m_syncCounter);
656
- for (int i = 0; i < SYNC_MARKER_LEN; ++i) {
657
- output[i].Char.UnicodeChar = str[i];
658
- output[i].Attributes = 7;
659
- }
660
- }
661
-
662
- int Scraper::findSyncMarker()
663
- {
664
- ASSERT(m_syncRow >= 0);
665
- CHAR_INFO marker[SYNC_MARKER_LEN];
666
- CHAR_INFO column[BUFFER_LINE_COUNT];
667
- syncMarkerText(marker);
668
- SmallRect rect(0, 0, 1, m_syncRow + SYNC_MARKER_LEN);
669
- m_consoleBuffer->read(rect, column);
670
- int i;
671
- for (i = m_syncRow; i >= 0; --i) {
672
- int j;
673
- for (j = 0; j < SYNC_MARKER_LEN; ++j) {
674
- if (column[i + j].Char.UnicodeChar != marker[j].Char.UnicodeChar)
675
- break;
676
- }
677
- if (j == SYNC_MARKER_LEN)
678
- return i;
679
- }
680
- return -1;
681
- }
682
-
683
- void Scraper::createSyncMarker(int row)
684
- {
685
- ASSERT(row >= 1);
686
-
687
- // Clear the lines around the marker to ensure that Windows 10's rewrapping
688
- // does not affect the marker.
689
- m_consoleBuffer->clearLines(row - 1, SYNC_MARKER_LEN + 1,
690
- m_consoleBuffer->bufferInfo());
691
-
692
- // Write a new marker.
693
- m_syncCounter++;
694
- CHAR_INFO marker[SYNC_MARKER_LEN];
695
- syncMarkerText(marker);
696
- m_syncRow = row;
697
- SmallRect markerRect(0, m_syncRow, 1, SYNC_MARKER_LEN);
698
- m_consoleBuffer->write(markerRect, marker);
699
- }