Update Help contents
@ -5,6 +5,11 @@ Change Log
|
||||
4.2.0 (unreleased)
|
||||
--------------------------
|
||||
|
||||
### Improvements
|
||||
|
||||
- [rc] Update the help contents.
|
||||
|
||||
|
||||
### Fixes
|
||||
|
||||
- [rc] Fix an issue that some UI states were not restored from the last session.
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 24.5">
|
||||
|
||||
<style>
|
||||
<style type="text/css">
|
||||
@media (prefers-color-scheme: dark) {
|
||||
path { fill: white }
|
||||
}
|
||||
|
Before Width: | Height: | Size: 757 B After Width: | Height: | Size: 773 B |
@ -4,7 +4,7 @@
|
||||
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 15 13" width="15" height="13">
|
||||
|
||||
<style>
|
||||
<style type="text/css">
|
||||
* { fill: transparent; stroke: -apple-system-blue; }
|
||||
</style>
|
||||
|
||||
|
Before Width: | Height: | Size: 559 B After Width: | Height: | Size: 575 B |
After Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 51 KiB |
@ -17,9 +17,12 @@
|
||||
<li>In order to run a script, you need to set execute permission for the script file.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Refer to the document file path</h2>
|
||||
|
||||
<p>If the frontmost document has already been saved, the absolute file path of the document will be referred to as an argument.</p>
|
||||
|
||||
|
||||
<h2>Pass text data to a script</h2>
|
||||
|
||||
<p>To pass text data from CotEditor to your script, you need to put a comment at the beginning of the script and write “<code>%%%{CotEditorXInput=xxxx}%%%</code>” inside. Replace “<code>xxxx</code>” with one of the parameters below.</p>
|
||||
@ -41,6 +44,7 @@
|
||||
<li>CotEditor passes text data with UTF-8 encoding.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Receive output data from a script</h2>
|
||||
|
||||
<p>To make CotEditor receive output data from a script, you need to put a comment at the beginning of the script and write “<code>%%%{CotEditorXOutput=xxxx}%%%</code>” inside. Replace “<code>xxxx</code>” with one of the parameters below.</p>
|
||||
@ -66,18 +70,34 @@
|
||||
<li>The text encoding of the text that CotEditor receives must be UTF-8.</li>
|
||||
</ul>
|
||||
|
||||
<h2>Example</h2>
|
||||
<p>The following Python script prepends “>” character to every line in the selection of the frontmost document.</p>
|
||||
|
||||
<pre class="source"><code><span class="comment">#!/usr/bin/env python
|
||||
<h2>Print text to the Console</h2>
|
||||
|
||||
<p>The string thrown to the standard error will be printed in the Console window.</p>
|
||||
|
||||
|
||||
<h2>Example</h2>
|
||||
|
||||
<p>The following Python script prepends “>” character to every line in the selection of the frontmost document, and then print the number of the processed lines to the Console.</p>
|
||||
|
||||
<pre class="source"><code><span class="comment">#!/usr/bin/env python3
|
||||
# %%%{CotEditorXInput=Selection}%%%
|
||||
# %%%{CotEditorXOutput=ReplaceSelection}%%%</span>
|
||||
|
||||
<span class="keyword">import</span> sys
|
||||
|
||||
count = 0
|
||||
<span class="keyword">for</span> line <span class="keyword">in</span> sys.stdin:
|
||||
count += 1
|
||||
print(<span class="string">">"</span> + line.rstrip())
|
||||
sys.stderr.write(<span class="string">"Processed {} lines."</span>.format(count))
|
||||
</code></pre>
|
||||
|
||||
<figure>
|
||||
<figcaption>Output to the Console</figcaption>
|
||||
<img src="../gfx/console@2x.png" width="406" alt="[2022-05-06 18:35:00] Example Code
Processed 5 lines."/>
|
||||
</figure>
|
||||
|
||||
<p>You can get more sample scripts on:<br/>
|
||||
<a href="https://github.com/coteditor/SampleScripts" rel="external">coteditor/SampleScripts -GitHub</a></p>
|
||||
|
||||
|
After Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 51 KiB |
@ -17,9 +17,12 @@
|
||||
<li>スクリプトには実行権限がなければなりません。</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>ファイルパスの受け取り</h2>
|
||||
|
||||
<p>最前面の書類が保存済みの場合は、その書類の絶対ファイルパスが引数 (argv) としてスクリプトに渡されます。</p>
|
||||
|
||||
|
||||
<h2>スクリプトにテキストを渡す</h2>
|
||||
|
||||
<p>スクリプトにCotEditorからデータを渡すには、スクリプトの冒頭にコメントを置き、固定文字列「<code>%%%{CotEditorXInput=xxxx}%%%</code>」を埋め込みます。「<code>xxxx</code>」で、受け渡すデータを指定します。</p>
|
||||
@ -41,6 +44,7 @@
|
||||
<li>スクリプトに渡されるテキストのテキストエンコーディングはUTF-8です。</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>スクリプトの出力を受け取る</h2>
|
||||
|
||||
<p>CotEditorでスクリプトの出力を受け取るには、スクリプトの冒頭にコメントを置き、固定文字列「<code>%%%{CotEditorXOutput=xxxx}%%%</code>」を埋め込みます。「<code>xxxx</code>」で、受け取ったあとの処理を指定します。</p>
|
||||
@ -66,18 +70,34 @@
|
||||
<li>CotEditorに返すテキストのテキストエンコーディングはUTF-8でなければなりません。</li>
|
||||
</ul>
|
||||
|
||||
<h2>例</h2>
|
||||
<p>以下のPythonスクリプトは最前面書類の選択範囲内のすべての行の行頭に「>」を追加します。</p>
|
||||
|
||||
<pre class="source"><code><span class="comment">#!/usr/bin/env python
|
||||
<h2>コンソールにテキストを表示する</h2>
|
||||
|
||||
<p>標準エラー出力に投げられたテキストはコンソールウインドウに出力されます。</p>
|
||||
|
||||
|
||||
<h2>例</h2>
|
||||
|
||||
<p>以下のPythonスクリプトは最前面書類の選択範囲内のすべての行の行頭に「>」を追加し、さらに処理した行数をコンソールに表示します。</p>
|
||||
|
||||
<pre class="source"><code><span class="comment">#!/usr/bin/env python3
|
||||
# %%%{CotEditorXInput=Selection}%%%
|
||||
# %%%{CotEditorXOutput=ReplaceSelection}%%%</span>
|
||||
|
||||
<span class="keyword">import</span> sys
|
||||
|
||||
count = 0
|
||||
<span class="keyword">for</span> line <span class="keyword">in</span> sys.stdin:
|
||||
count += 1
|
||||
print(<span class="string">">"</span> + line.rstrip())
|
||||
sys.stderr.write(<span class="string">"Processed {} lines."</span>.format(count))
|
||||
</code></pre>
|
||||
|
||||
<figure>
|
||||
<figcaption>コンソールへの出力結果</figcaption>
|
||||
<img src="../gfx/console@2x.png" width="406" alt="[2022-05-06 18:35:00] Example Code
Processed 3 lines."/>
|
||||
</figure>
|
||||
|
||||
<p>ほかにも、以下のサイトから様々なサンプルスクリプトを入手することができます:<br/>
|
||||
<a href="https://github.com/coteditor/SampleScripts" rel="external">coteditor/SampleScripts -GitHub</a></p>
|
||||
|
||||
|