/* * tags ファイルを作成する秀丸マクロ * * Ver.1.3 (2017-03-14) * * ディレクトリを上へと遡り、最初に見つかった prepare_tags_file.rb を実行します。 * 見つからなかった場合は秀丸エディタ標準の [tagsファイルの作成] ダイアログを表示します。 * * ※Rubyスクリプトを実行するには、Rubyをインストールしておく必要があります。 * http://rubyinstaller.org/ * * Yasunori Miyamoto * http://tipszone.jp/20121103_create_tags_file/ * mailto: nori@tipszone.jp */ $script_name = "prepare_tags_file.rb"; $command = "ruby " + $script_name + " --pause"; call FIND_SCRIPT $script_name; $script_dir = $$return; if ($script_dir == "") { run hidemarudir + "\\HIDETAGS.EXE"; } else { runex $command, 0, //sync 0:async 1:sync 0, "", //stdin 0:none 1:auto 2:file 3:(reserve) 4:all 5:select 0, "", //stdout 0:none 1:auto 2:file 3:add file 4:new 5:insert 6:replace 7:output frame 0, "", //stderr 0:none 1:=out 2:file 3:add file 4:new 5:insert 6:replace 7:output frame 2, $script_dir + "\\", //folder 0:none 1:current 2:specify 3:(reserve) 4:exe's folder 1, //show 0:auto 1:show 2:hide 0, //nodraw 0:draw 1:no draw 0; //unicode 0:ansi 2:unicode } endmacro; // ディレクトリを上へと遡り、引数で指定されたファイルを探す // Param: string ファイル名 // Return: string ファイルが見つかったディレクトリのフルパス // 見つからなかった場合は空文字列 FIND_SCRIPT: $$dir = directory; // ルートディレクトリの場合のみ末尾に \ がついているので、 // 他の場合と統一するために削除 if (rightstr($$dir, 1) == "\\") { $$dir = midstr($$dir, 0, strlen($$dir) - 1); } while ($$dir != "") { if (existfile($$dir + "\\" + $$1)) { return $$dir; } call PARENT_DIRECTORY, $$dir; $$dir = $$return; } return ""; // 親ディレクトリのパスを返す // Param: string パス // Return: string 親ディレクトリのパス // 親ディレクトリが存在しない場合は空文字列 PARENT_DIRECTORY: ##i = strrstr($$1, "\\"); if (0 < ##i) return leftstr($$1, ##i); return "";