TextEdit
提供: MacWiki
テキストエディット (TextEdit) とは?
Mac OS X 標準のテキストエディタ。 標準でリッチテキスト、標準テキスト、ワード、HTMLなどのフォーマットを扱うことができる。
機能
- 表
フォーマットメニューからテキスト > 表...とすれば、表を扱うことができる。
- ショートカット
Emacsのようなショートカットキーが使える。
control - f (前方へ一文字すすむ:[←]) control - b (後方へ一文字もどる:[→]) control - p (上の行へ:[↑]) control - n (下の行へ:[↓]) control - a (段落の最初へ:行頭へ) control - e (段落の最後へ:行末へ) control - v (下のページへ:文末へ) control - d (一文字削除 前方へすすむ:デリート) control - h (一文字削除 後方へもどる:バックスペース) control - t (文字の入れ替え:カーソルの左右の文字を入れ替えます) control - y (カットされていたテキストが挿入される:commad-vと使い分けると素晴らしい) control - k (カーソル位置から行末までカット:control - yでカットされていたテキストが挿入される) control - o (カーソル位置に改行を挿入:カーソルは移動しない) esc 単語の途中で候補を示す(ヘルプにはOpt-ESCとあるが?)
AppleScript
- 新規文書 (ウィンドウ) を作成
set theText to "* " & ((current date) as string) & return -- 新規文書に書き込む文字列(ここでは日時) tell application "TextEdit" activate if not (exists front document) then make new document if text of front document is "" then set theDoc to front document else set theDoc to make new document end if set text of theDoc to theText -- set size of text of theDoc to 14 end tell
- http://www.drycarbon.com/applescript/tips/karino/launch.html launch, run, activate
- 最前面の文書に新規段落を作成
-- set theText to "* " & ((current date) as string) -- 新規段落として書き込む文字列(ここでは日時) set theText to "* " & (do shell script "date '+%F %R (%Z)'") -- date コマンドを利用 tell application "TextEdit" activate if not (exists front document) then make new document tell front document if (exists last character) and (last character is not return) then make new character at end of characters of it with data return make new paragraph at end of paragraphs of it with data theText with properties {size:10, color:{0, 65535, 0}} -- 文字のサイズや色も指定できる make new character at end of characters of it with data return with properties {color:{0, 0, 0}} -- 色を黒に戻す end tell end tell
文字色のRGBの数値は、新規文書に適当な色の文字列を入力してから以下のようなスクリプトをAppleScriptエディタ(スクリプトエディタ)で実行することで調べられます(結果のところに表示される)
tell front document of application "TextEdit" to get color of first word
- 単語の数や文字数を数え上げる
tell front document of application "TextEdit" set charCount to number of characters -- characters の代わりに every character でもいい -- set charCount to count characters -- count を使ってもいい set wordCount to number of words -- words の代わりに every word でもいい -- set wordCount to count words set paraCount to number of paragraphs -- paragraphs の代わりに every paragraph でもいい -- set paraCount to count paragraphs display dialog "ワードカウント結果" & return & return & ¬ "文字数:" & charCount & return & ¬ "単語数:" & wordCount & return & ¬ "段落数:" & paraCount end tell
- 最前面の文書を保存
set theName to "untitled.rtfd" -- リッチテキスト -- set theName to "untitled.txt" -- 標準テキスト tell application "TextEdit" -- なぜか.rtfdでは保存、.txtでは別名で保存のような扱いになる save front document in (choose file name default name theName) -- save front document in (choose file name default name theName default location (path to desktop folder)) -- save front document in ((path to desktop folder) as string) & theName end tell
関連するソフトウェア
- rtfd2html
RTFD(添付ファイル付きリッチテキスト)ファイルをhtmlファイルに変換するアプリケーション。textutilコマンドのラッパー。
http://pencilsoftware.com/rtfd2html.html