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

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