PPvを分割して別のPPvを開いたり閉じたりする動作が気に入ったので、PPv+EBWIN4もこの形式にしてみる。
必要なもの
EBWIN4には、EPWING形式の辞書をあらかじめ登録しておこう。
準備
以下の二つのファイルをScriptフォルダに保存する。dic.luaのEBWIN4のパスは環境に応じて読み替えてください。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--EBWIN4で検索した結果をファイルに出力 | |
--第一変数:検索語 | |
--第二変数:出力ファイルパス | |
ebwin="D:\\bin\\EBWIN4\\ebwinc.exe /C=1 /E=u" | |
nyagos.exec(ebwin .. " " .. arg[1] .. " > " .. arg[2]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//!*script | |
// PPvのカーソル位置にある文字を返す | |
// 単語が空白区切りであることが前提 | |
// 例: *linemessage %*script(%0\Script\selectword.js) | |
var linetext = PPx.Extract('%*selecttext'); | |
var lh = PPx.Extract('%lH'); | |
// var blankpos = linetext.indexOf( ' ' ); | |
// 文字列を左右に分割し、空白前/後を削除 | |
var lstr = linetext.substr( 0, lh ).replace(/.*\s(.*?)$/, '$1'); | |
var rstr = linetext.substr( lh ).replace(/^(.*?)\s.*/, '$1'); | |
// 文字列を再結合 | |
var str = lstr+rstr; | |
// 句読点等を取り除く | |
var result = str.replace(/(\.|\,|\"|\'|\!|\?|\;|\:)/g, ''); | |
// ’以前を取り除く。フランス語の単語抽出用 | |
var result = result.replace(/.*’(.*)$/, '$1'); | |
// 文字数が45を超えていれば以降のコマンド実行を中止 | |
if (result.length > 45){ | |
PPx.SetPopLineMessage("文字数が多すぎます"); | |
PPx.Quit(-1); | |
} | |
PPx.Result = result; | |
PPx.Quit(); |
以下を編集して取込。
_Command = { ; ユーザコマンド・関数
splitppv = *string i,height0=%*windowrect(,h)
*string i,height1=%*calc("%*arg(2)*%*windowrect(,h)/100")
*string i,height2=%*calc("%*windowrect(,h)-%si"height1"")
*windowsize %N,%*windowrect(,w),%si"height1"
*ppv -bootid:X -k %%J"%*arg(1)" %%: *fitwindow %N,%%N,4 %%: *windowsize %%N,%*windowrect(,w),%si"height2" %%: *selectppx %n
ebwin2ppv = *string i,ratio=%*arg(1)
*string i,tempfile=%*temp(name,f)
%Oi nyagos -f %0Script\dic.lua %*script(%0Script\selectword.js) %si"tempfile"
*ifmatch 0,0%NVX %: *splitppv %si"tempfile",%si"ratio" %: *mapkey use,K_splitppv %: *stop
*execute VX,%%J%si"tempfile"
}
K_splitppv = {
Q ,*ifmatch !0,0%NVX %: %Oi *windowsize %N,%*windowrect(,w),%si"height0"
*mapkey delete,K_splitppv
*closeppx "%n,VX"
ENTER ,*ifmatch !0,0%NVX %: %Oi *windowsize %N,%*windowrect(,w),%si"height0" %: *closeppx VX %: *stop
*splitppv %si"tempfile",%si"ratio"
}
やり方
[I]でキャレットモードにしてから、辞書を引きたい単語を範囲選択して、以下のコマンドを実行する。
*ebwin2ppv 50
引数で分割の割合を変更できる。単位は百分率。半分にしたかったら50、四分の一なら75、とすればいい。 僕はマウス中クリックでこのコマンドを起動するようにしている。
MV_click = { ; PPv メイン窓
M_SPC ,*ebwin2ppv 50
}
0 件のコメント:
コメントを投稿