PHPの文法エラー行にマークをつけて移動するDMonkeyマクロ
VxEditorで使えるマクロです。ステータスバーにはエラーの内容が表示されます。
ソース
// phplint.dms var e = new Editor; var w = new Window; // マークをすべてはずす for( var i = 0; i < e.LineCount; i++){ e.SetMarked(i,false); } // 編集中のファイルのディレクトリを得る var dir = new File(w.FileName).extractPath(); // アウトプットファイルの名前を設定 var phplintfile = new File(w.FileName).extractName() + '.phplint.txt'; // cmd.exeを通じて起動 var cmd = 'cmd /c cd ' + dir + ' &php -l ' + w.FileName + ' > ' + phplintfile; new ActiveXObject('WScript.Shell').Run(cmd,0,true); // php lint の結果を取得 var f = new File(dir + phplintfile); f.open(); var result = f.read(); f.close(); f.remove(); // エラー行の取得 var reg = new RegExp(w.FileName.replace(/\\/g,'\\\') + ' on line (\d+)','i'); // エラー行にマークをつけて移動 if(reg.exec(result) != null){ e.SetMarked(parseInt(reg.$1)-1,true); e.Row = parseInt(reg.$1); e.TopRow = parseInt(reg.$1) - e.RowCount / 2; } // ステータスバーに表示 w.Status = result;