コメントアウト支援マクロ
トライ&エラーのお供に・・・
foo| bar // すでにコメントアウトしてある行は解除される
3回実行後
// foo // bar すでにコメントアウトしてある行は解除される |
if(exp){
実行後
// if(exp){
|if(exp){
Commentout
^/
Commentout.commentoutAndCopy?
^%/
Commentout
#include <windows.h>
mchar *getcomment(mchar *ext)
{
// 拡張子に対応するコメントを返す
if(stristr(".rb/.pl", ext)) return "#";
if(stristr(".log/.ini", ext)) return ";";
if(stristr(".bat",ext)) return "rem";
return "//";
}
commentoutAndCopy
{
mchar *cmt = getcomment(pathGetExt(text->szfilename));
txstr line; getpara(line);
if(strncmp(line, cmt, strlen(cmt))==0)
return;
jumplinetop;
insert(cmt+line+"\n");
}
// その行のみをコメント化・コメント解除する
commentout
{
mchar *cmt = getcomment(pathGetExt(text->szfilename));
txstr line; getpara(line);
jumplinetop;
if(strncmp(line, cmt, strlen(cmt))==0)
{
for(int i=0; i<strlen(cmt); i++)
deletechar;
if(getchar==' ')
deletechar;
}
else
insert(cmt+" ");
nextpara;
}
main
{
if(text->fClip)
{
walkstart;
while(iswalking)
commentout(text);
walkend;
}
else
commentout(text);
}
この記事は役に立ちましたか?