//メニューを表示する位置 0=caret, 1=mouse #menuSelect = 1; //パスがスラッシュで終わってる時に尻へ補完するファイル名 $indexFileName = "index.html"; //今のカーソル位置を記憶 #currentX = x; #currentY = y; //パスを取得 call getPath; $file = $$return; //取得パスがURLならそのままIEに渡す if (strstr($file, "http://") != -1) call execute 2; else { //メニュー項目用配列 $menuText[0] = "秀丸"; $menuText[1] = "IE"; //返ってきた識別子により実行モードを分岐 call extCheck $file; if ($$return == "Hidemaru") call execute 1; else if ($$return == "IE") call execute 2; else { if (#menuSelect == 1) menuarray $menuText, 2; else mousemenuarray $menuText, 2; call execute result; } } endmacro; //// マクロ終了 //// 以下関数群 //ファイルを開く execute: //秀丸で開く if (##1 == 1) openfile $file; //レジストリからIEのパスを取得して起動 else if (##1 == 2) { //IE openreg "LOCALMACHINE", "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\IEXPLORE.EXE"; if (!result) { message "IEがないよ?"; call exit; } $appPath = getregstr(""); closereg; run $appPath + " \"" + $file + "\""; } call exit; return; //パスを取得 getPath: //選択されてる時はそのまま取得、さらにhttp://が含まれていれば直で返す if (selecting) { $$path = gettext(seltopx, seltopy, selendx, selendy); if (strstr($$path, "http://") != -1) return $$path; } else { //カーソル位置のパスを取得 searchup "[\"']", regular; //文頭へ向かって " ' を検索 right 1; //選択解除してカーソル位置合わせ ##selTopX = x; ##selTopY = y; searchdown2 "[a-zA-Z/]+[?#]?[0-9a-zA-Z_~.\\-=/#&%:;]*[\"']", regular; //拡張子+許可文字を検索 right 1; //選択解除してカーソルを右端に left 1; //カーソル位置合わせ $$path = gettext(##selTopX, ##selTopY, x, y); if ($$path == "" || strstr($$path, " ") != -1) { message "パスを識別できませんでした"; call exit; } //URLの時 if (leftstr($$path, 7) == "http://") return $$path; //index指定の時は尻にindexファイル名を追加 if (rightstr($$path, 1) == "/") $$path = $$path + $indexFileName; //ルート指定の時はドライブレター+取得したパス if (leftstr($$path, 1) == "/") return leftstr(directory, 2) + "/" + midstr($$path, 1, strlen($$path)); } //相対階層がある時は数を勘定(同時に$$pathから"../"を除く) ##raise = 0; //上がる階層数 if (strstr($$path, "../") != -1) { while (strstr($$path, "../") != -1) { call clipRight $$path, "/"; $$path = $$return; ##raise = ##raise +1; } } //現在のディレクトリを\で分割して配列に格納(split) $$tmp = directory; ##dirLength = 0; while (strstr($$tmp, "\\") != -1) { call clipLeft $$tmp, "\\"; $$dirAry[##dirLength] = $$return; //頭のディレクトリを抜き出して配列に格納 call clipRight $$tmp, "\\"; $$tmp = $$return; //抜き出したディレクトリ部分を消去(余った部分に入れ替え) ##dirLength = ##dirLength +1; } $$dirAry[##dirLength] = $$tmp; //最後のディレクトリ //現在のパスから上がる階層分を引いて絶対パスを生成 $$returnPath = ""; ##tmpNum = 0; ##stopNum = ##dirLength - ##raise +1; //総階層数−上がる階層数+現在の階層分修正値 while (1) { $$returnPath = $$returnPath + $$dirAry[##tmpNum] + "/"; ##tmpNum = ##tmpNum +1; if (##stopNum == ##tmpNum) break; } return $$returnPath + $$path; //拡張子をチェックして実行モード識別子を返す extCheck: call clipRight $$1, "."; $$ext = $$return; //必ずIEで開く拡張子 $$ieAry[0] = "gif"; $$ieAry[1] = "GIF"; $$ieAry[2] = "jpg"; $$ieAry[3] = "JPG"; $$ieAry[4] = "png"; $$ieAry[5] = "PNG"; ##num = 0; while ($$ieAry[##num] != "") { if ($$ext == $$ieAry[##num]) return "IE"; ##num = ##num +1; } //メニューから選択する拡張子 $$htmlAry[0] = "htm"; $$htmlAry[1] = "HTM"; $$htmlAry[2] = "html"; $$htmlAry[3] = "HTML"; $$htmlAry[4] = "shtm"; $$htmlAry[5] = "SHTM"; $$htmlAry[6] = "shtml"; $$htmlAry[7] = "SHTML"; ##num = 0; while ($$htmlAry[##num] != "") { if ($$ext == $$htmlAry[##num]) return "Menu"; ##num = ##num +1; } //それ以外は必ず秀丸で開く return "Hidemaru"; //$$1の$$2から右を返す clipRight: ##num = strstr($$1, $$2); $$str = midstr($$1, ##num + strlen($$2), strlen($$1) - ##num); return $$str; //$$1の$$2から左を帰す clipLeft: ##num = strstr($$1, $$2); $$str = leftstr($$1, ##num); return $$str; //カーソル位置を戻してマクロ終了 exit: moveto #currentX, #currentY; endmacro; return;