Skip to content

Commit 7a2f5e6

Browse files
committed
Merge branch 'release/6.2.3'
2 parents 9229c38 + cebac97 commit 7a2f5e6

File tree

7 files changed

+448
-13
lines changed

7 files changed

+448
-13
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838
6.2.3 (unreleased)
3939
--------------------------
4040

41+
### New Features
42+
43+
- Add AppleScript support for `folder document`, including the `current document` property and forwarding of `document` commands.
44+
45+
4146
### Improvements
4247

4348
- Optimize the performance of scanning incompatible characters.

CotEditor/Resources/CotEditor.help/Contents/Resources/en.lproj/pgs/script_osascript.html

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,49 @@ <h2><code>document</code></h2>
8181
</section>
8282

8383

84+
<section>
85+
<p class="type">class</p>
86+
<h2><code>folder document</code></h2>
87+
88+
<p>CotEditor folder document</p>
89+
90+
<dl>
91+
<dt>Properties</dt>
92+
<dd><ul>
93+
<li><p><em><code>current document</code>:</em>
94+
The currently displayed document (document).</p></li>
95+
</ul></dd>
96+
</dl>
97+
98+
<p>A document opened by opening a folder is treated as an instance of the <code>folder document</code> class. You can obtain the currently open document in that folder document via the <code>current document</code> property. In addition, any <code>document</code> API sent directly to a <code>folder document</code> is forwarded to its <code>current document</code>. If no <code>current document</code> exists, commands that target <code>document</code> will return an error.</p>
99+
100+
101+
<h3>Example</h3>
102+
103+
<p>The following two commands produce the same result:</p>
104+
105+
<figure>
106+
<pre class="source"><code class="AppleScript">if front document is folder document then
107+
set theDocument to front document's current document
108+
else
109+
set theDocument to front document
110+
end if
111+
112+
tell theDocument
113+
set theText to contents of selection
114+
end tell</code></pre>
115+
<figcaption>Gets the front text document and sets its selection contents.</figcaption>
116+
</figure>
117+
118+
<figure>
119+
<pre class="source"><code class="AppleScript">tell front document
120+
set theText to contents of selection
121+
end tell</code></pre>
122+
<figcaption>Sets the selection contents of the front document.</figcaption>
123+
</figure>
124+
</section>
125+
126+
84127
<section>
85128
<p class="type">class</p>
86129
<h2><code>text selection</code></h2>

CotEditor/Resources/CotEditor.help/Contents/Resources/en.lproj/pgs/script_osascript_changes.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@ <h1>Support different CotEditor versions in AppleScript</h1>
1717
<p>This page lists notable changes to AppleScript support in previous versions of CotEditor.</p>
1818

1919

20+
<article>
21+
<h2>Changes in CotEditor 6.2.3</h2>
22+
23+
<section>
24+
<h3>Support of <code>folder document</code></h3>
25+
26+
<p>Folder documents can now be distinguished in scripts as <code>folder document</code>. In addition, any <code>document</code> API sent to a <code>folder document</code> is executed against the text document that is currently open in that folder document. You can also retrieve that text document from a <code>folder document</code> via the <code>current document</code> property.</p>
27+
</section>
28+
</article>
29+
30+
2031
<article>
2132
<h2>Changes in CotEditor 6.0.0</h2>
2233

CotEditor/Resources/CotEditor.help/Contents/Resources/ja.lproj/pgs/script_osascript.html

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,49 @@ <h2><code>document</code></h2>
8080
</section>
8181

8282

83+
<section>
84+
<p class="type">クラス</p>
85+
<h2><code>folder document</code></h2>
86+
87+
<p>CotEditorフォルダ書類</p>
88+
89+
<dl>
90+
<dt>プロパティ</dt>
91+
<dd><ul>
92+
<li><p><em><code>current document</code>:</em>
93+
現在表示されている書類(document型)</p></li>
94+
</ul></dd>
95+
</dl>
96+
97+
<p>フォルダを開いた書類は<code>folder document</code>クラスとして扱われ、<code>current document</code>プロパティからフォルダ書類で現在開いている書類を取得できます。さらに、<code>folder document</code>に対して直接送った<code>document</code>のAPIは、そのまま<code>current document</code>に転送されます。ただし、<code>current document</code>が存在しない場合、<code>document</code>を対象とするコマンドはエラーになります。</p>
98+
99+
100+
<h3></h3>
101+
102+
<p>以下の2つのコマンドは同じ結果になります。</p>
103+
104+
<figure>
105+
<pre class="source"><code class="AppleScript">if front document is folder document then
106+
set theDocument to front document's current document
107+
else
108+
set theDocument to front document
109+
end if
110+
111+
tell theDocument
112+
set theText to contents of selection
113+
end tell</code></pre>
114+
<figcaption>最前面のテキスト書類を取得して、その選択部分をセットします。</figcaption>
115+
</figure>
116+
117+
<figure>
118+
<pre class="source"><code class="AppleScript">tell front document
119+
set theText to contents of selection
120+
end tell</code></pre>
121+
<figcaption>最前面の書類の選択部分をセットします。</figcaption>
122+
</figure>
123+
</section>
124+
125+
83126
<section>
84127
<p class="type">クラス</p>
85128
<h2><code>text selection</code></h2>

CotEditor/Resources/CotEditor.help/Contents/Resources/ja.lproj/pgs/script_osascript_changes.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@ <h1>AppleScriptで異なるバージョンのCotEditorに対応する</h1>
1717
<p>このページでは、CotEditorのAppleScript対応における過去の仕様変更を説明します。</p>
1818

1919

20+
<article>
21+
<h2>CotEditor 6.2.3での仕様変更</h2>
22+
23+
<section>
24+
<h3><code>folder document</code>のサポート</h3>
25+
26+
<p>フォルダ書類を<code>folder document</code>としてスクリプト上で区別できるようになりました。さらに、<code>folder document</code>に対して送った<code>document</code>用のAPIは、そのままフォルダ書類で現在開いているテキスト書類を対象に実行されます。また、<code>folder document</code>から現在開いているテキスト書類を<code>current document</code>プロパティで取得できます。</p>
27+
</section>
28+
</article>
29+
30+
2031
<article>
2132
<h2>CotEditor 6.0.0での仕様変更</h2>
2233

CotEditor/Resources/CotEditor.sdef

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@
104104
</responds-to>
105105
</class-extension>
106106

107+
<class name="folder document" plural="folder documents" code="dDoc" inherits="document" description="A CotEditor folder document.">
108+
<cocoa class="CotEditor.DirectoryDocument"/>
109+
<property name="current document" code="cDoc" type="document" access="r" optional="yes" description="The current document in the folder document.">
110+
<cocoa key="scriptCurrentDocument"/>
111+
</property>
112+
</class>
113+
107114
<class name="text selection" plural="text selections" code="tSel" description="A way to refer to the state of the current selection.">
108115
<cocoa class="CotEditor.TextSelection"/>
109116
<access-group identifier="com.coteditor.CotEditor.edit" access="rw"/>
@@ -221,7 +228,7 @@
221228
<parameter name="RE" code="rEex" type="boolean" optional="yes" description="Is the search text regular expression?">
222229
<cocoa key="regularExpression"/>
223230
</parameter>
224-
<parameter name="wrap" code="wRsc" type="boolean" optional="yes" description="Should the search wrapped?">
231+
<parameter name="wrap" code="wRsc" type="boolean" optional="yes" description="Should the search wrap?">
225232
<cocoa key="wrapSearch"/>
226233
</parameter>
227234
<result type="boolean" description="Did the text found?"/>
@@ -248,7 +255,7 @@
248255
<parameter name="all" code="aLl " type="boolean" optional="yes" description="Should all of the references be replaced?">
249256
<cocoa key="all"/>
250257
</parameter>
251-
<parameter name="backwards" code="bKwd" type="boolean" optional="yes" description="Should the replacement be performed backwards? Can not use with RE.">
258+
<parameter name="backwards" code="bKwd" type="boolean" optional="yes" description="Should the replacement be performed backwards? This option can’t be used with the RE option.">
252259
<cocoa key="backwardsSearch"/>
253260
</parameter>
254261
<parameter name="ignore case" code="iGcs" type="boolean" optional="yes" description="Should case be ignored (case insensitive) on search?">
@@ -257,7 +264,7 @@
257264
<parameter name="RE" code="rEex" type="boolean" optional="yes" description="Is the search text regular expression?">
258265
<cocoa key="regularExpression"/>
259266
</parameter>
260-
<parameter name="wrap" code="wRsc" type="boolean" optional="yes" description="Should the search wrapped?">
267+
<parameter name="wrap" code="wRsc" type="boolean" optional="yes" description="Should the search wrap?">
261268
<cocoa key="wrapSearch"/>
262269
</parameter>
263270
<result type="integer" description="The number of replaced texts."/>
@@ -291,32 +298,32 @@
291298

