// 漢字番号 // 2006-11-20 (Mon) 00:45:28 高橋半魚 http://www.kanazawa-bidai.ac.jp/~hangyo/ // gen3adv を使って、カーソル前の西暦・元号を相互変換する。 // gen3adv.exe が必要です。16bitアプリですが、バックグラウンドで開くだけなので、良しとします。 // くれぐれも、作者の豊島正之さんに「32bit版をちょうだい!」などというmailを出さないこと! // (ほんとは、私が欲しいのですが :-) $gen = "c:\\bin\\gen3adv.exe "; $genoption = " "; $kansuji = "〇一二三四五六七八九"; $kakko = "()"; // 編集中のファイルの秀丸ハンドル、現在カーソル位置を取得 disabledraw; #workinghandle = hidemaruhandle(0); #x2 = x; #y2 = y; // カーソル前の文字列の検討 left; // 「年」があるか if(code == '年') left; // 数字だった場合は左へ、そうでなければマクロ終了 while(code >= 0x824F && code <= 0x8258 || // 2byte算用数字 code >= 0x30 && code <= 0x39 || // 1byte算用数字 strstr($kansuji,(char(code))) != -1){ // 漢数字 #r = result; left; #c = #c + 1; // 数字の個数の確認 } if(#r == false){ moveto #x2, #y2; endmacro; } if(#c >= 5 ){ // 数字が多すぎる moveto #x2,#y2; endmacro; } if(#c >= 3 ){ // 3桁以上なら西暦と看做します //4桁の数字か、3桁の数字か if(code >= 0x824F && code <= 0x8258 || code >= 0x30 && code <= 0x39 || strstr($kansuji,(char(code))) != -1){ #x1 = x; #y1 = y; }else{ right; #x1 = x; #y1 = y; } }else{ // 2桁以下なら元号と看做します。 wordleft; // gen3advは、行頭にある元号以外の文字列を無視してくれます(すばらしい!) #x1 = x; #y1 = y; } // 元号・西暦の取得 $str = gettext(#x1,#y1,#x2,#y2); // gen3advの実行 run $gen + $genoption +$str; if(result == false){ message "gen3advがありません."; endmacro; } // 実行結果の取り込み処理(実行結果は、別のWINDOWに自動で出力されます) setactivehidemaru(-1); #temphandle = hidemaruhandle(0); gofiletop; if(code == eof){ call tempwindowclose; endmacro; } // 出力結果は、 「明治3 > 1870」こういう形式なので while(code != '>'){ right; } right;right; // マッチしない場合、「昭成3 > no match」こういう形式 if(code == 'n'){ call tempwindowclose; // message "No match."; endmacro; } // 出力結果をクリップボードにコピー beginsel; golineend2; copy; call tempwindowclose; // moveto #x2, #y2; insert $kakko; left; paste; wordright;right; endmacro; // (sub) 出力結果のwindowを閉じて、元の編集中のwindowに戻る tempwindowclose: // closenew; setactivehidemaru(#workinghandle); closehidemaru(#temphandle); moveto #x2,#y2; return true;