Skip to content

Instantly share code, notes, and snippets.

@dck-jp
Last active August 29, 2015 13:57
Show Gist options
  • Save dck-jp/9404589 to your computer and use it in GitHub Desktop.
Save dck-jp/9404589 to your computer and use it in GitHub Desktop.
grep by pt in Hidemaru Editor
/* ptでgrep検索するマクロ (β)
実行結果は「アウトプット枠」へ書き出します。
【特徴】
ptでのgrep結果を即座に確認できます。
【動作環境】
秀丸エディタ ver8.01 で動作を確認。(ver8 以降なら動くはず。)
【インストール】
$g_search_directory にgrepの対象となるディレクトリのパスを代入してください。
$g_pt_pathにptのパスを代入して下さい。
秀丸のマクロディレクトリへコピーしたらキーアサインして下さい。
【動作】
$g_search_directory を検索対象とします。
選択中の文字列を用いて、ptでgrepを行います。
(選択文字列がない場合は、入力ダイアログが出ます。)
【連絡先】
D*isuke YAMAKAWA
WEB: http://www.clockahead.com/
【謝辞】
本マクロのコードの大部分は、@ohtorii様の「秀丸エディタでC#のコードを実行するマクロ」を
流用させて頂きました。この場を借りてお礼を申し上げます。
https://github.com/ohtorii
pt (Platinum Searcher)は、@monochromegane様作の日本語環境に対応した次世代grep検索ツールです。
大変便利なツールを作成頂きありがとうございます。
参考:
Go言語でag(The Silver Searcher)ライクな高速検索ツールをつくった。EUC-JP/Shift-JISも検索できマス。 - Thinking-megane
http://blog.monochromegane.com/blog/2014/01/16/the-platinum-searcher/
*/
$g_search_directory = "D:\\hogehoge\\VBACode";
$g_pt_path = "D:\\bin\\tool\\pt.exe";
call Main;
endmacro;
Main:
$$save = searchbuffer;
##save = searchoption;
disablehistory 0x0001| 0x0002| 0x0004| 0x0008| 0x0010| 0x0020| 0x0040| 0x0080;
disabledraw;
disableinvert;
##old_x=x;
##old_y=y;
call Start;
moveto ##old_x,##old_y;
setsearch $$save, ##save;
return ##return ;
Start:
if (!selecting) { $$word = input("検索文字列を指定してください",""); }
else { $$word = gettext(seltopx, seltopy, selendx, selendy); }
$$command = $g_pt_path + " " + $$word + " --nocolor " +$g_search_directory;
call SpawnExe $$command;
return true;
SpawnExe:
$$exe = $$1 ;
runex $$exe
, 1 //sync 0:async 1:sync
, 0, "" //stdin 0:none 1:auto 2:file 3:(reserve) 4:all 5:select
, 7, "" //stdout 0:none 1:auto 2:file 3:add file 4:new 5:insert 6:replace
, 1, "" //stderr 0:none 1:=out 2:file 3:add file 4:new 5:insert 6:replace
, 2, $$current_dir //folder 0:none 1:current 2:specify 3:(reserve) 4:exe's folder
, 2 //show 0:auto 1:show 2:hide
, 1 //nodraw 0:draw 1:no draw
, 0 //unicode 0:ansi 2:unicode
;
if(! result){
message("runex で失敗。!result");
return false;
}
return true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment