使用source insight 宏来插入doxygen可处理的注释

宏文件如下。



设置快捷键后,双击高亮要注释的内容,使用快捷键触发即可。



可自动识别

普通:在头部添加

宏:在末尾添加注释

变量:在末尾添加

函数:在头部添加,并自动识别函数个数

类:在头部添加



代码如下:保存为m.em即可加入source insight



macro insert_func_header_comment()
{
hbuf = GetCurrentBuf()
if( hbuf == 0 ) stop

// Get current time
szTime = GetSysTime(1)
Day = szTime.Day
Month = szTime.Month
Year = szTime.Year

chTab = CharFromAscii(9)
chComma = CharFromAscii(44)

ln = GetBufLnCur( hbuf )
start_ln = ln;
symbol = GetCurSymbol()
if( symbol == nil )
{//没有找到符号
  InsBufLine(hbuf, ln, "")
  SetBufIns(hbuf, start_ln, 10)
  stop
}

text = GetBufLine( hbuf, ln )
slen = strlen(text)

sbi = GetSymbolLocation( symbol )
if( sbi == nil )
{//无法得到符号记录,直接加一个简单记录了事
  PutBufLine( hbuf, ln, cat(text," //!< " )
  SetBufIns( hbuf, ln, slen + 6)
  stop
}

if( sbi.Type == "Function" || sbi.Type == "Method" || sbi.Type == "Function Prototype" )
{// function
  ich = 0
  while( text[ich] == " " || text[ich] == chTab )
  {
   ich = ich + 1
  }
  szPrefix = strmid(text, 0, ich)
  InsBufLine(hbuf, ln, cat( szPrefix, ""))
  SetBufIns(hbuf, start_ln, strlen(szPrefix) + 10) 
}
else if( sbi.Type == "Class" )
{// class
  if( (start_ln == sbi.lnFirst) )
  {//整个类注释
   InsBufLine(hbuf, ln, "")
   SetBufIns(hbuf, start_ln, 10)
  }
  else
  {//类成员
   PutBufLine( hbuf, ln, cat(text," //!< " )
   SetBufIns( hbuf, ln, slen + 6)
  }
}
else if( sbi.Type == "Structure" )
{// struct
  if( (start_ln == sbi.lnFirst) )
  {//整个结构体注释
   InsBufLine(hbuf, ln, "")
   SetBufIns(hbuf, start_ln, 10)
  }
  else
  {//结构体成员
   PutBufLine( hbuf, ln, cat(text," //!< " )
   SetBufIns( hbuf, ln, slen + 6)
  }
}
else if( sbi.Type == "Constant" )
{// macro
  PutBufLine( hbuf, ln, cat(text," //!< " )
  SetBufIns( hbuf, ln, slen + 6)
}
else if( sbi.Type == "Variable" )
{// variable
  PutBufLine( hbuf, ln, cat(text," //!< " )
  SetBufIns( hbuf, ln, slen + 6)
}
   
}


你可能感兴趣的:(prototype)