home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1998 January (DVD) / VPR980100.ISO / OLS / WIN32 / KAKIMAC / KAKIMACM.LZH / K_MARKM.MAC < prev    next >
Text File  |  1996-02-28  |  10KB  |  444 lines

  1. // k_MARKM.mac (書きマクロシリーズ第M集)
  2. // k_MARK Ver.1 マーク順に自動移動する、マーカーマクロ
  3. // by 水銀水(Suigwinsui)/小田明夫(HGD01603)
  4. // 平成08年02月28日(水) 午後01時50分00秒
  5.  
  6. //*設定開始
  7.  
  8. //●一回の操作での動作指定( []内の数字はデフォルト)
  9. #oneActionQuiet=0;    //[0] 1=1回の記憶や移動で即、マクロ終了(文書を把握している人向き)、0=[Esc]か[Ret]入力で終了
  10.  
  11. //●自動移動キーによる発見表示
  12. #dispConstLine=1;     //[1]行マーカー行を、秀丸の設定にまかせて表示させるか=0、上から何行目かを当マクロで強制的に一定位置に指定するか=1,
  13. #dispLineNum=-1;    //[-1]上から約n行あける=n、画面の縦位置の中央より少し上(^^)=-1、
  14.  
  15. //*設定終了
  16.  
  17.  
  18. call starting;
  19. call checkFileName;
  20. call markNewOn;
  21. disablebreak;
  22. while(1){
  23.     #i=keypressed;
  24.     if(#i==0x1B){// Esc 終了
  25.         break;
  26.     }else if(#i==0x2E){// [Del] 削除
  27.         call markDelete;
  28.         call markNewOn;
  29.     }else if(#i==13){// return
  30.         break;
  31.     }else if(#i==0x08 || #i==0x4F){//BackSpace 破棄
  32.         call backToOrgPosOrgHM;
  33.         call markNewOn;
  34.     }else if((#i>=0x31&&#i<=0x39)||(#i>=0x61&&#i<=0x69)){//1-9// 移動
  35.         if(#i<=0x39)#N=#i-0x30;
  36.         else #N=#i-0x60;
  37.         call jumpByNumber #N;
  38.         if(##return){if(#oneActionQuiet)goto ending;}
  39.     }else if(#i>=0x70&&#i<=0x78){//F1-F9,位置の強制上書き
  40.         ##F=#i-0x6F;
  41.         call writeLINE ##F;
  42.         if(#oneActionQuiet)goto ending;
  43.         else #N=##F;
  44.     }else if(#i==0x20){//Space
  45.         call nextMarkNumb y,0;//下方向
  46.     }else if(#i==0x10){//Shift
  47.         call nextMarkNumb y,1;//上方向
  48.     }else if(#i==0x24 || #i==0x54){//Home 
  49.         #N=0;
  50.         gofiletop;
  51.         call markNewOn;//???スピードも気になる(^^;
  52.     }else if(#i==0x23 || #i==0x45){//End 
  53.         #N=0;
  54.         gofileend;
  55.         call markNewOn;
  56.     }else if(#i==0x21){//PgUp 
  57.         #N=0;
  58.         prevpage;
  59.         call markNewOn;
  60.     }else if(#i==0x22){//PgDn 
  61.         #N=0;
  62.         nextpage;
  63.         call markNewOn;
  64.     }else if(#i==0x27){//→ 
  65.         golineend;
  66.     }else if(#i==0x25){//← 
  67.         golinetop;
  68.     }else if(#i==0x26){//↑ 
  69.         #N=0;
  70.         up;
  71.         call markNewOn;
  72.     }else if(#i==0x28){//↓ 
  73.         #N=0;
  74.         down;
  75.         call markNewOn;
  76.     }else if(#i==0x09){//Tabウィンドウ切り替え
  77.         call changeHM;
  78.     }else if(#i==0x4C){//lL
  79.         writeinistr $f,$fn,"latest",date;
  80.         execmacro "k_markL.mac";
  81.     }else if(#i==0x48){//hH for HELP
  82.         call k_helpMARK 1;
  83.     }else if(#i==0x55){// [U]最新登録番号の取り消し(letest undo)
  84.         call latestOneUndo;
  85.     }else if(#i!=0){
  86.         beep;
  87.     }
  88.     if(imestate)imeswitch;
  89. }
  90. goto ending;
  91.  
  92. backToOrgPosOrgHM:
  93.     if(#orgY[#hwnd[#w]]==y){
  94.         if(hidemaruhandle(0)!=#hwnd[0]){
  95.             #w=0;
  96.             setactivehidemaru #hwnd[#w];
  97.             call getIni;
  98.         }else beep;
  99.     }
  100.     moveto #orgX[#hwnd[#w]],#orgY[#hwnd[#w]];
  101. return;
  102.  
  103. markNewOn://マーク行にあるかどうか
  104.     call checkOnTheMark;
  105.     #N=##return;
  106.     call dispNewTitle;
  107. return;
  108.  
  109. changeHM://Tabウィンドウ切り替え
  110.     if(hidemarucount==1)beep;
  111.     else{
  112.         title 1;
  113.         nexthidemaru;//nexthidemaruicon;
  114.     }
  115.     #w=#w+1;
  116.     #hwnd[#w]=hidemaruhandle(0);
  117.     #orgX[#hwnd[#w]]=x;#orgY[#hwnd[#w]]=y;
  118.     call getIni;
  119.     call dispOrgTitle;
  120. return;
  121.  
  122. checkOnTheMark://マークされた行番号の上にあるかどうか
  123. while(1){
  124.     if(#M[##o+1]==y+1){
  125.         return (##o+1);
  126.     }else ##o=##o+1;
  127.     if(##o==9){
  128.         return 0;
  129.     }
  130. }
  131. return  ;
  132.  
  133. dispNewTitle://新規タイトル
  134.     call setMarkTitleAll;
  135.     $t[#N]="{"+str(#N)+"}"+str(#M[#N])+" ";
  136.     call dispTitle;
  137. return;
  138.  
  139. dispTitle://表示
  140.     if(##1==0)$hmH="■番順<H> ";
  141.     else if(##1==1){
  142.         $hmH="[×]削除<H> ";
  143.         call getIni;
  144.     }
  145.     $tt=$t[1]+$t[2]+$t[3]+$t[4]+$t[5]+$t[6]+$t[7]+$t[8]+$t[9];
  146.     if($tt=="")title $hmH+"  {行マーカー未登録}...[H:help]";
  147.     else title $hmH+$tt;
  148. return;
  149.  
  150. markDelete://マークキー削除
  151. call dispTitle 1;
  152. while(1){
  153.     ##k=keypressed;
  154.     if(##k==0x1B || ##k==0x2E){// Esc あるいは、再度[Del]でサイクリック
  155.         break;
  156.     }else if(##k==0x30 || ##k==0x60){//0全消去
  157.         question "●確認...当ファイル("+filename+")の全マーク情報を消去しますが、よろしいですね?";
  158.         if(!result)break;
  159.         else{
  160.             ##deleteAll=1;
  161.             call deleteAllMark;
  162.             if(!#oneActionQuiet)break;
  163.             else goto ending;
  164.         }
  165.     }else if(##k>=0x70&&##k<=0x78){//F1-F9個別消去
  166.         #N=##k-0x6F;
  167.         if(#M[#N]!=0){
  168.             call deleteMARK #N;
  169.             if(!#oneActionQuiet)break;
  170.             else goto ending;
  171.         }else beep;
  172.     }else if(##k==0x48){//hH for HELP
  173.         call k_helpMARK 2;
  174.     }else if(##k!=0)beep;
  175.     if(imestate)imeswitch;
  176. }
  177. return ##deleteAll;
  178.  
  179. deleteAllMark://全消去実行部
  180.     writeinistr $f,$fn,0,0;
  181.     call getIni;
  182.     call setMarkTitleAll;
  183.     call dispTitle 1;
  184. return;
  185.  
  186. deleteMARK:// キー削除実行部
  187.     #latestL=#M[##1];//維持行番号(保存前)
  188.     #latestM=##1;//維持行マーカー
  189.     writeinistr $f,$fn,str(##1),0;// 
  190.     #M[##1]=0;
  191.     $t[##1]="";
  192.     call getIni;
  193.     call checkOnTheMark;
  194.     #N=##return;
  195.     call setMarkTitleAll;
  196.     call dispTitle 1;
  197. return;
  198.  
  199. jumpByNumber://番号キーによるジャンプと再表示位置決定
  200. #N=##1;
  201.     if(#M[#N]!=0 && #M[#N]<=linecount){
  202.         if(!#dispConstLine)moveto 0,#M[#N]-1;
  203.         else{
  204.             disabledraw;
  205.             moveto 0,#M[#N]-1;
  206.             if(#dispLineNum<0)##dL=y-(windowheight/2)+5;
  207.             else ##dL=y-#dispLineNum;
  208.             enabledraw ##dL;
  209.         }
  210.         call dispNewTitle;
  211.     }else{
  212.         if(#M[#N]!=0)call dispNewTitle;
  213.         beep;
  214.         return 0;
  215.     }
  216. return 1;
  217.  
  218. nextMarkNumb://マークの上なら次のマーカー番号へ。上でないなら、次のマーカーを見つけて移動。
  219. ##yy=y;
  220. if(!#N){
  221.     call checkOnTheMark;
  222.     #N=##return;
  223. }
  224. if(#N<=0){
  225.     call getMarkNext ##1,##2;// param:現在の行数,方向
  226.     ##mL=##return-1;
  227.     if(#dispConstLine){
  228.         disabledraw;
  229.         moveto 0,##mL;
  230.         if(#dispLineNum<0)##dL=y-(windowheight/2)+5;
  231.         else ##dL=##mL+1-#dispLineNum;
  232.         enabledraw ##dL;
  233.     }else{
  234.         moveto 0,##mL;
  235.         ##dL=##return-1;
  236.     }
  237.     call markNewOn;
  238. }else{
  239.     call nextMarkNum ##2;
  240. }
  241. return ##dL;
  242.  
  243. nextMarkNum://次のマーク番号へ
  244.     if(!##1)call findNextML #N;
  245.     else call findForwordML #N;
  246.     #N=##return;
  247.     if(#N>0){
  248.         call jumpByNumber #N;
  249.         if(##return){
  250.             call dispNewTitle;
  251.         }
  252.     }else{
  253.         beep;
  254.     }
  255. return;
  256.  
  257. dispOrgTitle://基本タイトル表示
  258.     call setMarkTitleAll;
  259.     call dispTitle;
  260. return;
  261.  
  262. findNextML://次検出
  263. while(1){
  264.     if(#M[#N+##k+1]!=0){
  265.         return #N+##k+1;
  266.     }else ##k=##k+1;
  267.     if((#N+##k+1)>9){
  268.         ##k=0;
  269.         while(1){
  270.             if(#M[##k+1]!=0){
  271.                 return ##k+1;
  272.             }else ##k=##k+1;
  273.             if(#N<=##k+1)return 0;
  274.         }
  275.         return 0;
  276.     }
  277. }
  278. return;
  279.  
  280. findForwordML://前検出
  281. while(1){
  282.     if((#N+##k-1)==0){
  283.         ##k=10;
  284.         while(1){
  285.             if(#N>=##k-1)return 0;
  286.             if(#M[##k-1]!=0){
  287.                 return ##k-1;
  288.             }else ##k=##k-1;
  289.         }
  290.         return 0;
  291.     }
  292.     if(#M[#N+##k-1]!=0){
  293.         return #N+##k-1;
  294.     }else ##k=##k-1;
  295. }
  296. return;
  297.  
  298. getLargerMin:// カーソル位置よりも文末方向で、最も小さな行数を返す。
  299. if(##1<##3+1 && ##2<##3+1)##g=linecount+1;
  300. else if(##1>##3+1 && ##2<##3+1)##g=##1;
  301. else if(##1<##3+1 && ##2>##3+1)##g=##2;
  302. else if(##1>##3+1 && ##2>##3+1){
  303.     if(##1<=##2)##g=##1;
  304.     else ##g= ##2;
  305. }else{
  306.     if(##1==##3+1)##g=##2;
  307.     else ##g=##1;
  308. }
  309. return ##g;
  310.  
  311. getSmallerMax://カーソルより小さく、最も大きな数を返す
  312. if(##1>##3+1 && ##2>##3+1){
  313.     if(##1==0)##g=-1;
  314.     ##g=linecount+1;
  315. }else if(##1==##3+1){
  316.     if(##2!=0 && ##2<##3+1)##g=##2;
  317.     else ##g=linecount+1;
  318. }else if(##2==##3+1){
  319.     if(##1!=0 && ##1<##3+1)##g=##1;
  320.     else ##g=linecount+1;
  321. }else if(##1<##3+1 && ##2>##3+1)##g=##1;
  322.  else if(##1>##3+1 && ##2<##3+1)##g=##2;
  323.  else if(##1<##3+1 && ##2<##3+1){
  324.     if(##1>=##2)##g=##1;
  325.     else ##g=##2;
  326. }
  327. if(##1==0 && ##g==0)##g= -1;
  328. return ##g;
  329.  
  330. findNear://最近探査
  331. ##j=0;
  332. ##near=y+1;
  333. while(1){
  334.     ##j=##j+1;
  335.     if(!##2)call getLargerMin #M[##j],##near,##1;// 記録されているマーカー行,現在カーソル行,調査元の行番号    else call getSmallerMax #M[##j],##near,##1;
  336.     else call getSmallerMax #M[##j],##near,##1;
  337.     ##near=##return;
  338.     if(##j==9)break;
  339. }
  340. #N=##j;
  341. return ##near;
  342.  
  343. getMarkNext://もっとも近い行マークを見つけ、行番号を数値で返す
  344. call findNear ##1,##2;// 現在の行数,方向
  345. ##near=##return;
  346. if(!##2){
  347.     if(##near>=linecount+1){
  348.         call findNear -1,##2;
  349.         ##near=##return;
  350.     }else if(##near==-1)return ##1+1;
  351. }else{
  352.     if(##near==-1){
  353.         call findNear linecount,##2;
  354.         ##near=##return;
  355.     }
  356.     if(##near>=linecount+1)return ##1+1;
  357. }
  358. return ##near;
  359.  
  360. writeLINE://行マーカーの行番号を記憶(マーカーは固定)
  361.     #latestL=#M[##1];
  362.     writeininum $f,$fn,str(##1),y+1;
  363.     #M[##1]=y+1;
  364.     #latestM=##1;
  365.     call getIni;
  366.     call dispNewTitle;
  367.     call markNewOn;
  368. return;
  369.  
  370. latestOneUndo://直前登録アンドゥ
  371. if(#latestM){
  372.     if(#latestL){
  373.         writeininum $f,$fn,str(#latestM),#latestL;
  374.         #M[#latestM]=#latestL;
  375.         #N=#latestM;
  376.         call markNewOn;
  377.         #latestM=0;
  378.     }else{
  379.         writeininum $f,$fn,str(#latestM), 0;
  380.         $t[#latestM]="";
  381.         #M[#latestM]=0;
  382.         call checkOnTheMark;
  383.         #N=##return;
  384.         call dispTitle;
  385.         #latestM=0;
  386.     }
  387. }else beep;
  388. return;
  389.  
  390. checkFileName:// ファイル名のチェック
  391. //if(filename=="")#fileNameNO=1;
  392. //else writeinistr $f,"",0,0;// 無題ファイルも普通とおり記憶するが、ファイル名のあるファイルでk_MARKを起動すると、無題の記憶は破棄される
  393. $latestDate=getinistr($f,$fn,"latest");
  394. call getIni;
  395. //writeinistr $f,$fn,"latest",date;
  396. return;
  397.  
  398. starting:
  399. if(imestate)#imeON=1;
  400. $f=hidemarudir+"\\kakimac\\k_MARK.kdf";
  401. $f0=hidemarudir+"\\kakimac\\kakimac.kdf";
  402. $fn=filename;
  403. #hwnd[#w]=hidemaruhandle(0);
  404. #orgX[#hwnd[#w]]=x;#orgY[#hwnd[#w]]=y;
  405. return;
  406.  
  407. ending://終了処理
  408. if($t[1]+$t[2]+$t[3]+$t[4]+$t[5]+$t[6]+$t[7]+$t[8]+$t[9]=="")writeinistr $f,$fn,0,0;
  409. else writeinistr $f,$fn,"latest",date;
  410. if(#imeON){
  411.     if(!imestate)imeswitch;
  412. }else if(imestate)imeswitch;
  413. endmacroall;
  414.  
  415. setMarkTitleAll://変数格納
  416. if(#M[1]!=0)$t[1]="[1]"+str(#M[1])+" ";else $t[1]="";
  417. if(#M[2]!=0)$t[2]="[2]"+str(#M[2])+" ";else $t[2]="";
  418. if(#M[3]!=0)$t[3]="[3]"+str(#M[3])+" ";else $t[3]="";
  419. if(#M[4]!=0)$t[4]="[4]"+str(#M[4])+" ";else $t[4]="";
  420. if(#M[5]!=0)$t[5]="[5]"+str(#M[5])+" ";else $t[5]="";
  421. if(#M[6]!=0)$t[6]="[6]"+str(#M[6])+" ";else $t[6]="";
  422. if(#M[7]!=0)$t[7]="[7]"+str(#M[7])+" ";else $t[7]="";
  423. if(#M[8]!=0)$t[8]="[8]"+str(#M[8])+" ";else $t[8]="";
  424. if(#M[9]!=0)$t[9]="[9]"+str(#M[9])+" ";else $t[9]="";
  425. return;
  426.  
  427. getIni://読み込み
  428. $fn=filename;
  429. #M[1]=getininum($f,$fn,"1");
  430. #M[2]=getininum($f,$fn,"2");
  431. #M[3]=getininum($f,$fn,"3");
  432. #M[4]=getininum($f,$fn,"4");
  433. #M[5]=getininum($f,$fn,"5");
  434. #M[6]=getininum($f,$fn,"6");
  435. #M[7]=getininum($f,$fn,"7");
  436. #M[8]=getininum($f,$fn,"8");
  437. #M[9]=getininum($f,$fn,"9");
  438. return;
  439.  
  440. k_helpMARK://外部分離ヘルプ起動
  441.     writeininum $f0,"MARK","helpNumb",##1;
  442.     execmacro "k_markHL.mac";
  443. return;
  444.