Source Insight 宏的使用与自定义快捷键

 相信阅读过大型源代码的,都知道Source Insight。

    今天花了点时间,整理了两个宏,使用快捷键生成代码注释。很方便。

    废话少说,进入主题!

 

    ①打开Source Insight > Project > Open Project > Base > OK

    ②打开Utils.em 宏文件

    ③添加以下宏(跟C语言的函数差不多)

 


添加函数注释:

 

macro MyInsertHeader()  
{  
    // Get the owner's name from the environment variable: MYNAME.  
    // If the variable doesn't exist, then the owner field is skipped.  
    szMyName = getenv(MYNAME)  
  
    // Get a handle to the current file buffer and the name  
    // and location of the current symbol where the cursor is.  
    hbuf = GetCurrentBuf()  
    szFunc = GetCurSymbol()  
    ln = GetSymbolLine(szFunc)  
  
    InsBufLine(hbuf, ln, "/************************************************************");  
    ln = ln +1  
  
    // begin assembling the title string  
    sz = "** 函数名称: "   
  
    /* convert symbol name to T E X T   L I K E   T H I S */  
    cch = strlen(szFunc)  
    ich = 0  
    while (ich < cch)  
    {  
        ch = szFunc[ich]  
        if (ich > 0)  
            if (isupper(ch))  
                sz = cat(sz, "   ")  
            else  
                sz = cat(sz, " ")  
        sz = Cat(sz, toupper(ch))  
        ich = ich + 1  
    }   
    InsBufLine(hbuf, ln, sz)  
    ln = ln + 1  
  
    InsBufLine(hbuf, ln, "** 功能描述: ")  
    ln = ln + 1  
  
    InsBufLine(hbuf, ln, "** 输入参数:")  
    ln = ln + 1  
  
    InsBufLine(hbuf, ln, "** 输出参数: ")  
    ln = ln + 1  
  
    InsBufLine(hbuf, ln, "** 返 回 值    :")  
    ln = ln + 1  
  
    /* if owner variable exists, insert Owner: name */  
    if (strlen(szMyName) > 0)  
    {  
        InsBufLine(hbuf, ln, "** 作    者       :  @szMyName@")                   
    }  
    else  
    {  
        InsBufLine(hbuf, ln, "** 作    者       :  ")                   
    }  
    ln = ln + 1  
  
    // Get current time  
    szTime  = GetSysTime(1)  
    Day      = szTime.Day  
    Month   = szTime.Month  
    Year     = szTime.Year  
    if (Day < 10)  
        szDay = "0@Day@"  
    else  
        szDay = Day    
  
    InsBufLine(hbuf, ln, "** 日    期       :  @Year@年@Month@月@szDay@日")  
    ln = ln + 1  
  
    InsBufLine(hbuf, ln, "** 版    本       :  1.0")  
    ln = ln + 1  
  
    InsBufLine(hbuf, ln, "** 修改日期  版本号   修改人  修改内容")  
    ln = ln + 1  
  
    InsBufLine(hbuf, ln, "**************************************************************/")  
} 


[cpp]  view plain  c


添加头文件注释宏:

macro MyInsertFileHeader()  
{  
    szMyName = getenv(MYNAME)  
  
    hbuf = GetCurrentBuf()  
  
    InsBufLine(hbuf, 0, "/***************************************************************************")  
    InsBufLine(hbuf, 1, "** 版权所有:  Desay Copyright (c) 2016-2026  ********************             ")  
    filename = GetBufName(hbuf)  
    InsBufLine(hbuf, 2, "** 文件名称:  @filename@")  
    InsBufLine(hbuf, 3, "** 文件标识: ")  
    InsBufLine(hbuf, 4, "** 内容摘要:  ")  
    InsBufLine(hbuf, 5, "** 当前版本:  v1.0")  
  
    /* if owner variable exists, insert Owner: name */  
    if (strlen(szMyName) > 0)  
    {  
        sz = "** 作      者     :  @szMyName@"  
    }  
    else  
    {  
        sz = "** 作      者     :"  
    }  
  
    InsBufLine(hbuf, 6, sz)  
  
    // Get current time  
    szTime  = GetSysTime(1)  
    Day      = szTime.Day  
    Month   = szTime.Month  
    Year     = szTime.Year  
    if (Day < 10)  
        szDay = "0@Day@"  
    else  
        szDay = Day                 
  
    InsBufLine(hbuf, 7,   "** 完成日期: @Year@年@Month@月@szDay@日")  
    InsBufLine(hbuf, 8,   "** 修改记录: ")  
    InsBufLine(hbuf, 9,   "** 修改记录: ")  
    InsBufLine(hbuf, 10, "** 修改日期: ")  
    InsBufLine(hbuf, 11, "** 版本号      : ")  
    InsBufLine(hbuf, 12, "** 修改人      : ")  
    InsBufLine(hbuf, 13, "** 修改内容: ")  
    InsBu




    ④添加完后 > Ctrl + s 保存

    ⑤打开自己的工程 > Option > Key Assignments 可以找到:

        Macro : MultiLineComment

        Macro : SingleLineComment

    ⑥点击Assign New Key ...,设置完成以后,重启即可

        好了,设置自己习惯的快捷键吧!^^

        可以是Alt Ctrl 等等组合。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值