Comments on file comments and function headers inside Source Insight

Source: Internet
Author: User
Tags constant definition

1. Copy the following code into a file with the extension EM

2. Open the base project, add this file, and resynchronize

3. Add Hh_insertfuncheader shortcut keys, that is, the function header comment, the cursor needs to be placed in the function name line, otherwise invalid

4. Add Hh_insertfileheader shortcut keys, that is, the file header comments, and the header file (currently just. h) and source files (not. h files), the header file has

Macro Hh_insertfuncheader ()
{
Hbuf = Getcurrentbuf ()
Szfunc = Getcursymbol ()
if (strlen (szfunc) = = 0)
{
Return
}

ln = getsymbolline (szfunc)
if (ln = = "-1")
{
Return
}

Symbol = GETSYMBOLLOCATIONFROMLN (hbuf, LN)
if ((symbol = = Nil) | | (symbol. Type! = "Function"))
{
Return
}

Szmyname = Hh_get_author_name ()

Sztime = Getsystime (1)
Day = Sztime.day
if (Day < 10)
{
Day = "0" # Sztime.day
}
Month = Sztime.month
if (Month < 10)
{
Month = "0" # Sztime.month
}
Year = Sztime.year

Funclen = strlen (Szfunc)

HSYML = Symbolchildren (symbol)
Cchild = Symlistcount (HSYML)

Insbufline (Hbuf, ln++, "/*****************************************************************************/")
Insbufline (Hbuf, ln++, "/**")

Insbufline (Hbuf, ln++, "* \author @[email protected]")
Insbufline (Hbuf, ln++, "* \date @[email protected]/@[email protected]/@[email protected]")
Insbufline (Hbuf, ln++, "* \brief")

Ichild = 0
while (Ichild < cchild)
{
Childsym = Symlistitem (hsyml, Ichild)
if (Childsym.type = = "Parameter")
{
Symnamelen = strlen (Childsym.symbol)
Name = Strmid (Childsym.symbol, funclen+1, Symnamelen)
Insbufline (Hbuf, ln++, "* \param" # name)
}
Ichild = ichild + 1
}
Symlistfree (HSYML)

Insbufline (Hbuf, ln++, "* \return")
Insbufline (Hbuf, ln++, "* \remarks")

Insbufline (Hbuf, ln++, "******************************************************************************/")

Put the insertion point inside the header comment
Setbufins (hbuf, LN, 0)
}

Macro Hh_insertfileheader ()
{
Hbuf = Getcurrentbuf ()
Fullfilename = Getbufname (hbuf)
FileName = Hh_getfilenamefromfull (fullfilename)
Szmyname = Hh_get_author_name ()
ln = 0

Sztime = Getsystime (1)
Year = Sztime.year
Month = Sztime.month
if (Month < 10)
{
Month = "0" # Sztime.month
}
Day = Sztime.day
if (Day < 10)
{
Day = "0" # Sztime.day
}

FileType = Strmid (filename, strlen (filename)-2, strlen (filename))

Insbufline (Hbuf, ln++, "/*****************************************************************************/")
Insbufline (Hbuf, ln++, "/**")
Insbufline (Hbuf, ln++, "* \file" # FileName)
Insbufline (Hbuf, ln++, "* \author" # Szmyname)
Insbufline (Hbuf, ln++, "* \date @[email protected]/@[email protected]/@[email protected]")
Insbufline (Hbuf, ln++, "* \version V1")
Insbufline (Hbuf, ln++, "* \brief file description")
Insbufline (Hbuf, ln++, "* \note Copyright (c) 2000-2020 xxxxx Company")
Insbufline (Hbuf, ln++, "* \remarks modify Log")
Insbufline (Hbuf, ln++, "******************************************************************************/")

if (FileType = = ". H")
{
ln = Hh_insertheaderfileheader (hbuf, fileName, LN)
}
Else
{
ln = Hh_insertsourcefileheader (hbuf, fileName, LN)
}

Setbufins (hbuf, LN, 0)
}

Macro Hh_get_author_name ()
{
var szmyname
Szmyname = getenv (MYNAME)
if (Szmyname = = Nil)
{
Szmyname = Ask ("What ' s your name?");
Putenv (MYNAME, szmyname);
}

Return Szmyname
}

Macro Hh_insertheaderfileheader (Hbuf, fileName, LN)
{
Hbuf = Getcurrentbuf ()
Szmyname = Hh_get_author_name ()

Tmpfilename = ToUpper (fileName)
I=0
var upperfilename
while (i++ < strlen (tmpfilename))
{
ch = strmid (tmpfilename, i-1, i)

if (ch = = ".")
{
Upperfilename = Cat (Upperfilename, "_")
}
Else
{
Upperfilename = Cat (upperfilename, CH)
}
}
Upperfilename = Cat ("_", Upperfilename)
Upperfilename = Cat (Upperfilename, "_")

Insbufline (Hbuf, ln++, "#ifndef" # Upperfilename)
Insbufline (Hbuf, ln++, "#define" # Upperfilename)
Insbufline (Hbuf, ln++, "")
Insbufline (Hbuf, ln++, "/*****************************************************************************")
Insbufline (Hbuf, ln++, "* Header File Reference *")
Insbufline (Hbuf, ln++, "*****************************************************************************/")
Insbufline (Hbuf, ln++, "#ifdef __cplusplus")
Insbufline (Hbuf, ln++, "extern \" C\ "")
Insbufline (Hbuf, ln++, "{")
Insbufline (Hbuf, ln++, "#endif")
Insbufline (Hbuf, ln++, "")
Insbufline (Hbuf, ln++, "/*****************************************************************************")
Insbufline (Hbuf, ln++, "* Constant definition *")
Insbufline (Hbuf, ln++, "*****************************************************************************/")
Insbufline (Hbuf, ln++, "")
Insbufline (Hbuf, ln++, "/*****************************************************************************")
Insbufline (Hbuf, ln++, "* macro definition *")
Insbufline (Hbuf, ln++, "*****************************************************************************/")
Insbufline (Hbuf, ln++, "")
Insbufline (Hbuf, ln++, "/*****************************************************************************")
Insbufline (Hbuf, ln++, "* Global data type definition *")
Insbufline (Hbuf, ln++, "*****************************************************************************/")
Insbufline (Hbuf, ln++, "")
Insbufline (Hbuf, ln++, "/*****************************************************************************")
Insbufline (Hbuf, ln++, "* Global variable Declaration *")
Insbufline (Hbuf, ln++, "*****************************************************************************/")
Insbufline (Hbuf, ln++, "")
Insbufline (Hbuf, ln++, "/*****************************************************************************")
Insbufline (Hbuf, ln++, "* Global function Declaration *")
Insbufline (Hbuf, ln++, "*****************************************************************************/")
Insbufline (Hbuf, ln++, "")
Insbufline (Hbuf, ln++, "#ifdef __cplusplus")
Insbufline (Hbuf, ln++, "}")
Insbufline (Hbuf, ln++, "#endif")
Insbufline (Hbuf, ln++, "#endif")
Insbufline (Hbuf, ln++, "")

Return LN
}

Macro Hh_insertsourcefileheader (Hbuf, fileName, LN)
{
Hbuf = Getcurrentbuf ()
Szmyname = Hh_get_author_name ()

Insbufline (Hbuf, ln++, "/*****************************************************************************")
Insbufline (Hbuf, ln++, "* Header File Reference *")
Insbufline (Hbuf, ln++, "*****************************************************************************/")
Insbufline (Hbuf, ln++, "")
Insbufline (Hbuf, ln++, "/*****************************************************************************")
Insbufline (Hbuf, ln++, "* Local constant definition *")
Insbufline (Hbuf, ln++, "*****************************************************************************/")
Insbufline (Hbuf, ln++, "")
Insbufline (Hbuf, ln++, "/*****************************************************************************")
Insbufline (Hbuf, ln++, "* Local macro definition *")
Insbufline (Hbuf, ln++, "*****************************************************************************/")
Insbufline (Hbuf, ln++, "")
Insbufline (Hbuf, ln++, "/*****************************************************************************")
Insbufline (Hbuf, ln++, "* Local data type definition *")
Insbufline (Hbuf, ln++, "*****************************************************************************/")
Insbufline (Hbuf, ln++, "")
Insbufline (Hbuf, ln++, "/*****************************************************************************")
Insbufline (Hbuf, ln++, "* Local function declaration *")
Insbufline (Hbuf, ln++, "*****************************************************************************/")
Insbufline (Hbuf, ln++, "")
Insbufline (Hbuf, ln++, "/*****************************************************************************")
Insbufline (Hbuf, ln++, "* local variable definition *")
Insbufline (Hbuf, ln++, "*****************************************************************************/")
Insbufline (Hbuf, ln++, "")
Insbufline (Hbuf, ln++, "/*****************************************************************************")
Insbufline (Hbuf, ln++, "* global variable definition *")
Insbufline (Hbuf, ln++, "*****************************************************************************/")
Insbufline (Hbuf, ln++, "")
Insbufline (Hbuf, ln++, "/*****************************************************************************")
Insbufline (Hbuf, ln++, "* Global function definition *")
Insbufline (Hbuf, ln++, "*****************************************************************************/")
Insbufline (Hbuf, ln++, "")
Insbufline (Hbuf, ln++, "/*****************************************************************************")
Insbufline (Hbuf, ln++, "* Local function definition *")
Insbufline (Hbuf, ln++, "*****************************************************************************/")
Insbufline (Hbuf, ln++, "")

Return LN
}

Macro Hh_getfilenamefromfull (Fullfilename)
{
Len = strlen (fullfilename)
i = Len

while (i--> 0)
{
ch = strmid (Fullfilename, I, i+1)

if (ch = = "\")
{
Return Strmid (Fullfilename, i+1, Len)
}
}

Return ""
}

Comments on file comments and function headers inside Source Insight

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.