Tex-Edit Plus の書類内で選択されているテキストを Google で検索するためのアップルスクリプトです。
使用方法:
-
Tex-Edit Plus の書類内でテキストを選択します。
-
Tex-Edit Plus のスクリプトメニューからアップルスクリプトを選択します(キーボードショートカットでアップルスクリプトを実行させることもできます)。
-
選択テキストは Google で検索されます(検索はデフォルトブラウザ内で開かれます)。
スクリプトの作成方法
- 下記のテキストをアップルのスクリプトエディタアプリケーションの新規書類へコピーします。
- スクリプトエディタのファイルメニューの「保存...」コマンドを選択します。
- 表示される保存ダイアログでアプリケーション名を入力して、保存場所を選択します。
- 保存ダイアログの「フォーマット」ポップアップメニューから「スクリプト」オプションを選択します。
- 保存ダイアログの「オプション」セクションの「実行専用」チェックボックスを選択します。
- 保存ダイアログの「保存」ボタンをクリックします。
Tex-Edit Plus を起動する時に「Scripts」フォルダに入っているコンパイル済みスクリプトは全て「スクリプト」メニュー内で表示されます。「Scripts」フォルダは
Tex-Edit Plus アプリケーションと同じフォルダに入っていないとこの機能は無効になります。また、「Scripts」フォルダの名前を変更するとこの機能は無効になります。AppleScripts for Tex-Edit Archive の
ホームページから多数の
Tex-Edit Plus 用アップルスクリプトをダウンロードすることもできます。
Tex-Edit Plus のスクリプトメニュー内のアップルスクリプトのキーボードショートカット設定(※すべて半角ローマ字で設定します)
- コマンド:スクリプト名の最後に「_」(1つ)を追加します(例:私のスクリプト_0)。
- シフト+コマンド:「__」(2つ)を追加します(例:私のスクリプト__0)。
- ファンクションキー:「_」(1つ)+ F キーを追加します(例:私のスクリプト__F5)。
- コマンド+ファンクションキー:「__」(2つ)+ F キーを追加します(例:私のスクリプト__F5)。
- シフト+コマンド+ファンクションキー:「___」(3つ)+ F キーを追加します(例:私のスクリプト___F5)。
property baseURL : "http://www.google.co.jp/search?hl=ja&q="
tell application "Tex-Edit Plus"
if selection is not "" then
set sel to my fixChars(selection)
else
try
display dialog "テキストは選択されていません。" buttons {"キャンセル"} default button 1 with icon 2 giving up after 15
end try
error number -128
end if
end tell
set theURL to (baseURL & (my replaceChars(sel, " ", "+"))) as text
try
tell application "Finder"
open location theURL
end tell
end try
on replaceChars(txt, srch, rep)
set tid to AppleScript's text item delimiters
try
set AppleScript's text item delimiters to srch
set ev to every text item of txt
set AppleScript's text item delimiters to rep
set txt to ev as string
on error errStr number errNum
set AppleScript's text item delimiters to sd
error errStr number errNum
end try
set AppleScript's text item delimiters to tid
return txt
end replaceChars
on fixChars(a)
set myDelims to {"!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "-", ¬
"-", "+", "=", ":", ";", "'", ",", ".", "/", "<", ¬
">", "?", "{", "}", "[", "]"}
repeat with currentDelim in myDelims
set AppleScript's text item delimiters to currentDelim
set s to every text item of a
set AppleScript's text item delimiters to {""}
set a to s as string
end repeat
end fixChars