macro InsertHeader()
{
szMyName = getenv(MYNAME)
hbuf = GetCurrentBuf()
szFunc = GetCurSymbol()
ln = GetSymbolLine(szFunc)
sz = "/* "
cch = strlen(szFunc)
ich = 0
while (ich < cch)
{
ch = szFunc[ich]
if (ich > 0)
if (isupper(ch))
sz = cat(sz, " ")
else
sz = cat(sz, " ")
sz = Cat(sz, toupper(ch))
ich = ich + 1
}
sz = Cat(sz, " */")
InsBufLine(hbuf, ln, sz)
InsBufLine(hbuf, ln+1, "/*-------------------------------------------------------------------------")
if (strlen(szMyName) > 0)
{
InsBufLine(hbuf, ln+2, " Owner: @szMyName@")
InsBufLine(hbuf, ln+3, " ")
ln = ln + 4
}
else
ln = ln + 2
InsBufLine(hbuf, ln, " ")
InsBufLine(hbuf, ln+1, "-------------------------------------------------------------------------*/")
SetBufIns(hbuf, ln, 4)
}
macro InsertFileHeader()
{
szMyName = getenv(MYNAME)
hbuf = GetCurrentBuf()
InsBufLine(hbuf, 0, "/*-------------------------------------------------------------------------")
InsBufLine(hbuf, 1, " ")
if (strlen(szMyName) > 0)
{
sz = " Owner: @szMyName@"
InsBufLine(hbuf, 2, " ")
InsBufLine(hbuf, 3, sz)
ln = 4
}
else
ln = 2
InsBufLine(hbuf, ln, "-------------------------------------------------------------------------*/")
}
macro ReturnTrueOrFalse()
{
hbuf = GetCurrentBuf()
ln = GetBufLineCur(hbuf)
InsBufLine(hbuf, ln, " Returns True if successful or False if errors.")
}
macro IfdefReview()
{
IfdefSz("REVIEW");
}
macro IfdefBogus()
{
IfdefSz("BOGUS");
}
macro IfdefNever()
{
IfdefSz("NEVER");
}
macro InsertIfdef()
{
sz = Ask("Enter ifdef condition:")
if (sz != "")
IfdefSz(sz);
}
macro InsertCPlusPlus()
{
IfdefSz("__cplusplus");
}
macro IfdefSz(sz)
{
hwnd = GetCurrentWnd()
lnFirst = GetWndSelLnFirst(hwnd)
lnLast = GetWndSelLnLast(hwnd)
hbuf = GetCurrentBuf()
InsBufLine(hbuf, lnFirst, "#ifdef @sz@")
InsBufLine(hbuf, lnLast+2, "#endif /* @sz@ */")
}
macro KillLine()
{
hbufCur = GetCurrentBuf();
lnCur = GetBufLnCur(hbufCur)
hbufClip = GetBufHandle("Clipboard")
AppendBufLine(hbufClip, GetBufLine(hbufCur, lnCur))
DelBufLine(hbufCur, lnCur)
}
macro PasteKillLine()
{
Paste
EmptyBuf(GetBufHandle("Clipboard"))
}
macro EmptyBuf(hbuf)
{
lnMax = GetBufLineCount(hbuf)
while (lnMax > 0)
{
DelBufLine(hbuf, 0)
lnMax = lnMax - 1
}
}
macro JumpAnywhere()
{
symbol = Ask("What declaration would you like to see?")
JumpToSymbolDef(symbol)
}
macro OutputSiblingSymbols()
{
symbol = Ask("What symbol would you like to list siblings for?")
hbuf = ListAllSiblings(symbol)
SetCurrentBuf(hbuf)
}
macro ListAllSiblings(symbol)
{
loc = GetSymbolLocation(symbol)
if (loc == "")
{
msg ("@symbol@ not found.")
stop
}
hbufOutput = NewBuf("Results")
hbuf = OpenBuf(loc.file)
if (hbuf == 0)
{
msg ("Can't open file.")
stop
}
isymMax = GetBufSymCount(hbuf)
isym = 0;
while (isym < isymMax)
{
AppendBufLine(hbufOutput, GetBufSymName(hbuf, isym))
isym = isym + 1
}
CloseBuf(hbuf)
return hbufOutput
}
macro MultiLineComment()
{
hwnd = GetCurrentWnd()
selection = GetWndSel(hwnd)
LnFirst =GetWndSelLnFirst(hwnd)
LnLast =GetWndSelLnLast(hwnd)
hbuf = GetCurrentBuf()
if(GetBufLine(hbuf, 0) =="//magic-number:tph85666031"){
stop
}
Ln = Lnfirst
buf = GetBufLine(hbuf, Ln)
len = strlen(buf)
while(Ln <= Lnlast) {
buf = GetBufLine(hbuf, Ln)
if(buf ==""){
Ln = Ln + 1
continue
}
if(StrMid(buf, 0, 1) == "/"){
if(StrMid(buf, 1, 2) == "/"){
PutBufLine(hbuf, Ln, StrMid(buf, 2, Strlen(buf)))
}
}
if(StrMid(buf,0,1) !="/"){
PutBufLine(hbuf, Ln, Cat("//", buf))
}
Ln = Ln + 1
}
SetWndSel(hwnd, selection)
}
macro AddMacroComment()
{
hwnd=GetCurrentWnd()
sel=GetWndSel(hwnd)
lnFirst=GetWndSelLnFirst(hwnd)
lnLast=GetWndSelLnLast(hwnd)
hbuf=GetCurrentBuf()
if (LnFirst == 0) {
szIfStart = ""
} else {
szIfStart = GetBufLine(hbuf, LnFirst-1)
}
szIfEnd = GetBufLine(hbuf, lnLast+1)
if (szIfStart == "#if 0" && szIfEnd =="#endif") {
DelBufLine(hbuf, lnLast+1)
DelBufLine(hbuf, lnFirst-1)
sel.lnFirst = sel.lnFirst – 1
sel.lnLast = sel.lnLast – 1
} else {
InsBufLine(hbuf, lnFirst, "#if 0")
InsBufLine(hbuf, lnLast+2, "#endif")
sel.lnFirst = sel.lnFirst + 1
sel.lnLast = sel.lnLast + 1
}
SetWndSel( hwnd, sel )
}
macro CommentSingleLine()
{
hbuf = GetCurrentBuf()
ln = GetBufLnCur(hbuf)
str = GetBufLine (hbuf, ln)
str = cat("/*",str)
str = cat(str,"*/")
PutBufLine (hbuf, ln, str)
}
macro CommentSelStr()
{
hbuf = GetCurrentBuf()
ln = GetBufLnCur(hbuf)
str = GetBufSelText(hbuf)
str = cat("/*",str)
str = cat(str,"*/")
SetBufSelText (hbuf, str)
}
macro MyInsertHeader()
{
szMyName = getenv(MYNAME)
hbuf = GetCurrentBuf()
szFunc = GetCurSymbol()
ln = GetSymbolLine(szFunc)
InsBufLine(hbuf, ln, "/************************************************************");
ln = ln +1
sz = "* Function : "
cch = strlen(szFunc)
ich = 0
sz = Cat(sz,szFunc)
InsBufLine(hbuf, ln, sz)
ln = ln + 1
InsBufLine(hbuf, ln, "* brief : ")
ln = ln + 1
InsBufLine(hbuf, ln, "* args[in] : ")
ln = ln + 1
InsBufLine(hbuf, ln, "* args[out]: ")
ln = ln + 1
InsBufLine(hbuf, ln, "* return : ")
ln = ln + 1
InsBufLine(hbuf, ln, "*************************************************************/")
}
macro MyInsertFileHeader()
{
szMyName = getenv(MYNAME)
hbuf = GetCurrentBuf()
InsBufLine(hbuf, 0, "/***************************************************************************")
filename = GetBufName(hbuf)
InsBufLine(hbuf, 1, "** file : @filename@")
InsBufLine(hbuf, 2, "** brief : ")
InsBufLine(hbuf, 3, "** version: V1.0")
InsBufLine(hbuf, 4, "** author : chensong")
szTime = GetSysTime(1)
Day = szTime.Day
Month = szTime.Month
Year = szTime.Year
if (Day < 10)
szDay = "0@Day@"
else
szDay = Day
InsBufLine(hbuf, 5, "** date : @Year@.@Month@.@szDay@")
InsBufLine(hbuf, 6, "** modify : 1、chensong @Year@.@Month@.@szDay@")
InsBufLine(hbuf, 7, " content: create file")
InsBufLine(hbuf, 8, "***************************************************************************/")
}
macro MyCreateHeadFile()
{
szMyName = getenv(MYNAME)
hbuf = GetCurrentBuf()
szName = Ask("Enter file name:");
ln = 0
InsBufLine(hbuf, ln, "/***************************************************************************")
ln = ln + 1
filename = GetBufName(hbuf)
InsBufLine(hbuf, ln, "** file : @filename@")
ln = ln + 1
InsBufLine(hbuf, ln, "** brief : ")
ln = ln + 1
InsBufLine(hbuf, ln, "** version: V1.0")
ln = ln + 1
InsBufLine(hbuf, ln, "** author : chensong")
szTime = GetSysTime(1)
Day = szTime.Day
Month = szTime.Month
Year = szTime.Year
if (Day < 10)
szDay = "0@Day@"
else
szDay = Day
ln = ln + 1
InsBufLine(hbuf, ln, "** date : @Year@.@Month@.@szDay@")
ln = ln + 1
InsBufLine(hbuf, ln, "** modify : 1、chensong @Year@.@Month@.@szDay@")
ln = ln + 1
InsBufLine(hbuf, ln, " content: create file")
ln = ln + 1
InsBufLine(hbuf, ln, "***************************************************************************/")
ln = ln + 1
InsBufLine(hbuf, ln, "#ifndef @szName@_H")
ln = ln + 1
InsBufLine(hbuf, ln, "#define @szName@_H")
ln = ln + 1
InsBufLine(hbuf, ln, "/*----------------------------------------------*/")
ln = ln + 1
InsBufLine(hbuf, ln, "/* Macros & Typedefs */")
ln = ln + 1
InsBufLine(hbuf, ln, "/*----------------------------------------------*/")
ln = ln + 1
InsBufLine(hbuf, ln, "#define @szName@_ERR_OK (0)")
ln = ln + 1
InsBufLine(hbuf, ln, "#define @szName@_ERR_BASE (0x00100000)")
ln = ln + 1
InsBufLine(hbuf, ln, "#define @szName@_ERR_INVALID_PARAM (0x00000001 + @szName@_ERR_BASE)")
ln = ln + 1
InsBufLine(hbuf, ln, "#define @szName@_ERR_NULL_POINTER (0x00000002 + @szName@_ERR_BASE)")
ln = ln + 1
InsBufLine(hbuf, ln, "#define @szName@_ERR_PROCESS_FAILED (0x00000003 + @szName@_ERR_BASE)")
ln = ln + 1
InsBufLine(hbuf, ln, "#define @szName@_ERR_NOT_READY (0x00000004 + @szName@_ERR_BASE)")
ln = ln + 1
InsBufLine(hbuf, ln, "#define @szName@_ERR_INIT_FAILED (0x00000005 + @szName@_ERR_BASE)")
ln = ln + 1
InsBufLine(hbuf, ln, "#define @szName@_ERR_ALLOC_MEM_FAIED (0x00000006 + @szName@_ERR_BASE)")
ln = ln + 1
InsBufLine(hbuf, ln, "/*----------------------------------------------*/")
ln = ln + 1
InsBufLine(hbuf, ln, "/* Structure Declarations */")
ln = ln + 1
InsBufLine(hbuf, ln, "/*----------------------------------------------*/")
ln = ln + 1
InsBufLine(hbuf, ln, "/*----------------------------------------------*/")
ln = ln + 1
InsBufLine(hbuf, ln, "/* Class Declarations */")
ln = ln + 1
InsBufLine(hbuf, ln, "/*----------------------------------------------*/")
ln = ln + 1
InsBufLine(hbuf, ln, "/*----------------------------------------------*/")
ln = ln + 1
InsBufLine(hbuf, ln, "/* Function Declarations */")
ln = ln + 1
InsBufLine(hbuf, ln, "/*----------------------------------------------*/")
ln = ln + 1
InsBufLine(hbuf, ln, "/*----------------------------------------------*/")
ln = ln + 1
InsBufLine(hbuf, ln, "/* Global Variables */")
ln = ln + 1
InsBufLine(hbuf, ln, "/*----------------------------------------------*/")
ln = ln + 1
InsBufLine(hbuf, ln, "#endif")
}