Quicker宏在SI中的使用方法(下载地址:链接:https://pan.baidu.com/s/1VrDxlPhft7RPUCCOKxsGIg  提取码:2d4u)

Quicker宏的添加到SI中配置方法:

1. 运行SI,打开Base工程,如果没有该工程,则生成它,将Quicker.em加入到工程中

2. 安装触发热键和菜单,打开SI的Options的Key Assignments菜单,在Command窗口中选择Macro: AutoExpand然后对其赋一个热键,例如Ctrl Enter

3. 对于宏FormatLine,UpdateFunctionList,InsertTraceInfo,InsertFuncName,ReplaceBufTab,ReplaceTabInProj,ComentCPPtoC等功能,可以根据情况定义为菜单或热键

4. 选择Options的Save Configuration先保存自己的配置,以便回退,回退时选择Options的Load Configuration来装载该配置.

5. Quicker有两种命令,一种是扩展命令,一种是普通命令。

扩展命令:在代码文件中输入命令名,然后按前面AutoExpand宏所定义的热键(Ctrl Enter)来执行该命令通命令:直接根据定义的热键或菜单来执行,目前一般的扩展命令都对应有相应的普通命令

Quicker宏在SI中的使用方法:

1 标准C语言扩展

1.1 /* 自动生成/* */ 该命令自动生成C语言的注释,它能自动换行对齐,在把文档中一长串注释拷贝过来时特别管用,不用自己去对齐了。还能自动识别中文和英文单词,对于中文不会把一个字分开,对于英文单词分开时会自动添加连字符,下面是一个注释的例子abcdefghijk = abcd + cdefg + hijk /*该命令自动生成C语言的注释,它能自动换行对齐,在把文档中一长串注释拷贝过来时特别管用,不用自己去对齐了。*/

1.2 { 自动生成 }

1.3 while (wh) 自动生成While语句

while ( # )
{
#
}

1.4 if 自动生成if语句

if 生成if结构的语句
ife 对应生成if else结构的语句
ifs 对应生成if elseif else结构的f语句
if ( # )
{
#
}

1.5 for 自动生成for语句,支持块命令插入

该命令自动生成如下格式

for ( #; #; # )
{
#
}

1.5.1 fo 自动生成for语句与前一条命令相比它直接会定义循环变量

UINT32 ulI = ;

for ( ulI = ; ulI < #; ulI++ )
{
#
}

1.6 do 自动生成 do while语句

该命令自动生成如下格式

do
{
#
} while ( # );

1.7 #ifd 自动生成 #ifdef 命令

该命令生成如下格式

#ifdef UMSC

#endif /* UMSC */

1.8 #ifn 自动生成 #ifndef 命令

该命令生成如下格式

#ifndef UMSC

#endif /* UMSC */

1.9 #if 自动生成 #if 命令

该命令生成如下格式

#if ( UMSC == 1)
#endif /*if ( UMSC == 1) */

1.10 cpp 自动生成适用于c++的c原型说明定义

该命令生成如下格式

#ifdef __cplusplus
#if __cplusplus extern "C"{ #endif #endif /* __cplusplus */ #ifdef __cplusplus #if __cplusplus
}
#endif
#endif /* __cplusplus */

1.11 switch (sw) 自动生成switch语句

该命令将提示输入case的个数,生成如下格式

switch ( # )
{
case #:
#
break;
default:
#
}

1.12 case (ca)自动生成case语句

支持块命令输入

该命令生成如下格式,用它可以避免遗漏break

case #:
#
break;

1.13 struct (st) 自动生成结构类型

该命令自动生成如下结构定义,它提示输入结构名,会自动转换成大写形式,并且自动在其后添加_STRU作为结构类型

typedef struct HELLO_TEST
{
#
}HELLO_TEST_STRU;

1.14 enum (en) 自动生成枚举类型

该命令自动生成如下结构定义,它提示输入结构名,会自动转换成大写形式,并且自动在其后添加_STRU作为结构类型

typedef enum HELLO_TEST
{
#
}HELLO_TEST_ENUM;

2 标准说明生成

2.1  config (co) 配置用户名和标题的说明语种

用户名就是前面自动生成的作者,修改者的名字,语种。

2.2  file (fi) 生成标准的文件头

自动生成如下格式,它能自动取得文件名,作者名,时间,以及函数列表。

2.3 func (fu) 生成标准的函数头说明

其自动生成如下函数头,该函数必须在该函数的前一行执行,它能自动取得函数名,能够自动取得函数的输入、输出参数,并且排列好,同时生成日期和作者。能够 提示输入功能描述,输入的内容能够自动换行对齐,这样既可以避免遗漏说明,而且一般在详细设计中对每个函数的主要功能都有详细的描述,只要把这些描述 拷贝过来即可,它能自动排列好, 非常方便。(因为SI的宏功能有限,没能自动加入调用函数和被调函数的功能),如果不是在已存在的函数前执行则提示输入函数名,提示输入函数描述,提示输入返回值类型,提示输入函数入口参数,输完后按Esc退出。

2.4  hi  增加修改历史列表

自动在该行增加修改历史列表,用于文件头和函数头说明中的历史记录更新,其添加形式如下。

2.5  hd  自动生成函数头文件

该命令能够自动生成但前C文件的头文件定义,包括常用的宏定义,还有全部的函数原型定义。

2.6  Hdn  生成新的有文件

该命令能够自动生成指定的的头文件定义,包括常用的宏定义,提示输入函数原型的类型。

3 代码修改注释

3.1  pn  添加问题单号

在进行问题单修改时都要求在修改的地方注明问题单号和修改人以及修改时间,大部分一个问题单的修改都会涉及到几个地方,本功能提供自动取问题单号的功能,下面的几个命令所生成的问题单号就是有它提供,如果输入为#则不显示问题单号

3.2  ap 添加问题单修改说明

该命令提示输入问题单号和修改原因,生成如下格式的说明

3.3 ab 添加开始说明

它能自动生成如下说明:

1.有问题单号的情况,其中问题单号是由ap命令加入的。

/*BEGIN: Added by XXXX, 2002/5/13   问题单号:D02556*/

2.没有问题单号的情况,

/*BEGIN: Added by XXXX, 2002/5/13*/

3.4  ae  添加结束命令

该命令是as的对应命令,表示结束添加

支持块命令操作

3.5  abg 插入添加开始和结束说明

该命令是前两个命令的组合

支持块命令操作

3.6  db 删除开始命令

它能自动生成如下说明:

1.有问题单号的情况,其中问题单号是由ap命令加入的。

/*BEGIN: Deleted by XXXX, 2002/5/13   问题单号:D02556*/

2.没有问题单号的情况,

/*BEGIN: Deleted by XXXX, 2002/5/13 */

3.7  de  删除结束命令

该命令是ds的对应命令,表示删除结束

3.8  dbg 插入删除开始和结束说明

该命令是前两个命令的组合

支持块命令操作

3.9  mb 修改开始命令

它能自动生成如下说明:

1.有问题单号的情况,其中问题单号是由ap命令加入的。

/*BEGIN: Modified by XXXX, 2002/5/13   问题单号:D02556*/

2.没有问题单号的情况,

/*BEGIN: Modified by XXXX, 2002/5/13 */

3.10  me  修改结束命令

该命令是ms的对应命令,表示删除结束

3.11  mbg 插入修改开始和结束说明

该命令是前两个命令的组合

支持块命令操作

Quicker.em源码(下载地址 链接:https://pan.baidu.com/s/1tUn5vTbnOtY-tlT9lilL5w 提取码:nlwg)

/*****************************************************************************
函 数 名 : AutoExpand
功能描述 : 扩展命令入口函数
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 修改 *****************************************************************************/
macro AutoExpand() //Alt+~
{
//配置信息
// get window, sel, and buffer handles
hwnd = GetCurrentWnd()
if (hwnd == )
stop
sel = GetWndSel(hwnd)
if(sel.lnFirst != sel.lnLast)
{
/*块命令处理*/
BlockCommandProc()
}
if (sel.ichFirst == )
stop
hbuf = GetWndBuf(hwnd)
language = getreg(LANGUAGE)
if(language != )
{
language =
}
nVer =
nVer = GetVersion()
/*取得用户名*/
szMyName = getreg(MYNAME)
if(strlen( szMyName ) == )
{
szMyName = Ask("Enter your name:")
setreg(MYNAME, szMyName)
}
// get line the selection (insertion point) is on
szLine = GetBufLine(hbuf, sel.lnFirst);
// parse word just to the left of the insertion point
wordinfo = GetWordLeftOfIch(sel.ichFirst, szLine)
ln = sel.lnFirst;
chTab = CharFromAscii() // prepare a new indented blank line to be inserted.
// keep white space on left and add a tab to indent.
// this preserves the indentation level.
chSpace = CharFromAscii();
ich =
while (szLine[ich] == chSpace || szLine[ich] == chTab)
{
ich = ich +
}
szLine1 = strmid(szLine,,ich)
szLine = strmid(szLine, , ich) # " " sel.lnFirst = sel.lnLast
sel.ichFirst = wordinfo.ich
sel.ichLim = wordinfo.ich /*自动完成简化命令的匹配显示*/
wordinfo.szWord = RestoreCommand(hbuf,wordinfo.szWord)
sel = GetWndSel(hwnd)
if (wordinfo.szWord == "pn") /*问题单号的处理*/
{
DelBufLine(hbuf, ln)
AddPromblemNo()
return
}
/*配置命令执行*/
else if (wordinfo.szWord == "config" || wordinfo.szWord == "co")
{
DelBufLine(hbuf, ln)
ConfigureSystem()
return
}
/*修改历史记录更新*/
else if (wordinfo.szWord == "hi")
{
InsertHistory(hbuf,ln+,language)
DelBufLine(hbuf, ln)
return
}
else if (wordinfo.szWord == "abg")
{
sel.ichFirst = sel.ichFirst -
SetWndSel(hwnd,sel)
InsertReviseAdd()
PutBufLine(hbuf, ln+ ,szLine1)
SetBufIns(hwnd,ln+,sel.ichFirst)
return
}
else if (wordinfo.szWord == "dbg")
{
sel.ichFirst = sel.ichFirst -
SetWndSel(hwnd,sel)
InsertReviseDel()
PutBufLine(hbuf, ln+ ,szLine1)
SetBufIns(hwnd,ln+,sel.ichFirst)
return
}
else if (wordinfo.szWord == "mbg")
{
sel.ichFirst = sel.ichFirst -
SetWndSel(hwnd,sel)
InsertReviseMod()
PutBufLine(hbuf, ln+ ,szLine1)
SetBufIns(hwnd,ln+,sel.ichFirst)
return
}
if(language == )
{
ExpandProcEN(szMyName,wordinfo,szLine,szLine1,nVer,ln,sel)
}
else
{
ExpandProcCN(szMyName,wordinfo,szLine,szLine1,nVer,ln,sel)
}
} /*****************************************************************************
函 数 名 : ExpandProcEN
功能描述 : 英文说明的扩展命令处理
输入参数 : szMyName 用户名
wordinfo
szLine
szLine1
nVer
ln
sel
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月19日
作 者 : 张强
修改内容 : 新生成函数 2.日 期 : 2011年2月16日
作 者 : 彭军
修改内容 : 修改问题单号为mantis号,修改时间格式为xxxxxxxx(年、月、日),
中间没有分隔符,增加单行注释,自动扩展码为"an" 3.日 期 : 2011年2月22日
作 者 : 彭军
修改内容 : 修改单行注释头为add by、delete by、modify by,自动扩展码分别为"as"、"ds"、"ms"
修改单行注释为光标所在行的最后,不删除光标所在行
删除原自动扩展码为"an"的单行注释 *****************************************************************************/
macro ExpandProcEN(szMyName,wordinfo,szLine,szLine1,nVer,ln,sel)
{ szCmd = wordinfo.szWord
hwnd = GetCurrentWnd()
if (hwnd == )
stop
hbuf = GetWndBuf(hwnd)
/*英文注释*/
if (szCmd == "/*")
{
if(wordinfo.ichLim > )
{
Msg("The right margine is small, Please use a new line")
stop
}
szCurLine = GetBufLine(hbuf, sel.lnFirst);
szLeft = strmid(szCurLine,,wordinfo.ichLim)
lineLen = strlen(szCurLine)
kk =
while(wordinfo.ichLim + kk < lineLen)
{
if((szCurLine[wordinfo.ichLim + kk] != " ")||(szCurLine[wordinfo.ichLim + kk] != "\t")
{
msg("you must insert /* at the end of a line");
return
}
kk = kk +
}
szContent = Ask("Please input comment")
DelBufLine(hbuf, ln)
szLeft = cat( szLeft, " ")
CommentContent(hbuf,ln,szLeft,szContent,)
return
}
else if(szCmd == "{")
{
InsBufLine(hbuf, ln + , "@szLine@")
InsBufLine(hbuf, ln + , "@szLine1@" # "}");
SetBufIns (hbuf, ln + , strlen(szLine))
return
}
else if (szCmd == "while" )
{
SetBufSelText(hbuf, " ( # )")
InsBufLine(hbuf, ln + , "@szLine1@" # "{");
InsBufLine(hbuf, ln + , "@szLine@" # "#");
InsBufLine(hbuf, ln + , "@szLine1@" # "}");
}
else if( szCmd == "else" )
{
InsBufLine(hbuf, ln + , "@szLine1@" # "{");
InsBufLine(hbuf, ln + , "@szLine@");
InsBufLine(hbuf, ln + , "@szLine1@" # "}");
SetBufIns (hbuf, ln + , strlen(szLine))
return
}
else if (szCmd == "#ifd" || szCmd == "#ifdef") //#ifdef
{
DelBufLine(hbuf, ln)
InsIfdef()
return
}
else if (szCmd == "#ifn" || szCmd == "#ifndef") //#ifndef
{
DelBufLine(hbuf, ln)
InsIfndef()
return
}
else if (szCmd == "#if")
{
DelBufLine(hbuf, ln)
InsertPredefIf()
return
}
else if (szCmd == "cpp")
{
DelBufLine(hbuf, ln)
InsertCPP(hbuf,ln)
return
}
else if (szCmd == "if")
{
SetBufSelText(hbuf, " ( # )")
InsBufLine(hbuf, ln + , "@szLine1@" # "{");
InsBufLine(hbuf, ln + , "@szLine@" # "#");
InsBufLine(hbuf, ln + , "@szLine1@" # "}");
/* InsBufLine(hbuf, ln + 4, "@szLine1@" # "else");
InsBufLine(hbuf, ln + 5, "@szLine1@" # "{");
InsBufLine(hbuf, ln + 6, "@szLine@" # ";");
InsBufLine(hbuf, ln + 7, "@szLine1@" # "}");*/
}
else if (szCmd == "ef")
{
PutBufLine(hbuf, ln, szLine1 # "else if ( # )")
InsBufLine(hbuf, ln + , "@szLine1@" # "{");
InsBufLine(hbuf, ln + , "@szLine@" # "#");
InsBufLine(hbuf, ln + , "@szLine1@" # "}");
}
else if (szCmd == "ife")
{
PutBufLine(hbuf, ln, szLine1 # "if ( # )")
InsBufLine(hbuf, ln + , "@szLine1@" # "{");
InsBufLine(hbuf, ln + , "@szLine@" # "#");
InsBufLine(hbuf, ln + , "@szLine1@" # "}");
InsBufLine(hbuf, ln + , "@szLine1@" # "else");
InsBufLine(hbuf, ln + , "@szLine1@" # "{");
InsBufLine(hbuf, ln + , "@szLine@" # ";");
InsBufLine(hbuf, ln + , "@szLine1@" # "}");
}
else if (szCmd == "ifs")
{
PutBufLine(hbuf, ln, szLine1 # "if ( # )")
InsBufLine(hbuf, ln + , "@szLine1@" # "{");
InsBufLine(hbuf, ln + , "@szLine@" # "#");
InsBufLine(hbuf, ln + , "@szLine1@" # "}");
InsBufLine(hbuf, ln + , "@szLine1@" # "else if ( # )");
InsBufLine(hbuf, ln + , "@szLine1@" # "{");
InsBufLine(hbuf, ln + , "@szLine@" # ";");
InsBufLine(hbuf, ln + , "@szLine1@" # "}");
InsBufLine(hbuf, ln + , "@szLine1@" # "else");
InsBufLine(hbuf, ln + , "@szLine1@" # "{");
InsBufLine(hbuf, ln + , "@szLine@" # ";");
InsBufLine(hbuf, ln + , "@szLine1@" # "}");
}
else if (szCmd == "for")
{
SetBufSelText(hbuf, " (#; #; #)")
InsBufLine(hbuf, ln + , "@szLine1@" # "{")
InsBufLine(hbuf, ln + , "@szLine@" # "#")
InsBufLine(hbuf, ln + , "@szLine1@" # "}")
SetWndSel(hwnd, sel)
SearchForward()
szVar = ask("Please input loop variable")
newsel = sel
newsel.ichLim = GetBufLineLength (hbuf, ln)
SetWndSel(hwnd, newsel)
SetBufSelText(hbuf, " (@szVar@ = #; @szVar@ #; @szVar@++)")
}
else if (szCmd == "fo")
{
SetBufSelText(hbuf, "r (ulI = 0; ulI < #; ulI++)")
InsBufLine(hbuf, ln + , "@szLine1@" # "{")
InsBufLine(hbuf, ln + , "@szLine@" # "#")
InsBufLine(hbuf, ln + , "@szLine1@" # "}")
symname =GetCurSymbol ()
symbol = GetSymbolLocation(symname)
if(strlen(symbol) > )
{
nIdx = symbol.lnName + ;
while( )
{
szCurLine = GetBufLine(hbuf, nIdx);
nRet = strstr(szCurLine,"{")
if( nRet != 0xffffffff )
{
break;
}
nIdx = nIdx +
if(nIdx > symbol.lnLim)
{
break
}
}
InsBufLine(hbuf, nIdx + , " VOS_UINT32 ulI = 0;");
}
}
else if (szCmd == "switch" )
{
nSwitch = ask("Please input the number of case")
SetBufSelText(hbuf, " ( # )")
InsBufLine(hbuf, ln + , "@szLine1@" # "{")
InsertMultiCaseProc(hbuf,szLine1,nSwitch)
}
else if (szCmd == "do")
{
InsBufLine(hbuf, ln + , "@szLine1@" # "{")
InsBufLine(hbuf, ln + , "@szLine@" # "#");
InsBufLine(hbuf, ln + , "@szLine1@" # "} while ( # );")
}
else if (szCmd == "case" )
{
SetBufSelText(hbuf, " # :")
InsBufLine(hbuf, ln + , "@szLine@" # "#")
InsBufLine(hbuf, ln + , "@szLine@" # "break;")
}
else if (szCmd == "struct" || szCmd == "st")
{
DelBufLine(hbuf, ln)
szStructName = toupper(Ask("Please input struct name"))
InsBufLine(hbuf, ln, "@szLine1@typedef struct @szStructName@");
InsBufLine(hbuf, ln + , "@szLine1@{");
InsBufLine(hbuf, ln + , "@szLine@ ");
szStructName = cat(szStructName,"_STRU")
InsBufLine(hbuf, ln + , "@szLine1@}@szStructName@;");
SetBufIns (hbuf, ln + , strlen(szLine))
return
}
else if (szCmd == "enum" || szCmd == "en")
{
DelBufLine(hbuf, ln)
szStructName = toupper(Ask("Please input enum name"))
InsBufLine(hbuf, ln, "@szLine1@typedef enum @szStructName@");
InsBufLine(hbuf, ln + , "@szLine1@{");
InsBufLine(hbuf, ln + , "@szLine@ ");
szStructName = cat(szStructName,"_ENUM")
InsBufLine(hbuf, ln + , "@szLine1@}@szStructName@;");
SetBufIns (hbuf, ln + , strlen(szLine))
return
}
else if (szCmd == "file" || szCmd == "fi")
{
DelBufLine(hbuf, ln)
InsertFileHeaderEN( hbuf,, szMyName,".C file function description" )
return
}
else if (szCmd == "func" || szCmd == "fu")
{
DelBufLine(hbuf,ln)
lnMax = GetBufLineCount(hbuf)
if(ln != lnMax)
{
szNextLine = GetBufLine(hbuf,ln)
if( (strstr(szNextLine,"(") != 0xffffffff) || (nVer != ))
{
symbol = GetCurSymbol()
if(strlen(symbol) != )
{
FuncHeadCommentEN(hbuf, ln, symbol, szMyName,)
return
}
}
}
szFuncName = Ask("Please input function name")
FuncHeadCommentEN(hbuf, ln, szFuncName, szMyName, )
}
else if (szCmd == "tab")
{
DelBufLine(hbuf, ln)
ReplaceBufTab()
return
}
else if (szCmd == "ap")
{
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
} DelBufLine(hbuf, ln)
szQuestion = AddPromblemNo()
InsBufLine(hbuf, ln, "@szLine1@/* Promblem Number: @szQuestion@ Author:@szMyName@, Date:@sz@-@szMonth@-@szDay@ ");
szContent = Ask("Description")
szLeft = cat(szLine1," Description : ");
if(strlen(szLeft) > )
{
Msg("The right margine is small, Please use a new line")
stop
}
ln = CommentContent(hbuf,ln + ,szLeft,szContent,)
return
}
else if (szCmd == "hd")
{
DelBufLine(hbuf, ln)
CreateFunctionDef(hbuf,szMyName,)
return
}
else if (szCmd == "hdn")
{
DelBufLine(hbuf, ln) /*生成不要文件名的新头文件*/
CreateNewHeaderFile()
return
}
else if (szCmd == "ab")
{
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
} DelBufLine(hbuf, ln)
szQuestion = GetReg ("PNO")
if(strlen(szQuestion)>)
{
InsBufLine(hbuf, ln, "@szLine1@/* add begin by @szMyName@, @sz@-@szMonth@-@szDay@*/");
}
else
{
InsBufLine(hbuf, ln, "@szLine1@/* add begin by @szMyName@, @sz@-@szMonth@-@szDay@*/");
}
return
}
else if (szCmd == "ae")
{
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
} DelBufLine(hbuf, ln)
InsBufLine(hbuf, ln, "@szLine1@/* add end by @szMyName@, @sz@-@szMonth@-@szDay@ */");
return
}
else if (szCmd == "db")
{
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
} DelBufLine(hbuf, ln)
szQuestion = GetReg ("PNO")
if(strlen(szQuestion) > )
{
InsBufLine(hbuf, ln, "@szLine1@/* delete begin by @szMyName@, @sz@-@szMonth@-@szDay@ */");
}
else
{
InsBufLine(hbuf, ln, "@szLine1@/* delete begin by @szMyName@, @sz@-@szMonth@-@szDay@ */");
} return
}
else if (szCmd == "de")
{
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
} DelBufLine(hbuf, ln + )
InsBufLine(hbuf, ln, "@szLine1@/* delete end by @szMyName@, @sz@-@szMonth@-@szDay@ */");
return
}
else if (szCmd == "mb")
{
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
} DelBufLine(hbuf, ln)
szQuestion = GetReg ("PNO")
if(strlen(szQuestion) > )
{
InsBufLine(hbuf, ln, "@szLine1@/* modify begin by @szMyName@, @sz@-@szMonth@-@szDay@ */");
}
else
{
InsBufLine(hbuf, ln, "@szLine1@/* modify begin by @szMyName@, @sz@-@szMonth@-@szDay@ */");
}
return
}
else if (szCmd == "me")
{
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
} DelBufLine(hbuf, ln)
InsBufLine(hbuf, ln, "@szLine1@/* modify end by @szMyName@, @sz@-@szMonth@-@szDay@ */");
return
}
else if (szCmd == "as")
{
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
} szLine1 = strmid (GetBufLine(hbuf, ln), , GetBufLineLength (hbuf, ln)-)
DelBufLine(hbuf, ln) szQuestion = GetReg ("PNO")
if(strlen(szQuestion)>)
{
InsBufLine(hbuf, ln, "@szLine1@/* add by @szMyName@, @sz@-@szMonth@-@szDay@ */");
}
else
{
InsBufLine(hbuf, ln, "@szLine1@/* add by @szMyName@, @sz@-@szMonth@-@szDay@ */");
}
return
}
else if (szCmd == "cs")/*添加一个命令cs 用于生成注释comment by xxx . 该命令被王启国添加2014-5-4*/
{
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
} szLine1 = strmid (GetBufLine(hbuf, ln), , GetBufLineLength (hbuf, ln)-)
DelBufLine(hbuf, ln) szQuestion = GetReg ("PNO")
if(strlen(szQuestion)>)
{
InsBufLine(hbuf, ln, "@szLine1@/* comment by @szMyName@, @sz@-@szMonth@-@szDay@ */");
}
else
{
InsBufLine(hbuf, ln, "@szLine1@/* comment by @szMyName@, @sz@-@szMonth@-@szDay@ */");
}
return
}
else if (szCmd == "ds")
{
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
} szLine1 = strmid (GetBufLine(hbuf, ln), , GetBufLineLength (hbuf, ln)-)
DelBufLine(hbuf, ln)
szQuestion = GetReg ("PNO")
if(strlen(szQuestion)>)
{
InsBufLine(hbuf, ln, "@szLine1@/* delete by @szMyName@, @sz@-@szMonth@-@szDay@ */");
}
else
{
InsBufLine(hbuf, ln, "@szLine1@/* delete by @szMyName@, @sz@-@szMonth@-@szDay@ */");
}
return
}
else if (szCmd == "ms")
{
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
} szLine1 = strmid (GetBufLine(hbuf, ln), , GetBufLineLength (hbuf, ln)-)
DelBufLine(hbuf, ln)
szQuestion = GetReg ("PNO")
if(strlen(szQuestion)>)
{
InsBufLine(hbuf, ln, "@szLine1@/* modify by @szMyName@, @sz@-@szMonth@-@szDay@ */");
}
else
{
InsBufLine(hbuf, ln, "@szLine1@/* modify by @szMyName@, @sz@-@szMonth@-@szDay@ */");
}
return
}
else
{
SearchForward()
// ExpandBraceLarge()
stop
}
SetWndSel(hwnd, sel)
SearchForward()
} /*****************************************************************************
函 数 名 : ExpandProcCN
功能描述 : 中文说明的扩展命令
输入参数 : szMyName
wordinfo
szLine
szLine1
nVer
ln
sel
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月19日
作 者 : 张强
修改内容 : 新生成函数 2.日 期 : 2011年2月16日
作 者 : 彭军
修改内容 : 修改问题单号为mantis号,修改时间格式为xxxxxxxx(年、月、日),
中间没有分隔符,增加单行注释,自动扩展码为"an" 3.日 期 : 2011年2月22日
作 者 : 彭军
修改内容 : 修改单行注释头为add by、delete by、modify by,自动扩展码分别为"as"、"ds"、"ms"
修改单行注释为光标所在行的最后,不删除光标所在行
删除原自动扩展码为"an"的单行注释 4.日 期 : 2011年3月18日
作 者 : 彭军
修改内容 : 修改文件的注释不输入描述(不输入描述则文件头注释函数会自动提示用户输入) *****************************************************************************/
macro ExpandProcCN(szMyName,wordinfo,szLine,szLine1,nVer,ln,sel)
{
szCmd = wordinfo.szWord
hwnd = GetCurrentWnd()
if (hwnd == )
stop
hbuf = GetWndBuf(hwnd) //中文注释
if (szCmd == "/*")
{
if(wordinfo.ichLim > )
{
Msg("右边空间太小,请用新的行")
stop
} szCurLine = GetBufLine(hbuf, sel.lnFirst);
szLeft = strmid(szCurLine,,wordinfo.ichLim)
lineLen = strlen(szCurLine)
kk =
/*注释只能在行尾,避免注释掉有用代码*/
while(wordinfo.ichLim + kk < lineLen)
{
if(szCurLine[wordinfo.ichLim + kk] != " ")
{
msg("只能在行尾插入");
return
}
kk = kk +
}
szContent = Ask("请输入注释的内容")
DelBufLine(hbuf, ln)
szLeft = cat( szLeft, " ") //在/*后加一个空格,最后出来的格式是/* 要注释的内容 */
CommentContent(hbuf,ln,szLeft,szContent,)
return
}
else if(szCmd == "{")
{
InsBufLine(hbuf, ln + , "@szLine@")
InsBufLine(hbuf, ln + , "@szLine1@" # "}");
SetBufIns (hbuf, ln + , strlen(szLine))
return
}
else if (szCmd == "while" || szCmd == "wh")
{
SetBufSelText(hbuf, " ( # )")
InsBufLine(hbuf, ln + , "@szLine1@" # "{");
InsBufLine(hbuf, ln + , "@szLine@" # "#");
InsBufLine(hbuf, ln + , "@szLine1@" # "}");
}
else if( szCmd == "else" || szCmd == "el")
{
InsBufLine(hbuf, ln + , "@szLine1@" # "{");
InsBufLine(hbuf, ln + , "@szLine@");
InsBufLine(hbuf, ln + , "@szLine1@" # "}");
SetBufIns (hbuf, ln + , strlen(szLine))
return
}
else if (szCmd == "#ifd" || szCmd == "#ifdef") //#ifdef
{
DelBufLine(hbuf, ln)
InsIfdef()
return
}
else if (szCmd == "#ifn" || szCmd == "#ifndef") //#ifndef
{
DelBufLine(hbuf, ln)
InsIfndef()
return
}
else if (szCmd == "#if")
{
DelBufLine(hbuf, ln)
InsertPredefIf()
return
}
else if (szCmd == "cpp")
{
DelBufLine(hbuf, ln)
InsertCPP(hbuf,ln)
return
}
else if (szCmd == "if")
{
SetBufSelText(hbuf, " ( # )")
InsBufLine(hbuf, ln + , "@szLine1@" # "{");
InsBufLine(hbuf, ln + , "@szLine@" # "#");
InsBufLine(hbuf, ln + , "@szLine1@" # "}");
/* InsBufLine(hbuf, ln + 4, "@szLine1@" # "else");
InsBufLine(hbuf, ln + 5, "@szLine1@" # "{");
InsBufLine(hbuf, ln + 6, "@szLine@" # ";");
InsBufLine(hbuf, ln + 7, "@szLine1@" # "}");*/
}
else if (szCmd == "ef")
{
PutBufLine(hbuf, ln, szLine1 # "else if ( # )")
InsBufLine(hbuf, ln + , "@szLine1@" # "{");
InsBufLine(hbuf, ln + , "@szLine@" # "#");
InsBufLine(hbuf, ln + , "@szLine1@" # "}");
}
else if (szCmd == "ife")
{
PutBufLine(hbuf, ln, szLine1 # "if ( # )")
InsBufLine(hbuf, ln + , "@szLine1@" # "{");
InsBufLine(hbuf, ln + , "@szLine@" # "#");
InsBufLine(hbuf, ln + , "@szLine1@" # "}");
InsBufLine(hbuf, ln + , "@szLine1@" # "else");
InsBufLine(hbuf, ln + , "@szLine1@" # "{");
InsBufLine(hbuf, ln + , "@szLine@" # ";");
InsBufLine(hbuf, ln + , "@szLine1@" # "}");
}
else if (szCmd == "ifs")
{
PutBufLine(hbuf, ln, szLine1 # "if ( # )")
InsBufLine(hbuf, ln + , "@szLine1@" # "{");
InsBufLine(hbuf, ln + , "@szLine@" # "#");
InsBufLine(hbuf, ln + , "@szLine1@" # "}");
InsBufLine(hbuf, ln + , "@szLine1@" # "else if ( # )");
InsBufLine(hbuf, ln + , "@szLine1@" # "{");
InsBufLine(hbuf, ln + , "@szLine@" # ";");
InsBufLine(hbuf, ln + , "@szLine1@" # "}");
InsBufLine(hbuf, ln + , "@szLine1@" # "else");
InsBufLine(hbuf, ln + , "@szLine1@" # "{");
InsBufLine(hbuf, ln + , "@szLine@" # ";");
InsBufLine(hbuf, ln + , "@szLine1@" # "}");
}
else if (szCmd == "for")
{
SetBufSelText(hbuf, " (#; #; #)")
InsBufLine(hbuf, ln + , "@szLine1@" # "{")
InsBufLine(hbuf, ln + , "@szLine@" # "#")
InsBufLine(hbuf, ln + , "@szLine1@" # "}")
SetWndSel(hwnd, sel)
SearchForward()
szVar = ask("请输入循环变量")
newsel = sel
newsel.ichLim = GetBufLineLength (hbuf, ln)
SetWndSel(hwnd, newsel)
SetBufSelText(hbuf, " (@szVar@ = #; @szVar@ #; @szVar@++)")
}
else if (szCmd == "fo")
{
SetBufSelText(hbuf, "r (ulI = 0; ulI < #; ulI++)")
InsBufLine(hbuf, ln + , "@szLine1@" # "{")
InsBufLine(hbuf, ln + , "@szLine@" # "#")
InsBufLine(hbuf, ln + , "@szLine1@" # "}")
symname =GetCurSymbol ()
symbol = GetSymbolLocation(symname)
if(strlen(symbol) > )
{
nIdx = symbol.lnName + ;
while( )
{
szCurLine = GetBufLine(hbuf, nIdx);
nRet = strstr(szCurLine,"{")
if( nRet != 0xffffffff )
{
break;
}
nIdx = nIdx +
if(nIdx > symbol.lnLim)
{
break
}
}
InsBufLine(hbuf, nIdx + , " VOS_UINT32 ulI = 0;");
}
}
else if (szCmd == "switch" || szCmd == "sw")
{
nSwitch = ask("请输入case的个数")
SetBufSelText(hbuf, " ( # )")
InsBufLine(hbuf, ln + , "@szLine1@" # "{")
InsertMultiCaseProc(hbuf,szLine1,nSwitch)
}
else if (szCmd == "do")
{
InsBufLine(hbuf, ln + , "@szLine1@" # "{")
InsBufLine(hbuf, ln + , "@szLine@" # "#");
InsBufLine(hbuf, ln + , "@szLine1@" # "} while ( # );")
}
else if (szCmd == "case" || szCmd == "ca" )
{
SetBufSelText(hbuf, " # :")
InsBufLine(hbuf, ln + , "@szLine@" # "#")
InsBufLine(hbuf, ln + , "@szLine@" # "break;")
}
else if (szCmd == "struct" || szCmd == "st" )
{
DelBufLine(hbuf, ln)
szStructName = toupper(Ask("请输入结构名:"))
InsBufLine(hbuf, ln, "@szLine1@typedef struct @szStructName@");
InsBufLine(hbuf, ln + , "@szLine1@{");
InsBufLine(hbuf, ln + , "@szLine@ ");
szStructName = cat(szStructName,"_STRU")
InsBufLine(hbuf, ln + , "@szLine1@}@szStructName@;");
SetBufIns (hbuf, ln + , strlen(szLine))
return
}
else if (szCmd == "enum" || szCmd == "en")
{
DelBufLine(hbuf, ln)
//提示输入枚举名并转换为大写
szStructName = toupper(Ask("请输入枚举名:"))
InsBufLine(hbuf, ln, "@szLine1@typedef enum @szStructName@");
InsBufLine(hbuf, ln + , "@szLine1@{");
InsBufLine(hbuf, ln + , "@szLine@ ");
szStructName = cat(szStructName,"_ENUM")
InsBufLine(hbuf, ln + , "@szLine1@}@szStructName@;");
SetBufIns (hbuf, ln + , strlen(szLine))
return
}
else if (szCmd == "file" || szCmd == "fi" )
{
DelBufLine(hbuf, ln)
/*生成文件头说明*/
InsertFileHeaderCN( hbuf,, szMyName,"" )
return
}
else if (szCmd == "hd")
{
DelBufLine(hbuf, ln)
/*生成C语言的头文件*/
CreateFunctionDef(hbuf,szMyName,)
return
}
else if (szCmd == "hdn")
{
DelBufLine(hbuf, ln)
/*生成不要文件名的新头文件*/
CreateNewHeaderFile()
return
}
else if (szCmd == "func" || szCmd == "fu")
{
DelBufLine(hbuf,ln)
lnMax = GetBufLineCount(hbuf)
//最后一行肯定是新函数
if(ln != lnMax)
{
szNextLine = GetBufLine(hbuf,ln)
/*对于2.1版的si如果是非法symbol就会中断执行,故该为以后一行
是否有‘(’来判断是否是新函数*/
if( (strstr(szNextLine,"(") != 0xffffffff) || (nVer != ))
{
/*是已经存在的函数*/
symbol = GetCurSymbol()
if(strlen(symbol) != )
{
FuncHeadCommentCN(hbuf, ln, symbol, szMyName,)
return
}
}
}
szFuncName = Ask("请输入函数名称:")
/*是新函数*/
FuncHeadCommentCN(hbuf, ln, szFuncName, szMyName, )
}
else if (szCmd == "tab") /*将tab扩展为空格*/
{
DelBufLine(hbuf, ln)
ReplaceBufTab()
}
else if (szCmd == "ap")
{
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
} DelBufLine(hbuf, ln)
szQuestion = AddPromblemNo()
InsBufLine(hbuf, ln, "@szLine1@/* 问 题 单: @szQuestion@ 修改人:@szMyName@, 时间:@sz@-@szMonth@-@szDay@ ");
szContent = Ask("修改原因")
szLeft = cat(szLine1," 修改原因: ");
if(strlen(szLeft) > )
{
Msg("右边空间太小,请用新的行")
stop
}
ln = CommentContent(hbuf,ln + ,szLeft,szContent,)
return
}
else if (szCmd == "ab")
{
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
} DelBufLine(hbuf, ln)
szQuestion = GetReg ("PNO")
if(strlen(szQuestion)>)
{
InsBufLine(hbuf, ln, "@szLine1@/* add begin by @szMyName@, @sz@-@szMonth@-@szDay@, Mantis号:@szQuestion@ 原因: */");
}
else
{
InsBufLine(hbuf, ln, "@szLine1@/* add begin by @szMyName@, @sz@-@szMonth@-@szDay@, 原因: */");
}
return
}
else if (szCmd == "ae")
{
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
} DelBufLine(hbuf, ln)
InsBufLine(hbuf, ln, "@szLine1@/* add end by @szMyName@, @sz@-@szMonth@-@szDay@ */");
return
}
else if (szCmd == "db")
{
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
} DelBufLine(hbuf, ln)
szQuestion = GetReg ("PNO")
if(strlen(szQuestion) > )
{
InsBufLine(hbuf, ln, "@szLine1@/* delete begin by @szMyName@, @sz@-@szMonth@-@szDay@, Mantis号:@szQuestion@ 原因: */");
}
else
{
InsBufLine(hbuf, ln, "@szLine1@/* delete begin by @szMyName@, @sz@-@szMonth@-@szDay@, 原因: */");
} return
}
else if (szCmd == "de")
{
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
} DelBufLine(hbuf, ln + )
InsBufLine(hbuf, ln, "@szLine1@/* delete end by @szMyName@, @sz@-@szMonth@-@szDay@ */");
return
}
else if (szCmd == "mb")
{
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
} DelBufLine(hbuf, ln)
szQuestion = GetReg ("PNO")
if(strlen(szQuestion) > )
{
InsBufLine(hbuf, ln, "@szLine1@/* modify begin by @szMyName@, @sz@-@szMonth@-@szDay@, Mantis号:@szQuestion@ 原因: */");
}
else
{
InsBufLine(hbuf, ln, "@szLine1@/* modify begin by @szMyName@, @sz@-@szMonth@-@szDay@, 原因: */");
}
return
}
else if (szCmd == "me")
{
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
} DelBufLine(hbuf, ln)
InsBufLine(hbuf, ln, "@szLine1@/* modify end by @szMyName@, @sz@-@szMonth@-@szDay@ */");
return
}
else if (szCmd == "as")
{
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
} szLine1 = strmid (GetBufLine(hbuf, ln), , GetBufLineLength (hbuf, ln)-)
DelBufLine(hbuf, ln) szQuestion = GetReg ("PNO")
if(strlen(szQuestion)>)
{
InsBufLine(hbuf, ln, "@szLine1@/* add by @szMyName@, @sz@-@szMonth@-@szDay@, Mantis号:@szQuestion@, 原因: */");
}
else
{
InsBufLine(hbuf, ln, "@szLine1@/* add by @szMyName@, @sz@-@szMonth@-@szDay@, 原因: */");
}
return
}
else if (szCmd == "ds")
{
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
} szLine1 = strmid (GetBufLine(hbuf, ln), , GetBufLineLength (hbuf, ln)-)
DelBufLine(hbuf, ln)
szQuestion = GetReg ("PNO")
if(strlen(szQuestion)>)
{
InsBufLine(hbuf, ln, "@szLine1@/* delete by @szMyName@, @sz@-@szMonth@-@szDay@, Mantis号:@szQuestion@, 原因: */");
}
else
{
InsBufLine(hbuf, ln, "@szLine1@/* delete by @szMyName@, @sz@-@szMonth@-@szDay@, 原因: */");
}
return
}
else if (szCmd == "ms")
{
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
} szLine1 = strmid (GetBufLine(hbuf, ln), , GetBufLineLength (hbuf, ln)-)
DelBufLine(hbuf, ln)
szQuestion = GetReg ("PNO")
if(strlen(szQuestion)>)
{
InsBufLine(hbuf, ln, "@szLine1@/* modify by @szMyName@, @sz@-@szMonth@-@szDay@, Mantis号:@szQuestion@, 原因: */");
}
else
{
InsBufLine(hbuf, ln, "@szLine1@/* modify by @szMyName@, @sz@-@szMonth@-@szDay@, 原因: */");
}
return
}
else
{
SearchForward()
stop
}
SetWndSel(hwnd, sel)
SearchForward()
} /*****************************************************************************
函 数 名 : BlockCommandProc
功能描述 : 块命令处理函数
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro BlockCommandProc()
{
hwnd = GetCurrentWnd()
if (hwnd == )
stop
sel = GetWndSel(hwnd)
hbuf = GetWndBuf(hwnd)
if(sel.lnFirst > )
{
ln = sel.lnFirst -
}
else
{
stop
}
szLine = GetBufLine(hbuf,ln)
szLine = TrimString(szLine)
if(szLine == "while" || szLine == "wh")
{
InsertWhile() /*插入while*/
}
else if(szLine == "do")
{
InsertDo() //插入do while语句
}
else if(szLine == "for")
{
InsertFor() //插入for语句
}
else if(szLine == "if")
{
InsertIf() //插入if语句
}
else if(szLine == "el" || szLine == "else")
{
InsertElse() //插入else语句
DelBufLine(hbuf,ln)
stop
}
else if((szLine == "#ifd") || (szLine == "#ifdef"))
{
InsIfdef() //插入#ifdef
DelBufLine(hbuf,ln)
stop
}
else if((szLine == "#ifn") || (szLine == "#ifndef"))
{
InsIfndef() //插入#ifdef
DelBufLine(hbuf,ln)
stop
}
else if (szLine == "abg")
{
InsertReviseAdd()
DelBufLine(hbuf, ln)
stop
}
else if (szLine == "dbg")
{
InsertReviseDel()
DelBufLine(hbuf, ln)
stop
}
else if (szLine == "mbg")
{
InsertReviseMod()
DelBufLine(hbuf, ln)
stop
}
else if(szLine == "#if")
{
InsertPredefIf()
DelBufLine(hbuf,ln)
stop
}
DelBufLine(hbuf,ln)
SearchForward()
stop
} /*****************************************************************************
函 数 名 : RestoreCommand
功能描述 : 缩略命令恢复函数
输入参数 : hbuf
szCmd
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro RestoreCommand(hbuf,szCmd)
{
if(szCmd == "ca")
{
SetBufSelText(hbuf, "se")
szCmd = "case"
}
else if(szCmd == "sw")
{
SetBufSelText(hbuf, "itch")
szCmd = "switch"
}
else if(szCmd == "el")
{
SetBufSelText(hbuf, "se")
szCmd = "else"
}
else if(szCmd == "wh")
{
SetBufSelText(hbuf, "ile")
szCmd = "while"
}
return szCmd
} /*****************************************************************************
函 数 名 : SearchForward
功能描述 : 向前搜索#
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro SearchForward()
{
LoadSearchPattern("#", , , );
Search_Forward
} /*****************************************************************************
函 数 名 : SearchBackward
功能描述 : 向后搜索#
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro SearchBackward()
{
LoadSearchPattern("#", , , );
Search_Backward
} /*****************************************************************************
函 数 名 : InsertFuncName
功能描述 : 在当前位置插入但前函数名
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro InsertFuncName()
{
hwnd = GetCurrentWnd()
if (hwnd == )
stop
sel = GetWndSel(hwnd)
hbuf = GetWndBuf(hwnd)
symbolname = GetCurSymbol()
SetBufSelText (hbuf, symbolname)
} /*****************************************************************************
函 数 名 : strstr
功能描述 : 字符串匹配查询函数
输入参数 : str1 源串
str2 待匹配子串
输出参数 : 无
返 回 值 : 0xffffffff为没有找到匹配字符串,V2.1不支持-1故采用该值
其它为匹配字符串的起始位置
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro strstr(str1,str2)
{
i =
j =
len1 = strlen(str1)
len2 = strlen(str2)
if((len1 == ) || (len2 == ))
{
return 0xffffffff
}
while( i < len1)
{
if(str1[i] == str2[j])
{
while(j < len2)
{
j = j +
if(str1[i+j] != str2[j])
{
break
}
}
if(j == len2)
{
return i
}
j =
}
i = i +
}
return 0xffffffff
} /*****************************************************************************
函 数 名 : InsertTraceInfo
功能描述 : 在函数的入口和出口插入打印,不支持一行有多条语句的情况
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro InsertTraceInfo()
{
hwnd = GetCurrentWnd()
if (hwnd == )
stop
hbuf = GetWndBuf(hwnd)
sel = GetWndSel(hwnd)
symbol = GetSymbolLocationFromLn(hbuf, sel.lnFirst)
InsertTraceInCurFunction(hbuf,symbol)
} /*****************************************************************************
函 数 名 : InsertTraceInCurFunction
功能描述 : 在函数的入口和出口插入打印,不支持一行有多条语句的情况
输入参数 : hbuf
symbol
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro InsertTraceInCurFunction(hbuf,symbol)
{
ln = GetBufLnCur (hbuf)
symbolname = symbol.Symbol
nLineEnd = symbol.lnLim
nExitCount = ;
InsBufLine(hbuf, ln, " VOS_Debug_Trace(\"\\r\\n |@symbolname@() entry--- \");")
ln = ln +
fIsEnd =
fIsNeedPrt =
fIsSatementEnd =
szLeftOld = ""
while(ln < nLineEnd)
{
szLine = GetBufLine(hbuf, ln)
iCurLineLen = strlen(szLine) /*剔除其中的注释语句*/
RetVal = SkipCommentFromString(szLine,fIsEnd)
szLine = RetVal.szContent
fIsEnd = RetVal.fIsEnd
//查找是否有return语句
/* ret =strstr(szLine,"return")
if(ret != 0xffffffff)
{
if( (szLine[ret+6] == " " ) || (szLine[ret+6] == "\t" )
|| (szLine[ret+6] == ";" ) || (szLine[ret+6] == "(" ))
{
szPre = strmid(szLine,0,ret)
}
SetBufIns(hbuf,ln,ret)
Paren_Right
sel = GetWndSel(hwnd)
if( sel.lnLast != ln )
{
GetbufLine(hbuf,sel.lnLast)
RetVal = SkipCommentFromString(szLine,1)
szLine = RetVal.szContent
fIsEnd = RetVal.fIsEnd
}
}*/
//获得左边空白大小
nLeft = GetLeftBlank(szLine)
if(nLeft == )
{
szLeft = " "
}
else
{
szLeft = strmid(szLine,,nLeft)
}
szLine = TrimString(szLine)
iLen = strlen(szLine)
if(iLen == )
{
ln = ln +
continue
}
szRet = GetFirstWord(szLine)
// if( (szRet == "if") || (szRet == "else")
//查找是否有return语句
// ret =strstr(szLine,"return") if( szRet == "return")
{
if( fIsSatementEnd == )
{
fIsNeedPrt =
InsBufLine(hbuf,ln+,"@szLeftOld@}")
szEnd = cat(szLeft,"VOS_Debug_Trace(\"\\r\\n |@symbolname@() exit---: @nExitCount@ \");")
InsBufLine(hbuf, ln, szEnd )
InsBufLine(hbuf,ln,"@szLeftOld@{")
nExitCount = nExitCount +
nLineEnd = nLineEnd +
ln = ln +
}
else
{
fIsNeedPrt =
szEnd = cat(szLeft,"VOS_Debug_Trace(\"\\r\\n |@symbolname@() exit---: @nExitCount@ \");")
InsBufLine(hbuf, ln, szEnd )
nExitCount = nExitCount +
nLineEnd = nLineEnd +
ln = ln +
}
}
else
{
ret =strstr(szLine,"}")
if( ret != 0xffffffff )
{
fIsNeedPrt =
}
} szLeftOld = szLeft
ch = szLine[iLen-]
if( ( ch == ";" ) || ( ch == "{" )
|| ( ch == ":" )|| ( ch == "}" ) || ( szLine[] == "#" ))
{
fIsSatementEnd =
}
else
{
fIsSatementEnd =
}
ln = ln +
} //只要前面的return后有一个}了说明函数的结尾没有返回,需要再加一个出口打印
if(fIsNeedPrt == )
{
InsBufLine(hbuf, ln, " VOS_Debug_Trace(\"\\r\\n |@symbolname@() exit---: @nExitCount@ \");")
InsBufLine(hbuf, ln, "")
}
} /*****************************************************************************
函 数 名 : GetFirstWord
功能描述 : 取得字符串的第一个单词
输入参数 : szLine
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro GetFirstWord(szLine)
{
szLine = TrimLeft(szLine)
nIdx =
iLen = strlen(szLine)
while(nIdx < iLen)
{
if( (szLine[nIdx] == " ") || (szLine[nIdx] == "\t")
|| (szLine[nIdx] == ";") || (szLine[nIdx] == "(")
|| (szLine[nIdx] == ".") || (szLine[nIdx] == "{")
|| (szLine[nIdx] == ",") || (szLine[nIdx] == ":") )
{
return strmid(szLine,,nIdx)
}
nIdx = nIdx +
}
return "" } /*****************************************************************************
函 数 名 : AutoInsertTraceInfoInBuf
功能描述 : 自动当前文件的全部函数出入口加入打印,只能支持C++
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月24日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro AutoInsertTraceInfoInBuf()
{
hwnd = GetCurrentWnd()
if (hwnd == )
stop
sel = GetWndSel(hwnd)
hbuf = GetWndBuf(hwnd) isymMax = GetBufSymCount(hbuf)
isym =
while (isym < isymMax)
{
symbol = GetBufSymLocation(hbuf, isym)
isCodeBegin =
fIsEnd =
isBlandLine =
if(strlen(symbol) > )
{
if(symbol.Type == "Class Placeholder")
{
hsyml = SymbolChildren(symbol)
cchild = SymListCount(hsyml)
ichild =
while (ichild < cchild)
{
symbol = GetBufSymLocation(hbuf, isym)
hsyml = SymbolChildren(symbol)
childsym = SymListItem(hsyml, ichild)
ln = childsym.lnName
isCodeBegin =
fIsEnd =
isBlandLine =
while( ln < childsym.lnLim )
{
szLine = GetBufLine (hbuf, ln) //去掉注释的干扰
RetVal = SkipCommentFromString(szLine,fIsEnd)
szNew = RetVal.szContent
fIsEnd = RetVal.fIsEnd
if(isCodeBegin == )
{
szNew = TrimLeft(szNew)
//检测是否是可执行代码开始
iRet = CheckIsCodeBegin(szNew)
if(iRet == )
{
if( isBlandLine != )
{
ln = isBlandLine
}
InsBufLine(hbuf,ln,"")
childsym.lnLim = childsym.lnLim +
SetBufIns(hbuf, ln+ , )
InsertTraceInCurFunction(hbuf,childsym)
break
}
if(strlen(szNew) == )
{
if( isBlandLine == )
{
isBlandLine = ln;
}
}
else
{
isBlandLine =
}
}
//查找到函数的开始
if(isCodeBegin == )
{
iRet = strstr(szNew,"{")
if(iRet != 0xffffffff)
{
isCodeBegin =
}
}
ln = ln +
}
ichild = ichild +
}
SymListFree(hsyml)
}
else if( ( symbol.Type == "Function") || (symbol.Type == "Method") )
{
ln = symbol.lnName
while( ln < symbol.lnLim )
{
szLine = GetBufLine (hbuf, ln) //去掉注释的干扰
RetVal = SkipCommentFromString(szLine,fIsEnd)
szNew = RetVal.szContent
fIsEnd = RetVal.fIsEnd
if(isCodeBegin == )
{
szNew = TrimLeft(szNew)
//检测是否是可执行代码开始
iRet = CheckIsCodeBegin(szNew)
if(iRet == )
{
if( isBlandLine != )
{
ln = isBlandLine
}
SetBufIns(hbuf, ln , )
InsertTraceInCurFunction(hbuf,symbol)
InsBufLine(hbuf,ln,"")
break
}
if(strlen(szNew) == )
{
if( isBlandLine == )
{
isBlandLine = ln;
}
}
else
{
isBlandLine =
}
}
//查找到函数的开始
if(isCodeBegin == )
{
iRet = strstr(szNew,"{")
if(iRet != 0xffffffff)
{
isCodeBegin =
}
}
ln = ln +
}
}
}
isym = isym +
} } /*****************************************************************************
函 数 名 : CheckIsCodeBegin
功能描述 : 是否为函数的第一条可执行代码
输入参数 : szLine 左边没有空格和注释的字符串
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月24日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro CheckIsCodeBegin(szLine)
{
iLen = strlen(szLine)
if(iLen == )
{
return
}
nIdx =
nWord =
if( (szLine[nIdx] == "(") || (szLine[nIdx] == "-")
|| (szLine[nIdx] == "*") || (szLine[nIdx] == "+"))
{
return
}
if( szLine[nIdx] == "#" )
{
return
}
while(nIdx < iLen)
{
if( (szLine[nIdx] == " ")||(szLine[nIdx] == "\t")
|| (szLine[nIdx] == "(")||(szLine[nIdx] == "{")
|| (szLine[nIdx] == ";") )
{
if(nWord == )
{
if( (szLine[nIdx] == "(")||(szLine[nIdx] == "{")
|| (szLine[nIdx] == ";") )
{
return
}
szFirstWord = StrMid(szLine,,nIdx)
if(szFirstWord == "return")
{
return
}
}
while(nIdx < iLen)
{
if( (szLine[nIdx] == " ")||(szLine[nIdx] == "\t") )
{
nIdx = nIdx +
}
else
{
break
}
}
nWord = nWord +
if(nIdx == iLen)
{
return
}
}
if(nWord == )
{
asciiA = AsciiFromChar("A")
asciiZ = AsciiFromChar("Z")
ch = toupper(szLine[nIdx])
asciiCh = AsciiFromChar(ch)
if( ( szLine[nIdx] == "_" ) || ( szLine[nIdx] == "*" )
|| ( ( asciiCh >= asciiA ) && ( asciiCh <= asciiZ ) ) )
{
return
}
else
{
return
}
}
nIdx = nIdx +
}
return
} /*****************************************************************************
函 数 名 : AutoInsertTraceInfoInPrj
功能描述 : 自动当前工程全部文件的全部函数出入口加入打印,只能支持C++
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月24日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro AutoInsertTraceInfoInPrj()
{
hprj = GetCurrentProj()
ifileMax = GetProjFileCount (hprj)
ifile =
while (ifile < ifileMax)
{
filename = GetProjFileName (hprj, ifile)
szExt = toupper(GetFileNameExt(filename))
if( (szExt == "C") || (szExt == "CPP") )
{
hbuf = OpenBuf (filename)
if(hbuf != )
{
SetCurrentBuf(hbuf)
AutoInsertTraceInfoInBuf()
}
}
//自动保存打开文件,可根据需要打开
/* if( IsBufDirty (hbuf) )
{
SaveBuf (hbuf)
}
CloseBuf(hbuf)*/
ifile = ifile +
}
} /*****************************************************************************
函 数 名 : RemoveTraceInfo
功能描述 : 删除该函数的出入口打印
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月24日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro RemoveTraceInfo()
{
hwnd = GetCurrentWnd()
if (hwnd == )
stop
sel = GetWndSel(hwnd)
hbuf = GetWndBuf(hwnd)
if(hbuf == hNil)
stop
symbolname = GetCurSymbol()
symbol = GetSymbolLocationFromLn(hbuf, sel.lnFirst)
// symbol = GetSymbolLocation (symbolname)
nLineEnd = symbol.lnLim
szEntry = "VOS_Debug_Trace(\"\\r\\n |@symbolname@() entry--- \");"
szExit = "VOS_Debug_Trace(\"\\r\\n |@symbolname@() exit---:"
ln = symbol.lnName
fIsEntry =
while(ln < nLineEnd)
{
szLine = GetBufLine(hbuf, ln) /*剔除其中的注释语句*/
RetVal = TrimString(szLine)
if(fIsEntry == )
{
ret = strstr(szLine,szEntry)
if(ret != 0xffffffff)
{
DelBufLine(hbuf,ln)
nLineEnd = nLineEnd -
fIsEntry =
ln = ln +
continue
}
}
ret = strstr(szLine,szExit)
if(ret != 0xffffffff)
{
DelBufLine(hbuf,ln)
nLineEnd = nLineEnd -
}
ln = ln +
}
} /*****************************************************************************
函 数 名 : RemoveCurBufTraceInfo
功能描述 : 从当前的buf中删除添加的出入口打印信息
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月24日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro RemoveCurBufTraceInfo()
{
hbuf = GetCurrentBuf()
isymMax = GetBufSymCount(hbuf)
isym =
while (isym < isymMax)
{
isLastLine =
symbol = GetBufSymLocation(hbuf, isym)
fIsEnd =
if(strlen(symbol) > )
{
if(symbol.Type == "Class Placeholder")
{
hsyml = SymbolChildren(symbol)
cchild = SymListCount(hsyml)
ichild =
while (ichild < cchild)
{
hsyml = SymbolChildren(symbol)
childsym = SymListItem(hsyml, ichild)
SetBufIns(hbuf,childsym.lnName,)
RemoveTraceInfo()
ichild = ichild +
}
SymListFree(hsyml)
}
else if( ( symbol.Type == "Function") || (symbol.Type == "Method") )
{
SetBufIns(hbuf,symbol.lnName,)
RemoveTraceInfo()
}
}
isym = isym +
}
} /*****************************************************************************
函 数 名 : RemovePrjTraceInfo
功能描述 : 删除工程中的全部加入的函数的出入口打印
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月24日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro RemovePrjTraceInfo()
{
hprj = GetCurrentProj()
ifileMax = GetProjFileCount (hprj)
ifile =
while (ifile < ifileMax)
{
filename = GetProjFileName (hprj, ifile)
hbuf = OpenBuf (filename)
if(hbuf != )
{
SetCurrentBuf(hbuf)
RemoveCurBufTraceInfo()
}
//自动保存打开文件,可根据需要打开
/* if( IsBufDirty (hbuf) )
{
SaveBuf (hbuf)
}
CloseBuf(hbuf)*/
ifile = ifile +
}
} /*****************************************************************************
函 数 名 : InsertFileHeaderEN
功能描述 : 插入英文文件头描述
输入参数 : hbuf
ln 行号
szName 作者名
szContent 功能描述内容
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 2.日 期 : 2011年2月22日
作 者 : 彭军
修改内容 : 修改文件头的日期为当年 *****************************************************************************/
macro InsertFileHeaderEN(hbuf, ln,szName,szContent)
{ hnewbuf = newbuf("")
if(hnewbuf == hNil)
{
stop
}
SysTime = GetSysTime()
szYear=SysTime.Year
GetFunctionList(hbuf,hnewbuf)
InsBufLine(hbuf, ln + , "/********************************************************************************")
InsBufLine(hbuf, ln + , "")
InsBufLine(hbuf, ln + , " **** Copyright (C), @szYear@, xx xx xx xx info&tech Co., Ltd. ****")
InsBufLine(hbuf, ln + , "")
InsBufLine(hbuf, ln + , " ********************************************************************************")
sz = GetFileName(GetBufName (hbuf))
InsBufLine(hbuf, ln + , " * File Name : @sz@")
InsBufLine(hbuf, ln + , " * Author : @szName@")
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
}
InsBufLine(hbuf, ln + , " * Date : @sz@-@szMonth@-@szDay@") /*InsBufLine(hbuf, ln + 8, " Created : @sz@-@szMonth@-@szDay@")
InsBufLine(hbuf, ln + 9, " Last Modified :")*/
szTmp = " * Description : "
nlnDesc = ln
iLen = strlen (szContent)
InsBufLine(hbuf, ln + , " * Description : @szContent@")
InsBufLine(hbuf, ln + , " * Version : 1.0")
InsBufLine(hbuf, ln + ," * Function List :")
InsBufLine(hbuf, ln + ," * ")
//插入函数列表
/*ln = InsertFileList(hbuf,hnewbuf,ln + 12) - 12
closebuf(hnewbuf)
*/
InsBufLine(hbuf, ln + , " * Record :")
InsBufLine(hbuf, ln + , " * 1.Date : @sz@-@szMonth@-@szDay@")
InsBufLine(hbuf, ln + , " * Author : @szName@")
InsBufLine(hbuf, ln + , " * Modification: Created file")
InsBufLine(hbuf, ln + , "")
InsBufLine(hbuf, ln + , "*************************************************************************************************************/")
InsBufLine(hbuf, ln + , "") //InsBufLine(hbuf, ln + 19, "/*----------------------------------------------*")
//InsBufLine(hbuf, ln + 20, " * external variables *")
//InsBufLine(hbuf, ln + 21, " *----------------------------------------------*/")
//InsBufLine(hbuf, ln + 22, "")
//InsBufLine(hbuf, ln + 23, "/*----------------------------------------------*")
//InsBufLine(hbuf, ln + 24, " * external routine prototypes *")
//InsBufLine(hbuf, ln + 25, " *----------------------------------------------*/")
//InsBufLine(hbuf, ln + 26, "")
//InsBufLine(hbuf, ln + 27, "/*----------------------------------------------*")
//InsBufLine(hbuf, ln + 28, " * internal routine prototypes *")
//InsBufLine(hbuf, ln + 29, " *----------------------------------------------*/")
//InsBufLine(hbuf, ln + 30, "")
//InsBufLine(hbuf, ln + 31, "/*----------------------------------------------*")
//InsBufLine(hbuf, ln + 32, " * project-wide global variables *")
//InsBufLine(hbuf, ln + 33, " *----------------------------------------------*/")
//InsBufLine(hbuf, ln + 34, "")
//InsBufLine(hbuf, ln + 35, "/*----------------------------------------------*")
//InsBufLine(hbuf, ln + 36, " * module-wide global variables *")
//InsBufLine(hbuf, ln + 37, " *----------------------------------------------*/")
//InsBufLine(hbuf, ln + 38, "")
//InsBufLine(hbuf, ln + 39, "/*----------------------------------------------*")
//InsBufLine(hbuf, ln + 40, " * constants *")
//InsBufLine(hbuf, ln + 41, " *----------------------------------------------*/")
//InsBufLine(hbuf, ln + 42, "")
//InsBufLine(hbuf, ln + 43, "/*----------------------------------------------*")
//InsBufLine(hbuf, ln + 44, " * macros *")
//InsBufLine(hbuf, ln + 45, " *----------------------------------------------*/")
//InsBufLine(hbuf, ln + 46, "")
//InsBufLine(hbuf, ln + 47, "/*----------------------------------------------*")
//InsBufLine(hbuf, ln + 48, " * routines' implementations *")
//InsBufLine(hbuf, ln + 49, " *----------------------------------------------*/")
//InsBufLine(hbuf, ln + 50, "")
if(iLen != )
{
return
} //如果没有功能描述内容则提示输入
szContent = Ask("Description")
SetBufIns(hbuf,nlnDesc + ,)
DelBufLine(hbuf,nlnDesc +) //注释输出处理,自动换行
CommentContent(hbuf,nlnDesc + ," Description : ",szContent,)
} /*****************************************************************************
函 数 名 : InsertFileHeaderCN
功能描述 : 插入中文描述文件头说明
输入参数 : hbuf
ln
szName
szContent
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 2.日 期 : 2011年2月22日
作 者 : 彭军
修改内容 : 修改文件头的日期为当年 *****************************************************************************/
macro InsertFileHeaderCN(hbuf, ln,szName,szContent)
{
hnewbuf = newbuf("")
if(hnewbuf == hNil)
{
stop
}
SysTime = GetSysTime()
szYear=SysTime.Year
szMonth=SysTime.month
szDay=SysTime.day
GetFunctionList(hbuf,hnewbuf)
InsBufLine(hbuf, ln + , "/***********************************************************************************")
sz = GetFileName(GetBufName (hbuf))
InsBufLine(hbuf, ln + , " * 文 件 名 : @sz@")
/*InsBufLine(hbuf, ln + 6, " 版 本 号 : 初稿")*/
InsBufLine(hbuf, ln + , " * 负 责 人 : @szName@")
InsBufLine(hbuf, ln + , " * 创建日期 : @szYear@年@szMonth@月@szDay@日")
/*InsBufLine(hbuf, ln + 9, " 最近修改 :")*/
iLen = strlen (szContent)
nlnDesc = ln
szTmp = " * 文件描述 : "
InsBufLine(hbuf, ln + , " * 文件描述 : @szContent@")
InsBufLine(hbuf, ln + , " * 版权说明 : Copyright (c) 2008-@szYear@ xx xx xx xx 技术有限公司")
InsBufLine(hbuf, ln + , " * 其 他 : ")
InsBufLine(hbuf, ln + , " * 修改日志 : ")
InsBufLine(hbuf, ln + , "***********************************************************************************/")
InsBufLine(hbuf, ln + , "") // InsBufLine(hbuf, ln + 9, " * 版 本 号 : 1.0")
// InsBufLine(hbuf, ln + 10," * 函数列表 :")
// InsBufLine(hbuf, ln + 11," * ")
// //插入函数列表
// /*ln = InsertFileList(hbuf,hnewbuf,ln + 12) - 12
// closebuf(hnewbuf)
// */
// InsBufLine(hbuf, ln + 12, " * 历史记录 :")
// InsBufLine(hbuf, ln + 13, " * 1.日 期 : @sz@-@szMonth@-@szDay@")
//
// if( strlen(szMyName)>0 )
// {
// InsBufLine(hbuf, ln + 14, " * 作 者 : @szName@")
// }
// else
// {
// InsBufLine(hbuf, ln + 14, " * 作 者 : #")
// }
// InsBufLine(hbuf, ln + 15, " * 修改内容 : 创建文件")
// InsBufLine(hbuf, ln + 16, "")
// InsBufLine(hbuf, ln + 17, "***********************************************************************************/")
// InsBufLine(hbuf, ln + 18, "")
//InsBufLine(hbuf, ln + 19, "/*----------------------------------------------*")
//InsBufLine(hbuf, ln + 20, " * 外部变量说明 *")
//InsBufLine(hbuf, ln + 21, " *----------------------------------------------*/")
//InsBufLine(hbuf, ln + 22, "")
//InsBufLine(hbuf, ln + 23, "/*----------------------------------------------*")
//InsBufLine(hbuf, ln + 24, " * 外部函数原型说明 *")
//InsBufLine(hbuf, ln + 25, " *----------------------------------------------*/")
//InsBufLine(hbuf, ln + 26, "")
//InsBufLine(hbuf, ln + 27, "/*----------------------------------------------*")
//InsBufLine(hbuf, ln + 28, " * 内部函数原型说明 *")
//InsBufLine(hbuf, ln + 29, " *----------------------------------------------*/")
//InsBufLine(hbuf, ln + 30, "")
//InsBufLine(hbuf, ln + 31, "/*----------------------------------------------*")
//InsBufLine(hbuf, ln + 32, " * 全局变量 *")
//InsBufLine(hbuf, ln + 33, " *----------------------------------------------*/")
//InsBufLine(hbuf, ln + 34, "")
//InsBufLine(hbuf, ln + 35, "/*----------------------------------------------*")
//InsBufLine(hbuf, ln + 36, " * 模块级变量 *")
//InsBufLine(hbuf, ln + 37, " *----------------------------------------------*/")
//InsBufLine(hbuf, ln + 38, "")
//InsBufLine(hbuf, ln + 39, "/*----------------------------------------------*")
//InsBufLine(hbuf, ln + 40, " * 常量定义 *")
//InsBufLine(hbuf, ln + 41, " *----------------------------------------------*/")
//InsBufLine(hbuf, ln + 42, "")
//InsBufLine(hbuf, ln + 43, "/*----------------------------------------------*")
//InsBufLine(hbuf, ln + 44, " * 宏定义 *")
//InsBufLine(hbuf, ln + 45, " *----------------------------------------------*/")
//InsBufLine(hbuf, ln + 46, "")
if(strlen(szContent) != )
{
return
} //如果没有输入功能描述的话提示输入
szContent = Ask("请输入文件功能描述的内容") //设置光标位置为注释的最后一行
SetBufIns(hbuf,nlnDesc + ,) //将原"文件描述"行删掉
DelBufLine(hbuf,nlnDesc +) //自动排列显示功能描述
CommentContent(hbuf,nlnDesc+," * 文件描述 : ",szContent,)
} /*****************************************************************************
函 数 名 : GetFunctionList
功能描述 : 获得函数列表
输入参数 : hbuf
hnewbuf
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro GetFunctionList(hbuf,hnewbuf)
{
isymMax = GetBufSymCount (hbuf)
isym =
//依次取出全部的但前buf符号表中的全部符号
while (isym < isymMax)
{
symbol = GetBufSymLocation(hbuf, isym)
if(symbol.Type == "Class Placeholder")
{
hsyml = SymbolChildren(symbol)
cchild = SymListCount(hsyml)
ichild =
while (ichild < cchild)
{
childsym = SymListItem(hsyml, ichild)
AppendBufLine(hnewbuf,childsym.symbol)
ichild = ichild +
}
SymListFree(hsyml)
}
if(strlen(symbol) > )
{
if( (symbol.Type == "Method") ||
(symbol.Type == "Function") || ("Editor Macro" == symbol.Type) )
{
//取出类型是函数和宏的符号
symname = symbol.Symbol
//将符号插入到新buf中这样做是为了兼容V2.1
AppendBufLine(hnewbuf,symname)
}
}
isym = isym +
}
}
/*****************************************************************************
函 数 名 : InsertFileList
功能描述 : 函数列表插入
输入参数 : hbuf
ln
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro InsertFileList(hbuf,hnewbuf,ln)
{
if(hnewbuf == hNil)
{
return ln
}
isymMax = GetBufLineCount (hnewbuf)
isym =
while (isym < isymMax)
{
szLine = GetBufLine(hnewbuf, isym)
InsBufLine(hbuf,ln," @szLine@")
ln = ln +
isym = isym +
}
return ln
} /*****************************************************************************
函 数 名 : CommentContent1
功能描述 : 自动排列显示文本,因为msg对话框不能处理多行的情况,而且不能超过255
个字符,作为折中,采用了从简帖板取数据的办法,如果如果的数据是剪
贴板中内容的前部分的话就认为用户是拷贝的内容,这样做虽然有可能有
误,但这种概率非常低。与CommentContent不同的是它将剪贴板中的内容
合并成一段来处理,可以根据需要选择这两种方式
输入参数 : hbuf
ln 行号
szPreStr 首行需要加入的字符串
szContent 需要输入的字符串内容
isEnd 是否需要在末尾加入'*'和'/'
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro CommentContent1 (hbuf,ln,szPreStr,szContent,isEnd)
{
//将剪贴板中的多段文本合并
szClip = MergeString()
//去掉多余的空格
szTmp = TrimString(szContent)
//如果输入窗口中的内容是剪贴板中的内容说明是剪贴过来的
ret = strstr(szClip,szTmp)
if(ret == )
{
szContent = szClip
}
szLeftBlank = szPreStr
iLen = strlen(szPreStr)
k =
while(k < iLen)
{
szLeftBlank[k] = " ";
k = k + ;
}
iLen = strlen (szContent)
szTmp = cat(szPreStr,"#");
if( iLen == )
{
InsBufLine(hbuf, ln, "@szTmp@")
}
else
{
i =
while (iLen - i > - k )
{
j =
while(j < - k)
{
iNum = szContent[i + j]
//如果是中文必须成对处理
if( AsciiFromChar (iNum) > )
{
j = j +
}
else
{
j = j +
}
if( (j > - k) && (szContent[i + j] == " ") )
{
break
}
}
if( (szContent[i + j] != " " ) )
{
n = ;
iNum = szContent[i + j + n]
while( (iNum != " " ) && (AsciiFromChar (iNum) < ))
{
n = n +
if((n >= ) ||(i + j + n >= iLen))
break;
iNum = szContent[i + j + n]
}
if(n < )
{
j = j + n
sz1 = strmid(szContent,i,i+j)
sz1 = cat(szPreStr,sz1)
}
else
{
sz1 = strmid(szContent,i,i+j)
sz1 = cat(szPreStr,sz1)
if(sz1[strlen(sz1)-] != "-")
{
sz1 = cat(sz1,"-")
}
}
}
else
{
sz1 = strmid(szContent,i,i+j)
sz1 = cat(szPreStr,sz1)
}
InsBufLine(hbuf, ln, "@sz1@")
ln = ln +
szPreStr = szLeftBlank
i = i + j
while(szContent[i] == " ")
{
i = i +
}
}
sz1 = strmid(szContent,i,iLen)
sz1 = cat(szPreStr,sz1)
if(isEnd)
{
sz1 = cat(sz1,"*/")
}
InsBufLine(hbuf, ln, "@sz1@")
}
return ln
} /*****************************************************************************
函 数 名 : CommentContent
功能描述 : 自动排列显示文本,因为msg对话框不能处理多行的情况,而且不能超过255
个字符,作为折中,采用了从简帖板取数据的办法,如果如果的数据是剪
贴板中内容的前部分的话就认为用户是拷贝的内容,这样做虽然有可能有
误,但这种概率非常低
输入参数 : hbuf
ln 行号
szPreStr 首行需要加入的字符串
szContent 需要输入的字符串内容
isEnd 是否需要在末尾加入' '、'*'和'/'
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro CommentContent (hbuf,ln,szPreStr,szContent,isEnd)
{
szLeftBlank = szPreStr
iLen = strlen(szPreStr)
k =
while(k < iLen)
{
szLeftBlank[k] = " ";
k = k + ;
} hNewBuf = newbuf("clip")
if(hNewBuf == hNil)
return
SetCurrentBuf(hNewBuf)
PasteBufLine (hNewBuf, )
lnMax = GetBufLineCount( hNewBuf )
szTmp = TrimString(szContent) //判断如果剪贴板是0行时对于有些版本会有问题,要排除掉
if(lnMax != )
{
szLine = GetBufLine(hNewBuf , )
ret = strstr(szLine,szTmp)
if(ret == )
{
/*如果输入窗输入的内容是剪贴板的一部分说明是剪贴过来的取剪贴板中的内
容*/
szContent = TrimString(szLine)
}
else
{
lnMax =
}
}
else
{
lnMax =
}
szRet = ""
nIdx =
while ( nIdx < lnMax)
{
if(nIdx != )
{
szLine = GetBufLine(hNewBuf , nIdx)
szContent = TrimLeft(szLine)
szPreStr = szLeftBlank
}
iLen = strlen (szContent)
szTmp = cat(szPreStr,"#");
if( (iLen == ) && (nIdx == (lnMax - ))
{
InsBufLine(hbuf, ln, "@szTmp@")
}
else
{
i =
//以每行75个字符处理
while (iLen - i > - k )
{
j =
while(j < - k)
{
iNum = szContent[i + j]
if( AsciiFromChar (iNum) > )
{
j = j +
}
else
{
j = j +
}
if( (j > - k) && (szContent[i + j] == " ") )
{
break
}
}
if( (szContent[i + j] != " " ) )
{
n = ;
iNum = szContent[i + j + n]
//如果是中文字符只能成对处理
while( (iNum != " " ) && (AsciiFromChar (iNum) < ))
{
n = n +
if((n >= ) ||(i + j + n >= iLen))
break;
iNum = szContent[i + j + n]
}
if(n < )
{
//分段后只有小于3个的字符留在下段则将其以上去
j = j + n
sz1 = strmid(szContent,i,i+j)
sz1 = cat(szPreStr,sz1)
}
else
{
//大于3个字符的加连字符分段
sz1 = strmid(szContent,i,i+j)
sz1 = cat(szPreStr,sz1)
if(sz1[strlen(sz1)-] != "-")
{
sz1 = cat(sz1,"-")
}
}
}
else
{
sz1 = strmid(szContent,i,i+j)
sz1 = cat(szPreStr,sz1)
}
InsBufLine(hbuf, ln, "@sz1@")
ln = ln +
szPreStr = szLeftBlank
i = i + j
while(szContent[i] == " ")
{
i = i +
}
}
sz1 = strmid(szContent,i,iLen)
sz1 = cat(szPreStr,sz1)
if((isEnd == ) && (nIdx == (lnMax - ))
{
sz1 = cat(sz1," */")
}
InsBufLine(hbuf, ln, "@sz1@")
}
ln = ln +
nIdx = nIdx +
}
closebuf(hNewBuf)
return ln -
} /*****************************************************************************
函 数 名 : FormatLine
功能描述 : 将一行长文本进行自动分行
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro FormatLine()
{
hwnd = GetCurrentWnd()
if (hwnd == )
stop
sel = GetWndSel(hwnd)
if(sel.ichFirst > )
{
Msg("选择太靠右了")
stop
}
hbuf = GetWndBuf(hwnd)
// get line the selection (insertion point) is on
szCurLine = GetBufLine(hbuf, sel.lnFirst);
lineLen = strlen(szCurLine)
szLeft = strmid(szCurLine,,sel.ichFirst)
szContent = strmid(szCurLine,sel.ichFirst,lineLen)
DelBufLine(hbuf, sel.lnFirst)
CommentContent(hbuf,sel.lnFirst,szLeft,szContent,) } /*****************************************************************************
函 数 名 : CreateBlankString
功能描述 : 产生几个空格的字符串
输入参数 : nBlankCount
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro CreateBlankString(nBlankCount)
{
szBlank=""
nIdx =
while(nIdx < nBlankCount)
{
szBlank = cat(szBlank," ")
nIdx = nIdx +
}
return szBlank
} /*****************************************************************************
函 数 名 : TrimLeft
功能描述 : 去掉字符串左边的空格
输入参数 : szLine
输出参数 : 去掉左空格后的字符串
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro TrimLeft(szLine)
{
nLen = strlen(szLine)
if(nLen == )
{
return szLine
}
nIdx =
while( nIdx < nLen )
{
if( ( szLine[nIdx] != " ") && (szLine[nIdx] != "\t") )
{
break
}
nIdx = nIdx +
}
return strmid(szLine,nIdx,nLen)
} /*****************************************************************************
函 数 名 : TrimRight
功能描述 : 去掉字符串右边的空格
输入参数 : szLine
输出参数 : 去掉右空格后的字符串
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro TrimRight(szLine)
{
nLen = strlen(szLine)
if(nLen == )
{
return szLine
}
nIdx = nLen
while( nIdx > )
{
nIdx = nIdx -
if( ( szLine[nIdx] != " ") && (szLine[nIdx] != "\t") )
{
break
}
}
return strmid(szLine,,nIdx+)
} /*****************************************************************************
函 数 名 : TrimString
功能描述 : 去掉字符串左右空格
输入参数 : szLine
输出参数 : 去掉左右空格后的字符串
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro TrimString(szLine)
{
szLine = TrimLeft(szLine)
szLIne = TrimRight(szLine)
return szLine
} /*****************************************************************************
函 数 名 : GetFunctionDef
功能描述 : 将分成多行的函数参数头合并成一行
输入参数 : hbuf
symbol 函数符号
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro GetFunctionDef(hbuf,symbol)
{
ln = symbol.lnName
szFunc = ""
if(strlen(symbol) == )
{
return szFunc
}
fIsEnd =
// msg(symbol)
while(ln < symbol.lnLim)
{
szLine = GetBufLine (hbuf, ln)
//去掉被注释掉的内容
RetVal = SkipCommentFromString(szLine,fIsEnd)
szLine = RetVal.szContent
szLine = TrimString(szLine)
fIsEnd = RetVal.fIsEnd
//如果是{表示函数参数头结束了
ret = strstr(szLine,"{")
if(ret != 0xffffffff)
{
szLine = strmid(szLine,,ret)
szFunc = cat(szFunc,szLine)
break
}
szFunc = cat(szFunc,szLine)
ln = ln +
}
return szFunc
} /*****************************************************************************
函 数 名 : GetWordFromString
功能描述 : 从字符串中取得以某种方式分割的字符串组
输入参数 : hbuf 生成分割后字符串的buf
szLine 字符串
nBeg 开始检索位置
nEnd 结束检索位置
chBeg 开始的字符标志
chSeparator 分割字符
chEnd 结束字符标志
输出参数 : 最大字符长度
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro GetWordFromString(hbuf,szLine,nBeg,nEnd,chBeg,chSeparator,chEnd)
{
if((nEnd > strlen(szLine) || (nBeg > nEnd))
{
return
}
nMaxLen =
nIdx = nBeg
//先定位到开始字符标记处
while(nIdx < nEnd)
{
if(szLine[nIdx] == chBeg)
{
//nIdx不加1,在分隔符为标记的搜索中第一次就会搜到起始符
break
}
nIdx = nIdx +
}
nBegWord = nIdx + //用于检测chBeg和chEnd的配对情况,因定位到起始符是nIdx没有加1,所以iCount=0
iCount = nEndWord =
//以分隔符为标记进行搜索
while(nIdx < nEnd)
{
if(szLine[nIdx] == chSeparator)
{
szWord = strmid(szLine,nBegWord,nIdx)
szWord = TrimString(szWord)
nLen = strlen(szWord)
if(nMaxLen < nLen)
{
nMaxLen = nLen
}
AppendBufLine(hbuf,szWord)
nBegWord = nIdx +
}
if(szLine[nIdx] == chBeg)
{
iCount = iCount +
}
if(szLine[nIdx] == chEnd)
{
iCount = iCount -
nEndWord = nIdx
if( iCount == )
{
break
}
}
nIdx = nIdx +
}
//提取分隔符与结束符之间的字符串组
if(nEndWord > nBegWord)
{
szWord = strmid(szLine,nBegWord,nEndWord)
szWord = TrimString(szWord)
nLen = strlen(szWord)
if(nMaxLen < nLen)
{
nMaxLen = nLen
}
AppendBufLine(hbuf,szWord)
}
return nMaxLen
} /*****************************************************************************
函 数 名 : FuncHeadCommentCN
功能描述 : 生成中文的函数头注释
输入参数 : hbuf
ln 行号
szFunc 函数名
szMyName 作者名
newFunc 是否新函数
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro FuncHeadCommentCN(hbuf, ln, szFunc, szMyName,newFunc)
{
iIns =
if(newFunc != )
{
symbol = GetSymbolLocationFromLn(hbuf, ln)
if(strlen(symbol) > )
{
hTmpBuf = NewBuf("Tempbuf")
if(hTmpBuf == hNil)
{
stop
}
//将分成多行的函数参数头合并成一行并去掉了注释
szLine = GetFunctionDef(hbuf,symbol)
iBegin = symbol.ichName
//取出返回值定义
szTemp = strmid(szLine,,iBegin)
szTemp = TrimString(szTemp)
szRet = GetFirstWord(szTemp)
if(symbol.Type == "Method")
{
szTemp = strmid(szTemp,strlen(szRet),strlen(szTemp))
szTemp = TrimString(szTemp)
if(szTemp == "::")
{
szRet = ""
}
}
if(toupper (szRet) == "MACRO")
{
//对于宏返回值特殊处理
szRet = ""
}
//从函数头分离出函数参数
nMaxParamSize = GetWordFromString(hTmpBuf,szLine,iBegin,strlen(szLine),"(",",",")")
lnMax = GetBufLineCount(hTmpBuf)
ln = symbol.lnFirst
SetBufIns (hbuf, ln, )
}
}
else
{
lnMax =
szLine = ""
szRet = ""
}
InsBufLine(hbuf, ln, "/*****************************************************************************")
if( strlen(szFunc)> )
{
InsBufLine(hbuf, ln+, " * 函 数 名 : @szFunc@")
}
else
{
InsBufLine(hbuf, ln+, " * 函 数 名 : #")
}
oldln = ln
InsBufLine(hbuf, ln+, " * 负 责 人 : @szMyName@")
SysTime = GetSysTime();
/*szTime = SysTime.Date*/
SysTime = GetSysTime();
sz1=SysTime.Year
sz2=SysTime.month
sz3=SysTime.day
InsBufLine(hbuf, ln+, " * 创建日期 : @sz1@年@sz2@月@sz3@日")
InsBufLine(hbuf, ln+, " * 函数功能 : ")
szIns = " * 输入参数 : "
if(newFunc != )
{
//对于已经存在的函数插入函数参数
i =
while ( i < lnMax)
{
szTmp = GetBufLine(hTmpBuf, i)
nLen = strlen(szTmp);
szBlank = CreateBlankString(nMaxParamSize - nLen + )
szTmp = cat(szTmp,szBlank) //插入参数描述
szParamAsk = cat("请输入参数描述: ",szTmp)
szParamDescribe = Ask(szParamAsk)
szTmp = cat(szTmp,szParamDescribe) ln = ln + //这句是关键,每找到一个参数将ln加1,保证今后在ln+?行都是在所有参数基础后加的
szTmp = cat(szIns,szTmp)
InsBufLine(hbuf, ln+, "@szTmp@") //在第ln+4行插入是因为前面每个参数都ln=ln+1,其实是从ln5行开始每个参数插入一行
iIns = //函数是否存在参数标记
szIns = " " //第二个参数前面留空格对齐
i = i +
}
closebuf(hTmpBuf)
}
if(iIns == )
{
ln = ln + //为了保持如有参数的一致
InsBufLine(hbuf, ln+, " * 输入参数 : 无") //在第ln+4行插入是因为前面每个参数都ln=ln+1,其实是从ln5行开始每个参数插入一行
}
InsBufLine(hbuf, ln+, " * 输出参数 : 无")
InsBufLine(hbuf, ln+, " * 返 回 值 : @szRet@")
InsBufLine(hbuf, ln+, " * 调用关系 : ")
InsBufLine(hbuf, ln+, " * 其 它 : ")
/*InsBufLine(hbuf, ln+6, " 创 建 者 : @szMyName@")
InsbufLIne(hbuf, ln+7, " 创建时间 : @szTime@")*/
// InsBufLine(hbuf, ln+6, " * 记 录")
// SysTime = GetSysTime(1);
// /*szTime = SysTime.Date*/
// SysTime = GetSysTime(1);
// sz1=SysTime.Year
// sz2=SysTime.month
// sz3=SysTime.day
// if (sz2 < 10)
// {
// szMonth = "0@sz2@"
// }
// else
// {
// szMonth = sz2
// }
// if (sz3 < 10)
// {
// szDay = "0@sz3@"
// }
// else
// {
// szDay = sz3
// }
//
// InsBufLine(hbuf, ln+7, " * 1.日 期: @sz1@@szMonth@@szDay@")
//
// if( strlen(szMyName)>0 )
// {
// InsBufLine(hbuf, ln+8, " * 作 者: @szMyName@")
// }
// else
// {
// InsBufLine(hbuf, ln+8, " * 作 者: #")
// }
// InsBufLine(hbuf, ln+9, " * 修改内容: 新生成函数")
InsBufLine(hbuf, ln+, "")
InsBufLine(hbuf, ln+, "*****************************************************************************/")
//输入了函数名的新函数在注释后加上函数体
if ((newFunc == ) && (strlen(szFunc)>))
{
InsBufLine(hbuf, ln+, "VOS_UINT32 @szFunc@( # )")
InsBufLine(hbuf, ln+, "{");
InsBufLine(hbuf, ln+, " #");
InsBufLine(hbuf, ln+, "}");
SearchForward() //光标定位到最前面单独出现的#上,并选中#,即函数名后面的#(函数的参数位置)
}
hwnd = GetCurrentWnd()
if (hwnd == )
stop
//光标定位到"{"后
sel = GetWndSel(hwnd)
sel.ichFirst =
sel.ichLim = sel.ichFirst
sel.lnFirst = ln +
sel.lnLast = ln +
szContent = Ask("请输入函数功能描述的内容")
setWndSel(hwnd,sel)
DelBufLine(hbuf,oldln + ) //显示输入的功能描述内容
newln = CommentContent(hbuf,oldln+," * 函数功能 : ",szContent,) - //此处减4是因为CommentContent返回的值是传进去的oldln+4之后演算出来的
ln = ln + newln - oldln //加上增加行数
if ((newFunc == ) && (strlen(szFunc)>))
{
isFirstParam = //提示输入新函数的返回值
szRet = Ask("请输入返回值类型")
if(strlen(szRet) > )
{
PutBufLine(hbuf, ln+, " * 返 回 值 : @szRet@")
PutBufLine(hbuf, ln+, "@szRet@ @szFunc@( )")
SetbufIns(hbuf,ln+,strlen(szRet)+strlen(szFunc) + //光标定位到函数的左括号"("后一个空格处
}
szFuncDef = ""
sel.ichFirst = strlen(szFunc)+strlen(szRet) +
sel.ichLim = sel.ichFirst +
//循环输入参数
while ()
{
szParam = ask("请输入函数参数名")
szParam = TrimString(szParam)
szParamOriginal = szParam
szTmp = cat(szIns,szParam)
szParam = cat(szFuncDef,szParam) //光标定位到函数的最后一个参数后
sel.lnFirst = ln +
sel.lnLast = ln +
setWndSel(hwnd,sel) sel.ichFirst = sel.ichFirst + strlen(szParam)
sel.ichLim = sel.ichFirst
oldsel = sel //插入参数描述
szParamAsk = cat("请输入参数描述: ",szParamOriginal)
szParamDescribe = Ask(szParamAsk)
szTmp = cat(szTmp," ")
szTmp = cat(szTmp,szParamDescribe) //在函数头注释中插入参数
if(isFirstParam == )
{
PutBufLine(hbuf, ln+, "@szTmp@")
isFirstParam =
}
else
{
ln = ln +
InsBufLine(hbuf, ln+, "@szTmp@")
oldsel.lnFirst = ln +
oldsel.lnLast = ln +
} //在光标所在的位置插入参数
SetBufSelText(hbuf,szParam) //函数头注释的对齐
szIns = " "
//参数后加一个空格
szFuncDef = ", " //光标定位到函数"{"后的"#"处,并选中"#"
oldsel.lnFirst = ln +
oldsel.lnLast = ln +
oldsel.ichFirst =
oldsel.ichLim =
setWndSel(hwnd,oldsel)
}
}
return ln +
} /*****************************************************************************
函 数 名 : FuncHeadCommentEN
功能描述 : 函数头英文说明
输入参数 : hbuf
ln
szFunc
szMyName
newFunc
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro FuncHeadCommentEN(hbuf, ln, szFunc, szMyName,newFunc)
{
iIns =
if(newFunc != )
{
symbol = GetSymbolLocationFromLn(hbuf, ln)
if(strlen(symbol) > )
{
hTmpBuf = NewBuf("Tempbuf") //将文件参数头整理成一行并去掉了注释
szLine = GetFunctionDef(hbuf,symbol)
iBegin = symbol.ichName //取出返回值定义
szTemp = strmid(szLine,,iBegin)
szTemp = TrimString(szTemp)
szRet = GetFirstWord(szTemp)
if(symbol.Type == "Method")
{
szTemp = strmid(szTemp,strlen(szRet),strlen(szTemp))
szTemp = TrimString(szTemp)
if(szTemp == "::")
{
szRet = ""
}
}
if(toupper (szRet) == "MACRO")
{
//对于宏返回值特殊处理
szRet = ""
} //从函数头分离出函数参数
nMaxParamSize = GetWordFromString(hTmpBuf,szLine,iBegin,strlen(szLine),"(",",",")")
lnMax = GetBufLineCount(hTmpBuf)
ln = symbol.lnFirst
SetBufIns (hbuf, ln, )
}
}
else
{
lnMax =
szRet = ""
szLine = ""
}
InsBufLine(hbuf, ln, "/*****************************************************************************")
InsBufLine(hbuf, ln+, " * Function : @szFunc@")
InsBufLine(hbuf, ln+, " * Description : ")
oldln = ln
szIns = " * Input : "
if(newFunc != )
{
//对于已经存在的函数输出输入参数表
i =
while ( i < lnMax)
{
szTmp = GetBufLine(hTmpBuf, i)
nLen = strlen(szTmp); //对齐参数后面的空格,实际是对齐后面的参数的说明
szBlank = CreateBlankString(nMaxParamSize - nLen + )
szTmp = cat(szTmp,szBlank)
ln = ln +
szTmp = cat(szIns,szTmp)
InsBufLine(hbuf, ln+, "@szTmp@")
iIns =
szIns = " "
i = i +
}
closebuf(hTmpBuf)
}
if(iIns == )
{
ln = ln +
InsBufLine(hbuf, ln+, " * Input : None")
}
InsBufLine(hbuf, ln+, " * Output : None")
InsBufLine(hbuf, ln+, " * Return : @szRet@")
/*InsBufLine(hbuf, ln+5, " Calls : ")
InsBufLine(hbuf, ln+6, " Called By : ")*/
InsbufLIne(hbuf, ln+, " * Others : "); SysTime = GetSysTime();
sz1=SysTime.Year
sz2=SysTime.month
sz3=SysTime.day
if (sz2 < )
{
szMonth = "0@sz2@"
}
else
{
szMonth = sz2
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
} InsBufLine(hbuf, ln + , " * Record")
InsBufLine(hbuf, ln + , " * 1.Date : @sz1@@szMonth@@szDay@")
InsBufLine(hbuf, ln + , " * Author : @szMyName@")
InsBufLine(hbuf, ln + , " * Modification: Created function")
InsBufLine(hbuf, ln + , "")
InsBufLine(hbuf, ln + , "*****************************************************************************/")
if ((newFunc == ) && (strlen(szFunc)>))
{
InsBufLine(hbuf, ln+, "VOS_UINT32 @szFunc@( # )")
InsBufLine(hbuf, ln+, "{");
InsBufLine(hbuf, ln+, " #");
InsBufLine(hbuf, ln+, "}");
SearchForward()
}
hwnd = GetCurrentWnd()
if (hwnd == )
stop
sel = GetWndSel(hwnd)
sel.ichFirst =
sel.ichLim = sel.ichFirst
sel.lnFirst = ln +
sel.lnLast = ln +
szContent = Ask("Description")
DelBufLine(hbuf,oldln + )
setWndSel(hwnd,sel)
newln = CommentContent(hbuf,oldln + ," * Description : ",szContent,) -
ln = ln + newln - oldln
if ((newFunc == ) && (strlen(szFunc)>))
{
//提示输入函数返回值名
szRet = Ask("Please input return value type")
if(strlen(szRet) > )
{
PutBufLine(hbuf, ln+, " * Return : @szRet@")
PutBufLine(hbuf, ln+, "@szRet@ @szFunc@( # )")
SetbufIns(hbuf,ln+,strlen(szRet)+strlen(szFunc) +
}
szFuncDef = ""
isFirstParam =
sel.ichFirst = strlen(szFunc)+strlen(szRet) +
sel.ichLim = sel.ichFirst + //循环输入新函数的参数
while ()
{
szParam = ask("Please input parameter")
szParam = TrimString(szParam)
szTmp = cat(szIns,szParam)
szParam = cat(szFuncDef,szParam)
sel.lnFirst = ln +
sel.lnLast = ln +
setWndSel(hwnd,sel)
sel.ichFirst = sel.ichFirst + strlen(szParam)
sel.ichLim = sel.ichFirst
oldsel = sel
if(isFirstParam == )
{
PutBufLine(hbuf, ln+, "@szTmp@")
isFirstParam =
}
else
{
ln = ln +
InsBufLine(hbuf, ln+, "@szTmp@")
oldsel.lnFirst = ln +
oldsel.lnLast = ln +
}
SetBufSelText(hbuf,szParam)
szIns = " "
szFuncDef = ", "
oldsel.lnFirst = ln +
oldsel.lnLast = ln +
oldsel.ichFirst =
oldsel.ichLim =
setWndSel(hwnd,oldsel)
}
}
return ln +
} /*****************************************************************************
函 数 名 : InsertHistory
功能描述 : 插入修改历史记录
输入参数 : hbuf
ln 行号
language 语种
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro InsertHistory(hbuf,ln,language)
{
iHistoryCount =
// isLastLine = ln
// i = 0
// while(ln-i>0)
// {
// szCurLine = GetBufLine(hbuf, ln-i);
// iBeg1 = strstr(szCurLine,"日 期 ")
// iBeg2 = strstr(szCurLine,"Date ")
// if((iBeg1 != 0xffffffff) || (iBeg2 != 0xffffffff))
// {
// iHistoryCount = iHistoryCount + 1
// i = i + 1
// continue
// }
// iBeg1 = strstr(szCurLine,"修改历史")
// iBeg2 = strstr(szCurLine,"History ")
// if((iBeg1 != 0xffffffff) || (iBeg2 != 0xffffffff))
// {
// break
// }
// iBeg = strstr(szCurLine,"/**********************")
// if( iBeg != 0xffffffff )
// {
// break
// }
// i = i + 1
// }
if(language == )
{
InsertHistoryContentCN(hbuf,ln,iHistoryCount)
}
else
{
InsertHistoryContentEN(hbuf,ln,iHistoryCount)
}
} /*****************************************************************************
函 数 名 : UpdateFunctionList
功能描述 : 更新函数列表
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro UpdateFunctionList()
{
hnewbuf = newbuf("")
if(hnewbuf == hNil)
{
stop
}
hwnd = GetCurrentWnd()
if (hwnd == )
stop
sel = GetWndSel(hwnd)
hbuf = GetWndBuf(hwnd)
GetFunctionList(hbuf,hnewbuf)
ln = sel.lnFirst
iHistoryCount =
isLastLine = ln
iTotalLn = GetBufLineCount (hbuf)
while(ln < iTotalLn)
{
szCurLine = GetBufLine(hbuf, ln);
iLen = strlen(szCurLine)
j = ;
while(j < iLen)
{
if(szCurLine[j] != " ")
break
j = j +
} //以文件头说明中前有大于10个空格的为函数列表记录
if(j > )
{
DelBufLine(hbuf, ln)
}
else
{
break
}
iTotalLn = GetBufLineCount (hbuf)
} //插入函数列表
InsertFileList( hbuf,hnewbuf,ln )
closebuf(hnewbuf)
} /*****************************************************************************
函 数 名 : InsertHistoryContentCN
功能描述 : 插入历史修改记录中文说明
输入参数 : hbuf
ln
iHostoryCount
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro InsertHistoryContentCN(hbuf,ln,iHostoryCount)
{
//获取时间
SysTime = GetSysTime();
szYear=SysTime.Year
szMonth=SysTime.month
if (szMonth < )
{
szMonth = "0@szMonth@"
}
szDay=SysTime.day
if (szDay < )
{
szDay = "0@szDay@"
} //获取用户名
szMyName = getreg(MYNAME)
if(strlen( szMyName ) == )
{
szMyName = Ask("Enter your name:")
setreg(MYNAME, szMyName)
} //获取光标所在位置的左侧的字符串,即得到"hi"字符串
hwnd = GetCurrentWnd()
if (hwnd == )
stop
sel = GetWndSel(hwnd)
szLine = GetBufLine (hbuf, sel.lnFirst)
wordinfo = GetWordLeftOfIch(sel.ichFirst, szLine) //获取"hi"左侧的字符
strLeft = strmid (szLine, , wordinfo.ich) //判断左侧的字符是否有" * 修改日志 :"
ret =strstr(strLeft, " * 修改日志 :")
if(ret != 0xffffffff) //修改日志的第一行,保留"修改日志"字符串
{
szTmp = strLeft
}
else //修改日志的其他行,前面补空格
{
szTmp = CreateBlankString()
} //加上修改日期,修改人
szTmp = cat(szTmp,"@szYear@@szMonth@@szDay@ by @szMyName@, ") szContent = Ask("请输入修改的内容")
CommentContent(hbuf,ln,szTmp,szContent,) // SysTime = GetSysTime(1);
// szTime = SysTime.Date
// szMyName = getreg(MYNAME)
//
// InsBufLine(hbuf, ln, "")
// InsBufLine(hbuf, ln + 1, " @iHostoryCount@.日 期 : @szTime@")
//
// if( strlen(szMyName) > 0 )
// {
// InsBufLine(hbuf, ln + 2, " 作 者 : @szMyName@")
// }
// else
// {
// InsBufLine(hbuf, ln + 2, " 作 者 : #")
// }
// szContent = Ask("请输入修改的内容")
// CommentContent(hbuf,ln + 3," 修改内容 : ",szContent,0)
} /*****************************************************************************
函 数 名 : InsertHistoryContentEN
功能描述 : 插入历史修改记录英文说明
输入参数 : hbuf 当前buf
ln 当前行号
iHostoryCount 修改记录的编号
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro InsertHistoryContentEN(hbuf,ln,iHostoryCount)
{
SysTime = GetSysTime();
szTime = SysTime.Date
sz1=SysTime.Year
sz2=SysTime.month
sz3=SysTime.day
if (sz2 < )
{
szMonth = "0@sz2@"
}
else
{
szMonth = sz2
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
}
szMyName = getreg(MYNAME)
InsBufLine(hbuf, ln, "")
InsBufLine(hbuf, ln + , " @iHostoryCount@.Date : @sz1@@szMonth@@szDay@") InsBufLine(hbuf, ln + , " Author : @szMyName@")
szContent = Ask("Please input modification")
CommentContent(hbuf,ln + ," Modification : ",szContent,)
} /*****************************************************************************
函 数 名 : CreateFunctionDef
功能描述 : 生成C语言头文件
输入参数 : hbuf
szName
language
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro CreateFunctionDef(hbuf, szName, language)
{
ln = //获得当前没有后缀的文件名
szFileName = GetFileNameNoExt(GetBufName (hbuf))
if(strlen(szFileName) == )
{
sz = ask("请输入头文件名")
szFileName = GetFileNameNoExt(sz)
szExt = GetFileNameExt(szFileName)
szPreH = toupper (szFileName)
szPreH = cat("__",szPreH)
szExt = toupper(szExt)
szPreH = cat(szPreH,"_@szExt@__")
}
szPreH = toupper (szFileName)
sz = cat(szFileName,".h")
szPreH = cat("__",szPreH)
szPreH = cat(szPreH,"_H__")
hOutbuf = NewBuf(sz) // create output buffer
if (hOutbuf == )
stop
//搜索符号表取得函数名
SetCurrentBuf(hOutbuf)
isymMax = GetBufSymCount(hbuf)
isym =
while (isym < isymMax)
{
isLastLine =
symbol = GetBufSymLocation(hbuf, isym)
fIsEnd =
if(strlen(symbol) > )
{
if(symbol.Type == "Class Placeholder")
{
hsyml = SymbolChildren(symbol)
cchild = SymListCount(hsyml)
ichild =
szClassName = symbol.Symbol
InsBufLine(hOutbuf, ln, "}")
InsBufLine(hOutbuf, ln, "{")
InsBufLine(hOutbuf, ln, "class @szClassName@")
ln = ln +
while (ichild < cchild)
{
childsym = SymListItem(hsyml, ichild)
childsym.Symbol = szClassName
ln = CreateClassPrototype(hbuf,ln,childsym)
ichild = ichild +
}
SymListFree(hsyml)
InsBufLine(hOutbuf, ln + , "")
ln = ln +
}
else if( symbol.Type == "Function" )
{
ln = CreateFuncPrototype(hbuf,ln,"extern",symbol)
}
else if( symbol.Type == "Method" )
{
szLine = GetBufline(hbuf,symbol.lnName)
szClassName = GetLeftWord(szLine,symbol.ichName)
symbol.Symbol = szClassName
ln = CreateClassPrototype(hbuf,ln,symbol)
} }
isym = isym +
}
InsertCPP(hOutbuf,)
HeadIfdefStr(szPreH)
szContent = GetFileName(GetBufName (hbuf))
if(language == )
{
szContent = cat(szContent," 的头文件")
//插入文件头说明
InsertFileHeaderCN(hOutbuf,,szName,szContent)
}
else
{
szContent = cat(szContent," header file")
//插入文件头说明
InsertFileHeaderEN(hOutbuf,,szName,szContent)
}
} /*****************************************************************************
函 数 名 : GetLeftWord
功能描述 : 取得左边的单词
输入参数 : szLine
ichRight 开始取词位置
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年7月05日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro GetLeftWord(szLine,ichRight)
{
if(ich == )
{
return ""
}
ich = ichRight
while(ich > )
{
if( (szLine[ich] == " ") || (szLine[ich] == "\t")
|| ( szLine[ich] == ":") || (szLine[ich] == ".")) {
ich = ich -
ichRight = ich
}
else
{
break
}
}
while(ich > )
{
if(szLine[ich] == " ")
{
ich = ich +
break
}
ich = ich -
}
return strmid(szLine,ich,ichRight)
}
/*****************************************************************************
函 数 名 : CreateClassPrototype
功能描述 : 生成Class的定义
输入参数 : hbuf 当前文件
hOutbuf 输出文件
ln 输出行号
symbol 符号
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年7月05日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro CreateClassPrototype(hbuf,ln,symbol)
{
isLastLine =
fIsEnd =
hOutbuf = GetCurrentBuf()
szLine = GetBufLine (hbuf, symbol.lnName)
sline = symbol.lnFirst
szClassName = symbol.Symbol
ret = strstr(szLine,szClassName)
if(ret == 0xffffffff)
{
return ln
}
szPre = strmid(szLine,,ret)
szLine = strmid(szLine,symbol.ichName,strlen(szLine))
szLine = cat(szPre,szLine)
//去掉注释的干扰
RetVal = SkipCommentFromString(szLine,fIsEnd)
fIsEnd = RetVal.fIsEnd
szNew = RetVal.szContent
szLine = cat(" ",szLine)
szNew = cat(" ",szNew)
while((isLastLine == ) && (sline < symbol.lnLim))
{
i =
j =
iLen = strlen(szNew)
while(i < iLen)
{
if(szNew[i]=="(")
{
j = j + ;
}
else if(szNew[i]==")")
{
j = j - ;
if(j <= )
{
//函数参数头结束
isLastLine =
//去掉最后多余的字符
szLine = strmid(szLine,,i+);
szLine = cat(szLine,";")
break
}
}
i = i +
}
InsBufLine(hOutbuf, ln, "@szLine@")
ln = ln +
sline = sline +
if(isLastLine != )
{
//函数参数头还没有结束再取一行
szLine = GetBufLine (hbuf, sline)
//去掉注释的干扰
RetVal = SkipCommentFromString(szLine,fIsEnd)
szNew = RetVal.szContent
fIsEnd = RetVal.fIsEnd
}
}
return ln
} /*****************************************************************************
函 数 名 : CreateFuncPrototype
功能描述 : 生成C函数原型定义
输入参数 : hbuf 当前文件
hOutbuf 输出文件
ln 输出行号
szType 原型类型
symbol 符号
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年7月05日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro CreateFuncPrototype(hbuf,ln,szType,symbol)
{
isLastLine =
hOutbuf = GetCurrentBuf()
szLine = GetBufLine (hbuf,symbol.lnName)
//去掉注释的干扰
RetVal = SkipCommentFromString(szLine,fIsEnd)
szNew = RetVal.szContent
fIsEnd = RetVal.fIsEnd
szLine = cat("@szType@ ",szLine)
szNew = cat("@szType@ ",szNew)
sline = symbol.lnFirst
while((isLastLine == ) && (sline < symbol.lnLim))
{
i =
j =
iLen = strlen(szNew)
while(i < iLen)
{
if(szNew[i]=="(")
{
j = j + ;
}
else if(szNew[i]==")")
{
j = j - ;
if(j <= )
{
//函数参数头结束
isLastLine =
//去掉最后多余的字符
szLine = strmid(szLine,,i+);
szLine = cat(szLine,";")
break
}
}
i = i +
}
InsBufLine(hOutbuf, ln, "@szLine@")
ln = ln +
sline = sline +
if(isLastLine != )
{
//函数参数头还没有结束再取一行
szLine = GetBufLine (hbuf, sline)
szLine = cat(" ",szLine)
//去掉注释的干扰
RetVal = SkipCommentFromString(szLine,fIsEnd)
szNew = RetVal.szContent
fIsEnd = RetVal.fIsEnd
}
}
return ln
} /*****************************************************************************
函 数 名 : CreateNewHeaderFile
功能描述 : 生成一个新的头文件,文件名可输入
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月24日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro CreateNewHeaderFile()
{
hbuf = GetCurrentBuf()
language = getreg(LANGUAGE)
if(language != )
{
language =
}
szName = getreg(MYNAME)
if(strlen( szName ) == )
{
szMyName = Ask("Enter your name:")
setreg(MYNAME, szMyName)
}
isymMax = GetBufSymCount(hbuf)
isym =
ln =
//获得当前没有后缀的文件名
sz = ask("Please input header file name")
szFileName = GetFileNameNoExt(sz)
szExt = GetFileNameExt(sz)
szPreH = toupper (szFileName)
szPreH = cat("__",szPreH)
szExt = toupper(szExt)
szPreH = cat(szPreH,"_@szExt@__")
hOutbuf = NewBuf(sz) // create output buffer
if (hOutbuf == )
stop SetCurrentBuf(hOutbuf)
InsertCPP(hOutbuf,)
HeadIfdefStr(szPreH)
szContent = GetFileName(GetBufName (hbuf))
if(language == )
{
szContent = cat(szContent," 的头文件") //插入文件头说明
InsertFileHeaderCN(hOutbuf,,szName,szContent)
}
else
{
szContent = cat(szContent," header file") //插入文件头说明
InsertFileHeaderEN(hOutbuf,,szName,szContent)
} lnMax = GetBufLineCount(hOutbuf)
if(lnMax > )
{
ln = lnMax -
}
else
{
return
}
hwnd = GetCurrentWnd()
if (hwnd == )
stop
sel = GetWndSel(hwnd)
sel.lnFirst = ln
sel.ichFirst =
sel.ichLim =
SetBufIns(hOutbuf,ln,)
szType = Ask ("Please prototype type : extern or static")
//搜索符号表取得函数名
while (isym < isymMax)
{
isLastLine =
symbol = GetBufSymLocation(hbuf, isym)
fIsEnd =
if(strlen(symbol) > )
{
if(symbol.Type == "Class Placeholder")
{
hsyml = SymbolChildren(symbol)
cchild = SymListCount(hsyml)
ichild =
szClassName = symbol.Symbol
InsBufLine(hOutbuf, ln, "}")
InsBufLine(hOutbuf, ln, "{")
InsBufLine(hOutbuf, ln, "class @szClassName@")
ln = ln +
while (ichild < cchild)
{
childsym = SymListItem(hsyml, ichild)
childsym.Symbol = szClassName
ln = CreateClassPrototype(hbuf,ln,childsym)
ichild = ichild +
}
SymListFree(hsyml)
InsBufLine(hOutbuf, ln + , "")
ln = ln +
}
else if( symbol.Type == "Function" )
{
ln = CreateFuncPrototype(hbuf,ln,szType,symbol)
}
else if( symbol.Type == "Method" )
{
szLine = GetBufline(hbuf,symbol.lnName)
szClassName = GetLeftWord(szLine,symbol.ichName)
symbol.Symbol = szClassName
ln = CreateClassPrototype(hbuf,ln,symbol)
}
}
isym = isym +
}
sel.lnLast = ln
SetWndSel(hwnd,sel)
} /* G E T W O R D L E F T O F I C H */
/*-------------------------------------------------------------------------
Given an index to a character (ich) and a string (sz),
return a "wordinfo" record variable that describes the
text word just to the left of the ich. Output:
wordinfo.szWord = the word string
wordinfo.ich = the first ich of the word
wordinfo.ichLim = the limit ich of the word
-------------------------------------------------------------------------*/
macro GetWordLeftOfIch(ich, sz)
{
wordinfo = "" // create a "wordinfo" structure chTab = CharFromAscii() // scan backwords over white space, if any
ich = ich - ;
if (ich >= )
while (sz[ich] == " " || sz[ich] == chTab)
{
ich = ich - ;
if (ich < )
break;
} // scan backwords to start of word
ichLim = ich + ;
asciiA = AsciiFromChar("A")
asciiZ = AsciiFromChar("Z")
while (ich >= )
{
ch = toupper(sz[ich])
asciiCh = AsciiFromChar(ch) /* if ((asciiCh < asciiA || asciiCh > asciiZ)
&& !IsNumber(ch)
&& (ch != "#") )
break // stop at first non-identifier character
*/
//只提取字符和# { / *作为命令
if ((asciiCh < asciiA || asciiCh > asciiZ)
&& !IsNumber(ch)
&& ( ch != "#" && ch != "{" && ch != "/" && ch != "*"))
break; ich = ich - ;
} ich = ich +
wordinfo.szWord = strmid(sz, ich, ichLim)
wordinfo.ich = ich
wordinfo.ichLim = ichLim; return wordinfo
} /*****************************************************************************
函 数 名 : ReplaceBufTab
功能描述 : 替换tab为空格
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro ReplaceBufTab()
{
hwnd = GetCurrentWnd()
if (hwnd == )
stop
hbuf = GetWndBuf(hwnd)
iTotalLn = GetBufLineCount (hbuf)
nBlank = Ask("一个Tab替换几个空格")
if(nBlank == )
{
nBlank =
}
szBlank = CreateBlankString(nBlank)
ReplaceInBuf(hbuf,"\t",szBlank,, iTotalLn, , , , )
} /*****************************************************************************
函 数 名 : ReplaceTabInProj
功能描述 : 在整个工程内替换tab为空格
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro ReplaceTabInProj()
{
hprj = GetCurrentProj()
ifileMax = GetProjFileCount (hprj)
nBlank = Ask("一个Tab替换几个空格")
if(nBlank == )
{
nBlank =
}
szBlank = CreateBlankString(nBlank) ifile =
while (ifile < ifileMax)
{
filename = GetProjFileName (hprj, ifile)
hbuf = OpenBuf (filename)
if(hbuf != )
{
iTotalLn = GetBufLineCount (hbuf)
ReplaceInBuf(hbuf,"\t",szBlank,, iTotalLn, , , , )
}
if( IsBufDirty (hbuf) )
{
SaveBuf (hbuf)
}
CloseBuf(hbuf)
ifile = ifile +
}
} /*****************************************************************************
函 数 名 : ReplaceInBuf
功能描述 : 替换tab为空格,只在2.1中有效
输入参数 : hbuf
chOld
chNew
nBeg
nEnd
fMatchCase
fRegExp
fWholeWordsOnly
fConfirm
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro ReplaceInBuf(hbuf,chOld,chNew,nBeg,nEnd,fMatchCase, fRegExp, fWholeWordsOnly, fConfirm)
{
hwnd = GetCurrentWnd()
if (hwnd == )
stop
hbuf = GetWndBuf(hwnd)
sel = GetWndSel(hwnd)
sel.ichLim =
sel.lnLast =
sel.ichFirst = sel.ichLim
sel.lnFirst = sel.lnLast
SetWndSel(hwnd, sel)
LoadSearchPattern(chOld, , , );
while()
{
Search_Forward
selNew = GetWndSel(hwnd)
if(sel == selNew)
{
break
}
SetBufSelText(hbuf, chNew)
selNew.ichLim = selNew.ichFirst
SetWndSel(hwnd, selNew)
sel = selNew
}
} /*****************************************************************************
函 数 名 : ConfigureSystem
功能描述 : 配置系统
输入参数 : 无
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro ConfigureSystem()
{
szLanguage = ASK("Please select language: 0 Chinese ,1 English");
if(szLanguage == "#")
{
SetReg ("LANGUAGE", "")
}
else
{
SetReg ("LANGUAGE", szLanguage)
} szName = ASK("Please input your name");
if(szName == "#")
{
SetReg ("MYNAME", "")
}
else
{
SetReg ("MYNAME", szName)
}
} /*****************************************************************************
函 数 名 : GetLeftBlank
功能描述 : 得到字符串左边的空格字符数
输入参数 : szLine
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro GetLeftBlank(szLine)
{
nIdx =
nEndIdx = strlen(szLine)
while( nIdx < nEndIdx )
{
if( (szLine[nIdx] !=" ") && (szLine[nIdx] !="\t") )
{
break;
}
nIdx = nIdx +
}
return nIdx
} /*****************************************************************************
函 数 名 : ExpandBraceLittle
功能描述 : 小括号扩展
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro ExpandBraceLittle()
{
hwnd = GetCurrentWnd()
sel = GetWndSel(hwnd)
hbuf = GetCurrentBuf()
if( (sel.lnFirst == sel.lnLast)
&& (sel.ichFirst == sel.ichLim) )
{
SetBufSelText (hbuf, "( )")
SetBufIns (hbuf, sel.lnFirst, sel.ichFirst + )
}
else
{
SetBufIns (hbuf, sel.lnFirst, sel.ichFirst)
SetBufSelText (hbuf, "( ")
SetBufIns (hbuf, sel.lnLast, sel.ichLim + )
SetBufSelText (hbuf, " )")
} } /*****************************************************************************
函 数 名 : ExpandBraceMid
功能描述 : 中括号扩展
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro ExpandBraceMid()
{
hwnd = GetCurrentWnd()
sel = GetWndSel(hwnd)
hbuf = GetCurrentBuf()
if( (sel.lnFirst == sel.lnLast)
&& (sel.ichFirst == sel.ichLim) )
{
SetBufSelText (hbuf, "[]")
SetBufIns (hbuf, sel.lnFirst, sel.ichFirst + )
}
else
{
SetBufIns (hbuf, sel.lnFirst, sel.ichFirst)
SetBufSelText (hbuf, "[")
SetBufIns (hbuf, sel.lnLast, sel.ichLim + )
SetBufSelText (hbuf, "]")
} } /*****************************************************************************
函 数 名 : ExpandBraceLarge
功能描述 : 大括号扩展
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月18日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro ExpandBraceLarge()
{
hwnd = GetCurrentWnd()
sel = GetWndSel(hwnd)
hbuf = GetCurrentBuf()
ln = sel.lnFirst
nlineCount =
retVal = ""
szLine = GetBufLine( hbuf, ln )
nLeft = GetLeftBlank(szLine)
szLeft = strmid(szLine,,nLeft);
szRight = ""
szMid = ""
if(sel.lnFirst == sel.lnLast && sel.ichFirst == sel.ichLim)
{
//对于没有块选择的情况,直接插入{}即可
if( nLeft == strlen(szLine) )
{
SetBufSelText (hbuf, "{")
}
else
{
ln = ln +
InsBufLine(hbuf, ln, "@szLeft@{")
nlineCount = nlineCount + }
InsBufLine(hbuf, ln + , "@szLeft@ ")
InsBufLine(hbuf, ln + , "@szLeft@}")
nlineCount = nlineCount +
SetBufIns (hbuf, ln + , strlen(szLeft)+)
}
else
{
//对于有块选择的情况还得考虑将块选择区分开了 //检查选择区内是否大括号配对,如果嫌太慢则注释掉下面的判断
RetVal= CheckBlockBrace(hbuf)
if(RetVal.iCount != )
{
msg("Invalidated brace number")
stop
} //取出选中区前的内容
szOld = strmid(szLine,,sel.ichFirst)
if(sel.lnFirst != sel.lnLast)
{
//对于多行的情况 //第一行的选中部分
szMid = strmid(szLine,sel.ichFirst,strlen(szLine))
szMid = TrimString(szMid)
szLast = GetBufLine(hbuf,sel.lnLast)
if( sel.ichLim > strlen(szLast) )
{
//如果选择区长度大于改行的长度,最大取该行的长度
szLineselichLim = strlen(szLast)
}
else
{
szLineselichLim = sel.ichLim
} //得到最后一行选择区为的字符
szRight = strmid(szLast,szLineselichLim,strlen(szLast))
szRight = TrimString(szRight)
}
else
{
//对于选择只有一行的情况
if(sel.ichLim >= strlen(szLine))
{
sel.ichLim = strlen(szLine)
} //获得选中区的内容
szMid = strmid(szLine,sel.ichFirst,sel.ichLim)
szMid = TrimString(szMid)
if( sel.ichLim > strlen(szLine) )
{
szLineselichLim = strlen(szLine)
}
else
{
szLineselichLim = sel.ichLim
} //同样得到选中区后的内容
szRight = strmid(szLine,szLineselichLim,strlen(szLine))
szRight = TrimString(szRight)
}
nIdx = sel.lnFirst
while( nIdx < sel.lnLast)
{
szCurLine = GetBufLine(hbuf,nIdx+)
if( sel.ichLim > strlen(szCurLine) )
{
szLineselichLim = strlen(szCurLine)
}
else
{
szLineselichLim = sel.ichLim
}
szCurLine = cat(" ",szCurLine)
if(nIdx == sel.lnLast - )
{
//对于最后一行应该是选中区内的内容后移四位
szCurLine = strmid(szCurLine,,szLineselichLim + )
PutBufLine(hbuf,nIdx+,szCurLine)
}
else
{
//其它情况是整行的内容后移四位
PutBufLine(hbuf,nIdx+,szCurLine)
}
nIdx = nIdx +
}
if(strlen(szRight) != )
{
//最后插入最后一行没有被选择的内容
InsBufLine(hbuf, sel.lnLast + , "@szLeft@@szRight@")
}
InsBufLine(hbuf, sel.lnLast + , "@szLeft@}")
nlineCount = nlineCount +
if(nLeft < sel.ichFirst)
{
//如果选中区前的内容不是空格,则要保留该部分内容
PutBufLine(hbuf,ln,szOld)
InsBufLine(hbuf, ln+, "@szLeft@{")
nlineCount = nlineCount +
ln = ln +
}
else
{
//如果选中区前没有内容直接删除该行
DelBufLine(hbuf,ln)
InsBufLine(hbuf, ln, "@szLeft@{")
}
if(strlen(szMid) > )
{
//插入第一行选择区的内容
InsBufLine(hbuf, ln+, "@szLeft@ @szMid@")
nlineCount = nlineCount +
ln = ln +
}
}
retVal.szLeft = szLeft
retVal.nLineCount = nlineCount
//返回行数和左边的空白
return retVal
} /*
macro ScanStatement(szLine,iBeg)
{
nIdx = 0
iLen = strlen(szLine)
while(nIdx < iLen -1)
{
if(szLine[nIdx] == "/" && szLine[nIdx + 1] == "/")
{
return 0xffffffff
}
if(szLine[nIdx] == "/" && szLine[nIdx + 1] == "*")
{
while(nIdx < iLen)
{
if(szLine[nIdx] == "*" && szLine[nIdx + 1] == "/")
{
break
}
nIdx = nIdx + 1 }
}
if( (szLine[nIdx] != " ") && (szLine[nIdx] != "\t" ))
{
return nIdx
}
nIdx = nIdx + 1
}
if( (szLine[iLen -1] == " ") || (szLine[iLen -1] == "\t" ))
{
return 0xffffffff
}
return nIdx
}
*/
/*
macro MoveCommentLeftBlank(szLine)
{
nIdx = 0
iLen = strlen(szLine)
while(nIdx < iLen - 1)
{
if(szLine[nIdx] == "/" && szLine[nIdx+1] == "*")
{
szLine[nIdx] = " "
szLine[nIdx + 1] = " "
nIdx = nIdx + 2
while(nIdx < iLen - 1)
{
if(szLine[nIdx] != " " && szLine[nIdx] != "\t")
{
szLine[nIdx - 2] = "/"
szLine[nIdx - 1] = "*"
return szLine
}
nIdx = nIdx + 1
} }
if(szLine[nIdx] == "/" && szLine[nIdx+1] == "/")
{
szLine[nIdx] = " "
szLine[nIdx + 1] = " "
nIdx = nIdx + 2
while(nIdx < iLen - 1)
{
if(szLine[nIdx] != " " && szLine[nIdx] != "\t")
{
szLine[nIdx - 2] = "/"
szLine[nIdx - 1] = "/"
return szLine
}
nIdx = nIdx + 1
} }
nIdx = nIdx + 1
}
return szLine
}*/ /*****************************************************************************
函 数 名 : DelCompoundStatement
功能描述 : 删除一个复合语句
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月19日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro DelCompoundStatement()
{
hwnd = GetCurrentWnd()
sel = GetWndSel(hwnd)
hbuf = GetCurrentBuf()
ln = sel.lnFirst
szLine = GetBufLine(hbuf,ln )
nLeft = GetLeftBlank(szLine)
szLeft = strmid(szLine,,nLeft);
Msg("@szLine@ will be deleted !")
fIsEnd =
while()
{
RetVal = SkipCommentFromString(szLine,fIsEnd)
szTmp = RetVal.szContent
fIsEnd = RetVal.fIsEnd
//查找复合语句的开始
ret = strstr(szTmp,"{")
if(ret != 0xffffffff)
{
szNewLine = strmid(szLine,ret+,strlen(szLine))
szNew = strmid(szTmp,ret+,strlen(szTmp))
szNew = TrimString(szNew)
if(szNew != "")
{
InsBufLine(hbuf,ln + ,"@szLeft@ @szNewLine@");
}
sel.lnFirst = ln
sel.lnLast = ln
sel.ichFirst = ret
sel.ichLim = ret
//查找对应的大括号 //使用自己编写的代码速度太慢
retTmp = SearchCompoundEnd(hbuf,ln,ret)
if(retTmp.iCount == )
{ DelBufLine(hbuf,retTmp.ln)
sel.ichFirst =
sel.ichLim =
DelBufLine(hbuf,ln)
sel.lnLast = retTmp.ln -
SetWndSel(hwnd,sel)
Indent_Left
} //使用Si的大括号配对方法,但V2.1时在注释嵌套时可能有误
/* SetWndSel(hwnd,sel)
Block_Down
selNew = GetWndSel(hwnd)
if(selNew != sel)
{ DelBufLine(hbuf,selNew.lnFirst)
sel.ichFirst = 0
sel.ichLim = 0
DelBufLine(hbuf,ln)
sel.lnLast = selNew.lnFirst - 1
SetWndSel(hwnd,sel)
Indent_Left
}*/
break
}
szTmp = TrimString(szTmp)
iLen = strlen(szTmp)
if(iLen != )
{
if(szTmp[iLen-] == ";")
{
break
}
}
DelBufLine(hbuf,ln)
if( ln == GetBufLineCount(hbuf ))
{
break
}
szLine = GetBufLine(hbuf,ln)
}
} /*****************************************************************************
函 数 名 : CheckBlockBrace
功能描述 : 检测定义块中的大括号配对情况
输入参数 : hbuf
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月19日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro CheckBlockBrace(hbuf)
{
hwnd = GetCurrentWnd()
sel = GetWndSel(hwnd)
ln = sel.lnFirst
nCount =
RetVal = ""
szLine = GetBufLine( hbuf, ln )
if(sel.lnFirst == sel.lnLast && sel.ichFirst == sel.ichLim)
{
RetVal.iCount =
RetVal.ich = sel.ichFirst
return RetVal
}
if(sel.lnFirst == sel.lnLast && sel.ichFirst != sel.ichLim)
{
RetTmp = SkipCommentFromString(szLine,fIsEnd)
szTmp = RetTmp.szContent
RetVal = CheckBrace(szTmp,sel.ichFirst,sel.ichLim,"{","}",,)
return RetVal
}
if(sel.lnFirst != sel.lnLast)
{
fIsEnd =
while(ln <= sel.lnLast)
{
if(ln == sel.lnFirst)
{
RetVal = CheckBrace(szLine,sel.ichFirst,strlen(szLine)-,"{","}",nCount,fIsEnd)
}
else if(ln == sel.lnLast)
{
RetVal = CheckBrace(szLine,,sel.ichLim,"{","}",nCount,fIsEnd)
}
else
{
RetVal = CheckBrace(szLine,,strlen(szLine)-,"{","}",nCount,fIsEnd)
}
fIsEnd = RetVal.fIsEnd
ln = ln +
nCount = RetVal.iCount
szLine = GetBufLine( hbuf, ln )
}
}
return RetVal
} /*****************************************************************************
函 数 名 : SearchCompoundEnd
功能描述 : 查找一个复合语句的结束点
输入参数 : hbuf
ln 查询起始行
ichBeg 查询起始点
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月19日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro SearchCompoundEnd(hbuf,ln,ichBeg)
{
hwnd = GetCurrentWnd()
sel = GetWndSel(hwnd)
ln = sel.lnFirst
nCount =
SearchVal = ""
// szLine = GetBufLine( hbuf, ln )
lnMax = GetBufLineCount(hbuf)
fIsEnd =
while(ln < lnMax)
{
szLine = GetBufLine( hbuf, ln )
RetVal = CheckBrace(szLine,ichBeg,strlen(szLine)-,"{","}",nCount,fIsEnd)
fIsEnd = RetVal.fIsEnd
ichBeg =
nCount = RetVal.iCount //如果nCount=0则说明{}是配对的
if(nCount == )
{
break
}
ln = ln +
// szLine = GetBufLine( hbuf, ln )
}
SearchVal.iCount = RetVal.iCount
SearchVal.ich = RetVal.ich
SearchVal.ln = ln
return SearchVal
} /*****************************************************************************
函 数 名 : CheckBrace
功能描述 : 检测括号的配对情况
输入参数 : szLine 输入字符串
ichBeg 检测起始
ichEnd 检测结束
chBeg 开始字符(左括号)
chEnd 结束字符(右括号)
nCheckCount
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月19日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro CheckBrace(szLine,ichBeg,ichEnd,chBeg,chEnd,nCheckCount,isCommentEnd)
{
retVal = ""
retVal.ich =
nIdx = ichBeg
nLen = strlen(szLine)
if(ichEnd >= nLen)
{
ichEnd = nLen -
}
fIsEnd =
while(nIdx <= ichEnd)
{
//如果是/*注释区,跳过该段
if( (isCommentEnd == ) || (szLine[nIdx] == "/" && szLine[nIdx+] == "*"))
{
fIsEnd =
while(nIdx <= ichEnd )
{
if(szLine[nIdx] == "*" && szLine[nIdx+] == "/")
{
nIdx = nIdx +
fIsEnd =
isCommentEnd =
break
}
nIdx = nIdx +
}
if(nIdx > ichEnd)
{
break
}
}
//如果是//注释则停止查找
if(szLine[nIdx] == "/" && szLine[nIdx+] == "/")
{
break
}
if(szLine[nIdx] == chBeg)
{
nCheckCount = nCheckCount +
}
if(szLine[nIdx] == chEnd)
{
nCheckCount = nCheckCount -
if(nCheckCount == )
{
retVal.ich = nIdx
}
}
nIdx = nIdx +
}
retVal.iCount = nCheckCount
retVal.fIsEnd = fIsEnd
return retVal
} /*****************************************************************************
函 数 名 : InsertElse
功能描述 : 插入else语句
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月19日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro InsertElse()
{
hwnd = GetCurrentWnd()
sel = GetWndSel(hwnd)
hbuf = GetCurrentBuf()
ln = sel.lnFirst
if(sel.lnFirst == sel.lnLast && sel.ichFirst == sel.ichLim)
{
szLeft = CreateBlankString(sel.ichFirst)
InsBufLine(hbuf, ln,szLeft)
SetWndSel(hwnd,sel)
}
val = ExpandBraceLarge()
szLeft = val.szLeft
InsBufLine(hbuf, ln, "@szLeft@else")
if(sel.lnFirst == sel.lnLast && sel.ichFirst == sel.ichLim)
{
PutBufLine(hbuf,ln+, "@szLeft@ ")
SetBufIns (hbuf, ln+, strlen(szLeft)+)
return
}
SetBufIns (hbuf, ln, strlen(szLeft)+)
} /*****************************************************************************
函 数 名 : InsertCase
功能描述 : 插入case语句
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月19日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro InsertCase()
{
hwnd = GetCurrentWnd()
sel = GetWndSel(hwnd)
hbuf = GetCurrentBuf()
ln = sel.lnFirst
szLine = GetBufLine( hbuf, ln )
nLeft = GetLeftBlank(szLine)
szLeft = strmid(szLine,,nLeft);
InsBufLine(hbuf, ln, "@szLeft@" # "case # :")
InsBufLine(hbuf, ln + , "@szLeft@" # " " # "#")
InsBufLine(hbuf, ln + , "@szLeft@" # " " # "break;")
SearchForward()
} /*****************************************************************************
函 数 名 : InsertSwitch
功能描述 : 插入swich语句
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月19日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro InsertSwitch()
{
hwnd = GetCurrentWnd()
sel = GetWndSel(hwnd)
hbuf = GetCurrentBuf()
ln = sel.lnFirst
szLine = GetBufLine( hbuf, ln )
nLeft = GetLeftBlank(szLine)
szLeft = strmid(szLine,,nLeft);
InsBufLine(hbuf, ln, "@szLeft@switch ( # )")
InsBufLine(hbuf, ln + , "@szLeft@" # "{")
nSwitch = ask("请输入case的个数")
InsertMultiCaseProc(hbuf,szLeft,nSwitch)
SearchForward()
} /*****************************************************************************
函 数 名 : InsertMultiCaseProc
功能描述 : 插入多个case
输入参数 : hbuf
szLeft
nSwitch
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月19日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro InsertMultiCaseProc(hbuf,szLeft,nSwitch)
{
hwnd = GetCurrentWnd()
sel = GetWndSel(hwnd)
ln = sel.lnFirst nIdx =
if(nSwitch == )
{
hNewBuf = newbuf("clip")
if(hNewBuf == hNil)
return
SetCurrentBuf(hNewBuf)
PasteBufLine (hNewBuf, )
nLeftMax =
lnMax = GetBufLineCount(hNewBuf )
i =
fIsEnd =
while ( i < lnMax)
{
szLine = GetBufLine(hNewBuf , i)
//先去掉代码中注释的内容
RetVal = SkipCommentFromString(szLine,fIsEnd)
szLine = RetVal.szContent
fIsEnd = RetVal.fIsEnd
// nLeft = GetLeftBlank(szLine)
//从剪贴板中取得case值
szLine = GetSwitchVar(szLine)
if(strlen(szLine) != )
{
ln = ln +
InsBufLine(hbuf, ln - , "@szLeft@ " # "case @szLine@:")
InsBufLine(hbuf, ln , "@szLeft@ " # " " # "#")
InsBufLine(hbuf, ln + , "@szLeft@ " # " " # "break;")
}
i = i +
}
closebuf(hNewBuf)
}
else
{
while(nIdx < nSwitch)
{
ln = ln +
InsBufLine(hbuf, ln - , "@szLeft@ " # "case # :")
InsBufLine(hbuf, ln , "@szLeft@ " # " " # "#")
InsBufLine(hbuf, ln + , "@szLeft@ " # " " # "break;")
nIdx = nIdx +
}
}
InsBufLine(hbuf, ln + , "@szLeft@ " # "default:")
InsBufLine(hbuf, ln + , "@szLeft@ " # " " # "#")
InsBufLine(hbuf, ln + , "@szLeft@" # "}")
SetWndSel(hwnd, sel)
SearchForward()
} /*****************************************************************************
函 数 名 : GetSwitchVar
功能描述 : 从枚举、宏定义取得case值
输入参数 : szLine
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月19日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro GetSwitchVar(szLine)
{
if( (szLine == "{") || (szLine == "}") )
{
return ""
}
ret = strstr(szLine,"#define" )
if(ret != 0xffffffff)
{
szLine = strmid(szLine,ret + ,strlen(szLine))
}
szLine = TrimLeft(szLine)
nIdx =
nLen = strlen(szLine)
while( nIdx < nLen)
{
if((szLine[nIdx] == " ") || (szLine[nIdx] == ",") || (szLine[nIdx] == "="))
{
szLine = strmid(szLine,,nIdx)
return szLine
}
nIdx = nIdx +
}
return szLine
} /*
macro SkipControlCharFromString(szLine)
{
nLen = strlen(szLine)
nIdx = 0
newStr = ""
while(nIdx < nLen - 1)
{
if(szLine[nIdx] == "\t")
{
newStr = cat(newStr," ")
}
else if(szLine[nIdx] < " ")
{
newStr = cat(newStr," ")
}
else
{
newStr = cat(newStr," ")
}
}
}
*/
/*****************************************************************************
函 数 名 : SkipCommentFromString
功能描述 : 去掉注释的内容,将注释内容清为空格
输入参数 : szLine 输入行的内容
isCommentEnd 是否但前行的开始已经是注释结束了
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月19日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro SkipCommentFromString(szLine,isCommentEnd)
{
RetVal = ""
fIsEnd =
nLen = strlen(szLine)
nIdx =
while(nIdx < nLen )
{
//如果当前行开始还是被注释,或遇到了注释开始的变标记,注释内容改为空格
if( (isCommentEnd == ) || (szLine[nIdx] == "/" && szLine[nIdx+] == "*"))
{
fIsEnd =
while(nIdx < nLen )
{
if(szLine[nIdx] == "*" && szLine[nIdx+] == "/")
{
szLine[nIdx+] = " "
szLine[nIdx] = " "
nIdx = nIdx +
fIsEnd =
isCommentEnd =
break
}
szLine[nIdx] = " " //如果是倒数第二个则最后一个也肯定是在注释内
// if(nIdx == nLen -2 )
// {
// szLine[nIdx + 1] = " "
// }
nIdx = nIdx +
} //如果已经到了行尾终止搜索
if(nIdx == nLen)
{
break
}
} //如果遇到的是//来注释的说明后面都为注释
if(szLine[nIdx] == "/" && szLine[nIdx+] == "/")
{
szLine = strmid(szLine,,nIdx)
break
}
nIdx = nIdx +
}
RetVal.szContent = szLine;
RetVal.fIsEnd = fIsEnd
return RetVal
} /*****************************************************************************
函 数 名 : InsertDo
功能描述 : 插入Do语句
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月19日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro InsertDo()
{
hwnd = GetCurrentWnd()
sel = GetWndSel(hwnd)
hbuf = GetCurrentBuf()
ln = sel.lnFirst
if(sel.lnFirst == sel.lnLast && sel.ichFirst == sel.ichLim)
{
szLeft = CreateBlankString(sel.ichFirst)
InsBufLine(hbuf, ln,szLeft)
SetWndSel(hwnd,sel)
}
val = ExpandBraceLarge()
szLeft = val.szLeft
if(sel.lnFirst == sel.lnLast && sel.ichFirst == sel.ichLim)
{
PutBufLine(hbuf,ln+, "@szLeft@ #")
}
PutBufLine(hbuf, sel.lnLast + val.nLineCount, "@szLeft@}while ( # );")
// SetBufIns (hbuf, sel.lnLast + val.nLineCount, strlen(szLeft)+8)
InsBufLine(hbuf, ln, "@szLeft@do")
SearchForward()
} /*****************************************************************************
函 数 名 : InsertWhile
功能描述 : 插入While语句
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月19日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro InsertWhile()
{
hwnd = GetCurrentWnd()
sel = GetWndSel(hwnd)
hbuf = GetCurrentBuf()
ln = sel.lnFirst
if(sel.lnFirst == sel.lnLast && sel.ichFirst == sel.ichLim)
{
szLeft = CreateBlankString(sel.ichFirst)
InsBufLine(hbuf, ln,szLeft)
SetWndSel(hwnd,sel)
}
val = ExpandBraceLarge()
szLeft = val.szLeft
InsBufLine(hbuf, ln, "@szLeft@while ( # )")
if(sel.lnFirst == sel.lnLast && sel.ichFirst == sel.ichLim)
{
PutBufLine(hbuf,ln+, "@szLeft@ #")
}
SetBufIns (hbuf, ln, strlen(szLeft)+)
SearchForward()
} /*****************************************************************************
函 数 名 : InsertFor
功能描述 : 插入for语句
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月19日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro InsertFor()
{
hwnd = GetCurrentWnd()
sel = GetWndSel(hwnd)
hbuf = GetCurrentBuf()
ln = sel.lnFirst
if(sel.lnFirst == sel.lnLast && sel.ichFirst == sel.ichLim)
{
szLeft = CreateBlankString(sel.ichFirst)
InsBufLine(hbuf, ln,szLeft)
SetWndSel(hwnd,sel)
}
val = ExpandBraceLarge()
szLeft = val.szLeft
InsBufLine(hbuf, ln,"@szLeft@for ( # ; # ; # )")
if(sel.lnFirst == sel.lnLast && sel.ichFirst == sel.ichLim)
{
PutBufLine(hbuf,ln+, "@szLeft@ #")
}
sel.lnFirst = ln
sel.lnLast = ln
sel.ichFirst =
sel.ichLim =
SetWndSel(hwnd, sel)
SearchForward()
szVar = ask("请输入循环变量")
PutBufLine(hbuf,ln, "@szLeft@for ( @szVar@ = # ; @szVar@ # ; @szVar@++ )")
SearchForward()
} /*****************************************************************************
函 数 名 : InsertIf
功能描述 : 插入If语句
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月19日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro InsertIf()
{
hwnd = GetCurrentWnd()
sel = GetWndSel(hwnd)
hbuf = GetCurrentBuf()
ln = sel.lnFirst
if(sel.lnFirst == sel.lnLast && sel.ichFirst == sel.ichLim)
{
szLeft = CreateBlankString(sel.ichFirst)
InsBufLine(hbuf, ln,szLeft)
SetWndSel(hwnd,sel)
}
val = ExpandBraceLarge()
szLeft = val.szLeft
InsBufLine(hbuf, ln, "@szLeft@if ( # )")
if(sel.lnFirst == sel.lnLast && sel.ichFirst == sel.ichLim)
{
PutBufLine(hbuf,ln+, "@szLeft@ #")
}
// SetBufIns (hbuf, ln, strlen(szLeft)+4)
SearchForward()
} /*****************************************************************************
函 数 名 : MergeString
功能描述 : 将剪贴板中的语句合并成一行
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月24日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro MergeString()
{
hbuf = newbuf("clip")
if(hbuf == hNil)
return
SetCurrentBuf(hbuf)
PasteBufLine (hbuf, ) //如果剪贴板中没有内容,则返回
lnMax = GetBufLineCount(hbuf )
if( lnMax == )
{
closebuf(hbuf)
return ""
}
lnLast =
if(lnMax > )
{
lnLast = lnMax -
i = lnMax -
}
while ( i > )
{
szLine = GetBufLine(hbuf , i-)
szLine = TrimLeft(szLine)
nLen = strlen(szLine)
if(szLine[nLen - ] == "-")
{
szLine = strmid(szLine,,nLen - )
}
nLen = strlen(szLine)
if( (szLine[nLen - ] != " ") && (AsciiFromChar (szLine[nLen - ]) <= ))
{
szLine = cat(szLine," ")
}
SetBufIns (hbuf, lnLast, )
SetBufSelText(hbuf,szLine)
i = i -
}
szLine = GetBufLine(hbuf,lnLast)
closebuf(hbuf)
return szLine
} /*****************************************************************************
函 数 名 : ClearPrombleNo
功能描述 : 清除问题单号
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月19日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro ClearPrombleNo()
{
SetReg ("PNO", "")
} /*****************************************************************************
函 数 名 : AddPromblemNo
功能描述 : 添加问题单号
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月19日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro AddPromblemNo()
{
szQuestion = ASK("Please Input problem number ");
if(szQuestion == "#")
{
szQuestion = ""
SetReg ("PNO", "")
}
else
{
SetReg ("PNO", szQuestion)
}
return szQuestion
} /*
this macro convet selected C++ coment block to C comment block
for example:
line " // aaaaa "
convert to /* aaaaa */
*/
/*macro ComentCPPtoC()
{
hwnd = GetCurrentWnd()
lnFirst = GetWndSelLnFirst( hwnd )
lnLast = GetWndSelLnLast( hwnd ) lnCurrent = lnFirst
fIsEnd = 1
while ( lnCurrent <= lnLast )
{
fIsEnd = CmtCvtLine( lnCurrent,fIsEnd )
lnCurrent = lnCurrent + 1;
}
}*/ /*****************************************************************************
函 数 名 : ComentCPPtoC
功能描述 : 转换C++注释为C注释
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年7月02日
作 者 : 张强
修改内容 : 新生成函数,支持块注释 *****************************************************************************/
macro ComentCPPtoC()
{
hwnd = GetCurrentWnd()
hbuf = GetCurrentBuf()
lnFirst = GetWndSelLnFirst( hwnd )
lnCurrent = lnFirst
lnLast = GetWndSelLnLast( hwnd )
ch_comment = CharFromAscii()
isCommentEnd =
isCommentContinue =
while ( lnCurrent <= lnLast )
{ ich =
szLine = GetBufLine(hbuf,lnCurrent)
ilen = strlen(szLine)
while ( ich < ilen )
{
if( (szLine[ich] != " ") && (szLine[ich] != "\t") )
{
break
}
ich = ich +
}
/*如果是空行,跳过该行*/
if(ich == ilen)
{
lnCurrent = lnCurrent +
szOldLine = szLine
continue
} /*如果该行只有一个字符*/
if(ich > ilen - )
{
if( isCommentContinue == )
{
szOldLine = cat(szOldLine," */")
PutBufLine(hbuf,lnCurrent-,szOldLine)
isCommentContinue =
}
lnCurrent = lnCurrent +
szOldLine = szLine
continue
}
if( isCommentEnd == )
{
/*如果不是在注释区内*/
if(( szLine[ich]==ch_comment ) && (szLine[ich+]==ch_comment))
{ /* 去掉中间嵌套的注释 */
nIdx = ich +
while ( nIdx < ilen - )
{
if( (( szLine[nIdx] == "/" ) && (szLine[nIdx+] == "*")||
( szLine[nIdx] == "*" ) && (szLine[nIdx+] == "/") )
{
szLine[nIdx] = " "
szLine[nIdx+] = " "
}
nIdx = nIdx +
} if( isCommentContinue == )
{
/* 如果是连续的注释*/
szLine[ich] = " "
szLine[ich+] = " "
}
else
{
/*如果不是连续的注释则是新注释的开始*/
szLine[ich] = "/"
szLine[ich+] = "*"
}
if ( lnCurrent == lnLast )
{
/*如果是最后一行则在行尾添加结束注释符*/
szLine = cat(szLine," */")
isCommentContinue =
}
/*更新该行*/
PutBufLine(hbuf,lnCurrent,szLine)
isCommentContinue =
szOldLine = szLine
lnCurrent = lnCurrent +
continue
}
else
{
/*如果该行的起始不是//注释*/
if( isCommentContinue == )
{
szOldLine = cat(szOldLine," */")
PutBufLine(hbuf,lnCurrent-,szOldLine)
isCommentContinue =
}
}
}
while ( ich < ilen - )
{
//如果是/*注释区,跳过该段
if( (isCommentEnd == ) || (szLine[ich] == "/" && szLine[ich+] == "*"))
{
isCommentEnd =
while(ich < ilen - )
{
if(szLine[ich] == "*" && szLine[ich+] == "/")
{
ich = ich +
isCommentEnd =
break
}
ich = ich +
}
if(ich >= ilen - )
{
break
}
} if(( szLine[ich]==ch_comment ) && (szLine[ich+]==ch_comment))
{
/* 如果是//注释*/
isCommentContinue =
nIdx = ich
//去掉期间的/* 和 */注释符以免出现注释嵌套错误
while ( nIdx < ilen - )
{
if( (( szLine[nIdx] == "/" ) && (szLine[nIdx+] == "*")||
( szLine[nIdx] == "*" ) && (szLine[nIdx+] == "/") )
{
szLine[nIdx] = " "
szLine[nIdx+] = " "
}
nIdx = nIdx +
}
szLine[ich+] = "*"
if( lnCurrent == lnLast )
{
szLine = cat(szLine," */")
}
PutBufLine(hbuf,lnCurrent,szLine)
break
}
ich = ich +
}
szOldLine = szLine
lnCurrent = lnCurrent +
}
} macro ComentLine()
{
hwnd = GetCurrentWnd()
hbuf = GetCurrentBuf()
lnFirst = GetWndSelLnFirst( hwnd )
lnCurrent = lnFirst
lnLast = GetWndSelLnLast( hwnd )
lnOld =
while ( lnCurrent <= lnLast )
{
szLine = GetBufLine(hbuf,lnCurrent)
DelBufLine(hbuf,lnCurrent)
nLeft = GetLeftBlank(szLine)
szLeft = strmid(szLine,,nLeft);
szLine = TrimString(szLine)
ilen = strlen(szLine)
if(iLen == )
{
continue
}
nIdx =
//去掉期间的/* 和 */注释符以免出现注释嵌套错误
while ( nIdx < ilen - )
{
if( (( szLine[nIdx] == "/" ) && (szLine[nIdx+] == "*")||
( szLine[nIdx] == "*" ) && (szLine[nIdx+] == "/") )
{
szLine[nIdx] = " "
szLine[nIdx+] = " "
}
nIdx = nIdx +
}
szLine = cat("/* ",szLine)
lnOld = lnCurrent
lnCurrent = CommentContent(hbuf,lnCurrent,szLeft,szLine,)
lnLast = lnCurrent - lnOld + lnLast
lnCurrent = lnCurrent +
}
} /*****************************************************************************
函 数 名 : CmtCvtLine
功能描述 : 将//转换成/*注释
输入参数 : lnCurrent
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 :
作 者 :
修改内容 : 2.日 期 : 2008年7月02日
作 者 : 张强
修改内容 : 修改了注释嵌套所产生的问题 *****************************************************************************/
macro CmtCvtLine(lnCurrent, isCommentEnd)
{
hbuf = GetCurrentBuf()
szLine = GetBufLine(hbuf,lnCurrent)
ch_comment = CharFromAscii()
ich =
ilen = strlen(szLine) fIsEnd =
iIsComment = ; while ( ich < ilen - )
{
//如果是/*注释区,跳过该段
if( (isCommentEnd == ) || (szLine[ich] == "/" && szLine[ich+] == "*"))
{
fIsEnd =
while(ich < ilen - )
{
if(szLine[ich] == "*" && szLine[ich+] == "/")
{
ich = ich +
fIsEnd =
isCommentEnd =
break
}
ich = ich +
}
if(ich >= ilen - )
{
break
}
}
if(( szLine[ich]==ch_comment ) && (szLine[ich+]==ch_comment))
{
nIdx = ich
while ( nIdx < ilen - )
{
if( (( szLine[nIdx] == "/" ) && (szLine[nIdx+] == "*")||
( szLine[nIdx] == "*" ) && (szLine[nIdx+] == "/") )
{
szLine[nIdx] = " "
szLine[nIdx+] = " "
}
nIdx = nIdx +
}
szLine[ich+] = "*"
szLine = cat(szLine," */")
DelBufLine(hbuf,lnCurrent)
InsBufLine(hbuf,lnCurrent,szLine)
return fIsEnd
}
ich = ich +
}
return fIsEnd
} /*****************************************************************************
函 数 名 : GetFileNameExt
功能描述 : 得到文件扩展名
输入参数 : sz
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月19日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro GetFileNameExt(sz)
{
i =
j =
szName = sz
iLen = strlen(sz)
if(iLen == )
return ""
while( i <= iLen)
{
if(sz[iLen-i] == ".")
{
j = iLen-i
szExt = strmid(sz,j + ,iLen)
return szExt
}
i = i +
}
return ""
} /*****************************************************************************
函 数 名 : GetFileNameNoExt
功能描述 : 得到函数名没有扩展名
输入参数 : sz
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月19日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro GetFileNameNoExt(sz)
{
i =
szName = sz
iLen = strlen(sz)
j = iLen
if(iLen == )
return ""
while( i <= iLen)
{
if(sz[iLen-i] == ".")
{
j = iLen-i
}
if( sz[iLen-i] == "\\" )
{
szName = strmid(sz,iLen-i+,j)
return szName
}
i = i +
}
szName = strmid(sz,,j)
return szName
} /*****************************************************************************
函 数 名 : GetFileName
功能描述 : 得到带扩展名的文件名
输入参数 : sz
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月19日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro GetFileName(sz)
{
i =
szName = sz
iLen = strlen(sz)
if(iLen == )
return ""
while( i <= iLen)
{
if(sz[iLen-i] == "\\")
{
szName = strmid(sz,iLen-i+,iLen)
break
}
i = i +
}
return szName
} /*****************************************************************************
函 数 名 : InsIfdef
功能描述 : 插入#ifdef语句
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月19日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro InsIfdef()
{
sz = Ask("Enter #ifdef condition:")
if (sz != "")
IfdefStr(sz);
} /*****************************************************************************
函 数 名 : InsIfndef
功能描述 : #ifndef语句对插入的入口调用宏
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月24日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro InsIfndef()
{
sz = Ask("Enter #ifndef condition:")
if (sz != "")
IfndefStr(sz);
} /*****************************************************************************
函 数 名 : InsertCPP
功能描述 : 在buf中插入C类型定义
输入参数 : hbuf
ln
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月24日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro InsertCPP(hbuf,ln)
{
InsBufLine(hbuf, ln, "")
InsBufLine(hbuf, ln, "#endif /* __cplusplus */")
InsBufLine(hbuf, ln, "#endif")
InsBufLine(hbuf, ln, "extern \"C\"{")
InsBufLine(hbuf, ln, "#if __cplusplus")
InsBufLine(hbuf, ln, "#ifdef __cplusplus")
InsBufLine(hbuf, ln, "") iTotalLn = GetBufLineCount (hbuf)
InsBufLine(hbuf, iTotalLn, "")
InsBufLine(hbuf, iTotalLn, "#endif /* __cplusplus */")
InsBufLine(hbuf, iTotalLn, "#endif")
InsBufLine(hbuf, iTotalLn, "}")
InsBufLine(hbuf, iTotalLn, "#if __cplusplus")
InsBufLine(hbuf, iTotalLn, "#ifdef __cplusplus")
InsBufLine(hbuf, iTotalLn, "")
} /*****************************************************************************
函 数 名 : ReviseCommentProc
功能描述 : 问题单修改命令处理
输入参数 : hbuf
ln
szCmd
szMyName
szLine1
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月24日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro ReviseCommentProc(hbuf,ln,szCmd,szMyName,szLine1)
{
if (szCmd == "ap")
{
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
} DelBufLine(hbuf, ln)
szQuestion = AddPromblemNo()
InsBufLine(hbuf, ln, "@szLine1@/* 问 题 单: @szQuestion@ 修改人:@szMyName@, 时间:@sz@-@szMonth@-@szDay@ ");
szContent = Ask("修改原因")
szLeft = cat(szLine1," 修改原因: ");
if(strlen(szLeft) > )
{
Msg("The right margine is small, Please use a new line")
stop
}
ln = CommentContent(hbuf,ln + ,szLeft,szContent,)
return
}
else if (szCmd == "ab")
{
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
} DelBufLine(hbuf, ln)
szQuestion = GetReg ("PNO")
if(strlen(szQuestion)>)
{
InsBufLine(hbuf, ln, "@szLine1@/* add begin by @szMyName@, @sz@-@szMonth@-@szDay@, Mantis号:@szQuestion@ */");
}
else
{
InsBufLine(hbuf, ln, "@szLine1@/* add begin by @szMyName@, @sz@-@szMonth@-@szDay@ */");
}
return
}
else if (szCmd == "ae")
{
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
} DelBufLine(hbuf, ln)
InsBufLine(hbuf, ln, "@szLine1@/* add end by @szMyName@, @sz@-@szMonth@-@szDay@ */");
return
}
else if (szCmd == "db")
{
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
} DelBufLine(hbuf, ln)
szQuestion = GetReg ("PNO")
if(strlen(szQuestion) > )
{
InsBufLine(hbuf, ln, "@szLine1@/* delete begin by @szMyName@, @sz@-@szMonth@-@szDay@, Mantis号:@szQuestion@ */");
}
else
{
InsBufLine(hbuf, ln, "@szLine1@/* delete begin by @szMyName@, @sz@-@szMonth@-@szDay@ */");
} return
}
else if (szCmd == "de")
{
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
} DelBufLine(hbuf, ln + )
InsBufLine(hbuf, ln, "@szLine1@/* delete end by @szMyName@, @sz@-@szMonth@-@szDay@ */");
return
}
else if (szCmd == "mb")
{
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
} DelBufLine(hbuf, ln)
szQuestion = GetReg ("PNO")
if(strlen(szQuestion) > )
{
InsBufLine(hbuf, ln, "@szLine1@/* modify begin by @szMyName@, @sz@-@szMonth@-@szDay@, Mantis号:@szQuestion@ */");
}
else
{
InsBufLine(hbuf, ln, "@szLine1@/* modify begin by @szMyName@, @sz@-@szMonth@-@szDay@ */");
}
return
}
else if (szCmd == "me")
{
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
} DelBufLine(hbuf, ln)
InsBufLine(hbuf, ln, "@szLine1@/* modify end by @szMyName@, @sz@-@szMonth@-@szDay@ */");
return
}
} /*****************************************************************************
函 数 名 : InsertReviseAdd
功能描述 : 插入添加修改注释对
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月19日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro InsertReviseAdd()
{
hwnd = GetCurrentWnd()
sel = GetWndSel(hwnd)
hbuf = GetCurrentBuf()
lnMax = GetBufLineCount(hbuf)
language = getreg(LANGUAGE)
if(language != )
{
language =
}
szMyName = getreg(MYNAME)
if(strlen( szMyName ) == )
{
szMyName = Ask("Enter your name:")
setreg(MYNAME, szMyName)
}
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
} if(sel.lnFirst == sel.lnLast && sel.ichFirst == sel.ichLim)
{
szLeft = CreateBlankString(sel.ichFirst)
}
else
{
szLine = GetBufLine( hbuf, sel.lnFirst )
nLeft = GetLeftBlank(szLine)
szLeft = strmid(szLine,,nLeft);
}
szQuestion = GetReg ("PNO")
if(strlen(szQuestion)>)
{
InsBufLine(hbuf, sel.lnFirst, "@szLeft@/* add begin by @szMyName@, @sz@-@szMonth@-@szDay@, Mantis号:@szQuestion@ */");
}
else
{
InsBufLine(hbuf, sel.lnFirst, "@szLeft@/* add begin by @szMyName@, @sz@-@szMonth@-@szDay@ */";
} if(sel.lnLast < lnMax - )
{
InsBufLine(hbuf, sel.lnLast + , "@szLeft@/* add end by @szMyName@, @sz@-@szMonth@-@szDay@ */");
}
else
{
AppendBufLine(hbuf, "@szLeft@/* add end by @szMyName@, @sz@-@szMonth@-@szDay@ */");
}
SetBufIns(hbuf,sel.lnFirst + ,strlen(szLeft))
} /*****************************************************************************
函 数 名 : InsertReviseDel
功能描述 : 插入删除修改注释对
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月19日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro InsertReviseDel()
{
hwnd = GetCurrentWnd()
sel = GetWndSel(hwnd)
hbuf = GetCurrentBuf()
lnMax = GetBufLineCount(hbuf)
language = getreg(LANGUAGE)
if(language != )
{
language =
}
szMyName = getreg(MYNAME)
if(strlen( szMyName ) == )
{
szMyName = Ask("Enter your name:")
setreg(MYNAME, szMyName)
}
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
}
if(sel.lnFirst == sel.lnLast && sel.ichFirst == sel.ichLim)
{
szLeft = CreateBlankString(sel.ichFirst)
}
else
{
szLine = GetBufLine( hbuf, sel.lnFirst )
nLeft = GetLeftBlank(szLine)
szLeft = strmid(szLine,,nLeft);
}
szQuestion = GetReg ("PNO")
if(strlen(szQuestion)>)
{
InsBufLine(hbuf, sel.lnFirst, "@szLeft@/* delete begin by @szMyName@, @sz@-@szMonth@-@szDay@, Mantis号:@szQuestion@*/");
}
else
{
InsBufLine(hbuf, sel.lnFirst, "@szLeft@/* delete begin by @szMyName@, @sz@-@szMonth@-@szDay@ */");
} if(sel.lnLast < lnMax - )
{
InsBufLine(hbuf, sel.lnLast + , "@szLeft@/* delete end by @szMyName@, @sz@-@szMonth@-@szDay@ */");
}
else
{
AppendBufLine(hbuf, "@szLeft@/* delete end by @szMyName@, @sz@-@szMonth@-@szDay@ */");
}
SetBufIns(hbuf,sel.lnFirst + ,strlen(szLeft))
} /*****************************************************************************
函 数 名 : InsertReviseMod
功能描述 : 插入修改注释对
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月19日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro InsertReviseMod()
{
hwnd = GetCurrentWnd()
sel = GetWndSel(hwnd)
hbuf = GetCurrentBuf()
lnMax = GetBufLineCount(hbuf)
language = getreg(LANGUAGE)
if(language != )
{
language =
}
szMyName = getreg(MYNAME)
if(strlen( szMyName ) == )
{
szMyName = Ask("Enter your name:")
setreg(MYNAME, szMyName)
}
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
}
//得到光标所选的字符左侧的空白部分,保存在szLeft中,目的是保证缩进
if(sel.lnFirst == sel.lnLast && sel.ichFirst == sel.ichLim)
{
szLeft = CreateBlankString(sel.ichFirst)
}
else
{
szLine = GetBufLine( hbuf, sel.lnFirst )
nLeft = GetLeftBlank(szLine)
szLeft = strmid(szLine,,nLeft);
}
szQuestion = GetReg ("PNO")
if(strlen(szQuestion)>)
{
InsBufLine(hbuf, sel.lnFirst, "@szLeft@/* modify begin by @szMyName@, @sz@-@szMonth@-@szDay@, Mantis号:@szQuestion@ */");
}
else
{
InsBufLine(hbuf, sel.lnFirst, "@szLeft@/* modify begin by @szMyName@, @sz@-@szMonth@-@szDay@ */");
} if(sel.lnLast < lnMax - )
{
InsBufLine(hbuf, sel.lnLast + , "@szLeft@/* modify end by @szMyName@, @sz@-@szMonth@-@szDay@ */");
}
else
{
AppendBufLine(hbuf, "@szLeft@/* modif end by @szMyName@, @sz@-@szMonth@-@szDay@ */");
}
SetBufIns(hbuf,sel.lnFirst + ,strlen(szLeft))
} // Wrap ifdef <sz> .. endif around the current selection
macro IfdefStr(sz)
{
hwnd = GetCurrentWnd()
lnFirst = GetWndSelLnFirst(hwnd)
lnLast = GetWndSelLnLast(hwnd)
hbuf = GetCurrentBuf()
lnMax = GetBufLineCount(hbuf)
if(lnMax != )
{
szLine = GetBufLine( hbuf, lnFirst )
}
nLeft = GetLeftBlank(szLine)
szLeft = strmid(szLine,,nLeft); hbuf = GetCurrentBuf()
if(lnLast + < lnMax)
{
InsBufLine(hbuf, lnLast+, "@szLeft@#endif /* @sz@ */")
}
else if(lnLast + == lnMax)
{
AppendBufLine(hbuf, "@szLeft@#endif /* @sz@ */")
}
else
{
AppendBufLine(hbuf, "")
AppendBufLine(hbuf, "@szLeft@#endif /* @sz@ */")
}
InsBufLine(hbuf, lnFirst, "@szLeft@#ifdef @sz@")
SetBufIns(hbuf,lnFirst + ,strlen(szLeft))
} /*****************************************************************************
函 数 名 : IfndefStr
功能描述 : 插入#ifndef语句对
输入参数 : sz
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月24日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro IfndefStr(sz)
{
hwnd = GetCurrentWnd()
lnFirst = GetWndSelLnFirst(hwnd)
lnLast = GetWndSelLnLast(hwnd)
hbuf = GetCurrentBuf()
lnMax = GetBufLineCount(hbuf)
if(lnMax != )
{
szLine = GetBufLine( hbuf, lnFirst )
}
nLeft = GetLeftBlank(szLine)
szLeft = strmid(szLine,,nLeft); hbuf = GetCurrentBuf()
if(lnLast + < lnMax)
{
InsBufLine(hbuf, lnLast+, "@szLeft@#endif /* @sz@ */")
}
else if(lnLast + == lnMax)
{
AppendBufLine(hbuf, "@szLeft@#endif /* @sz@ */")
}
else
{
AppendBufLine(hbuf, "")
AppendBufLine(hbuf, "@szLeft@#endif /* @sz@ */")
}
InsBufLine(hbuf, lnFirst, "@szLeft@#ifndef @sz@")
SetBufIns(hbuf,lnFirst + ,strlen(szLeft))
} /*****************************************************************************
函 数 名 : InsertPredefIf
功能描述 : 插入#if语句对的入口调用宏
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月24日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro InsertPredefIf()
{
sz = Ask("Enter #if condition:")
PredefIfStr(sz)
} /*****************************************************************************
函 数 名 : PredefIfStr
功能描述 : 在选择行前后插入#if语句对
输入参数 : sz
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月24日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro PredefIfStr(sz)
{
hwnd = GetCurrentWnd()
lnFirst = GetWndSelLnFirst(hwnd)
lnLast = GetWndSelLnLast(hwnd)
hbuf = GetCurrentBuf()
lnMax = GetBufLineCount(hbuf)
if(lnMax != )
{
szLine = GetBufLine( hbuf, lnFirst )
}
nLeft = GetLeftBlank(szLine)
szLeft = strmid(szLine,,nLeft); hbuf = GetCurrentBuf()
if(lnLast + < lnMax)
{
InsBufLine(hbuf, lnLast+, "@szLeft@#endif /* #if @sz@ */")
}
else if(lnLast + == lnMax)
{
AppendBufLine(hbuf, "@szLeft@#endif /* #if @sz@ */")
}
else
{
AppendBufLine(hbuf, "")
AppendBufLine(hbuf, "@szLeft@#endif /* #if @sz@ */")
}
InsBufLine(hbuf, lnFirst, "@szLeft@#if @sz@")
SetBufIns(hbuf,lnFirst + ,strlen(szLeft))
} /*****************************************************************************
函 数 名 : HeadIfdefStr
功能描述 : 在选择行前后插入#ifdef语句对
输入参数 : sz
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月24日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro HeadIfdefStr(sz)
{
hwnd = GetCurrentWnd()
lnFirst = GetWndSelLnFirst(hwnd)
hbuf = GetCurrentBuf()
InsBufLine(hbuf, lnFirst, "")
InsBufLine(hbuf, lnFirst, "#define @sz@")
InsBufLine(hbuf, lnFirst, "#ifndef @sz@")
iTotalLn = GetBufLineCount (hbuf)
InsBufLine(hbuf, iTotalLn, "#endif /* @sz@ */")
InsBufLine(hbuf, iTotalLn, "")
} /*****************************************************************************
函 数 名 : GetSysTime
功能描述 : 取得系统时间,只在V2.1时有用
输入参数 : a
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月24日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro GetSysTime(a)
{
//从sidate取得时间
RunCmd ("sidate")
SysTime=""
SysTime.Year=getreg(Year)
if(strlen(SysTime.Year)==)
{
setreg(Year,"")
setreg(Month,"")
setreg(Day,"")
SysTime.Year=""
SysTime.month=""
SysTime.day=""
SysTime.Date="2008年05月20日"
}
else
{
SysTime.Month=getreg(Month)
SysTime.Day=getreg(Day)
SysTime.Date=getreg(Date)
/* SysTime.Date=cat(SysTime.Year,"年")
SysTime.Date=cat(SysTime.Date,SysTime.Month)
SysTime.Date=cat(SysTime.Date,"月")
SysTime.Date=cat(SysTime.Date,SysTime.Day)
SysTime.Date=cat(SysTime.Date,"日")*/
}
return SysTime
} /*****************************************************************************
函 数 名 : HeaderFileCreate
功能描述 : 生成头文件
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月19日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro HeaderFileCreate()
{
hwnd = GetCurrentWnd()
if (hwnd == )
stop
sel = GetWndSel(hwnd)
hbuf = GetWndBuf(hwnd)
language = getreg(LANGUAGE)
if(language != )
{
language =
}
szMyName = getreg(MYNAME)
if(strlen( szMyName ) == )
{
szMyName = Ask("Enter your name:")
setreg(MYNAME, szMyName)
} CreateFunctionDef(hbuf,szMyName,language)
} /*****************************************************************************
函 数 名 : FunctionHeaderCreate
功能描述 : 生成函数头
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月19日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro FunctionHeaderCreate()
{
hwnd = GetCurrentWnd()
if (hwnd == )
stop
sel = GetWndSel(hwnd)
ln = sel.lnFirst
hbuf = GetWndBuf(hwnd)
language = getreg(LANGUAGE)
if(language != )
{
language =
}
szMyName = getreg(MYNAME)
if(strlen( szMyName ) == )
{
szMyName = Ask("Enter your name:")
setreg(MYNAME, szMyName)
}
nVer = GetVersion()
lnMax = GetBufLineCount(hbuf)
if(ln != lnMax)
{
szNextLine = GetBufLine(hbuf,ln)
if( (strstr(szNextLine,"(") != 0xffffffff) || (nVer != ))
{
symbol = GetCurSymbol()
if(strlen(symbol) != )
{
if(language == )
{
FuncHeadCommentCN(hbuf, ln, symbol, szMyName,)
}
else
{
FuncHeadCommentEN(hbuf, ln, symbol, szMyName,)
}
return
}
}
}
if(language == )
{
szFuncName = Ask("请输入函数名称:")
FuncHeadCommentCN(hbuf, ln, szFuncName, szMyName, )
}
else
{
szFuncName = Ask("Please input function name")
FuncHeadCommentEN(hbuf, ln, szFuncName, szMyName, ) }
} /*****************************************************************************
函 数 名 : GetVersion
功能描述 : 得到Si的版本号
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月19日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro GetVersion()
{
Record = GetProgramInfo ()
return Record.versionMajor
} /*****************************************************************************
函 数 名 : GetProgramInfo
功能描述 : 获得程序信息,V2.1才用
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月19日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro GetProgramInfo ()
{
Record = ""
Record.versionMajor =
Record.versionMinor =
return Record
} /*****************************************************************************
函 数 名 : FileHeaderCreate
功能描述 : 生成文件头
输出参数 : 无
返 回 值 :
调用函数 :
被调函数 : 修改历史 :
1.日 期 : 2008年6月19日
作 者 : 张强
修改内容 : 新生成函数 *****************************************************************************/
macro FileHeaderCreate()
{
hwnd = GetCurrentWnd()
if (hwnd == )
stop
ln =
hbuf = GetWndBuf(hwnd)
language = getreg(LANGUAGE)
if(language != )
{
language =
}
szMyName = getreg(MYNAME)
if(strlen( szMyName ) == )
{
szMyName = Ask("Enter your name:")
setreg(MYNAME, szMyName)
}
SetBufIns (hbuf, , )
if(language == )
{
InsertFileHeaderCN( hbuf,ln, szMyName,"" )
}
else
{
InsertFileHeaderEN( hbuf,ln, szMyName,"" )
}
}

代码非原创,如有侵权,请联系删除

SourceInsight宏插件2(非常好用,强力推荐)的更多相关文章

  1. SourceInsight宏插件1(非常好用,强力推荐)

    对于一直使用sourceinsight编辑C/C++代码的工程师们,sourceinsight是一个非常好用的编辑工具可以任意定位,跳转,回退,本人一直使用该工具做C/C++开发,sourceinsi ...

  2. SourceInsight宏插件3(非常好用,强力推荐)

    openfolder.em源码:(链接:https://pan.baidu.com/s/1draaimWzCHZ3vLxL--lfiQ  提取码:zyq4) //使用资源管理器打开当前文件所在文件夹, ...

  3. 利用sourceinsight宏(Quicker.em)提高编码效率和质量

    利用sourceinsight宏(Quicker.em)提高编码效率和质量Marco是sourceinsight软件一个强大的功能,用户可以通过编写宏来实现自定义功能.这里有个比较流行的宏文件quic ...

  4. 非常适用的Sourceinsight插件,提高效率【强力推荐】

    转自:http://www.cnblogs.com/heiyue/p/6225975.html 一直使用sourceinsight编辑C/C++代码,sourceinsight是一个非常好用的编辑工具 ...

  5. quicker+.em SourceInsight 宏加强版制作

    这两天苦于新建的文件每次都要手动添加文件头,新建的函数每次都要手动添加函数说明,连.h也要手动生成.于是乎,上网搜了搜,发现了lushengwen写的一个神器:quicker.em .好家伙,有了这个 ...

  6. 我的Android进阶之旅------>经典的大牛博客推荐(排名不分先后)!!

    本文来自:http://blog.csdn.net/ouyang_peng/article/details/11358405 今天看到一篇文章,收藏了很多大牛的博客,在这里分享一下 谦虚的天下 柳志超 ...

  7. 如何让Ubuntu系统支持WebP图片格式

    本文主要向大家介绍如何让 Ubuntu 系统支持查看 WebP 图片格式,以及如何将 WebP 转为 JPEG 或 PNG 图片格式的方法. 什么是WebP图片 Google开发并推出 WebP 图片 ...

  8. excel多个sheet表拆分成独立的excel文件

    一.问题: 公司做一个项目,给的用户上报文是一个包含多个sheet页的excel文件, 但是在实际处理报文数据的时候需要拆分excel文件为多个独立的报文excel文件 二.解决: (1)一个一个的复 ...

  9. 性能测试之nmon对linux服务器的监控

    大家都知道在做性能测试的时候,需要监控服务器的资源情况,而大多数服务器是Linux系统,网上资料嘿多,这里汇总介绍下Nmon监控工具: -------------------------------- ...

随机推荐

  1. /usr/lib/x86_64-linux-gnu/libopencv_highgui.so:对‘TIFFReadRGBAStrip@LIBTIFF_4.0’未定义的引用

     LIBRARIES += boost_thread stdc++ boost_regex     https://github.com/rbgirshick/fast-rcnn/issues/52

  2. webpack-dev-server报错

    运行npm run dev报错,---- webpack-dev-server --inline --progress --config build/webpack.dev.conf.js npm E ...

  3. 安装SSD

    前面两篇文章讲了用SSD检测框架训练自己的数据集,这篇补充一下SSD的安装.github链接:https://github.com/weiliu89/caffe/tree/ssdSSD是16年ECCV ...

  4. Thymeleaf中href与 th:href的区别

    语法格式如下: <a th:href="@{/channel/page/add}">添加渠道 </a> <a href="/channel/ ...

  5. 泊爷带你学go -- 加锁的问题

    package main import ( "fmt" "sync" ) var l sync.Mutex var a string func f() { a ...

  6. 2018-CVTE中央研究院-自然语言处理算法工程师-电话初面问题

    楼主NLP初学者一名,有幸参加2018年CVTE中央研究院自然语言处理电话面试,问题总结如下: 1.详细的介绍自己的学术论文(感觉他们非常重视这块),会问你网络的具体构造,注意力机制如何计算以及为何你 ...

  7. 2019 Power BI最Top50面试题,助你面试脱颖而出系列<上>

    距离4月还剩11天, 你是否还在投简历找工作而机会寥寥? 你是否还在四处奔波疲于面试而结果不意? ....... 知否知否, 天下武功唯快不破, 传说江湖有本Power BI 面试真香秘籍, 能助你快 ...

  8. 【论文阅读】Wing Loss for Robust Facial Landmark Localisation with Convolutional Neural Networks

    Wing Loss for Robust Facial Landmark Localisation with Convolutional Neural Networks 参考 1. 人脸关键点: 2. ...

  9. [LeetCode&Python] Problem 415. Add Strings

    Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2 ...

  10. Android应用程序启动过程

    有没有想过,当我们点击桌面应用程序图标是怎样打开APP启动应用程序的呢? 当我们点击应用图标会调用Launcher的startActivitySafely()方法,方法实现如下,其实是调用的start ...