Classes.html 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>Classes Reference</title>
  5. <link rel="stylesheet" type="text/css" href="css/jazzy.css" />
  6. <link rel="stylesheet" type="text/css" href="css/highlight.css" />
  7. <meta charset='utf-8'>
  8. <script src="js/jquery.min.js" defer></script>
  9. <script src="js/jazzy.js" defer></script>
  10. </head>
  11. <body>
  12. <a name="//apple_ref/swift/Section/Classes" class="dashAnchor"></a>
  13. <a title="Classes Reference"></a>
  14. <header>
  15. <div class="content-wrapper">
  16. <p><a href="index.html">SwiftTerm 1.0 Docs</a> (61% documented)</p>
  17. <p class="header-right"><a href="https://github.com/migueldeicaza/SwiftTerm"><img src="img/gh.png"/>View on GitHub</a></p>
  18. <p class="header-right"><a href="dash-feed://https%3A%2F%2Fmigueldeicaza%2Egithub%2Eio%2FSwiftTerm%2Fdocsets%2FSwiftTerm%2Exml"><img src="img/dash.png"/>Install in Dash</a></p>
  19. </div>
  20. </header>
  21. <div class="content-wrapper">
  22. <p id="breadcrumbs">
  23. <a href="index.html">SwiftTerm Reference</a>
  24. <img id="carat" src="img/carat.png" />
  25. Classes Reference
  26. </p>
  27. </div>
  28. <div class="content-wrapper">
  29. <nav class="sidebar">
  30. <ul class="nav-groups">
  31. <li class="nav-group-name">
  32. <a href="Classes.html">Classes</a>
  33. <ul class="nav-group-tasks">
  34. <li class="nav-group-task">
  35. <a href="Classes/HeadlessTerminal.html">HeadlessTerminal</a>
  36. </li>
  37. <li class="nav-group-task">
  38. <a href="Classes/LocalProcess.html">LocalProcess</a>
  39. </li>
  40. <li class="nav-group-task">
  41. <a href="Classes/LocalProcessTerminalView.html">LocalProcessTerminalView</a>
  42. </li>
  43. <li class="nav-group-task">
  44. <a href="Classes/PseudoTerminalHelpers.html">PseudoTerminalHelpers</a>
  45. </li>
  46. <li class="nav-group-task">
  47. <a href="Classes/Terminal.html">Terminal</a>
  48. </li>
  49. <li class="nav-group-task">
  50. <a href="Classes/Terminal/MouseMode.html">– MouseMode</a>
  51. </li>
  52. <li class="nav-group-task">
  53. <a href="Classes/Terminal/WindowManipulationCommand.html">– WindowManipulationCommand</a>
  54. </li>
  55. <li class="nav-group-task">
  56. <a href="Classes/TerminalDebugView.html">TerminalDebugView</a>
  57. </li>
  58. <li class="nav-group-task">
  59. <a href="Classes/TerminalView.html">TerminalView</a>
  60. </li>
  61. <li class="nav-group-task">
  62. <a href="Classes/TerminalView/Options.html">– Options</a>
  63. </li>
  64. <li class="nav-group-task">
  65. <a href="Classes/TerminalView.html">TerminalView</a>
  66. </li>
  67. <li class="nav-group-task">
  68. <a href="Classes/TerminalView/Options.html">– Options</a>
  69. </li>
  70. </ul>
  71. </li>
  72. <li class="nav-group-name">
  73. <a href="Enums.html">Enumerations</a>
  74. <ul class="nav-group-tasks">
  75. <li class="nav-group-task">
  76. <a href="Enums/CursorStyle.html">CursorStyle</a>
  77. </li>
  78. </ul>
  79. </li>
  80. <li class="nav-group-name">
  81. <a href="Extensions.html">Extensions</a>
  82. <ul class="nav-group-tasks">
  83. <li class="nav-group-task">
  84. <a href="Extensions/TerminalViewDelegate.html">TerminalViewDelegate</a>
  85. </li>
  86. </ul>
  87. </li>
  88. <li class="nav-group-name">
  89. <a href="Protocols.html">Protocols</a>
  90. <ul class="nav-group-tasks">
  91. <li class="nav-group-task">
  92. <a href="Protocols/LocalProcessDelegate.html">LocalProcessDelegate</a>
  93. </li>
  94. <li class="nav-group-task">
  95. <a href="Protocols/LocalProcessTerminalViewDelegate.html">LocalProcessTerminalViewDelegate</a>
  96. </li>
  97. <li class="nav-group-task">
  98. <a href="Protocols/TerminalDelegate.html">TerminalDelegate</a>
  99. </li>
  100. <li class="nav-group-task">
  101. <a href="Protocols/TerminalViewDelegate.html">TerminalViewDelegate</a>
  102. </li>
  103. </ul>
  104. </li>
  105. <li class="nav-group-name">
  106. <a href="Structs.html">Structures</a>
  107. <ul class="nav-group-tasks">
  108. <li class="nav-group-task">
  109. <a href="Structs/Attribute.html">Attribute</a>
  110. </li>
  111. <li class="nav-group-task">
  112. <a href="Structs/Attribute/Color.html">– Color</a>
  113. </li>
  114. <li class="nav-group-task">
  115. <a href="Structs/CharData.html">CharData</a>
  116. </li>
  117. <li class="nav-group-task">
  118. <a href="Structs/CharacterStyle.html">CharacterStyle</a>
  119. </li>
  120. <li class="nav-group-task">
  121. <a href="Structs/TerminalOptions.html">TerminalOptions</a>
  122. </li>
  123. <li class="nav-group-task">
  124. <a href="Structs/TinyAtom.html">TinyAtom</a>
  125. </li>
  126. </ul>
  127. </li>
  128. </ul>
  129. </nav>
  130. <article class="main-content">
  131. <section>
  132. <section class="section">
  133. <h1>Classes</h1>
  134. <p>The following classes are available globally.</p>
  135. </section>
  136. <section class="section task-group-section">
  137. <div class="task-group">
  138. <ul>
  139. <li class="item">
  140. <div>
  141. <code>
  142. <a name="/c:@M@SwiftTerm@objc(cs)TerminalView"></a>
  143. <a name="//apple_ref/swift/Class/TerminalView" class="dashAnchor"></a>
  144. <a class="token" href="#/c:@M@SwiftTerm@objc(cs)TerminalView">TerminalView</a>
  145. </code>
  146. </div>
  147. <div class="height-container">
  148. <div class="pointer-container"></div>
  149. <section class="section">
  150. <div class="pointer"></div>
  151. <div class="abstract">
  152. <p>TerminalView provides an AppKit front-end to the <code><a href="Classes/Terminal.html">Terminal</a></code> termininal emulator.
  153. It is up to a subclass to either wire the terminal emulator to a remote terminal
  154. via some socket, to an application that wants to run with terminal emulation, or
  155. wiring this up to a pseudo-terminal.</p>
  156. <p>Users are notified of interesting events in their implementation of the <code><a href="Protocols/TerminalViewDelegate.html">TerminalViewDelegate</a></code>
  157. methods - an instance must be provided to the constructor of <code>TerminalView</code>.</p>
  158. <p>Developers might want to surface UIs for <code>optionAsMetaKey</code> and <code>allowMouseReporting</code> in
  159. their application. They both default to true, but this means that Option-Letter is hijacked for
  160. terminal purposes to send the sequence ESC-Letter, instead of the macOS specific character` and
  161. means that when mouse-aware applications are running, they hijack the normal selection process.</p>
  162. <p>Call the <code>getTerminal</code> method to get a reference to the underlying <code><a href="Classes/Terminal.html">Terminal</a></code> that backs this
  163. view.</p>
  164. <a href="Classes/TerminalView.html" class="slightly-smaller">See more</a>
  165. </div>
  166. <div class="declaration">
  167. <h4>Declaration</h4>
  168. <div class="language">
  169. <p class="aside-title">Swift</p>
  170. <pre class="highlight swift"><code><span class="kd">open</span> <span class="kd">class</span> <span class="kt">TerminalView</span> <span class="p">:</span> <span class="kt">NSView</span><span class="p">,</span> <span class="kt">NSTextInputClient</span><span class="p">,</span> <span class="kt">NSUserInterfaceValidations</span></code></pre>
  171. <pre class="highlight swift"><code><span class="kd">extension</span> <span class="kt">TerminalView</span><span class="p">:</span> <span class="kt"><a href="Protocols/TerminalDelegate.html">TerminalDelegate</a></span></code></pre>
  172. </div>
  173. </div>
  174. <div class="slightly-smaller">
  175. <a href="https://github.com/migueldeicaza/SwiftTerm/tree/master/Sources/SwiftTerm/Mac/MacTerminalView.swift#L35-L989">Show on GitHub</a>
  176. </div>
  177. </section>
  178. </div>
  179. </li>
  180. <li class="item">
  181. <div>
  182. <code>
  183. <a name="/s:9SwiftTerm16HeadlessTerminalC"></a>
  184. <a name="//apple_ref/swift/Class/HeadlessTerminal" class="dashAnchor"></a>
  185. <a class="token" href="#/s:9SwiftTerm16HeadlessTerminalC">HeadlessTerminal</a>
  186. </code>
  187. </div>
  188. <div class="height-container">
  189. <div class="pointer-container"></div>
  190. <section class="section">
  191. <div class="pointer"></div>
  192. <div class="abstract">
  193. <p>A <code>HeadlessTerminal</code> provides a terminal emulator that runs a local process, but the output does not go
  194. anywhere. You can use this to script applications and screen scrape the output for example, by accessing the
  195. <code>terminal</code> from this class.</p>
  196. <a href="Classes/HeadlessTerminal.html" class="slightly-smaller">See more</a>
  197. </div>
  198. <div class="declaration">
  199. <h4>Declaration</h4>
  200. <div class="language">
  201. <p class="aside-title">Swift</p>
  202. <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">HeadlessTerminal</span> <span class="p">:</span> <span class="kt"><a href="Protocols/TerminalDelegate.html">TerminalDelegate</a></span><span class="p">,</span> <span class="kt"><a href="Protocols/LocalProcessDelegate.html">LocalProcessDelegate</a></span></code></pre>
  203. </div>
  204. </div>
  205. <div class="slightly-smaller">
  206. <a href="https://github.com/migueldeicaza/SwiftTerm/tree/master/Sources/SwiftTerm/HeadlessTerminal.swift#L15-L61">Show on GitHub</a>
  207. </div>
  208. </section>
  209. </div>
  210. </li>
  211. <li class="item">
  212. <div>
  213. <code>
  214. <a name="/s:9SwiftTerm12LocalProcessC"></a>
  215. <a name="//apple_ref/swift/Class/LocalProcess" class="dashAnchor"></a>
  216. <a class="token" href="#/s:9SwiftTerm12LocalProcessC">LocalProcess</a>
  217. </code>
  218. </div>
  219. <div class="height-container">
  220. <div class="pointer-container"></div>
  221. <section class="section">
  222. <div class="pointer"></div>
  223. <div class="abstract">
  224. <p>This class provides the capabilities to launch a local Unix process, and connect it to a <code><a href="Classes/Terminal.html">Terminal</a></code>
  225. class or subclass.</p>
  226. <p>The <code>MacLocalTerminalView</code> is an example of this, it is a subclass of the
  227. <code>MacTerminalView</code> NSView, and it connects that view to the local system, providing a complete
  228. terminal emulator connected to running local commands.</p>
  229. <p>When you create an instance of <code>LocalProcess</code>, you provide a delegate that is used to notify
  230. your application when data is received from the lcoal process, to request the desired window size
  231. that you would like to give to the child process, and when the process terminates.</p>
  232. <p>Once you create this instance, you can start a child process by calling the <code>startProcess</code> method
  233. which will start the process. You can then send data to this underlying process using the
  234. <code>send(data:)</code> method, and you will receive the output on the provided delegate with the
  235. <code>dataReceived(slice:)</code> method.</p>
  236. <p>Received data is dispatched via the queue that you provide in the LocalProcess constructor, if none
  237. is provided, this will default to <code>DispatchQueue.main</code>. Generally, this is a good default, but if you
  238. have your own main loop or a different dispatching system, you will need to pass your own (for example,
  239. the <code><a href="Classes/HeadlessTerminal.html">HeadlessTerminal</a></code> implementation in the test suite does this.</p>
  240. <a href="Classes/LocalProcess.html" class="slightly-smaller">See more</a>
  241. </div>
  242. <div class="declaration">
  243. <h4>Declaration</h4>
  244. <div class="language">
  245. <p class="aside-title">Swift</p>
  246. <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">LocalProcess</span></code></pre>
  247. </div>
  248. </div>
  249. <div class="slightly-smaller">
  250. <a href="https://github.com/migueldeicaza/SwiftTerm/tree/master/Sources/SwiftTerm/LocalProcess.swift#L48-L215">Show on GitHub</a>
  251. </div>
  252. </section>
  253. </div>
  254. </li>
  255. <li class="item">
  256. <div>
  257. <code>
  258. <a name="/c:@M@SwiftTerm@objc(cs)TerminalDebugView"></a>
  259. <a name="//apple_ref/swift/Class/TerminalDebugView" class="dashAnchor"></a>
  260. <a class="token" href="#/c:@M@SwiftTerm@objc(cs)TerminalDebugView">TerminalDebugView</a>
  261. </code>
  262. </div>
  263. <div class="height-container">
  264. <div class="pointer-container"></div>
  265. <section class="section">
  266. <div class="pointer"></div>
  267. <div class="abstract">
  268. <p>Undocumented</p>
  269. <a href="Classes/TerminalDebugView.html" class="slightly-smaller">See more</a>
  270. </div>
  271. <div class="declaration">
  272. <h4>Declaration</h4>
  273. <div class="language">
  274. <p class="aside-title">Swift</p>
  275. <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">TerminalDebugView</span> <span class="p">:</span> <span class="kt">NSView</span></code></pre>
  276. </div>
  277. </div>
  278. <div class="slightly-smaller">
  279. <a href="https://github.com/migueldeicaza/SwiftTerm/tree/master/Sources/SwiftTerm/Mac/MacDebugView.swift#L11-L126">Show on GitHub</a>
  280. </div>
  281. </section>
  282. </div>
  283. </li>
  284. <li class="item">
  285. <div>
  286. <code>
  287. <a name="/c:@M@SwiftTerm@objc(cs)LocalProcessTerminalView"></a>
  288. <a name="//apple_ref/swift/Class/LocalProcessTerminalView" class="dashAnchor"></a>
  289. <a class="token" href="#/c:@M@SwiftTerm@objc(cs)LocalProcessTerminalView">LocalProcessTerminalView</a>
  290. </code>
  291. </div>
  292. <div class="height-container">
  293. <div class="pointer-container"></div>
  294. <section class="section">
  295. <div class="pointer"></div>
  296. <div class="abstract">
  297. <p><code>LocalProcessTerminalView</code> is an AppKit NSView that can be used to host a local process
  298. the process is launched inside a pseudo-terminal.</p>
  299. <p>Call the <code>startProcess</code> to launch the underlying process inside a pseudo terminal.</p>
  300. <p>Generally, for the <code>LocalProcessTerminalView</code> to be useful, you will want to disable the sandbox
  301. for your application, otherwise the underlying shell will not have access to much - not the majority of
  302. commands, not assorted places on the file systems and so on. For this, you need to disable for your
  303. target in &ldquo;Signing and Capabilities&rdquo; the sandbox entirely.</p>
  304. <p>Note: instances of <code>LocalProcessTerminalView</code> will set the <code><a href="Classes/TerminalView.html">TerminalView</a></code>&lsquo;s <code>delegate</code>
  305. property and capture and consume the messages. The messages that are most likely needed for
  306. consumer applications are reposted to the <code><a href="Protocols/LocalProcessTerminalViewDelegate.html">LocalProcessTerminalViewDelegate</a></code> in
  307. <code>processDelegate</code>. If you override the <code>delegate</code> directly, you might inadvertently break
  308. the internal working of <code>LocalProcessTerminalView</code>. If you must change the <code>delegate</code>
  309. make sure that you proxy the values in your implementation to the values set after initializing this instance</p>
  310. <a href="Classes/LocalProcessTerminalView.html" class="slightly-smaller">See more</a>
  311. </div>
  312. <div class="declaration">
  313. <h4>Declaration</h4>
  314. <div class="language">
  315. <p class="aside-title">Swift</p>
  316. <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">LocalProcessTerminalView</span> <span class="p">:</span> <span class="kt"><a href="Classes/TerminalView.html">TerminalView</a></span><span class="p">,</span> <span class="kt"><a href="Protocols/TerminalViewDelegate.html">TerminalViewDelegate</a></span><span class="p">,</span> <span class="kt"><a href="Protocols/LocalProcessDelegate.html">LocalProcessDelegate</a></span></code></pre>
  317. </div>
  318. </div>
  319. <div class="slightly-smaller">
  320. <a href="https://github.com/migueldeicaza/SwiftTerm/tree/master/Sources/SwiftTerm/Mac/MacLocalTerminalView.swift#L54-L154">Show on GitHub</a>
  321. </div>
  322. </section>
  323. </div>
  324. </li>
  325. <li class="item">
  326. <div>
  327. <code>
  328. <a name="/s:9SwiftTerm21PseudoTerminalHelpersC"></a>
  329. <a name="//apple_ref/swift/Class/PseudoTerminalHelpers" class="dashAnchor"></a>
  330. <a class="token" href="#/s:9SwiftTerm21PseudoTerminalHelpersC">PseudoTerminalHelpers</a>
  331. </code>
  332. </div>
  333. <div class="height-container">
  334. <div class="pointer-container"></div>
  335. <section class="section">
  336. <div class="pointer"></div>
  337. <div class="abstract">
  338. <p>APIs to assist in controlling a Unix pseudo-terminal from Swift, it provides a wrapper for
  339. the libc <code>forkpty</code>API in the form of <code>fork(andExec:args:env:desiredWindowSize:</code> method,
  340. <code>setWinSize</code> and <code>availableBytes</code></p>
  341. <a href="Classes/PseudoTerminalHelpers.html" class="slightly-smaller">See more</a>
  342. </div>
  343. <div class="declaration">
  344. <h4>Declaration</h4>
  345. <div class="language">
  346. <p class="aside-title">Swift</p>
  347. <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">PseudoTerminalHelpers</span></code></pre>
  348. </div>
  349. </div>
  350. <div class="slightly-smaller">
  351. <a href="https://github.com/migueldeicaza/SwiftTerm/tree/master/Sources/SwiftTerm/Pty.swift#L16-L101">Show on GitHub</a>
  352. </div>
  353. </section>
  354. </div>
  355. </li>
  356. <li class="item">
  357. <div>
  358. <code>
  359. <a name="/s:9SwiftTerm8TerminalC"></a>
  360. <a name="//apple_ref/swift/Class/Terminal" class="dashAnchor"></a>
  361. <a class="token" href="#/s:9SwiftTerm8TerminalC">Terminal</a>
  362. </code>
  363. </div>
  364. <div class="height-container">
  365. <div class="pointer-container"></div>
  366. <section class="section">
  367. <div class="pointer"></div>
  368. <div class="abstract">
  369. <p>The <code>Terminal</code> class provides the terminal emulation engine, and can be used to feed data to the
  370. terminal emulator. Typically users will intereact with a higher-level implementation that provides a
  371. UI toolkit-specific rendering and connects the input to the UI toolkit.</p>
  372. <p>A front-end would draw the contents of the terminal, and take input from the user, which is in turn
  373. either mapped to one of the public APIs here, or if it is user input is passed to the <code>feed</code> methods here.</p>
  374. <p>The terminal is also connected to a backend that is conneted to the client, and data from this
  375. client is fed into the emulator by calling the <code>sendResponse method</code></p>
  376. <p>The behavior of the terminal is configured by implementing the <code><a href="Protocols/TerminalDelegate.html">TerminalDelegate</a></code> protocol
  377. that is provided in the constructor call.</p>
  378. <a href="Classes/Terminal.html" class="slightly-smaller">See more</a>
  379. </div>
  380. <div class="declaration">
  381. <h4>Declaration</h4>
  382. <div class="language">
  383. <p class="aside-title">Swift</p>
  384. <pre class="highlight swift"><code><span class="kd">open</span> <span class="kd">class</span> <span class="kt">Terminal</span></code></pre>
  385. </div>
  386. </div>
  387. <div class="slightly-smaller">
  388. <a href="https://github.com/migueldeicaza/SwiftTerm/tree/master/Sources/SwiftTerm/Terminal.swift#L145-L4008">Show on GitHub</a>
  389. </div>
  390. </section>
  391. </div>
  392. </li>
  393. <li class="item">
  394. <div>
  395. <code>
  396. <a name="/"></a>
  397. <a name="//apple_ref/swift/Class/TerminalView" class="dashAnchor"></a>
  398. <a class="token" href="#/">TerminalView</a>
  399. </code>
  400. </div>
  401. <div class="height-container">
  402. <div class="pointer-container"></div>
  403. <section class="section">
  404. <div class="pointer"></div>
  405. <div class="abstract">
  406. <p>TerminalView provides an UIKit front-end to the <code><a href="Classes/Terminal.html">Terminal</a></code> termininal emulator.
  407. It is up to a subclass to either wire the terminal emulator to a remote terminal
  408. via some socket, to an application that wants to run with terminal emulation, or
  409. wiring this up to a pseudo-terminal.</p>
  410. <p>Users are notified of interesting events in their implementation of the <code><a href="Protocols/TerminalViewDelegate.html">TerminalViewDelegate</a></code>
  411. methods - an instance must be provided to the constructor of <code>TerminalView</code>.</p>
  412. <a href="Classes/TerminalView.html" class="slightly-smaller">See more</a>
  413. </div>
  414. <div class="declaration">
  415. <h4>Declaration</h4>
  416. <div class="language">
  417. <p class="aside-title">Swift</p>
  418. </div>
  419. </div>
  420. </section>
  421. </div>
  422. </li>
  423. </ul>
  424. </div>
  425. </section>
  426. </section>
  427. <section id="footer">
  428. <p>&copy; 2020 <a class="link" href="https://tirania.org/" target="_blank" rel="external">Miguel de Icaza</a>. All rights reserved. (Last updated: 2020-04-28)</p>
  429. <p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.13.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
  430. </section>
  431. </article>
  432. </div>
  433. </body>
  434. </div>
  435. </html>