home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2002 April / VPR0204A.ISO / OLS / GREP109 / grep109.lzh / searchEx / blockGrep.mac next >
Text File  |  2001-12-17  |  2KB  |  96 lines

  1. //block 出力 grep
  2. $ini = macrodir + "\\searchEx\\searchEx.ini";
  3. writeininum $ini,"SEARCH","tmp2",hidemaruhandle(0);
  4. $directory = getinistr($ini,"SEARCH","directory");
  5. $hilight = getinistr($ini,"SEARCH","block");
  6. openreg "CURRENTUSER", "Software\\Hidemaruo\\Hidemaru\\Env";
  7. #PasteCursorFix = getregnum("PasteCursorFix");
  8. writeregnum "PasteCursorFix",0;
  9. envchanged;
  10. closereg;
  11.  
  12. newfile;
  13. if( !result ){
  14.     message "メモリー不足などの理由により、ファイルオープンに失敗しました。";
  15.     call PasteCursorFix;
  16.     endmacroall;
  17. }
  18. showwindow 0;
  19. writeininum $ini,"SEARCH","tmp",hidemaruhandle(0);
  20. writeininum $ini,"SEARCH","tmp3",getininum($ini,"SEARCH","tmp2");
  21. execmacro macrodir + "\\searchEx\\SetActive.mac";
  22. while( 1 ){
  23.     if(code == eof)break;
  24.     //disabledraw;
  25.     execmacro macrodir + "\\searchEx\\OpenFile.mac";
  26.     execmacro macrodir + "\\searchEx\\FindLine.mac";
  27.     if( getininum($ini,"SEARCH","NullFind") )continue;
  28.     call SelectBlock;
  29.     //selectfunc では見つかった行を含むブロックが選択されない場合がある。
  30.     if( seltopy == 0 && selendy == linecount -1)call InFile;
  31.     else call PastBlock;
  32. }
  33. execmacro macrodir + "\\searchEx\\CloseFile.mac";
  34. call PasteCursorFix;
  35. endmacro;
  36.  
  37. PastBlock:
  38.     $$file = getinistr($ini,"SEARCH","tmp1");
  39.     while( 1 ){
  40.         if(y == linecount -1)gofileend;
  41.         ##x = selendx;
  42.         ##y = selendy;
  43.         indent;
  44.         appendcopy;
  45.         undo;
  46.         moveto ##x ,##y;
  47.         if( column )addclipboard "\x0D\x0A";
  48.         finddown2;
  49.         if( !result )break;
  50.         addclipboard $$file + "(" + str(lineno) + ")\x0D\x0A";
  51.         call SelectBlock;
  52.     }
  53.     call ChangeWindow;
  54.     paste;
  55.     return;
  56.  
  57. ChangeWindow:
  58.     writeininum $ini,"SEARCH","tmp3",getininum($ini,"SEARCH","tmp2");
  59.     execmacro macrodir + "\\searchEx\\SetActive.mac";
  60.     //disabledraw;
  61.     movetolineno 1, lineno + 1;
  62.     return;
  63.  
  64. InFile:
  65.     $$file = filename;
  66.     call ChangeWindow;
  67.     ##x = x;
  68.     ##y = y;
  69.     insertfile $$file;
  70.     if( column )insert "\n";
  71.     beginsel;
  72.     moveto ##x, ##y;
  73.     indent;
  74.     moveto selendx,selendy;
  75.     escape;
  76.     return;
  77.  
  78. SelectBlock:
  79.     ##y = y;
  80.     //selectfunc では見つかった行を含むブロックが選択されない場合がある。
  81.     prevfunc;
  82.     beginsel;
  83.     nextfunc;
  84.     if( y == ##y ){
  85.         escape;
  86.         beginsel;
  87.         nextfunc;
  88.     }
  89.     return;
  90.  
  91. PasteCursorFix:
  92.     openreg "CURRENTUSER", "Software\\Hidemaruo\\Hidemaru\\Env";
  93.     writeregnum "PasteCursorFix",#PasteCursorFix;
  94.     envchanged;
  95.     return;
  96.