home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 2000 April
/
VPR0004A.BIN
/
OLS
/
CSSH102
/
CSSH102.LZH
/
csshtml
/
selecting.mac
< prev
next >
Wrap
Text File
|
2000-01-04
|
6KB
|
207 lines
////////////////////////////////////////////////////////////
// selecting.mac
// Toshiyuki Akutsu <locrian@mbd.sphere.ne.jp>
// Mon, 20 Dec 1999 21:30:54
////////////////////////////////////////////////////////////
openreg "CURRENTUSER", "Software\\Hidemaruo\\Hidemaru\\Env";
if( ! result ) endmacro;
$__macroPath = getregstr( "MacroPath" );
closereg;
if( $__macroPath == "" ) $__macroPath = hidemarudir;
if( rightstr( $__macroPath, 1 ) != "\\" ) $__macroPath = $__macroPath + "\\";
$__INI = $__macroPath + "csshtml\\csshtml.ini";
////////////////////////////////////////////////////////////
writeininum $__INI, "SUBMACRO", "EXECUTE", 0;
////////////////////////////////////////////////////////////
if( (seltopx + selendx) != 0 ){
message "行選択ではありません。\n行頭で、Shift + ↓ or ↑\n"+
"csshtml#selecting.mac マクロ終了。";
endmacro;
}
#__TOP = seltopy; #__END = selendy;
##cy = y;
RE_MENU:
menu "<< csshtml#selecting >>",
"&1 行末 <BR> 挿入",
"&2 行末 <BR> 削除",
"&3 文字参照化",
"&4 文字参照復元",
"&5 コメント化",
"&6 コメント有効化",
"&7 CSV -> TABLE", //7
"&8 TABLE -> CSV", //8
"---------------------", //9
"&9 OL", //10
"&0 UL", //11
"---------------------", //12
"&T 全タグ 削除", //13
"&Q 終了 ( ESC )"; //14
##item = result - 1;
if( ##item <= 0 || ##item == 15 ){
endmacro;
}else if( ##item == 9 || ##item == 12 ){
goto RE_MENU;
}
disabledraw; escape;
moveto 0, #__END; #__END = lineno;
moveto 0, #__TOP; #__TOP = lineno;
if( ##item == 1 ) call insertBR;
else if( ##item == 2 ) call deleteBR;
else if( ##item == 3 ) call encodeNumCharRef;
else if( ##item == 4 ) call decodeNumCharRef;
else if( ##item == 5 ) call invalidateCode;
else if( ##item == 6 ) call validateCode;
else if( ##item == 7 ) call CSVtoTABLE;
else if( ##item == 8 ) call TABLEtoCSV;
else if( ##item == 10 ) call insertLIST "<OL TYPE=\"1\">","</OL>";
else if( ##item == 11 ) call insertLIST "<UL TYPE=\"CIRCLE\">","</UL>";
else if( ##item == 13 ) call deleteAllTags;
if( ##item <= 8 || ##item >= 13 ) moveto 0, ##cy;
writeininum $__INI, "SUBMACRO", "EXECUTE", 1;
endmacro;
// End of selecting.mac
//////////////////////////////
//////////////////////////////
replaceInSelectArea:
##size = ##1;
##i = 0;
while( ##i < ##size ){
escape; movetolineno 1, #__TOP;
beginsel; movetolineno 1, #__END;
replaceallfast $__BUF[##i][0], $__BUF[##i][1], inselect;
##i = ##i + 1;
}
escape;
return;
// end replaceInSelectArea
//////////////////////////////
reSelectLine:
escape; movetolineno 1, #__TOP;
beginsel; movetolineno 1, #__END;
return;
// end reSelectLine
//////////////////////////////
//数値文字参照(Numeric character references)
encodeNumCharRef:
$__BUF[0][0] = "&"; $__BUF[0][1] = "";
$__BUF[1][0] = "<"; $__BUF[1][1] = "<";
$__BUF[2][0] = ">"; $__BUF[2][1] = ">";
$__BUF[3][0] = "\""; $__BUF[3][1] = """;
call replaceInSelectArea 4;
return;
// end encodeNumCharRef
decodeNumCharRef:
$__BUF[0][0] = "<"; $__BUF[0][1] = "<";
$__BUF[1][0] = ">"; $__BUF[1][1] = ">";
$__BUF[2][0] = """; $__BUF[2][1] = "\"";
$__BUF[3][0] = ""; $__BUF[3][1] = "&";
call replaceInSelectArea 4;
return;
// end decodeNumCharRef
//////////////////////////////
insertBR:
call reSelectLine;
replaceallfast "\\n", "<BR>\\n", regular, inselect;
return;
// end insertBR
deleteBR:
call reSelectLine;
replaceallfast "<[Bb][Rr]>$", "", regular, inselect;
return;
// end deleteBR
//////////////////////////////
invalidateCode:
movetolineno 1, #__END; insert "-->\n";
movetolineno 1, #__TOP; insert "<!--\n";
return;
// end invalidateCode
validateCode:
call reSelectLine;
replacedown "<!--", "", inselect;
while( result ) finddown;
call reSelectLine;
replacedown "-->", "", inselect;
while( result ) finddown;
return;
// end validateCode
//////////////////////////////
CSVtoTABLE:
call reSelectLine;
replaceallfast ",", "</TD><TD>", inselect;
call reSelectLine;
replaceallfast "^\\f.+$", "<TR><TD>\\1</TD></TR>", regular, inselect;
movetolineno 1, #__END; insert "</TABLE>\n";
movetolineno 1, #__TOP; insert "<TABLE BORDER=\"1\">\n";
return;
// end CSVtoTABLE
TABLEtoCSV:
call reSelectLine;
replaceallfast "</[Tt][Dd]>[ \\t]*<[Tt][Dd]>", ",", regular,inselect;
call reSelectLine;
replaceallfast "</[Tt][Dd]>[ \\t]*<[Tt][Dd][ \\t]+[^>]+>", ",", regular,inselect;
$$tmp = "[Tt]([Aa][Bb][Ll][Ee]|[Rr]|[Dd])";
call reSelectLine;
replaceallfast "</?" + $$tmp + ">", "", regular, inselect;
call reSelectLine;
replaceallfast "<" + $$tmp + "[ \\t]+[^>]+>", "", regular, inselect;
return;
// end TABLEtoCSV
//////////////////////////////
insertLIST:
//$$left = $$1; $$right = $$2;
##tick = tickcount + 100;
$$deno = "/" + str(#__END) + " LIST";
movetolineno 1, #__TOP;
while( lineno < #__END ){
while( (code==0x09)||(code==0x20)||(code==0x8140) ) right;
if( code != 0x0d ){ // 空行除く
beginsel; right 4;
$$tmp = gettext( seltopx, seltopy, selendx, selendy );
escape; left 4;
if( $$tmp != "<LI>" ) insert "<LI>";
}
if( tickcount > ##tick ){
title str(lineno) + $$deno;
##tick = tickcount + 2000;
}
movetolineno 1, lineno + 1;
}
movetolineno 1, #__END; insert $$2 + "\n";
movetolineno 1, #__TOP; insertfix $$1 + "\n";
right strlen($$1)-2;
title 0;
return;
// end insertLIST
//////////////////////////////
deleteAllTags:
question "選択範囲の全タグを削除します。\n" +
"注、改行をまたいでいるタグは削除できません。\n" +
"よろしいですか?";
if( ! result ) return;
call reSelectLine;
//属性の無い開始タグ、終了タグ
replaceallfast "</?[A-Za-z][A-Za-z0-9]*>", "", regular, inselect;
call reSelectLine;
//属性のある開始タグ、XMLの<???/>にもマッチ
replaceallfast "<[A-Za-z][^>]+>", "", regular, inselect;
call reSelectLine;
//コメント、SGML、XML
replaceallfast "<![^>]+>", "", regular, inselect;
escape;
return;
//////////////////////////////