// バージョン:1.03 // 公開日 :2004.11.23 // 連絡先 :siteCTS // 動作に必要なもの:田楽DLL $ini = macrodir + "\\Nepo103.ini"; //設定ファイルのパス $env = macrodir + "\\NepoEnv103.mac"; //環境設定マクロのパス //パス設定を変更する時は、環境設定マクロも同時に修正する必要があります。 //マクロ開始 call initialize; //マクロ終了 ////// ■ メイン関数群 ■ ////// 基本的に上から下へ実行 // &initialize 初期化 // initialize: disabledraw; $abs = ""; //ファイルの絶対パス $dir = ""; //フォルダの絶対パス $log = ""; //デバッグ用のテキスト //Ctrl,Shift,Altが押されていればメニューをキャレット(文字カーソル)に出す if (iskeydown(0x10) || iskeydown(0x11) || iskeydown(0x12)) #menuPosition = 1; //caret else #menuPosition = 0; //mouse //メニュー配列 $menuName[0] = ""; $menuPath[0] = ""; #menuSize = 0; //バッファ #currentX = x; #currentY = y; #selTopX = 0; #selTopY = 0; #selEndX = 0; #selEndY = 0; $sbuffer = searchbuffer; #soption = searchoption; //よく使う設定はグローバル変数に入れておく #log = getininum($ini, "General", "LogMode"); #EnvExpand = getininum($ini, "General", "EnvExpand"); #FolderOpen = getininum($ini, "General", "FolderOpen"); #FileSearch = getininum($ini, "General", "FileSearch"); #hitWebReplace = 0; //Webパス変換にヒットしたら1 #thisFile = 0; //現在編集中のファイルを対象にした時は登録拡張子がなくてもエディタメニューを強制追加 //田楽DLLロード loaddll hidemarudir + "\\DengakuDLL.dll"; if (!result) call error "「文字列からファイルを開くマクロ」\n\n田楽DLLのロードに失敗しました。\n" + hidemarudir +" に DengakuDLL.dll があるか確認してください。"; else if (!existfile($ini)) { call question "initialize : 設定ファイルが見つかりません\n\n開こうとした設定ファイルのパス = " + $ini + "\n\n「はい」  … 環境設定ダイアログを開きます。\n「いいえ」 … そのまま終了します。\n\n※初回起動では設定ファイルがないので、「はい」を押してください。"; if (##return) { call message "\"" + $ini + "\" を作ります。\nなにか問題があって設定を初期化したい時は、このファイルを削除してください。\n\n※環境設定マクロは重いので、起動に数秒かかります。(866MHzマシンで約4秒)"; execmacro $env; } goto exit; } //次へ if (selecting) goto acquirePath; else goto interpretPath; return; //initialize.end // interpretPath パス部分を解釈して選択 // interpretPath: if (!getininum($ini, "General", "FastSelect")) enabledraw; //セパレータ識別子が見つかるまで右へ行く while (code != ' ' && code != '"' && code != '\'' && code != '\t' && code != 0x0D && code != '>' && code != '|' && code != eof) right; ##sep = code; //セパレータを記憶 beginsel; //選択開始 //パスの左端まで選択する while (1) { left; if ( (x == 0 && y == 0) || code == '\t' || code == 0x0D || //ファイルの先頭・タブ・改行にきたら終了 code == '"' || code == '\'' || code == '|' || code == '<' || //セパレータを見つけたら終了 ##sep == code || //セパレータと同じ文字を見つけたら終了(空白) (code == ' ' && ##sep != '"' && ##sep != '\'' && ##sep != '>' && ##sep != '|' && ##sep != ' ') //セパレータがない時は空白が見つかるまで ) break; } //カーソル位置がセパレータの時は選択範囲を調整 if (code == '\t' || code == 0x0D || code == ' ' || code == '"' || code == '\'' || code == '<' || code == '|') right; endsel; //選択完了 disabledraw; goto acquirePath; //次へ return; //interpretPath.end // acquirePath パス文字列の取得 // acquirePath: #selTopX = seltopx; #selTopY = seltopy; #selEndX = selendx; #selEndY = selendy; //exitの再選択で使用 $abs = gettext(seltopx, seltopy, selendx, selendy); moveto #selTopX, #selTopY; beginsel; moveto #selEndX, #selEndY; endsel; //環境設定起動キーワード $$keyword = getinistr($ini, "General", "EnvsetKeyword"); if ($abs == $$keyword && $$keyword != "__EnvsetKeywordDisabled__") { if (#log) call log "acquirePath: 環境設定マクロの起動キーワードにマッチング"; execmacro $env; call exit; //取得文字列なし } else if ($abs == "") { if (getininum($ini, "General", "AltThisFile")) { $abs = filename; //現在のファイルを対象にする #thisFile = 1; //登録拡張子がなくてもエディタメニューを強制追加 } else { if (#log) call log "acquirePath: 取得できる文字列がありません"; call exit 2; } } if (#log) { if (#thisFile) { call log "acquirePath: 現在のファイルを対象に変更\n\t取得した文字列 = なし\n\t変更後のパス = " + $abs; } else { call log "acquirePath: 取得した文字列\n\t" + $abs;}} call replacePath; //パス変換 call envExpand $$return; //環境変数展開 $abs = $$return; //パスにエスケープとしての \\ が含まれる時は \ に置換 if (strstr($abs, "\\\\") != -1) { $$before = $abs; if (leftstr($abs, 4) == "\\\\\\\\") //ネットワークパスで先頭が \\\\ の時は先に // にして置換を避ける $abs = dllfuncstr("GSUB", $abs, "\\\\\\\\", "//", 1); if (leftstr($abs, 2) == "\\\\") //ネットワークパスで先頭が \\ の時は先に // にして置換を避ける $abs = dllfuncstr("GSUB", $abs, "\\\\", "//", 1); $abs = dllfuncstr("GSUB", $abs, "\\\\", "/", -1); //すべての \\ を / へ置換 if (#log) call log "acquirePath: エスケープ文字を検出\n\t変換前のパス = " + $$before + "\n\t変換後のパス = " + $abs; } $abs = dllfuncstr("GSUB", $abs, "\\", "/", -1); //すべての \ を / へ置換 //パス強制認識 if (getininum($ini, "General", "AbsMatchForced")) { ##letter = 0; //ドライブレター分の修正値 if (strstr($abs, "http://") != -1) $$find = "http://"; else if (strstr($abs, "https://") != -1) $$find = "https://"; else if (strstr($abs, "ftp://") != -1) $$find = "ftp://"; else if (strstr($abs, "file://") != -1) $$find = "file://"; else if (strstr($abs, "mailto:") != -1) $$find = "mailto:"; else if (strstr($abs, "./") != -1) $$find = "./"; else if (strstr($abs, "../") != -1) $$find = "../"; else if (strstr($abs, ":/") != -1) { $$find = ":/"; ##letter = 1;} if ($$find != "") { ##n = dllfunc("STRSTR2", $abs, $$find) - ##letter; if (##n > 0) { //パスが先頭にない call substr $abs, ##n; $$after = $$return; if (#log) call log "acquirePath: パス強制認識を適用\n\tキーワード = " + $$find + "\n\t変換前のパス = " + $abs + "\n\t変換後のパス = " + $$after; $menuName[0] = $$after + " として認識(パスを強制認識)"; $menuName[1] = $abs + " として認識(そのまま)"; #menuSize = 2; call showMenu; ##n = ##return; if (##n == 1) $abs = $$after; else if (##n != 2) call exit 3; } } } // call absMatchForced $abs; // $abs = $$return; //JavaScriptやCSSやPerlとかのコメントをパスと勘違いしないように //頭に // があるとネットワークパスと判断する //頭に /* があるとルートパスと勘違いする //頭に # があるとアンカーと勘違いする //"///" は "//" にしてもいい(ただし //remotePC/... 形式のネットワークパスには対応しなくなる) if (leftstr($abs, 3) == "///" || leftstr($abs, 2) == "/*" || leftstr($abs, 1) == "#") { if (#log) call log "acquirePath: コメントアウトかアンカーと判断\n\tパス = " + $abs; call exit 2; } //選択開始が行頭からで、末尾が ) : の時はタグジャンプ if (#selTopX == 0 && (rightstr($abs, 1) == ")" || rightstr($abs, 1) == ":")) { if (#log) call log "acquirePath: タグジャンプコマンドを発行\n\t認識したパス = " + $abs; moveto #currentX, #currentY; tagjump; call exit 4; } if ((strstr($abs, ".") == -1 && midstr($abs, 1, 1) != ":") && rightstr($abs, 1) != "/") { if (#log) call log "acquirePath: パスではない文字列と判断\n\t取得文字列 = " + $abs; call exit 2; } // w:/cts/lfs/?web goto createAbsolutePath; //次へ return; //acquirePath.end // createAbsolutePath 絶対パスの生成 // createAbsolutePath: call checkScheme $abs; //URL・メールアドレス・ネットワークパス・すでに絶対パス → そのまま if (##return || leftstr($abs, 2) == "//" || midstr($abs, 1, 2) == ":/") { $abs = $abs; //ルートパス → "ドライブレター+取得したパス" } else if (leftstr($abs, 1) == "/") { $abs = leftstr(directory, 2) + $abs; //カレントフォルダ → ./ を削除して "カレントディレクトリ+取得したパス" } else if (leftstr($abs, 2) == "./") { call substr $abs, 2; $abs = directory + "\\" + $$return; //相対パス → 絶対パスに変換 } else if (strstr($abs, "../") != -1) { //カレントディレクトリのパスを配列へ分割 $$dir[0] = dllfuncstr("GETTOKEN", directory, "\\"); ##n = 1; while (1) { if (!dllfunc("HASMORETOKENS")) break; $$s = dllfuncstr("GETTOKEN", "", "\\"); if ($$s != "") { $$dir[##n] = $$s; ##n = ##n +1; } } ##dirlength = ##n; $$file = dllfuncstr("GSUB", $abs, "../", "", -1); //"../"を削除 ##n = 0; ##stopNum = ##dirlength - dllfunc("STRCOUNT", $abs, "../"); //総階層数−上がる階層数 $abs = ""; //初期化して再生成 while (1) { $abs = $abs + $$dir[##n] + "\\"; ##n = ##n +1; if (##stopNum == ##n) break; } $abs = $abs + $$file; //その他 → "カレントディレクトリ+取得したパス" } else if ($abs != "") { $abs = directory + "/" + $abs; //取得文字列なし } else call exit 2; $abs = dllfuncstr("GSUB", $abs, "\\", "/", -1); //区切りは / に置換しておく if (#log) call log "createAbsolutePath: 取得文字列から生成した絶対パス\n\t" + $abs; goto createMenu; //次へ return; //createAbsolutePath.end // &createMenu ■選択メニュー作成 // createMenu: call clearMenu; //メニューを初期化 call cutFileName $abs; $dir = $$return; call checkScheme $abs; // mailto:かメールアドレス // cts@creasus.net if (##return >= 4) { call log "createMenu: メールアドレスと認識しました"; if (getininum($ini, "Mailer", "Use")) { if (##return == 4) { //mailto:を削除 call substr $abs, 7; $abs = $$return; } call replace $abs, "@", "@"; call replace getinistr($ini, "Mailer", "Option"), "$address$", $$return; $menuName[0] = "メールを送信 / コマンドライン = " + $$return; $menuPath[0] = "__SendMail__"; $menuName[1] = "メーラーを起動"; $menuPath[1] = "__SendMail__"; #menuSize = 2; goto executeMenu; } // Webパス // } else if (##return) { call log "createMenu: Webパスと認識しました"; call appendMenu "Browser"; goto executeMenu; // ファイラ // パスの末尾が / の時はファイラ } else if (rightstr($abs, 1) == "/") { call log "createMenu: フォルダのパスと認識"; call appendMenu "Filer"; call appendMenu "SearchFileMenu"; //他のファイルを検索 goto executeMenu; // クエリ選択 // "../?query" などファイル名がなくてクエリかアンカーがある時 } else if (strstr($abs, "/?") != -1 || strstr($abs, "/#") != -1) { call cutQueryString $abs; $menuName[#menuSize] = "クエリをカットしてファイラで開く → " + $$return; $menuPath[#menuSize] = $$return; #menuSize = #menuSize +1; call replacePath "Web"; //Webパス変換 if (#hitWebReplace) { //ヒットがあれば追加 $menuName[#menuSize] = "Webパスに変換してブラウザで開く → " + $$return; $menuPath[#menuSize] = $$return; #menuSize = #menuSize +1; } call appendMenu "SearchFileMenu"; goto executeMenu; } //以下はファイル名があるので存在チェック if (!existfile($abs)) { call cutQueryString $abs; if (!existfile($$return)) { //クエリをカットして再挑戦 if (#log) call log "createMenu: ファイルが存在しません。\n\t開こうとしたパス = " + $abs; call exit 2; } } //拡張子ごとの分岐 call checkExt $abs; $$res = $$return; if (#log) call log "createMenu: 拡張子ごとの分岐判定\n\t" + $$res; // Webパス変換 // エディタかブラウザを選択 html,xht,cgi,shtml if ($$res == "Webパス変換") { $$webpath = $abs; call cutQueryString $abs; $$abs = $$return; $menuName[0] = $$abs + " をエディタで開く"; $menuPath[0] = $$abs; $menuName[1] = $$abs + " をブラウザで開く"; $menuPath[1] = $$abs; #menuSize = 2; call replacePath "Web"; //Webパス変換 if (#hitWebReplace) { //ヒットがあれば追加 $menuName[2] = $$return + " をブラウザで開く"; $menuPath[2] = $$return; #menuSize = 3; } call appendMenu "FolderOpenMenu"; call appendMenu "SearchFileMenu"; call showMenu; ##n = ##return; if (!##n) call exit 3; ##n = ##n -1; if (##n == 0) { $abs = $menuPath[##n]; call appendMenu "Editor"; } else if (##n == 1) { $abs = $menuPath[##n]; call appendMenu "Browser"; } else if (##n == 2 && #hitWebReplace) { //ヒットがあれば追加メニューが入ってる $abs = $menuPath[##n]; call appendMenu "Browser"; } else if ($menuPath[##n] == "__SearchFileMenu__" || $menuPath[##n] == "__FolderOpenMenu__" || $menuPath[##n] == "__ThisFileMenu__") { call executeMenu ##n; //searchfileとfolderopenとthisfileはexecuteMenuで拾う } // その他 // } else if ($$res == "エディタ") call appendMenu "Editor"; else if ($$res == "ブラウザ") call appendMenu "Browser"; else if ($$res == "ビューア") call appendMenu "Viewer"; else if ($$res == "プレイヤー") call appendMenu "Player"; else if ($$res == "実行ファイル") call appRun "", "\"" + $abs + "\""; //exit else { if (#thisFile) call appendMenu "Editor"; else call exit 2; } call appendMenu "FolderOpenMenu"; call appendMenu "SearchFileMenu"; goto executeMenu; //次へ return; //createMenu.end // &executeMenu ■実行 // 選択したメニューを実行 executeMenu: if (##1) //先にメニューを出してる時は引数有 ##n = ##1; else { call showMenu; ##n = ##return; if (!##n) call exit 3; ##n = ##n -1; //メニューは1から、配列は0から始まるので-1 } if ($menuPath[##n] == "__CancelMenu__") { call exit 3; // ファイル検索 // } else if ($menuPath[##n] == "__SearchFileMenu__") { call clearMenu; $$dir = dllfuncstr("GSUB", $dir, "/", "\\", -1); call substr $$dir, 0, strlen($$dir) -1; //尻の区切り子を削除 $$dir = $$return; $$ext = getinistr($ini, "General", "SearchFilter"); ##r = dllfunc("ENUMFILE", $$dir + " " + $$ext); while (1) { $$file = dllfuncstr("FINDNEXT"); if ($$file == "") break; $menuName[#menuSize] = $$file; $menuPath[#menuSize] = $dir + $$file; #menuSize = #menuSize +1; } if ($menuName[0] == "") goto createMenu; else { call showMenu 1; //ひとつしかなくてもメニューを強制表示 ##n = ##return; if (##n) { $abs = $menuPath[##return -1]; goto createMenu; } call exit 3; } // フォルダオープン // } else if ($menuPath[##n] == "__FolderOpenMenu__") { call cutFileName $abs; $abs = $$return; goto createMenu; // 現在のファイルを対象にして再実行 // } else if ($menuPath[##n] == "__ThisFileMenu__") { $abs = dllfuncstr("GSUB", filename, "\\", "/", -1); goto createMenu; // メール送信 // } else if ($menuPath[##n] == "__SendMail__") { call envExpand getinistr($ini, "Mailer", "Path"), 1; //強制展開 $$path = $$return; if (strstr($menuName[##n], "送信") != -1) { call replace $abs, "@", "@"; call replace getinistr($ini, "Mailer", "Option"), "$address$", $$return; $abs = $$return; } else $abs = ""; call appRun $menuName[##n], $$path, $abs; //次へ // クエリ選択→ファイラで開く // } else if (strstr($menuName[##n], "クエリをカットしてファイラで開く") != -1) { $abs = $menuPath[##n]; goto createMenu; // クエリ選択→Webパスに変換してブラウザで開く // ヒット時のみ出現 } else if (strstr($menuName[##n], "Webパスに変換してブラウザで開く") != -1) { $abs = $menuPath[##n]; call clearMenu; call appendMenu "Browser"; call appendMenu "FolderOpenMenu"; call appendMenu "SearchFileMenu"; goto executeMenu; } call appRun $menuName[##n], $menuPath[##n], $abs; //次へ return; //executeMenu.end // appRun アプリケーションの起動 // appRun: $$appName = $$1; $$appPath = $$2; $abs = $$3; call checkScheme $abs; ##scheme = ##return; if (!##scheme) //file: $abs = dllfuncstr("GSUB", $abs, "/", "\\", -1); // \ でないと動かないソフトがあるので置換しておく else if (##scheme < 4) //mailto:以外 $abs = "\"" + $abs + "\""; if (#log) call log "appRun: \n\t実行ファイルのパス = " + $$appPath + "\n\tコマンドライン = " + $abs; if ($abs != "") { if (##scheme || (rightstr($abs, 1) == "\\" || existfile($abs))) run $$appPath + " " + $abs; else { if (#log) call log "appRun: ファイルが存在しません\n\tパス = " + $$3; call exit 2; } } else run $$appPath; if (result) call exit 1; else call exit 2; return; //appRun.end // e&xit 終了処理 // exit: setsearch $sbuffer, #soption; //検索条件を復元 escape; //##1 : 0=強制終了, 1=正常終了, 2=パスではない, 3=処理中止, 4=タグジャンプ if (##1 != 4) //タグジャンプした時はすでに戻してある moveto #currentX, #currentY; if (##1) { if (##1 == 1 && getininum($ini, "General", "OkSelect")) ##f = 2; else if (##1 == 3 && getininum($ini, "General", "CancelSelect")) ##f = 2; else ##f = ##1; if (##f == 2) { //パスではなかった時 ##ExitSelect = getininum($ini, "General", "ExitSelect"); if (##ExitSelect == 1) { //選択範囲そのまま moveto #selTopX, #selTopY; beginsel; moveto #selEndX, #selEndY; endsel; } else if (##ExitSelect == 2) { //単語選択 selectword; endsel; } if (##1 == 2 && getininum($ini, "General", "ExitExecMacro")) { //指定マクロを実行 $$macro = getinistr($ini, "General", "ExitExecMacroFile"); if (strstr($$macro, "\\") == -1) //ファイル名だけの時はフルパスにする $$macro = macrodir + "\\" + $$macro; execmacro $$macro; } } } //ログファイル出力 if (#log) { $$log = getinistr($ini, "General", "LogFile"); if ($$log != "") { call envExpand $$log; writeinistr $$return, "log", 0, 0; writeinistr $$return, "log", "date", date + " " + time; writeinistr $$return, "log", "message", "\n\n" + $log + "終了"; } } freedll; endmacro; return; //exit.end ////// ■ サブ関数群 ■ ////// log: $log = $log + "関数名 / " + $$1 + "\n\n"; return; //絶対パスの強制認識 absMatchForced: ##letter = 0; //ドライブレター分の修正値 if (strstr($$1, "http://") != -1) $$find = "http://"; else if (strstr($$1, "https://") != -1) $$find = "https://"; else if (strstr($$1, "ftp://") != -1) $$find = "ftp://"; else if (strstr($$1, "file://") != -1) $$find = "file://"; else if (strstr($$1, "mailto:") != -1) $$find = "mailto:"; else if (strstr($$1, ":/") != -1) { $$find = ":/"; ##letter = 1;} else return $$1; ##n = dllfunc("STRSTR2", $$1, $$find) - ##letter; if (##n == 0) return $$1; //パスが先頭からの場合はそのまま返す call substr $$1, ##n; $$after = $$return; $menuName[0] = $$after + " として認識(絶対パスを強制認識)"; $menuName[1] = $$1 + " として認識(そのまま)"; $menuName[2] = "やめる"; #menuSize = 3; call showMenu; ##n = ##return; if (##n == 1) return $$after; else if (##n == 2) return $$1; else call exit 3; return; //absMatchForced.end // envExpand 環境変数の展開 // GETTOKENだとかえって効率悪い(変数内で正規表現が使えればなぁ) envExpand: if (dllfunc("STRCOUNT", $$1, "%") < 2 || (#EnvExpand == 0 && ##2 != 1)) return $$1; $$path = $$1; while (1) { $$temp = $$path; //加工するのでパスをコピーする ##spos = strstr($$temp, "%"); //最初の%を検索 $$temp = dllfuncstr("GSUB", $$temp, "%", "", 1); //最初の%を削除 ##epos = strstr($$temp, "%"); //次の%を検索 $$temp = dllfuncstr("GSUB", $$temp, "%", "", 1); //次の%を削除 ##strings = ##epos - ##spos; //%〜%間の文字数 $$envstr = midstr($$temp, ##spos, ##strings); //環境変数と思われる文字列を抽出 $$expandstr = getenv($$envstr); //展開してみる if ($$expandstr != "") { if (#log) call log "envExpand: 環境変数の展開にマッチング\n\t展開前の環境変数 = %" + $$envstr + "%\n\t展開後の環境変数 = " + $$expandstr; call replace $$path, "%" + $$envstr + "%", $$expandstr; //展開できたら%ごと置換 } else { //展開できなかったらスキップマークに置換 call replace $$path, "%" + $$envstr + "%", "::::" + $$envstr + "::::"; } $$path = $$return; if (dllfunc("STRCOUNT", $$path, "%") < 2) //パスに含まれる%が1個以下になったら終了 break; } return dllfuncstr("GSUB", $$path, "::::", "%", -1); //スキップマークを元に戻す //envExpand.end // &replacePath パス変換 // call=createAbsolutePath replacePath: $$key = "Replace" + $$1 + "Path"; //Webパス変換の時は$$1="Web" $$abs = $abs; if (!getininum($ini, $$key, "Use")) return $$abs; #hitWebReplace = 0; //複数箇所から呼ばれるので初期化しておく(グローバル) ##hit = 0; ##i = 0; while (1) { $$before = getinistr($ini, $$key, "Befor" + str(##i)); $$after = getinistr($ini, $$key, "After" + str(##i)); if ($$before == "" || $$after == "") break; else { $$absLeft = dllfuncstr("TOLOWER", leftstr($$abs, strlen($$before))); //beforeと同じ文字数を切り出し if ($$absLeft == dllfuncstr("TOLOWER", $$before)) { $$absBefore = $$abs; $$abs = dllfuncstr("GSUB", $$abs, $$absLeft, $$after, 1); //absのbefore部分をafterへ置換 ##hit = 1; break; } } ##i = ##i +1; } if (##hit) { if ($$1 == "Web") #hitWebReplace = 1; if (#log) call log "replacePath: 取得したパスが" + $$1 + "パス変換の設定にマッチング\n\tマッチした設定 = " + $$before + ">" + $$after + "\n\t変換前のパス = " + $$absBefore + "\n\t変換後のパス = " + $$abs; } return $$abs; //replacePath.end // &replacePath パス変換 // call=createAbsolutePath //replacePath: // if (!getininum($ini, "ReplacePath", "UseReplacePath")) return; // ##hit = 0; // ##i = 0; // while (1) { // $$before = getinistr($ini, "ReplacePath", "Befor" + str(##i)); // $$after = getinistr($ini, "ReplacePath", "After" + str(##i)); // if ($$before == "" || $$after == "") // break; // else { // ##length = strlen($$before); // if (dllfuncstr("TOLOWER", leftstr($abs, ##length)) == dllfuncstr("TOLOWER", $$before)) { // $$absBefore = $abs; // $abs = dllfuncstr("GSUB", $abs, $$before, $$after, 1); // ##hit = 1; // break; // } // } // ##i = ##i +1; // } // // if (dllfunc("STRCOUNT", $abs, "%") > 1) { // call envExpand $abs; // $abs = $$return; // } // // if (#log && ##hit) // call message "replacePath: 取得したパスがパス変換の設定にマッチング\n\n変換前のパス = " + $$absBefore + "\n変換後のパス = " + $abs; // return; //replacePath.end // replaceWebPath Webパス変換 // //replaceWebPath: // if (!getininum($ini, "ReplaceWebPath", "UseReplaceWebPath")) return $$1; // // $$abs = $$1; // $$abslower = dllfuncstr("TOLOWER", $$abs); // #hitWebReplace = 0; //複数箇所から呼ばれるので初期化しておく(グローバル) // // ##i = 0; // while (1) { // $$before = getinistr($ini, "ReplaceWebPath", "Befor" + str(##i)); // $$after = getinistr($ini, "ReplaceWebPath", "After" + str(##i)); // // if ($$before == "" || $$after == "") // break; // else if (strstr($$abslower, dllfuncstr("TOLOWER", $$droot)) != -1) { // #hitWebReplace = 1; // $$absBefore = $abs; // $$abs = dllfuncstr("GSUB", $$abs, $$droot, $$wroot, 1); // break; // } // ##i = ##i +1; // } // // if (#log && #hitWebReplace) // call message "replaceWebPath: 取得したパスがWebパス変換の設定にマッチング\n\n変換前のパス = " + $$1 + "\n変換後のパス = " + $$abs; // return $$abs; //replaceWebPath.end // &appendMenu メニュー配列作成 // appendMenu: //キャンセルメニュー if ($$1 == "CancelMenu") { $menuName[#menuSize] = "やめる"; $menuPath[#menuSize] = "__" + $$1 + "__"; #menuSize = #menuSize +1; //ファイラメニュー } else if ($$1 == "FolderOpenMenu") { if (#FolderOpen) { $menuName[#menuSize] = $dir + " をファイラで開く"; $menuPath[#menuSize] = "__" + $$1 + "__"; #menuSize = #menuSize +1; } //ファイル検索メニュー } else if ($$1 == "SearchFileMenu") { if (#FileSearch) { $menuName[#menuSize] = $dir + " にある他のファイルを探す"; $menuPath[#menuSize] = "__" + $$1 + "__"; #menuSize = #menuSize +1; } //アプリケーションメニュー } else { //Filer, Editor, Browser, Viewer, Player ##i = 0; ##j = ##i; while (##i < 10) { $$name = getinistr($ini, $$1, "Name" + str(##i)); $$path = getinistr($ini, $$1, "Path" + str(##i)); if ($$name != "" && $$path != "") { $menuName[##j] = $$name; call envExpand $$path, 1; //強制展開 $menuPath[##j] = $$return; ##j = ##j +1; #menuSize = ##j; } ##i = ##i +1; } } return; //appendMenu.end // showMenu メニュー表示 // showMenu: if ($menuName[1] == "" && str(##1) != "1") //選択メニューがひとつしかない時はそのまま開く ##n = 1; else { //選択メニューが複数ある時はメニュー表示 call appendMenu "CancelMenu"; // moveto #currentX, #currentY; enabledraw; if (#menuPosition) menuarray $menuName, #menuSize; else mousemenuarray $menuName, #menuSize; disabledraw; ##n = result; } return ##n; //showMenu.end // clearMenu メニュー配列を消去 // clearMenu: ##i = 0; while (##i < #menuSize +1) { $menuName[##i] = ""; $menuPath[##i] = ""; ##i = ##i +1; } #menuSize = 0; return; //clearMenu.end // checkExt 拡張子ごとの動作判定 // checkExt: //クエリをカットして拡張子を取得 call cutQueryString $abs; $$abs = $$return; call lastIndexOf $$abs, "."; if (##return == -1) return ""; call substr $$abs, ##return +1; $$ext = $$return; if (#log) call log "checkExt: パスから取得された拡張子\n\tパス = " + $abs + "\n\t拡張子 = " + $$ext; call listExist getinistr($ini, "ExtensionList", "SelectExt"), $$ext; if (##return) return "Webパス変換"; call listExist getinistr($ini, "ExtensionList", "EditorExt"), $$ext; if (##return) return "エディタ"; call listExist getinistr($ini, "ExtensionList", "BrowserExt"), $$ext; if (##return) return "ブラウザ"; call listExist getinistr($ini, "ExtensionList", "ViewerExt"), $$ext; if (##return) return "ビューア"; call listExist getinistr($ini, "ExtensionList", "PlayerExt"), $$ext; if (##return) return "プレイヤー"; call listExist getinistr($ini, "ExtensionList", "ExecuteExt"), $$ext; if (##return) return "実行ファイル"; return "拡張子リストに登録されてません"; //checkExt.end ////// ■ 汎用関数群 ■ ////// question: enabledraw; question $$1; disabledraw; return result; message: enabledraw; message $$1; disabledraw; return; error: call message $$1; call exit; return; //$$1=リスト, $$2=検索される文字列, $$3=区切り子, ##4=無変換フラグ listExist: if ($$3 == "") $$3 = " "; if (!##4) { $$1 = dllfuncstr("TOLOWER", $$1); $$2 = dllfuncstr("TOLOWER", $$2); } $$s = dllfuncstr("GETTOKEN", $$1, $$3); while (1) { if ($$s == $$2) return 1; if (!dllfunc("HASMORETOKENS")) break; $$s = dllfuncstr("GETTOKEN", "", $$3); } return 0; checkScheme: if (leftstr($$1, 5) == "http:") return 1; else if (leftstr($$1, 6) == "https:") return 2; else if (leftstr($$1, 4) == "ftp:") return 3; else if (leftstr($$1, 7) == "mailto:") return 4; else if (strstr($$1, " ") == -1 && strstr($$1, ".") != -1 && (strstr($$1, "@") != -1 || strstr($$1, "@") != -1)) return 5; else return 0; cutFileName: call cutQueryString $$1; call lastIndexOf $$return, "/"; call substr $$1, 0, ##return +1; return $$return; cutQueryString: if (strstr($$1, "?") != -1) { //クエリカット call subleft $$1, "?"; $$1 = $$return; } if (strstr($$1, "#") != -1) { //アンカーカット call subleft $$1, "#"; $$1 = $$return; } return $$1; replace: if (!##4) ##4 = -1; return dllfuncstr("GSUB", $$1, $$2, $$3, ##4); lastIndexOf: return dllfunc("STRRSTR2", $$1, $$2); substr: if (!##3) ##3 = dllfunc("STRLEN2", $$1) - ##2; return dllfuncstr("MIDSTR2", $$1, ##2, ##3); subleft: return dllfuncstr("LEFTSTR2", $$1, dllfunc("STRSTR2", $$1, $$2)); subright: ##n = dllfunc("STRSTR2", $$1, $$2); return dllfuncstr("MIDSTR2", $$1, ##n + dllfunc("STRLEN2", $$2), dllfunc("STRLEN2", $$1) - ##n);