source insight 使用

1.前言
工欲善其事必先利其器。source insight 在阅读大工程代码时,无疑是神器。
这里介绍source insight 的 两个比较好用的功能。


2.功能增加
⑴在代码当中插入注释
①打开base工程
打开的base工程文件

②插入脚本
插入代码

③脚本内容

//add  by leon 2015-10-12
// insert current date
macro MonthToName(MonthNum)

{
    if (MonthNum== 1)
     return "01"

    if (MonthNum== 2)
        return "02"

    if (MonthNum== 3)
        return "03"

    if (MonthNum== 4)
        return "04"

    if (MonthNum== 5)
        return "05"

    if (MonthNum== 6)
        return "06"

    if (MonthNum== 7)
        return "07"

    if (MonthNum== 8)
        return "08"

    if (MonthNum== 9)
        return "09"

    if (MonthNum== 10)
        return "10"

    if (MonthNum== 11)
        return "11"

    if (MonthNum== 12)
        return "12"

}

macro DisplayDate()
{

    szTime = GetSysTime(1)
    Day = szTime.Day
    Month = szTime.Month
    Year = szTime.Year
    Hour = szTime.Hour
    Minute = szTime.Minute
    Second = szTime.Second
    if (Day < 10)
        szDay = "0@Day@"
    else
        szDay = Day
    szMonth = MonthToName(Month)

    hbuf = GetCurrentBuf()

    SetBufSelText(hbuf, "//mod by leon.  @Year@/@szMonth@/@szDay@  @Hour@:@Minute@:@Second@ ")

}

macro InsertCommentsInfo()  
{  
    szTime = GetSysTime(1)
    Day = szTime.Day
    Month = szTime.Month
    Year = szTime.Year
    Hour = szTime.Hour
    Minute = szTime.Minute
    Second = szTime.Second
    if (Day < 10)
        szDay = "0@Day@"
    else
        szDay = Day
    szMonth = MonthToName(Month)

    line_headr = "/***************************************************"  
    line_1 = " * Function : "  
    line_2 = " * Author : leon"  
    line_3 = " * Creat Date : @Year@/@szMonth@/@szDay@  @Hour@:@Minute@:@Second@"  
    line_4 = " * Description : "  
    line_5 = " * In-Parameter : "  
    line_6 = " * Return : "  
    line_7 = " * Modify : "  
    line_end = " **************************************************/"  

    hbuf = GetCurrentBuf()
    ln = GetBufLnCur(hbuf)


    InsBufLine(hbuf, ln,   line_headr)  
    InsBufLine(hbuf, ln+1, line_1)  
    InsBufLine(hbuf, ln+2, line_2)  
    InsBufLine(hbuf, ln+3, line_3)  
    InsBufLine(hbuf, ln+4, line_4)  
    InsBufLine(hbuf, ln+5, line_5)  
    InsBufLine(hbuf, ln+6, line_6)  
    InsBufLine(hbuf, ln+7, line_7)  
    InsBufLine(hbuf, ln+8, line_end)  
} 

macro AddNewFunctionDescription()
{
    InsertCommentsInfo()
}
//end by leon

④ 增加快捷键
KEY
KEY1
KEY2

⑵格式化代码
格式化代码我们需要依赖于开源程序AStyle,可以在官网下载Artistic Style
下载后,笔者放在D:\ 下, 可执行程序路径: D:\AStyle\bin\AStyle.exe

①相关脚本
A.格式化当前文件

D:\AStyle\bin\AStyle.exe --style=linux -s4 -S -N -L -m0 -M40 --pad-oper --suffix=none --convert-tabs %f

Unix统一风格:

D:\AStyle\bin\AStyle.exe --style=linux -s4 -S -N -L -p -m0 -M40 -z2 -q --pad-oper --indent=tab   %f

B.格式化当前目录下所有 .c .h 文件

D:\AStyle\bin\AStyle.exe --style=linux -s4 -S -N -L -m0 -M40 --suffix=none --convert-tabs --recursive ./*.c ./*h

Unix统一风格:

D:\AStyle\bin\AStyle.exe --style=ansi -s4 -S -N -L -m0 -M40 --suffix=none --convert-tabs --recursive ./*.c ./*h

②增加命令
KEY4
KEY5
KEY6
KEY7

③为命令增加快捷键

KEY8
KEY9


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值