配置source insight使用快捷键快速添加注释

第一步打开source insight的base工程,然后打开utils.em文件,将本文最后的三个function拷贝进去,并保存

第二步,点击options->key assignments,将三个function分别映射对应的快捷键,可按需定义,这样后续使用快捷键可快速添加注释
三个函数解释:
InsertFunctionHeader:注释函数头;
InsertSingleLineComment:单行注释;
InsertMultiLineComment:多行注释;
需要插入的代码如下:
1 macro InsertFunctionHeader() 2 { 3 hwnd = GetCurrentWnd() 4 lnFirst = GetWndSelLnFirst(hwnd) 5 // Get current time 6 szTime = GetSysTime(1) 7 Day = szTime.Day 8 month = szTime.Month 9 Year = szTime.Year 10 if (Day < 10) 11 szDay = "0@Day@" 12 else 13 szDay = Day 14 15 hbuf = GetCurrentBuf() 16 InsBufLine(hbuf, lnFirst, "/**") 17 InsBufLine(hbuf, lnFirst+1, " * \@brief ") 18 InsBufLine(hbuf, lnFirst+2, " * \@details ") 19 InsBufLine(hbuf, lnFirst+3, " * \@param [in] ") 20 InsBufLine(hbuf, lnFirst+4, " * \@param [out] ") 21 InsBufLine(hbuf, lnFirst+5, " * \@return ") 22 InsBufLine(hbuf, lnFirst+6, " */") 23 24 } 25 26 macro InsertSingleLineComment() 27 { 28 hwnd = GetCurrentWnd() 29 lnFirst = GetWndSelLnFirst(hwnd) 30 hbuf = GetCurrentBuf() 31 sz = GetBufLine(hbuf,lnFirst) 32 sz = sz # "/* */" 33 PutBufLine (hbuf, lnFirst, sz) 34 len = strlen(sz) 35 len = len-strlen(" */") 36 SetBufIns (hbuf, lnFirst, len) 37 } 38 39 macro InsertMultiLineComment() 40 { 41 hwnd = GetCurrentWnd() 42 lnFirst = GetWndSelLnFirst(hwnd) 43 hbuf = GetCurrentBuf() 44 sz = GetBufLine(hbuf,lnFirst) 45 sz = sz # "/*" 46 InsBufLine (hbuf, lnFirst, sz) 47 48 tz = GetBufLine(hbuf,lnFirst + 1) 49 tz = tz # " * " 50 InsBufLine (hbuf, lnFirst + 1, tz) 51 52 uz = GetBufLine(hbuf,lnFirst + 2) 53 uz = uz # " */" 54 InsBufLine (hbuf, lnFirst + 2, uz) 55 56 len = strlen(tz) 57 SetBufIns (hbuf, lnFirst + 1, len) 58 }

浙公网安备 33010602011771号