0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

サクラエディタマクロ(C関数Grep)

Last updated at Posted at 2022-06-07

サクラディタのマクロ

C言語の関数をGrep

C関数Grep.js
var str1 = '^[_a-zA-Z][^\\(=;:]*[\\t ]+\\**[_a-zA-Z][_a-zA-Z0-9]*\\([^;]*$';
var str2 = "*.c";
var int4 = 0x4631d;
var int5 = 0x63;
var str3 = FolderDialog("フォルダを指定", ExpandParameter("$e"));
if(str3){
    Grep(str1, str2, str3, int4, int5);
}

int4のパラメータは

を参照(少し記述が食い違っているような気がしますが)してお好みで変えてください。

正規表現のパターンは

から流用させていただきました。

Grep結果をタグファイル化

Grep結果タグ化.mac
SetDrawSwitch(0);
AddRefUndoBuffer(); // Redo用

// Grep結果以外の部分を削除
S_GoFileTop(0); // ファイルの先頭に移動

//S_ReplaceAll('^□検索条件', '', 2860);
S_ReplaceAll('^検索対象', '', 2860);
S_ReplaceAll('^フォルダ', '', 2860);
S_ReplaceAll('^除外ファイル', '', 2860);
S_ReplaceAll('^除外フォルダ', '', 2860);
S_ReplaceAll('^    \\(', '', 2860);

S_ReplaceAll('^\\r\\n', '', 2860);

S_ReplaceAll('^\d+ 個が検索されました。', '', 44);

// 整形処理
S_ReplaceAll('^・', '.\\\\', 44);    // 行頭の・を相対パスに置換
S_ReplaceAll('\\t', '    ', 44);    // TAB→空白置換
S_ReplaceAll('(^.*?)\\(', '$1\\t', 44); // すべて置換
S_ReplaceAll('(^.*?),\\d+\\)  \\[\S{3,9}\\]: +', '$1\\t', 44); // すべて置換
S_GoFileTop(0); // ファイルの先頭に移動


S_SelectAll(0); // すべて選択
S_Copy(0);  // コピー
S_CancelMode(0);    // 各種モードの取り消し

S_SearchClearMark(0);   // 検索マークの切替え
SetDrawSwitch(1);
SetUndoBuffer();
S_ReDraw(0);    // 再描画

のGrep結果成型の改造です。

テキスト保存してもF12でタグジャンプできるようになります。
ctagsを使ったタグジャンプと併用すると便利かと。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?