292299
<command name="move line up" code="cEd1SLup" description="Swap selected lines with the line just above.">
293300
<access-group identifier="com.coteditor.CotEditor.edit" access="rw"/>
294-
<direct-parameter type="text selection" description="The selection to move"/>
301+
<direct-parameter type="text selection" description="The selection to move."/>
295302
</command>
296303

297-
<command name="move line down" code="cEd1SLdw" description="Swap selected lines with the line just below">
304+
<command name="move line down" code="cEd1SLdw" description="Swap selected lines with the line just below.">
298305
<access-group identifier="com.coteditor.CotEditor.edit" access="rw"/>
299-
<direct-parameter type="text selection" description="The selection to move"/>
306+
<direct-parameter type="text selection" description="The selection to move."/>
300307
</command>
301308

302-
<command name="sort lines" code="cEd1Sort" description="Sort selected lines ascending">
309+
<command name="sort lines" code="cEd1Sort" description="Sort selected lines in ascending order.">
303310
<access-group identifier="com.coteditor.CotEditor.edit" access="rw"/>
304-
<direct-parameter type="text selection" description="The selection to sort"/>
311+
<direct-parameter type="text selection" description="The selection to sort."/>
305312
</command>
306313

307-
<command name="reverse lines" code="cEd1Revl" description="Reverse selected lines">
314+
<command name="reverse lines" code="cEd1Revl" description="Reverse selected lines.">
308315
<access-group identifier="com.coteditor.CotEditor.edit" access="rw"/>
309-
<direct-parameter type="text selection" description="The selection to reverse"/>
316+
<direct-parameter type="text selection" description="The selection to reverse."/>
310317
</command>
311318

312-
<command name="delete duplicate line" code="cEd1Dldp" description="Delete duplicate lines in selection">
319+
<command name="delete duplicate line" code="cEd1Dldp" description="Delete duplicate lines in the selection.">
313320
<access-group identifier="com.coteditor.CotEditor.edit" access="rw"/>
314-
<direct-parameter type="text selection" description="The selection to check duplication"/>
321+
<direct-parameter type="text selection" description="The selection to check duplication."/>
315322
</command>
316323

317324
<command name="comment out" code="cEd1Cout" description="Append comment delimiters to the selected text.">
318325
<access-group identifier="com.coteditor.CotEditor.edit" access="rw"/>
319-
<direct-parameter type="text selection" description="The selection to comment out"/>
326+
<direct-parameter type="text selection" description="The selection to comment out."/>
320327
</command>
321328

322329
<command name="uncomment" code="cEd1Uncm" description="Remove comment delimiters from the selected text.">

0 commit comments

Comments
 (0)