mirror of
https://github.com/coteditor/CotEditor.git
synced 2024-09-11 11:25:57 +03:00
Improve guidance of sample scripts
This commit is contained in:
parent
57502c6f50
commit
c5fec360a0
@ -24,7 +24,7 @@ changelog
|
||||
- Update “R” syntax style:
|
||||
- Add file name `.Rprofile` to file mapping.
|
||||
- Update documents for scripting with AppleScript.
|
||||
- Rename some sample scripts that had Japanese file names to English.
|
||||
- Update sample scripts.
|
||||
- Remove syntax style for “eRuby”.
|
||||
|
||||
|
||||
|
@ -55,7 +55,7 @@
|
||||
<li>Add file name <code>.Rprofile</code> to file mapping.</li>
|
||||
</ul></li>
|
||||
<li>Update documents for scripting with AppleScript.</li>
|
||||
<li>Rename some sample scripts that had Japanese file names to English.</li>
|
||||
<li>Update sample scripts.</li>
|
||||
<li>Remove syntax style for “eRuby”.</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
@ -55,7 +55,7 @@
|
||||
<li>ファイル名 <code>.Rprofile</code> をファイル関連付けに追加</li>
|
||||
</ul></li>
|
||||
<li>ドキュメント「AppleScript でのスクリプト作成」を更新</li>
|
||||
<li>サンプルスクリプトのスクリプト名をすべて英語に統一</li>
|
||||
<li>サンプルスクリプトを更新</li>
|
||||
<li>“eRuby” シンタックス定義を削除</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
@ -0,0 +1,23 @@
|
||||
(*
|
||||
Input Current Time.applescript
|
||||
Sample Script for CotEditor
|
||||
|
||||
Description:
|
||||
Insert current time stamp to the insertion point.
|
||||
|
||||
This script was based on the following article (2005-10-09)
|
||||
http://www001.upp.so-net.ne.jp/hanaden/osa/samples.html#_Smart_Quote
|
||||
|
||||
modified by 1024jp on 2014-11-22
|
||||
*)
|
||||
|
||||
property format : "%Y-%m-%dT%H:%M:%S%z"
|
||||
|
||||
--
|
||||
tell application "CotEditor"
|
||||
if not (exists front document) then return
|
||||
|
||||
tell front document
|
||||
set contents of selection to (do shell script "date " & quoted form of ("+" & format))
|
||||
end tell
|
||||
end tell
|
Binary file not shown.
Binary file not shown.
@ -1,23 +0,0 @@
|
||||
(*
|
||||
最前面のウィンドウの選択範囲の直後に、選択範囲をコピーするスクリプト。
|
||||
Mac OS X 10.5+ で選択範囲の直前/直後へのドラッグ&ドロップができなくなったことへの対策として作成。
|
||||
*)
|
||||
(* written by nakamuxu. 2008.01.05 *)
|
||||
(* modified by 1024jp. 2014-10-11 *)
|
||||
--
|
||||
--
|
||||
--
|
||||
tell application "CotEditor"
|
||||
if exists front document then
|
||||
tell front document
|
||||
set oldRange to range of selection as list
|
||||
set len to item 2 of oldRange
|
||||
if len > 0 then
|
||||
set copyStr to contents of selection
|
||||
set loc to item 1 of oldRange
|
||||
set range of selection to {loc + len, 0}
|
||||
set contents of selection to copyStr
|
||||
end if
|
||||
end tell
|
||||
end if
|
||||
end tell
|
@ -1,23 +0,0 @@
|
||||
(*
|
||||
最前面のウィンドウの選択範囲の直後に、選択範囲をコピーするスクリプト。
|
||||
Mac OS X 10.5+ で選択範囲の直前/直後へのドラッグ&ドロップができなくなったことへの対策として作成。
|
||||
*)
|
||||
(* written by nakamuxu. 2008.01.05 *)
|
||||
(* modified by 1024jp. 2014-10-11 *)
|
||||
--
|
||||
--
|
||||
--
|
||||
tell application "CotEditor"
|
||||
if exists front document then
|
||||
tell front document
|
||||
set oldRange to range of selection as list
|
||||
set len to item 2 of oldRange
|
||||
if len > 0 then
|
||||
set copyStr to contents of selection
|
||||
set loc to item 1 of oldRange
|
||||
set range of selection to {loc, 0}
|
||||
set contents of selection to copyStr
|
||||
end if
|
||||
end tell
|
||||
end if
|
||||
end tell
|
Binary file not shown.
@ -1,32 +0,0 @@
|
||||
(* written by nakamuxu. 2005.03.14 *)
|
||||
--
|
||||
property beginStr : "<!-- "
|
||||
property endStr : " -->"
|
||||
property preMargin : 0
|
||||
--
|
||||
--
|
||||
tell application "CotEditor"
|
||||
if exists front document then
|
||||
set {loc, len} to range of selection of front document
|
||||
if (len = 0) then
|
||||
set newStr to beginStr & endStr
|
||||
if (preMargin = 0) then
|
||||
set numOfMove to count of character of beginStr
|
||||
else
|
||||
set numOfMove to preMargin
|
||||
end if
|
||||
else if (len > 0) then
|
||||
set curStr to contents of selection of front document
|
||||
set newStr to beginStr & curStr & endStr
|
||||
if (preMargin = 0) then
|
||||
set numOfMove to count of character of newStr
|
||||
else
|
||||
set numOfMove to preMargin
|
||||
end if
|
||||
else
|
||||
return
|
||||
end if
|
||||
set contents of selection of front document to newStr
|
||||
set range of selection of front document to {loc + numOfMove, 0}
|
||||
end if
|
||||
end tell
|
@ -1,13 +1,22 @@
|
||||
(* written by 1024jp. 2014-10-11 *)
|
||||
(*
|
||||
Open in Safari.applescript
|
||||
Sample Script for CotEditor
|
||||
|
||||
Description:
|
||||
Open the frontmost document in Safari.
|
||||
|
||||
modified by 1024jp on 2014-11-22
|
||||
*)
|
||||
|
||||
--
|
||||
tell application "CotEditor"
|
||||
if exists front document then
|
||||
set theFile to file of front document
|
||||
if theFile exists then
|
||||
tell application "Safari"
|
||||
activate
|
||||
open theFile
|
||||
end tell
|
||||
end if
|
||||
end if
|
||||
end tell
|
||||
set theFile to file of front document
|
||||
|
||||
-- do nothing if the frontmost document has not been saved.
|
||||
if not theFile exists then return
|
||||
|
||||
tell application "Safari"
|
||||
activate
|
||||
open theFile
|
||||
end tell
|
||||
end tell
|
||||
|
@ -1,9 +0,0 @@
|
||||
(*
|
||||
下記の情報を参考にさせていただきました (2005.10.09)
|
||||
http://www001.upp.so-net.ne.jp/hanaden/osa/samples.html#_Smart_Quote
|
||||
*)
|
||||
tell application "CotEditor"
|
||||
if exists front document then
|
||||
set (contents of selection of front document) to (do shell script "date '+%Y-%m-%dT%H:%M:%S%z' | sed 's/00$/:00/'")
|
||||
end if
|
||||
end tell
|
@ -1,28 +0,0 @@
|
||||
{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410
|
||||
{\fonttbl\f0\fswiss\fcharset77 Helvetica-Bold;\f1\fswiss\fcharset77 Helvetica;}
|
||||
{\colortbl;\red255\green255\blue255;}
|
||||
\paperw11900\paperh16840\margl1440\margr1440\vieww11040\viewh12000\viewkind0
|
||||
\pard\tx565\tx1133\tx1700\tx2266\tx2833\tx3401\tx3967\tx4535\tx5102\tx5669\tx6235\tx6802\ql\qnatural
|
||||
|
||||
\f0\b\fs32 \cf0 About AppleScript Template Files
|
||||
\f1\b0\fs24 \
|
||||
\pard\tx565\tx1133\tx1700\tx2266\tx2833\tx3401\tx3967\tx4535\tx5102\tx5669\tx6235\tx6802\qr
|
||||
\cf0 2005.04.14\
|
||||
\pard\tx565\tx1133\tx1700\tx2266\tx2833\tx3401\tx3967\tx4535\tx5102\tx5669\tx6235\tx6802\ql\qnatural
|
||||
\cf0 \
|
||||
\pard\tx565\tx1133\tx1700\tx2266\tx2833\tx3401\tx3967\tx4535\tx5102\tx5669\tx6235\tx6802\ql\qnatural
|
||||
|
||||
\f0\b \cf0 tmp_1.applescript
|
||||
\f1\b0 \
|
||||
Replaces the selection of the frontmost window with a user-defined string, then selects the inserted string.\
|
||||
\
|
||||
|
||||
\f0\b tmp_2.applescript
|
||||
\f1\b0 \
|
||||
Replaces the selection of the frontmost window with a user-defined string, then places the caret right after the inserted string.\
|
||||
\
|
||||
|
||||
\f0\b tmp_3.applescript
|
||||
\f1\b0 \
|
||||
Wraps the selection of the frontmost window with two user-defined strings, then places the caret right after the inserted strings. If no selection is made, places the caret between the two strings.\
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
{\rtf1\mac\ansicpg10001\cocoartf102
|
||||
{\fonttbl\f0\fswiss\fcharset77 Helvetica-Bold;\f1\fnil\fcharset78 HiraKakuPro-W6;\f2\fnil\fcharset78 HiraKakuPro-W3;
|
||||
\f3\fswiss\fcharset77 Helvetica;}
|
||||
{\colortbl;\red255\green255\blue255;}
|
||||
\paperw11900\paperh16840\margl1440\margr1440\vieww11040\viewh12000\viewkind0
|
||||
\pard\tx565\tx1133\tx1700\tx2266\tx2833\tx3401\tx3967\tx4535\tx5102\tx5669\tx6235\tx6802\ql\qnatural
|
||||
|
||||
\f0\b\fs30 \cf0 AppleScript
|
||||
\f1 \'83\'65\'83\'93\'83\'76\'83\'8c\'81\'5b\'83\'67\'83\'74\'83\'40\'83\'43\'83\'8b\'82\'c9\'82\'c2\'82\'a2\'82\'c4
|
||||
\f2\b0\fs24 \
|
||||
\pard\tx565\tx1133\tx1700\tx2266\tx2833\tx3401\tx3967\tx4535\tx5102\tx5669\tx6235\tx6802\qr
|
||||
\cf0 2005.04.14\
|
||||
\pard\tx565\tx1133\tx1700\tx2266\tx2833\tx3401\tx3967\tx4535\tx5102\tx5669\tx6235\tx6802\ql\qnatural
|
||||
\cf0 \
|
||||
\pard\tx565\tx1133\tx1700\tx2266\tx2833\tx3401\tx3967\tx4535\tx5102\tx5669\tx6235\tx6802\ql\qnatural
|
||||
|
||||
\f0\b \cf0 tmp_1.applescript
|
||||
\f3\b0 \
|
||||
\pard\tx565\tx1133\tx1700\tx2266\tx2833\tx3401\tx3967\tx4535\tx5102\tx5669\tx6235\tx6802\ql\qnatural
|
||||
|
||||
\f2 \cf0 \'8d\'c5\'91\'4f\'96\'ca\'82\'cc\'83\'45\'83\'42\'83\'93\'83\'68\'83\'45\'82\'cc\'91\'49\'91\'f0\'94\'cd\'88\'cd\'82\'f0\'90\'dd\'92\'e8\'82\'b3\'82\'ea\'82\'bd\'95\'b6\'8e\'9a\'97\'f1\'82\'c5\'92\'75\'82\'ab\'8a\'b7\'82\'a6\'81\'41\'92\'75\'82\'ab\'8a\'b7\'82\'a6\'82\'bd\'95\'b6\'8e\'9a\'97\'f1\'82\'f0\'91\'49\'91\'f0\'8f\'f3\'91\'d4\'82\'c9\'82\'b5\'82\'dc\'82\'b7\'81\'42\
|
||||
\
|
||||
\pard\tx565\tx1133\tx1700\tx2266\tx2833\tx3401\tx3967\tx4535\tx5102\tx5669\tx6235\tx6802\ql\qnatural
|
||||
|
||||
\f0\b \cf0 tmp_2.applescript
|
||||
\f3\b0 \
|
||||
\pard\tx565\tx1133\tx1700\tx2266\tx2833\tx3401\tx3967\tx4535\tx5102\tx5669\tx6235\tx6802\ql\qnatural
|
||||
|
||||
\f2 \cf0 \'8d\'c5\'91\'4f\'96\'ca\'82\'cc\'83\'45\'83\'42\'83\'93\'83\'68\'83\'45\'82\'cc\'91\'49\'91\'f0\'94\'cd\'88\'cd\'82\'f0\'90\'dd\'92\'e8\'82\'b3\'82\'ea\'82\'bd\'95\'b6\'8e\'9a\'97\'f1\'82\'c5\'92\'75\'82\'ab\'8a\'b7\'82\'a6\'81\'41\'83\'4c\'83\'83\'83\'8c\'83\'62\'83\'67\'82\'f0\'92\'75\'82\'ab\'8a\'b7\'82\'a6\'82\'e7\'82\'ea\'82\'bd\'95\'b6\'8e\'9a\'97\'f1\'82\'cc\'92\'bc\'8c\'e3\'82\'c9\'88\'da\'93\'ae\'82\'b5\'82\'dc\'82\'b7\'81\'42\
|
||||
\
|
||||
\pard\tx565\tx1133\tx1700\tx2266\tx2833\tx3401\tx3967\tx4535\tx5102\tx5669\tx6235\tx6802\ql\qnatural
|
||||
|
||||
\f0\b \cf0 tmp_3.applescript
|
||||
\f3\b0 \
|
||||
\pard\tx565\tx1133\tx1700\tx2266\tx2833\tx3401\tx3967\tx4535\tx5102\tx5669\tx6235\tx6802\ql\qnatural
|
||||
|
||||
\f2 \cf0 \'8d\'c5\'91\'4f\'96\'ca\'82\'cc\'83\'45\'83\'42\'83\'93\'83\'68\'83\'45\'82\'cc\'91\'49\'91\'f0\'94\'cd\'88\'cd\'82\'f0\'90\'dd\'92\'e8\'82\'b3\'82\'ea\'82\'bd\'82\'d3\'82\'bd\'82\'c2\'82\'cc\'95\'b6\'8e\'9a\'97\'f1\'82\'c5\'88\'cd\'82\'dd\'81\'41\'83\'4c\'83\'83\'83\'8c\'83\'62\'83\'67\'82\'f0\'90\'56\'82\'b5\'82\'a2\'95\'b6\'8e\'9a\'97\'f1\'82\'cc\'92\'bc\'8c\'e3\'82\'c9\'88\'da\'93\'ae\'82\'b5\'82\'dc\'82\'b7\'81\'42\'91\'49\'91\'f0\'94\'cd\'88\'cd\'82\'aa\'82\'c8\'82\'a2\'82\'c6\'82\'ab\'82\'cd\'81\'41\'82\'d3\'82\'bd\'82\'c2\'82\'cc\'95\'b6\'8e\'9a\'97\'f1\'82\'cc\'8a\'d4\'82\'c9\'83\'4c\'83\'83\'83\'8c\'83\'62\'83\'67\'82\'f0\'88\'da\'93\'ae\'82\'b3\'82\'b9\'82\'dc\'82\'b7\'81\'42\
|
||||
\
|
||||
\
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,14 +0,0 @@
|
||||
(*
|
||||
最前面のウィンドウの選択範囲を property newStr に設定された文字列で置き換えるスクリプト。
|
||||
この例では、「TEMPLATE」に置換します。処理後は、「TEMPLATE」を選択状態にします。
|
||||
*)
|
||||
(* written by nakamuxu. 2005.04.14 *)
|
||||
--
|
||||
property newStr : "TEMPLATE"
|
||||
--
|
||||
--
|
||||
tell application "CotEditor"
|
||||
if exists front document then
|
||||
set contents of selection of front document to newStr
|
||||
end if
|
||||
end tell
|
@ -1,17 +0,0 @@
|
||||
(*
|
||||
最前面のウィンドウの選択範囲を property newStr に設定された文字列で置き換えるスクリプト。
|
||||
この例では、「TEMPLATE」に置換します。処理後は、「TEMPLATE」の直後にキャレットを移動します。
|
||||
*)
|
||||
(* written by nakamuxu. 2005.04.14 *)
|
||||
--
|
||||
property newStr : "TEMPLATE"
|
||||
--
|
||||
--
|
||||
tell application "CotEditor"
|
||||
if exists front document then
|
||||
set {loc, len} to range of selection of front document
|
||||
set numOfMove to count of character of newStr
|
||||
set contents of selection of front document to newStr
|
||||
set range of selection of front document to {loc + numOfMove, 0}
|
||||
end if
|
||||
end tell
|
@ -1,37 +0,0 @@
|
||||
(*
|
||||
最前面のウィンドウの選択範囲を property beginStr と endStr に設定された文字列で囲むスクリプト。
|
||||
この例では、「<h1>」と「</h1>」で囲みます。処理後は、選択範囲があった場合には「</h1>」の直後に、なかった場合は前に、キャレットを移動します。
|
||||
property preMargin に0 以外の数値を入れると、処理前の選択範囲の開始位置から preMargin 文字分、キャレットを強制的に移動できます。
|
||||
*)
|
||||
(* written by nakamuxu. 2005.04.14 *)
|
||||
--
|
||||
property beginStr : "<h1>"
|
||||
property endStr : "</h1>"
|
||||
property preMargin : 0
|
||||
--
|
||||
--
|
||||
tell application "CotEditor"
|
||||
if exists front document then
|
||||
set {loc, len} to range of selection of front document
|
||||
if (len = 0) then
|
||||
set newStr to beginStr & endStr
|
||||
if (preMargin = 0) then
|
||||
set numOfMove to count of character of beginStr
|
||||
else
|
||||
set numOfMove to preMargin
|
||||
end if
|
||||
else if (len > 0) then
|
||||
set curStr to contents of selection of front document
|
||||
set newStr to beginStr & curStr & endStr
|
||||
if (preMargin = 0) then
|
||||
set numOfMove to count of character of newStr
|
||||
else
|
||||
set numOfMove to preMargin
|
||||
end if
|
||||
else
|
||||
return
|
||||
end if
|
||||
set contents of selection of front document to newStr
|
||||
set range of selection of front document to {loc + numOfMove, 0}
|
||||
end if
|
||||
end tell
|
@ -0,0 +1,6 @@
|
||||
Ruby Scripts
|
||||
============
|
||||
|
||||
written by yosito for CotEditor.
|
||||
|
||||
2007-11-30
|
@ -1,13 +0,0 @@
|
||||
{\rtf1\ansi\ansicpg932\cocoartf949
|
||||
{\fonttbl\f0\fnil\fcharset0 LucidaGrande;\f1\fnil\fcharset0 BitstreamVeraSansMono-Roman;}
|
||||
{\colortbl;\red255\green255\blue255;}
|
||||
\paperw11900\paperh16840\vieww9000\viewh8400\viewkind0
|
||||
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural
|
||||
|
||||
\f0\b\fs26 \cf0 Ruby scripts
|
||||
\b0\fs24 \
|
||||
\
|
||||
written by
|
||||
\f1 yosito for CotEditor.\
|
||||
\
|
||||
2007.11.30}
|
@ -1,6 +1,9 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
# Sample Shell Script for CotEditor
|
||||
#
|
||||
# %%%{CotEditorXInput=Selection}%%%
|
||||
# %%%{CotEditorXOutput=ReplaceSelection}%%%
|
||||
|
||||
INPUT=`cat -`
|
||||
echo "<h1>${INPUT}</h1>"
|
||||
echo "<h1>${INPUT}</h1>"
|
@ -1,8 +1,11 @@
|
||||
#! /usr/bin/perl
|
||||
#
|
||||
# Sample Perl Script for CotEditor
|
||||
#
|
||||
# %%%{CotEditorXInput=Selection}%%%
|
||||
# %%%{CotEditorXOutput=ReplaceSelection}%%%
|
||||
|
||||
$INPUT=`cat -`;
|
||||
|
||||
$INPUT =~ tr/a-z/A-Z/;
|
||||
print $INPUT;
|
||||
print $INPUT;
|
@ -1,5 +1,8 @@
|
||||
#! /usr/bin/php -q
|
||||
<?php
|
||||
#
|
||||
# Sample PHP Script for CotEditor
|
||||
#
|
||||
# %%%{CotEditorXInput=Selection}%%%
|
||||
# %%%{CotEditorXOutput=ReplaceSelection}%%%
|
||||
|
||||
@ -13,4 +16,4 @@ do {
|
||||
|
||||
$OUTPUT = mb_convert_kana($INPUT, "R", "UTF-8");
|
||||
fwrite(STDOUT, $OUTPUT);
|
||||
?>
|
||||
?>
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/ruby
|
||||
#
|
||||
# xx)pre.rb
|
||||
# Sample Ruby Script for CotEditor
|
||||
#
|
||||
# %%%{CotEditorXInput=Selection}%%%
|
||||
# %%%{CotEditorXOutput=ReplaceSelection}%%%
|
||||
@ -13,4 +13,4 @@ print <<PRETAG
|
||||
<pre>
|
||||
#{CGI::escapeHTML(preText.chomp)}
|
||||
</pre>
|
||||
PRETAG
|
||||
PRETAG
|
@ -1,5 +1,7 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Sample Python Script for CotEditor
|
||||
#
|
||||
# %%%{CotEditorXInput=Selection}%%%
|
||||
# %%%{CotEditorXOutput=ReplaceSelection}%%%
|
||||
|
Loading…
Reference in New Issue
Block a user