123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <title>LocalProcess Class Reference</title>
- <link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
- <link rel="stylesheet" type="text/css" href="../css/highlight.css" />
- <meta charset='utf-8'>
- <script src="../js/jquery.min.js" defer></script>
- <script src="../js/jazzy.js" defer></script>
-
- <script src="../js/lunr.min.js" defer></script>
- <script src="../js/typeahead.jquery.js" defer></script>
- <script src="../js/jazzy.search.js" defer></script>
- </head>
- <body>
- <a name="//apple_ref/swift/Class/LocalProcess" class="dashAnchor"></a>
- <a title="LocalProcess Class Reference"></a>
- <header>
- <div class="content-wrapper">
- <p><a href="../index.html">SwiftTerm 1.0 Docs</a> (68% documented)</p>
- <p class="header-right"><a href="https://github.com/migueldeicaza/SwiftTerm"><img src="../img/gh.png"/>View on GitHub</a></p>
- <p class="header-right"><a href="dash-feed://https%3A%2F%2Fmigueldeicaza.github.io%2FSwiftTerm%2Fdocsets%2FSwiftTerm.xml"><img src="../img/dash.png"/>Install in Dash</a></p>
- <p class="header-right">
- <form role="search" action="../search.json">
- <input type="text" placeholder="Search documentation" data-typeahead>
- </form>
- </p>
- </div>
- </header>
- <div class="content-wrapper">
- <p id="breadcrumbs">
- <a href="../index.html">SwiftTerm Reference</a>
- <img id="carat" src="../img/carat.png" />
- LocalProcess Class Reference
- </p>
- </div>
- <div class="content-wrapper">
- <nav class="sidebar">
- <ul class="nav-groups">
- <li class="nav-group-name">
- <a href="../Classes.html">Classes</a>
- <ul class="nav-group-tasks">
- <li class="nav-group-task">
- <a href="../Classes/BufferLine.html">BufferLine</a>
- </li>
- <li class="nav-group-task">
- <a href="../Classes/Color.html">Color</a>
- </li>
- <li class="nav-group-task">
- <a href="../Classes/HeadlessTerminal.html">HeadlessTerminal</a>
- </li>
- <li class="nav-group-task">
- <a href="../Classes/ImageCell.html">ImageCell</a>
- </li>
- <li class="nav-group-task">
- <a href="../Classes/LocalProcess.html">LocalProcess</a>
- </li>
- <li class="nav-group-task">
- <a href="../Classes/LocalProcessTerminalView.html">LocalProcessTerminalView</a>
- </li>
- <li class="nav-group-task">
- <a href="../Classes/PseudoTerminalHelpers.html">PseudoTerminalHelpers</a>
- </li>
- <li class="nav-group-task">
- <a href="../Classes/Terminal.html">Terminal</a>
- </li>
- <li class="nav-group-task">
- <a href="../Classes/Terminal/MouseMode.html">– MouseMode</a>
- </li>
- <li class="nav-group-task">
- <a href="../Classes/Terminal/WindowManipulationCommand.html">– WindowManipulationCommand</a>
- </li>
- <li class="nav-group-task">
- <a href="../Classes/Terminal/BufferKind.html">– BufferKind</a>
- </li>
- <li class="nav-group-task">
- <a href="../Classes/TerminalAccessory.html">TerminalAccessory</a>
- </li>
- <li class="nav-group-task">
- <a href="../Classes/TerminalDebugView.html">TerminalDebugView</a>
- </li>
- <li class="nav-group-task">
- <a href="../Classes/TerminalView.html">TerminalView</a>
- </li>
- <li class="nav-group-task">
- <a href="../Classes/TerminalView.html">TerminalView</a>
- </li>
- </ul>
- </li>
- <li class="nav-group-name">
- <a href="../Enums.html">Enumerations</a>
- <ul class="nav-group-tasks">
- <li class="nav-group-task">
- <a href="../Enums/CursorStyle.html">CursorStyle</a>
- </li>
- <li class="nav-group-task">
- <a href="../Enums/ImageSizeRequest.html">ImageSizeRequest</a>
- </li>
- </ul>
- </li>
- <li class="nav-group-name">
- <a href="../Extensions.html">Extensions</a>
- <ul class="nav-group-tasks">
- <li class="nav-group-task">
- <a href="../Extensions/TerminalViewDelegate.html">TerminalViewDelegate</a>
- </li>
- <li class="nav-group-task">
- <a href="../Extensions/UIImage.html">UIImage</a>
- </li>
- </ul>
- </li>
- <li class="nav-group-name">
- <a href="../Protocols.html">Protocols</a>
- <ul class="nav-group-tasks">
- <li class="nav-group-task">
- <a href="../Protocols/LocalProcessDelegate.html">LocalProcessDelegate</a>
- </li>
- <li class="nav-group-task">
- <a href="../Protocols/LocalProcessTerminalViewDelegate.html">LocalProcessTerminalViewDelegate</a>
- </li>
- <li class="nav-group-task">
- <a href="../Protocols/TerminalDelegate.html">TerminalDelegate</a>
- </li>
- <li class="nav-group-task">
- <a href="../Protocols/TerminalImage.html">TerminalImage</a>
- </li>
- <li class="nav-group-task">
- <a href="../Protocols/TerminalViewDelegate.html">TerminalViewDelegate</a>
- </li>
- </ul>
- </li>
- <li class="nav-group-name">
- <a href="../Structs.html">Structures</a>
- <ul class="nav-group-tasks">
- <li class="nav-group-task">
- <a href="../Structs/Attribute.html">Attribute</a>
- </li>
- <li class="nav-group-task">
- <a href="../Structs/Attribute/Color.html">– Color</a>
- </li>
- <li class="nav-group-task">
- <a href="../Structs/CharData.html">CharData</a>
- </li>
- <li class="nav-group-task">
- <a href="../Structs/CharacterStyle.html">CharacterStyle</a>
- </li>
- <li class="nav-group-task">
- <a href="../Structs/TerminalOptions.html">TerminalOptions</a>
- </li>
- <li class="nav-group-task">
- <a href="../Structs/TinyAtom.html">TinyAtom</a>
- </li>
- </ul>
- </li>
- <li class="nav-group-name">
- <a href="../Typealiases.html">Type Aliases</a>
- <ul class="nav-group-tasks">
- <li class="nav-group-task">
- <a href="../Typealiases.html#/TTImage">TTImage</a>
- </li>
- <li class="nav-group-task">
- <a href="../Typealiases.html#/s:9SwiftTerm7TTImagea">TTImage</a>
- </li>
- </ul>
- </li>
- </ul>
- </nav>
- <article class="main-content">
- <section>
- <section class="section">
- <h1>LocalProcess</h1>
- <div class="declaration">
- <div class="language">
-
- <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">LocalProcess</span></code></pre>
- </div>
- </div>
- <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>
- class or subclass.</p>
- <p>The <code>MacLocalTerminalView</code> is an example of this, it is a subclass of the
- <code>MacTerminalView</code> NSView, and it connects that view to the local system, providing a complete
- terminal emulator connected to running local commands.</p>
- <p>When you create an instance of <code>LocalProcess</code>, you provide a delegate that is used to notify
- your application when data is received from the lcoal process, to request the desired window size
- that you would like to give to the child process, and when the process terminates.</p>
- <p>Once you create this instance, you can start a child process by calling the <code>startProcess</code> method
- which will start the process. You can then send data to this underlying process using the
- <code>send(data:)</code> method, and you will receive the output on the provided delegate with the
- <code>dataReceived(slice:)</code> method.</p>
- <p>Received data is dispatched via the queue that you provide in the LocalProcess constructor, if none
- is provided, this will default to <code>DispatchQueue.main</code>. Generally, this is a good default, but if you
- have your own main loop or a different dispatching system, you will need to pass your own (for example,
- the <code><a href="../Classes/HeadlessTerminal.html">HeadlessTerminal</a></code> implementation in the test suite does this.</p>
- </section>
- <section class="section task-group-section">
- <div class="task-group">
- <ul>
- <li class="item">
- <div>
- <code>
- <a name="/s:9SwiftTerm12LocalProcessC7childfds5Int32Vvp"></a>
- <a name="//apple_ref/swift/Property/childfd" class="dashAnchor"></a>
- <a class="token" href="#/s:9SwiftTerm12LocalProcessC7childfds5Int32Vvp">childfd</a>
- </code>
- </div>
- <div class="height-container">
- <div class="pointer-container"></div>
- <section class="section">
- <div class="pointer"></div>
- <div class="abstract">
- <p>Undocumented</p>
- </div>
- <div class="declaration">
- <h4>Declaration</h4>
- <div class="language">
- <p class="aside-title">Swift</p>
- <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">private(set)</span> <span class="k">var</span> <span class="nv">childfd</span><span class="p">:</span> <span class="kt">Int32</span> <span class="p">{</span> <span class="k">get</span> <span class="p">}</span></code></pre>
- </div>
- </div>
- </section>
- </div>
- </li>
- <li class="item">
- <div>
- <code>
- <a name="/s:9SwiftTerm12LocalProcessC8delegate13dispatchQueueAcA0cD8Delegate_p_So03OS_F6_queueCSgtcfc"></a>
- <a name="//apple_ref/swift/Method/init(delegate:dispatchQueue:)" class="dashAnchor"></a>
- <a class="token" href="#/s:9SwiftTerm12LocalProcessC8delegate13dispatchQueueAcA0cD8Delegate_p_So03OS_F6_queueCSgtcfc">init(delegate:<wbr>dispatchQueue:<wbr>)</a>
- </code>
- </div>
- <div class="height-container">
- <div class="pointer-container"></div>
- <section class="section">
- <div class="pointer"></div>
- <div class="abstract">
- <p>Initializes the LocalProcess runner and communication with the host happens via the provided
- <code><a href="../Protocols/LocalProcessDelegate.html">LocalProcessDelegate</a></code> instance.</p>
- </div>
- <div class="declaration">
- <h4>Declaration</h4>
- <div class="language">
- <p class="aside-title">Swift</p>
- <pre class="highlight swift"><code><span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="nv">delegate</span><span class="p">:</span> <span class="kt"><a href="../Protocols/LocalProcessDelegate.html">LocalProcessDelegate</a></span><span class="p">,</span> <span class="nv">dispatchQueue</span><span class="p">:</span> <span class="kt">DispatchQueue</span><span class="p">?</span> <span class="o">=</span> <span class="kc">nil</span><span class="p">)</span></code></pre>
- </div>
- </div>
- <div>
- <h4>Parameters</h4>
- <table class="graybox">
- <tbody>
- <tr>
- <td>
- <code>
- <em>delegate</em>
- </code>
- </td>
- <td>
- <div>
- <p>the delegate that will receive events or request data from your application</p>
- </div>
- </td>
- </tr>
- <tr>
- <td>
- <code>
- <em>dispatchQueue</em>
- </code>
- </td>
- <td>
- <div>
- <p>this is the queue that will be used to post data received from the
- child process when calling the <code>send(dataReceived:)</code> delegate method. If the value provided is <code>nil</code>,
- then this will default to <code>DispatchQueue.main</code></p>
- </div>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- </section>
- </div>
- </li>
- <li class="item">
- <div>
- <code>
- <a name="/s:9SwiftTerm12LocalProcessC4send4datays10ArraySliceVys5UInt8VG_tF"></a>
- <a name="//apple_ref/swift/Method/send(data:)" class="dashAnchor"></a>
- <a class="token" href="#/s:9SwiftTerm12LocalProcessC4send4datays10ArraySliceVys5UInt8VG_tF">send(data:<wbr>)</a>
- </code>
- </div>
- <div class="height-container">
- <div class="pointer-container"></div>
- <section class="section">
- <div class="pointer"></div>
- <div class="abstract">
- <p>Sends the array slice to the local process using DispatchIO</p>
- </div>
- <div class="declaration">
- <h4>Declaration</h4>
- <div class="language">
- <p class="aside-title">Swift</p>
- <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">send</span><span class="p">(</span><span class="nv">data</span><span class="p">:</span> <span class="kt">ArraySlice</span><span class="o"><</span><span class="kt">UInt8</span><span class="o">></span><span class="p">)</span></code></pre>
- </div>
- </div>
- <div>
- <h4>Parameters</h4>
- <table class="graybox">
- <tbody>
- <tr>
- <td>
- <code>
- <em>data</em>
- </code>
- </td>
- <td>
- <div>
- <p>The range of bytes to send to the child process</p>
- </div>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- </section>
- </div>
- </li>
- <li class="item">
- <div>
- <code>
- <a name="/s:9SwiftTerm12LocalProcessC7runningSbvp"></a>
- <a name="//apple_ref/swift/Property/running" class="dashAnchor"></a>
- <a class="token" href="#/s:9SwiftTerm12LocalProcessC7runningSbvp">running</a>
- </code>
- </div>
- <div class="height-container">
- <div class="pointer-container"></div>
- <section class="section">
- <div class="pointer"></div>
- <div class="abstract">
- <p>Indicates if the child process is currently running</p>
- </div>
- <div class="declaration">
- <h4>Declaration</h4>
- <div class="language">
- <p class="aside-title">Swift</p>
- <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">private(set)</span> <span class="k">var</span> <span class="nv">running</span><span class="p">:</span> <span class="kt">Bool</span> <span class="p">{</span> <span class="k">get</span> <span class="p">}</span></code></pre>
- </div>
- </div>
- </section>
- </div>
- </li>
- <li class="item">
- <div>
- <code>
- <a name="/s:9SwiftTerm12LocalProcessC05startD010executable4args11environment8execNameySS_SaySSGAISgSSSgtF"></a>
- <a name="//apple_ref/swift/Method/startProcess(executable:args:environment:execName:)" class="dashAnchor"></a>
- <a class="token" href="#/s:9SwiftTerm12LocalProcessC05startD010executable4args11environment8execNameySS_SaySSGAISgSSSgtF">startProcess(executable:<wbr>args:<wbr>environment:<wbr>execName:<wbr>)</a>
- </code>
- </div>
- <div class="height-container">
- <div class="pointer-container"></div>
- <section class="section">
- <div class="pointer"></div>
- <div class="abstract">
- <p>Launches a child process inside a pseudo-terminal</p>
- </div>
- <div class="declaration">
- <h4>Declaration</h4>
- <div class="language">
- <p class="aside-title">Swift</p>
- <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">startProcess</span><span class="p">(</span><span class="nv">executable</span><span class="p">:</span> <span class="kt">String</span> <span class="o">=</span> <span class="s">"/bin/bash"</span><span class="p">,</span> <span class="nv">args</span><span class="p">:</span> <span class="p">[</span><span class="kt">String</span><span class="p">]</span> <span class="o">=</span> <span class="p">[],</span> <span class="nv">environment</span><span class="p">:</span> <span class="p">[</span><span class="kt">String</span><span class="p">]?</span> <span class="o">=</span> <span class="kc">nil</span><span class="p">,</span> <span class="nv">execName</span><span class="p">:</span> <span class="kt">String</span><span class="p">?</span> <span class="o">=</span> <span class="kc">nil</span><span class="p">)</span></code></pre>
- </div>
- </div>
- <div>
- <h4>Parameters</h4>
- <table class="graybox">
- <tbody>
- <tr>
- <td>
- <code>
- <em>executable</em>
- </code>
- </td>
- <td>
- <div>
- <p>The executable to launch inside the pseudo terminal, defaults to /bin/bash</p>
- </div>
- </td>
- </tr>
- <tr>
- <td>
- <code>
- <em>args</em>
- </code>
- </td>
- <td>
- <div>
- <p>an array of strings that is passed as the arguments to the underlying process</p>
- </div>
- </td>
- </tr>
- <tr>
- <td>
- <code>
- <em>environment</em>
- </code>
- </td>
- <td>
- <div>
- <p>an array of environment variables to pass to the child process, if this is null, this picks a good set of defaults from <code>Terminal.getEnvironmentVariables</code>.</p>
- </div>
- </td>
- </tr>
- <tr>
- <td>
- <code>
- <em>execName</em>
- </code>
- </td>
- <td>
- <div>
- <p>If provided, this is used as the Unix argv[0] parameter, otherwise, the executable is used as the args [0], this is used when the intent is to set a different process name than the file that backs it.</p>
- </div>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- </section>
- </div>
- </li>
- <li class="item">
- <div>
- <code>
- <a name="/s:9SwiftTerm12LocalProcessC14setHostLogging9directoryySSSg_tF"></a>
- <a name="//apple_ref/swift/Method/setHostLogging(directory:)" class="dashAnchor"></a>
- <a class="token" href="#/s:9SwiftTerm12LocalProcessC14setHostLogging9directoryySSSg_tF">setHostLogging(directory:<wbr>)</a>
- </code>
- </div>
- <div class="height-container">
- <div class="pointer-container"></div>
- <section class="section">
- <div class="pointer"></div>
- <div class="abstract">
- <p>Use this method to toggle the logging of data coming from the host, or pass nil to stop</p>
- </div>
- <div class="declaration">
- <h4>Declaration</h4>
- <div class="language">
- <p class="aside-title">Swift</p>
- <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">setHostLogging</span><span class="p">(</span><span class="nv">directory</span><span class="p">:</span> <span class="kt">String</span><span class="p">?)</span></code></pre>
- </div>
- </div>
- <div>
- <h4>Parameters</h4>
- <table class="graybox">
- <tbody>
- <tr>
- <td>
- <code>
- <em>directory</em>
- </code>
- </td>
- <td>
- <div>
- <p>location where the log files will be stored.</p>
- </div>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- </section>
- </div>
- </li>
- </ul>
- </div>
- </section>
- </section>
- <section id="footer">
- <p>© 2021 <a class="link" href="https://tirania.org/" target="_blank" rel="external">Miguel de Icaza</a>. All rights reserved. (Last updated: 2021-04-28)</p>
- <p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.13.6</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
- </section>
- </article>
- </div>
- </body>
- </div>
- </html>
|