分享

Source Insight文件注释及函数注释的实现方法

 戴维图书馆 2016-03-15

1、Source Insight的注释实现步骤:

 1.1、Project->Open Project->Base

 Source <wbr>Insight文件注释及函数注释的实现方法

点击OK,里面有个文件utils.em,全是macro 函数名,接下来你可以直接将你需要的macro函数名称添加到最下端,也可以另外起后缀为.em的文件
1.2、Optition->Key Assigments,主要是为了实现功能添加快捷键,而紧接着下面的Menu Assigments为将功能添加到对应的标题下,如编辑,文件,亦或是帮助。个人的做法:设置了快捷键。
1.3、快捷键的设置方法
Key Assigments中如图:
 Source <wbr>Insight文件注释及函数注释的实现方法

CommentBlock为单行注释
UCCommentBlock为取消单行注释
其他的源码如下:
1、文件注释

macro InsFileHeader_Avr()
{
// Get the owner's name from the environment variable: szMyName.
// If the variable doesn't exist, then the owner field is skipped.
AuthorName = "Han qj"
hbuf = GetCurrentBuf()//申请变量空间,Get a handle to the current file buffer and the name
PathName = GetBufName(hBuf)
FileName = GetFileName(PathName)
//FileName = toupper(FileName) 全部转换为大写

//szFunc = GetCurSymbol()    //获取文件名
//ln = GetSymbolLine(szFunc)//获取首行
ln=0 //行号

szTime = GetSysTime(1)     //Get current time
File_Date =szTime.date
File_Time =szTime.time


File_Version = Ask("File Version ? 1.0 2.0 or other?")
//szDescription = Ask("Enter the description of function:")

// begin assembling the title string
InsBufLine(hbuf, ln,     " ")
InsBufLine(hbuf, ln + 19," ")
InsBufLine(hbuf, ln + 20," #include<.h>")
SetBufIns(hbuf, ln + 20, 10)// put the insertion point inside the header comment
}

macro GetFileName(pathName)
{
nlength = strlen(pathName)
i = nlength - 1
name = ""
while (i + 1)
{
   ch = pathName[i]
   if ("\\" == "@ch@")
    break
   i = i - 1
}
i = i + 1
while (i < nlength)
{
   name = cat(name, pathName[i])
   i = i + 1
}

return name
}

2、函数注释

macro InsFucHeader_Avr()
{

AuthorName = "fast_sky\@sina.com"
hwnd = GetCurrentWnd()
lnFirst = GetWndSelLnFirst(hwnd)
hbuf = GetCurrentBuf()//申请变量空间,Get a handle to the current file buffer and the name

InsBufLine(hbuf, lnFirst, "")

}

以上是自己参考网上的代码完成的,我想说的重点是如何将快捷键写入,是将鼠标点到KeyStroks里,然后按住你想要的按键,点击Assigned new...即可。呵呵,这里花我时间不少,希望对大家有用。

1.4、功能往菜单的添加方法
 Source <wbr>Insight文件注释及函数注释的实现方法

 
Menu选项为你想要放在的标签下面,具体的自己看着处理,个人爱好不同,先点击左边comand下面选中的,再点击menu contents里,insert就会点亮,接下来就容易了!
2、Source Insight的几个概念介绍:
对于函数可以自己实现封装,常用的几种概念如下,可以自己组装自己想要的内容

SourceInsight编程时每行为一个指令(和Dos命令行相似,后面没有命令分隔符)

变量赋值时如:Day = szTime.Day

引用时如:szDay = "0@Day@",使用@@引用变量

使用 // 进行注释

 

GetSysTime 获取系统时间

 

szTime = GetSysTime(1)

Hour = szTime.Hour

Minute = szTime.Minute

Second = szTime.Second

Day = szTime.Day

Month = szTime.Month

Year = szTime.Year

 

hwnd = GetCurrentWnd() 获取当前窗口句柄

lnFirst = GetWndSelLnFirst(hwnd) 获取选定区域的最小行号(以0开始)

lnLast = GetWndSelLnLast(hwnd) 获取选定区域的最大行号(以0开始)

hbuf = GetCurrentBuf() 获取选中区域内容

InsBufLine(hbuf, lnFirst, "") 插入信息

 

hprj = GetCurrentProj () 获取当前工程句柄

SyncProj (hprj) 同步工程

 

 

 

添加自定义menu或快捷键的方法

1.      选中菜单中的Options

2.      选择 Menu Assignments或Key Assignments

3.      在Command栏写入macro,然后找到自己填加的函数

 

为了使SourceInsight能够找到自己所写的文件(*.em),可以将自己做成的这个文件添加到工程中,或者Systm统一识别的位置,如:

xp下是My Documents\Source Insight\Projects\Base

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多