home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2000 April / VPR0004A.BIN / OLS / CSSH102 / CSSH102.LZH / csshtml / selecting.mac < prev    next >
Text File  |  2000-01-04  |  6KB  |  207 lines

  1. ////////////////////////////////////////////////////////////
  2. // selecting.mac
  3. // Toshiyuki Akutsu <locrian@mbd.sphere.ne.jp>
  4. // Mon, 20 Dec 1999 21:30:54
  5. ////////////////////////////////////////////////////////////
  6.     openreg "CURRENTUSER", "Software\\Hidemaruo\\Hidemaru\\Env";
  7.     if( ! result ) endmacro;
  8.     $__macroPath = getregstr( "MacroPath" );
  9.     closereg;
  10.     if( $__macroPath == "" ) $__macroPath = hidemarudir;
  11.     if( rightstr( $__macroPath, 1 ) != "\\" ) $__macroPath = $__macroPath + "\\";
  12.     $__INI = $__macroPath + "csshtml\\csshtml.ini";
  13. ////////////////////////////////////////////////////////////
  14.     writeininum $__INI, "SUBMACRO", "EXECUTE", 0;
  15.  
  16. ////////////////////////////////////////////////////////////
  17.  if( (seltopx + selendx) != 0 ){
  18.     message "行選択ではありません。\n行頭で、Shift + ↓ or ↑\n"+
  19.             "csshtml#selecting.mac マクロ終了。";
  20.     endmacro;
  21.  }
  22.     #__TOP = seltopy; #__END = selendy;
  23.     ##cy = y;
  24.     RE_MENU:
  25. menu "<< csshtml#selecting >>",
  26.     "&1 行末 <BR> 挿入",
  27.     "&2 行末 <BR> 削除",
  28.     "&3 文字参照化",
  29.     "&4 文字参照復元",
  30.     "&5 コメント化",
  31.     "&6 コメント有効化",
  32.     "&7 CSV -> TABLE",            //7
  33.     "&8 TABLE -> CSV",            //8
  34.     "---------------------",     //9
  35.     "&9 OL",                    //10
  36.     "&0 UL",                    //11
  37.     "---------------------",    //12
  38.     "&T 全タグ 削除",            //13
  39.     "&Q 終了 ( ESC )";            //14
  40.  
  41.     ##item = result - 1;
  42.     if( ##item <= 0 || ##item == 15 ){
  43.         endmacro;
  44.     }else if( ##item == 9 || ##item == 12 ){
  45.         goto RE_MENU;
  46.     }
  47.  
  48.     disabledraw; escape;
  49.     moveto 0, #__END; #__END = lineno;
  50.     moveto 0, #__TOP; #__TOP = lineno;
  51.     if( ##item == 1 ) call insertBR;
  52.     else if( ##item == 2 ) call deleteBR;
  53.     else if( ##item == 3 ) call encodeNumCharRef;
  54.     else if( ##item == 4 ) call decodeNumCharRef;
  55.     else if( ##item == 5 ) call invalidateCode;
  56.     else if( ##item == 6 ) call validateCode;
  57.     else if( ##item == 7 ) call CSVtoTABLE;
  58.     else if( ##item == 8 ) call TABLEtoCSV;
  59.     else if( ##item == 10 ) call insertLIST "<OL TYPE=\"1\">","</OL>";
  60.     else if( ##item == 11 ) call insertLIST "<UL TYPE=\"CIRCLE\">","</UL>";
  61.     else if( ##item == 13 ) call deleteAllTags;
  62.  
  63.     if( ##item <= 8 || ##item >= 13 ) moveto 0, ##cy;
  64.     writeininum $__INI, "SUBMACRO", "EXECUTE", 1;
  65.  
  66. endmacro;
  67. // End of selecting.mac
  68. //////////////////////////////
  69. //////////////////////////////
  70. replaceInSelectArea:
  71.     ##size = ##1;
  72.     ##i = 0;
  73.     while( ##i < ##size ){
  74.         escape; movetolineno 1, #__TOP;
  75.         beginsel; movetolineno 1, #__END;
  76.         replaceallfast $__BUF[##i][0], $__BUF[##i][1], inselect;
  77.         ##i = ##i + 1;
  78.     }
  79.     escape;
  80. return;
  81. // end replaceInSelectArea
  82. //////////////////////////////
  83. reSelectLine:
  84.     escape; movetolineno 1, #__TOP;
  85.     beginsel; movetolineno 1, #__END;
  86. return;
  87. // end reSelectLine
  88. //////////////////////////////
  89. //数値文字参照(Numeric character references)
  90. encodeNumCharRef:
  91.  
  92. $__BUF[0][0] = "&";            $__BUF[0][1] = "";
  93. $__BUF[1][0] = "<";            $__BUF[1][1] = "<";
  94. $__BUF[2][0] = ">";            $__BUF[2][1] = ">";
  95. $__BUF[3][0] = "\"";        $__BUF[3][1] = """;
  96.     call replaceInSelectArea 4;
  97.  
  98. return;
  99. // end encodeNumCharRef
  100. decodeNumCharRef:
  101.  
  102. $__BUF[0][0] = "<";        $__BUF[0][1] = "<";
  103. $__BUF[1][0] = ">";        $__BUF[1][1] = ">";
  104. $__BUF[2][0] = """;        $__BUF[2][1] = "\"";
  105. $__BUF[3][0] = "";        $__BUF[3][1] = "&";
  106.     call replaceInSelectArea 4;
  107.  
  108. return;
  109. // end decodeNumCharRef
  110. //////////////////////////////
  111. insertBR:
  112.     call reSelectLine;
  113.     replaceallfast "\\n", "<BR>\\n", regular, inselect;
  114. return;
  115. // end insertBR
  116. deleteBR:
  117.     call reSelectLine;
  118.     replaceallfast "<[Bb][Rr]>$", "", regular, inselect;
  119. return;
  120. // end deleteBR
  121. //////////////////////////////
  122. invalidateCode:
  123.     movetolineno 1, #__END; insert "-->\n";
  124.     movetolineno 1, #__TOP; insert "<!--\n";
  125. return;
  126. // end invalidateCode
  127. validateCode:
  128.     call reSelectLine;
  129.     replacedown "<!--", "", inselect;
  130.     while( result ) finddown;
  131.     call reSelectLine;
  132.     replacedown "-->", "", inselect;
  133.     while( result ) finddown;
  134. return;
  135. // end validateCode
  136. //////////////////////////////
  137. CSVtoTABLE:
  138.  
  139.     call reSelectLine;
  140. replaceallfast ",", "</TD><TD>", inselect;
  141.     call reSelectLine;
  142. replaceallfast "^\\f.+$", "<TR><TD>\\1</TD></TR>", regular, inselect;
  143.     movetolineno 1, #__END; insert "</TABLE>\n";
  144.     movetolineno 1, #__TOP; insert "<TABLE BORDER=\"1\">\n";
  145. return;
  146. // end CSVtoTABLE
  147. TABLEtoCSV:
  148.  
  149.     call reSelectLine;
  150.     replaceallfast "</[Tt][Dd]>[ \\t]*<[Tt][Dd]>", ",", regular,inselect;
  151.     call reSelectLine;
  152. replaceallfast "</[Tt][Dd]>[ \\t]*<[Tt][Dd][ \\t]+[^>]+>", ",", regular,inselect;
  153.  
  154.     $$tmp = "[Tt]([Aa][Bb][Ll][Ee]|[Rr]|[Dd])";
  155.     call reSelectLine;
  156.     replaceallfast "</?" + $$tmp + ">", "", regular, inselect;
  157.     call reSelectLine;
  158.     replaceallfast "<" + $$tmp + "[ \\t]+[^>]+>", "", regular, inselect;
  159.  
  160. return;
  161. // end TABLEtoCSV
  162. //////////////////////////////
  163. insertLIST:
  164.     //$$left = $$1; $$right = $$2;
  165.     ##tick = tickcount + 100;
  166.     $$deno = "/" + str(#__END) + " LIST";
  167.  
  168.     movetolineno 1, #__TOP;
  169.     while( lineno < #__END ){
  170.         while( (code==0x09)||(code==0x20)||(code==0x8140) ) right;
  171.         if( code != 0x0d ){ // 空行除く
  172.             beginsel; right 4;
  173.             $$tmp = gettext( seltopx, seltopy, selendx, selendy );
  174.             escape; left 4;
  175.             if( $$tmp != "<LI>" ) insert "<LI>";
  176.         }
  177.         if( tickcount > ##tick ){
  178.             title str(lineno) + $$deno;
  179.             ##tick = tickcount + 2000;
  180.         }
  181.         movetolineno 1, lineno + 1;
  182.     }
  183.     movetolineno 1, #__END; insert $$2 + "\n";
  184.     movetolineno 1, #__TOP; insertfix $$1 + "\n";
  185.     right strlen($$1)-2;
  186.     title 0;
  187. return;
  188. // end insertLIST
  189. //////////////////////////////
  190. deleteAllTags:
  191. question "選択範囲の全タグを削除します。\n" +
  192.         "注、改行をまたいでいるタグは削除できません。\n" +
  193.         "よろしいですか?";
  194.     if( ! result ) return;
  195.     call reSelectLine;
  196. //属性の無い開始タグ、終了タグ
  197. replaceallfast "</?[A-Za-z][A-Za-z0-9]*>", "", regular, inselect;
  198.     call reSelectLine;
  199. //属性のある開始タグ、XMLの<???/>にもマッチ
  200. replaceallfast "<[A-Za-z][^>]+>", "", regular, inselect;
  201.     call reSelectLine;
  202. //コメント、SGML、XML
  203. replaceallfast "<![^>]+>", "", regular, inselect;
  204.     escape;
  205. return;
  206. //////////////////////////////
  207.