// // まとめて閉じる v1.02 (2005/09/02) // Made by IKKI http://www18.big.or.jp/~fujiwara/ikki/ // // 2005/09/02 v1.02 [保存する] or [問い合わせる] で [Grep結果は保存しない] = ON のとき、Grep結果ウィンドウへ切り替えない(高速化?) // 無題ウィンドウで保存ダイアログをキャンセルしたら処理全体を中止 // 2005/08/31 v1.01 ダイアログ表示中に秀丸のウィンドウを切り替えると違うウィンドウが閉じられるバグ修正 // 2005/08/31 v1.0 初版 // #debug = 1; #orghandle = hidemaruhandle(0); openfile "/h"; #tmphandle = hidemaruhandle(0); call LoadDengakuDLL; call Dialog; call Execute; call FreeDengakuDLL; setactivehidemaru #tmphandle; exit; endmacro; //.----- ダイアログ ---------------------------------------------------------------------------- Dialog: call BeginDialog; while (!#action) { call WaitNotify; ##notify = ##return; call UpdateDialog ##notify; } call EndDialog; return; BeginDialog: ##_ = dllfunc("NEWDIALOG", "まとめて閉じる", 80); // メッセージ ##_ = dllfunc("NEWCONTROL", "text", "", "閉じるウィンドウを選択してください(&W):"); // チェックリスト ##_ = dllfunc("NEWCONTROL", "chklist", "lList", ""); ##_ = dllfunc("SETCTRLHEIGHT", "", 20); ##i = 1; // 自分 (#tmphandle) は除く while (##i < hidemarucount) { if (filetype[##i] == "new") { ##_ = dllfunc("SETCTRLITEM", "lList", "(無題)", ##i); } else if (filetype[##i] == "grep") { ##_ = dllfunc("SETCTRLITEM", "lList", "(grep結果)", ##i); } else if (filetype[##i] == "exeresult") { ##_ = dllfunc("SETCTRLITEM", "lList", "(実行結果)", ##i); } else { ##_ = dllfunc("SETCTRLITEM", "lList", filename2[##i], ##i); } #handleof[##i] = hidemaruhandle(##i); $all = $all + str(##i) + ","; ##i = ##i + 1; } $all = leftstr($all, strlen($all) - 1); ##_ = dllfunc("SETCTRLSTATE", "lList", $all); // オプション ##_ = dllfunc("NEWCONTROL", "button", "bCheck", "全選択(&A)"); ##_ = dllfunc("SETCTRLNOTIFY", "", "101"); ##_ = dllfunc("SETCTRLWIDTH", "", 12); ##_ = dllfunc("NEWCONTROL", "button", "bUncheck", "全解除(&D)"); ##_ = dllfunc("SETCTRLNOTIFY", "", "102"); ##_ = dllfunc("SETCTRLWIDTH", "", 12); ##_ = dllfunc("NEWPAGE", 80); ##_ = dllfunc("NEWCONTROL", "text", "", "更新されてたら(&S):"); ##_ = dllfunc("SETCTRLWIDTH", "", 14); ##_ = dllfunc("NEWCONTROL", "cmblist", "lSave"); ##_ = dllfunc("SETCTRLNOTIFY", "", "201,201"); ##_ = dllfunc("SETCTRLWIDTH", "", 14); ##_ = dllfunc("SETCTRLITEM", "", "保存する", "1"); ##_ = dllfunc("SETCTRLITEM", "", "問い合わせる", "2"); ##_ = dllfunc("SETCTRLITEM", "", "保存しない", "3"); ##_ = dllfunc("SETCTRLSTATE", "", "1"); ##_ = dllfunc("NEWCONTROL", "text", "", ""); ##_ = dllfunc("SETCTRLWIDTH", "", 2); ##_ = dllfunc("NEWCONTROL", "check", "cKill", "Grep結果・実行結果は更新されてても保存しない(&G)"); ##_ = dllfunc("SETCTRLSTATE", "", "0"); // ボタン ##_ = dllfunc("NEWPAGE", 80); ##_ = dllfunc("NEWCONTROL", "text", "", ""); ##_ = dllfunc("SETCTRLWIDTH", "", 56); ##_ = dllfunc("NEWCONTROL", "defbutton", "bOK", "OK"); ##_ = dllfunc("SETCTRLNOTIFY", "", "1"); ##_ = dllfunc("SETCTRLWIDTH", "", 12); ##_ = dllfunc("NEWCONTROL", "button", "bCancel", "キャンセル"); ##_ = dllfunc("SETCTRLNOTIFY", "", "0"); ##_ = dllfunc("SETCTRLWIDTH", "", 12); if (!dllfunc("SHOWDIALOG", 0, 0)) call Error "マクロのエラーです\n発生位置: BeginDialog"; call _lSave; return; EndDialog: $list = dllfuncstr("GETCTRLSTATE", "lList"); #save = val(dllfuncstr("GETCTRLSTATE", "lSave")); #kill = val(dllfuncstr("GETCTRLSTATE", "cKill")); if (#debug) message $list + "\n" + str(#save) + "\n" + str(#kill); if (!dllfunc("ENDDIALOG")) call Error "マクロのエラーです\n発生位置: EndDialog"; return; WaitNotify: // ##return = 通知コード while (true) { $$n = dllfuncstr("WAITCTRLNOTIFY", 10); if ($$n != "") return val($$n); } return 0; // NOTREACHED UpdateDialog: // ##1 = 通知コード #action = 0x00; if (##1 == 0) #action = 0x10; // キャンセル else if (##1 == 1) #action = 0x11; // 実行 else if (##1 == 101) call _bCheck; // 全選択 else if (##1 == 102) call _bUncheck; // 全解除 else if (##1 == 201) call _lSave; // 更新されてたら return; _bCheck: ##i = 1; while (##i <= hidemarucount) { $$s = $$s + str(##i) + ","; ##i = ##i + 1; } ##_ = dllfunc("SETCTRLSTATE", "lList", $$s); return; _bUncheck: ##_ = dllfunc("SETCTRLSTATE", "lList", ""); return; _lSave: ##_ = dllfunc("ENABLECTRL", (dllfuncstr("GETCTRLSTATE", "lSave") != "3"), "cKill"); return; //.----- 実行 ---------------------------------------------------------------------------------- Execute: if (#action == 0x10) return false; if ($list == "") return false; ##h[0] = #handleof[val(dllfuncstr("GETTOKEN", $list, ","))]; ##k = 1; while (dllfunc("HASMORETOKENS")) { ##h[##k] = #handleof[val(dllfuncstr("GETTOKEN", "", ","))]; ##k = ##k + 1; } disabledraw; // 保存しない if (#save == 3) { setactivehidemaru #tmphandle; ##i = 0; while (##i < ##k) { closehidemaruforced ##h[##i]; ##i = ##i + 1; } } // 保存する/問い合わせる else { // Grep結果・実行結果を先に閉じる if (#kill) { setactivehidemaru #tmphandle; ##i = 0; while (##i < ##k) { if (filetype[##h[##i]] == "grep" || filetype[##h[##i]] == "exeresult") { closehidemaruforced ##h[##i]; } ##i = ##i + 1; } } // 保存する if (#save == 1) { ##i = 0; while (##i < ##k) { setactivehidemaru ##h[##i]; if (updated) { save; if (!result) return false; } setactivehidemaru #tmphandle; closehidemaruforced ##h[##i]; ##i = ##i + 1; } } // 問い合わせる else { ##i = 0; while (##i < ##k) { setactivehidemaru ##h[##i]; if (updated) { enabledraw; setactivehidemaru #tmphandle; $$ans = dllfuncstr("MSGBOX", basename2[##h[##i]] + " は更新されています。保存しますか?", "/b yesnocancel /i exclamation", "秀丸エディタ"); if ($$ans == "cancel") return false; if ($$ans == "yes") { setactivehidemaru ##h[##i]; save; if (!result) return false; } disabledraw; } setactivehidemaru #tmphandle; closehidemaruforced ##h[##i]; ##i = ##i + 1; } } } enabledraw; return true; //.----- 共通サブルーチン ---------------------------------------------------------------------- LoadDengakuDLL: loaddll currentmacrodirectory + "\\DengakuDLL.dll"; if (!result) loaddll macrodir + "\\DengakuDLL.dll"; if (!result) loaddll "DengakuDLL.dll"; if (!result) call Error "DengakuDLL.dll がロードできません。\nHidemaru.exe と同じフォルダかマクロファイル用のフォルダに置いてください"; if (dllfuncstr("GETVERSION") < "2.80") call Error "田楽 DLL v2.80 以降をインストールしてください"; return; FreeDengakuDLL: freedll; return; Error: // エラー if ($$1 != "") message currentmacrobasename + ": " + $$1; freedll; setactivehidemaru #tmphandle; exit; endmacro; // (C) IKKI 2005