「CotEditor」の版間の差分

提供: MacWiki
移動: 案内検索
(Tips)
(Tips)
行33: 行33:
 
<pre>
 
<pre>
 
tell front document of application "CotEditor"
 
tell front document of application "CotEditor"
tell text of it
+
set theText to text of it
display dialog "ワードカウント結果" & return & return & ¬
+
-- set theText to contents of selection -- 選択範囲を処理
"文字数:" & number of every character & return & ¬
+
display dialog "ワードカウント結果" & return & return & ¬
"単語数:" & number of every word & return & ¬
+
"文字数:" & number of every character of theText & return & ¬
"段落数:" & number of every paragraph
+
"単語数:" & number of every word of theText & return & ¬
end tell
+
"段落数:" & number of every paragraph of theText
 
end tell
 
end tell
 
</pre>
 
</pre>

2008年3月12日 (水) 23:32時点における版

CotEditor とは?

プレーンテキストのエディタ。OgreKit, Oniguruma正規表現検索機能が組み込まれているとのことです。


Tips

  • UTF-8 対応、AppleScript 対応とのことですので、下記のようなこともできます。
tell application "CotEditor"
set string_utf8 to (contents of selection of front document)
-- 置き換えを実行します
-- なお、utf8toutf at http://www.fsci.fuk.kindai.ac.jp/aftp/pub/ptex/utils/
set (contents of selection of front document) to (do shell script "echo ¥"" & string_utf8 & "¥" | utf8toutf")
end tell
  • 新規文書 (ウィンドウ) を作成
set theText to "* " & ((current date) as string) & return
tell application "CotEditor"
	activate
	if not (exists front document) then make new document
	if contents of front document is not "" then make new document
	set contents of front document to theText
end tell
  • 単語の数や文字数を数え上げる
tell front document of application "CotEditor"
	set theText to text of it
	-- set theText to contents of selection -- 選択範囲を処理
	display dialog "ワードカウント結果" & return & return & ¬
		"文字数:" & number of every character of theText & return & ¬
		"単語数:" & number of every word of theText & return & ¬
		"段落数:" & number of every paragraph of theText
end tell

Wiki内の関連ページ