/* Franco.em - a small collection of useful editing macros */
macro getMyName()
{
return "zhoumin"
}
macro MyInsFileHeader()
{
szMyName = getMyName()
szTime = GetSysTime(1)
date = getDate()
Day = szTime.Day
Month = szTime.Month
Year = szTime.Year
if (Day < 10) {
szDay = "0@Day@"
}else {
szDay = Day
}
hBuf = GetCurrentBuf()
szpathName = GetBufName(hBuf)
szfileName = GetFileName(szpathName)
nlength = StrLen(szfileName)
// szInf = Ask("Enter the information of file:")
szDescription = ""
hbuf = GetCurrentBuf()
InsBufLine(hbuf, 0, "/******************************************************************************")
InsBufLine(hbuf, 1, " * Filename : @szfileName@")
InsBufLine(hbuf, 2, " * Copyright: Copyright 2007 O2Micro, Inc")
InsBufLine(hbuf, 3, " * Created : @date@ by @szMyName@")
InsBufLine(hbuf, 4, " * Description -")
InsBufLine(hbuf, 5, " * @szDescription@")
InsBufLine(hbuf, 6, " ******************************************************************************/")
InsBufLine(hbuf, 7, "")
// InsBufLine(hbuf, 6, " ******************************************************************************")
// InsBufLine(hbuf, 7, " * cvs log info:")
// InsBufLine(hbuf, 8, " * $Log: @szfileName@,v $")
// InsBufLine(hbuf, 9, " ******************************************************************************/")
// InsBufLine(hbuf, 10, "")
SetBufIns(hbuf, 5, 3)
}
macro MyInsFunHeader()
{
szMyName = getMyName()
hbuf = GetCurrentBuf()
szFunc = GetCurSymbol()
ln = GetSymbolLine(szFunc)
if(ln < 0) {
// msg ("line: @ln@, focus should be in a function!")
return
}
date = getDate()
szDescription = ""
InsBufLine(hbuf, ln + 0, "/***************************************************************")
InsBufLine(hbuf, ln + 1, " Function: ")
InsBufLine(hbuf, ln + 2, " Description: ")
InsBufLine(hbuf, ln + 3 ," Input: ")
InsBufLine(hbuf, ln + 4 ," Output: ")
InsBufLine(hbuf, ln + 5, " Return: ")
InsBufLine(hbuf, ln + 6, " author:")
InsBufLine(hbuf, ln + 7, " @date@ @szMyName@")
InsBufLine(hbuf, ln + 8, "**************************************************************/")
SetBufIns(hbuf, ln + 2, 15)
}
/* insert head file define */
macro MyInsHDef()
{
hBuf = GetCurrentBuf()
szpathName = GetBufName(hBuf)
szfileName = GetFileName(szpathName)
szfileName = toupper(szfileName)
nlength = StrLen(szfileName)
i = 0
szdefineName = ""
while (i < nlength) {
if (szfileName[i] == ".") {
szdefineName = Cat(szdefineName, "_")
}else {
szdefineName = Cat(szdefineName, szfileName[i])
}
i = i + 1
}
szdefineName = Cat("_", szdefineName)
IfdefineSz(szdefineName)
}
macro MyInsCommentInLine()
{
hwnd = GetCurrentWnd()
lnFirst = GetWndSelLnFirst(hwnd)
lnLast = GetWndSelLnLast(hwnd)
hbuf = GetCurrentBuf()
if(lnLast == lnFirst) {
hbufText = GetBufSelText(hbuf)
SetBufSelText(hbuf, "/* @hbufText@ */")
}else {
InsBufLine(hbuf, lnFirst, "/* ")
InsBufLine(hbuf, lnLast+2, "*/")
SetBufIns( hbuf,lnFirst,3)
}
}
macro MyInsDebugInfo()
{
hbuf = GetCurrentBuf()
SetBufSelText(hbuf, "DEBUG_INFO(());")
}
macro MyInsIfDef()
{
hwnd = GetCurrentWnd()
lnFirst = GetWndSelLnFirst(hwnd)
lnLast = GetWndSelLnLast(hwnd)
hbuf = GetCurrentBuf()
date = getDateTime();
line = lnFirst+1;
InsBufLine(hbuf, lnFirst, "#ifdef remark_here /* @date@ reason: */")
InsBufLine(hbuf, lnLast+2, "#endif /* #ifdef remark_here (line:@line@)*/")
SetBufIns( hbuf,lnFirst,StrLen(date) + 30)
}
macro MyInsIfDefined()
{
hwnd = GetCurrentWnd()
lnFirst = GetWndSelLnFirst(hwnd)
lnLast = GetWndSelLnLast(hwnd)
hbuf = GetCurrentBuf()
date = getDateTime();
line = lnFirst+1;
InsBufLine(hbuf, lnFirst, "#if defined(SUPPORT_THAI_LANGUAGE)")
InsBufLine(hbuf, lnLast+2, "#endif ")
SetBufIns( hbuf,lnFirst,StrLen(date) + 30)
}
macro GetFileName(pathName)
{
nlength = strlen(pathName)
i = nlength - 1
name = ""
while (i + 1) {
ch = pathName[i]
if ("//" == "@ch@") {
break
}
i = i - 1
}
i = i + 1
while (i < nlength) {
name = cat(name, pathName[i])
i = i + 1
}
return name
}
macro getDate()
{
szTime = GetSysTime(1)
Year = szTime.Year
Month = szTime.Month
Day = szTime.Day
return "@Year@-@Month@-@Day@"
}
macro getDateTime()
{
szTime = GetSysTime(1)
Year = szTime.Year
Month = szTime.Month
Day = szTime.Day
Hour = szTime.Hour
Minute = szTime.Minute
Second = szTime.Second
return "@Year@-@Month@-@Day@ @Hour@:@Minute@:@Second@"
}
个人sourceinsight宏定义文件
最新推荐文章于 2023-08-25 16:32:51 发布