function 定義や、Variablesの定義を、コードの上に書いている方向け、 選択範囲(or カーソルのある単語)のID(FunctionやVariable)で、開いているソースを上から検索するマクロ
個人的には、ctrl+Shift+Fに割り当てて使うと、使い勝手が良い。
(function(){
//
// 選択されたwordで上を検索する
// local method
var deleteChars = function(str, chars){
if(typeof(chars) === 'undefined') chars = '\s';
var regx = new RegExp('[' + chars + ']', 'g');
return (str.replace(regx, ''))
}
var get_target = function(expandParam){
// $F : opened file's full path
// $f : opened file's name
// $e : opened file's folder path
// $b : opened file's extention
// $C : 選択中の場合、選択テキストの1行目のテキスト(改行コード除く)
// 選択中でない場合、カーソル位置の単語
var ret = Editor.ExpandParameter(expandParam);
return ret;
};
function doProcess(){
var target_ = get_target('$C');
var searchopt_str = "11-0000" ;
var searchopt = deleteChars(searchopt_str,'\-');
var sopt = parseInt(searchopt,2);
//var line_num = 0;
//Editor.Jump(line_num);
Editor.SearchNext(target_,sopt)
}
// --------------------------------------- entry point
if(typeof(Editor) !== 'undefined'){
doProcess();
} else {
if(typeof(WScript) !== 'undefined'){
WScript.Echo('This script is for sakura macro. A env is maybe wsh.')
} else {
console.log('This script is for sakura macro. A env is maybe node.')
}
}
}())