参考了别人的文章,记录下有用的代码。
macro SingleLineComment()
{
hbuf = GetCurrentBuf()
hwnd = GetCurrentWnd();
lnFirst = GetWndSelLnFirst(hwnd)
lnLast = GetWndSelLnLast(hwnd)
while(lnFirst < lnLast+1)
{
tmpBuf = GetBufLine(hbuf,lnFirst)
if(tmpBuf != Nil)
{
commentBuf = cat("//",tmpBuf)
DelBufLine(hbuf,lnFirst)
InsBufLine(hbuf,lnFirst,commentBuf)
}
lnFirst = lnFirst + 1
}
}
macro strstr(src,dst)
{
dstLen = strlen(dst)
srcLen = strlen(src)
loop = 0
index = 0
while(loop < dstLen)
{
if(dst[loop] == src[loop])
{
index = index +1
loop = loop + 1
}
else
{
index = index + 1
loop = 0
if((index + dstLen) > srcLen)
{
return invalid
}
}
}
index = index - dstLen
return index
}
macro SingleLine_UnComment()
{
hbuf = GetCurrentBuf()
hwnd = GetCurrentWnd();
lnFirst = GetWndSelLnFirst(hwnd)
lnLast = GetWndSelLnLast(hwnd)
while(lnFirst < lnLast+1)
{
tmpBuf = GetBufLine(hbuf,lnFirst)
if(tmpBuf != Nil)
{
index = strstr(tmpBuf,"//")
if(index != invalid)
{
index = index + 2
unCommentBuf = strmid(tmpBuf,index,strlen(tmpBuf))
DelBufLine(hbuf,lnFirst)
InsBufLine(hbuf,lnFirst,unCommentBuf)
}
}
lnFirst = lnFirst + 1
}
}
阅读(1897) | 评论(0) | 转发(0) |