//grepの結果に検索文字列が使用されている関数名を追記するマクロ
//①タブモード
//②grep結果ウィンドウを右端に置いておく
//③grep結果ウィンドウをアクティブにしてから実行
call Initialize;
call Main;
call Finalize;
endmacro;
Initialize:
disabledraw; //画面の更新を抑止
//grep結果バックアップ
call AllCopy;
newfile; //新規ファイルを開く(resultまとめ用)
newfile; //新規ファイルを開く(grep結果バックアップ)
call AllPaste;
prevtab;
prevtab;
//grep結果の行数カウント
gofileend; //ファイルの末尾にカーソルを移動
#MAX_COLUMNS = y; //カーソル位置(行)を取得
gofiletop; //ファイルの先頭にカーソルを移動
#lineNo = 0;
$C_FUNC_SEIKI_GREP = "^[_a-zA-Z][^\\(=;:]*[\\t ]+\\**[_a-zA-Z][_a-zA-Z0-9]*\\([^;]*$"; //関数名取得正規表現(C言語)
$FILE_NAME_X = "):"; //ソース名を抽出するために利用
return;
Main:
while ( #MAX_COLUMNS > #lineNo )
{
call SearchFunction;
}
nexttab;
replaceall "\n【改行削除用文字列】", "",regular;
call AllCopy;
prevtab;
call AllPaste;
return;
SearchFunction:
#lineNo = #lineNo + 1;
moveto2 0, #lineNo;
selectline;
$findText = gettext(seltopx,seltopy,selendx,selendy); //grep結果のある一行
#fileNameEndNo = strstr( $findText, $FILE_NAME_X ); //ファイル名までの文字盤目を検索
$fileName = leftstr( $findText, (#fileNameEndNo + strlen($FILE_NAME_X)) ); //ファイル名抽出
$grepText = rightstr( $findText, (strlen($findText) - #fileNameEndNo - strlen($FILE_NAME_X)) ); //検索文字列抽出
tagjump;
searchup2 $C_FUNC_SEIKI_GREP, regular; //関数名を上方向に検索
if(result)
{
selectline;
$functionText = gettext(seltopx, seltopy, selendx, selendy); //関数名取得
}
else
{
message "関数がみつかりません。";
}
backtagjump;
nexttab;
insert $fileName + "\t" + $functionText + "【改行削除用文字列】" + $grepText;
prevtab;
return;
Finalize:
enabledraw; //画面の更新を許可します
message "完了";
return;
//*****************************//
AllCopy:
selectall;
copy;
return;
AllPaste:
selectall;
paste;
return;
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme