SourceInsight的宏语言使用
集成开发环境之Source Insight使用教程
![集成开发环境之Source Insight使用教程](https://img.taocdn.com/s3/m/6d52663910a6f524ccbf85dc.png)
它编辑器产品不同,Source Insight能在你编辑的同时分析你的源代码,为你
提供实用的信息并立即进行分析。
让编程更简单更高效更规范
项目管理(1)
①
新建一个项目
快捷键 Alt + Shift + N 可以打开新建项目对话框,然后根据提示填好项目存
文档窗口-文档类型选项窗口
Alt + Y 打开文 档类型选项窗 口,修改字体 显示大小、是
否显示行号、
解析语言选择、 工程文件过滤、 扩展tab键、 是否显示符号 窗口等。
文档窗口(3)
扩充1:Source Insight可以定义风格,菜单栏->选项->风格,即可以打开风
格窗口,可以新建一个风格或修改一个风格。风格可以继承(和C++继承差 不多)。
储位置,源文件位置等。然后会出现添加删除项目文件对话框,选中自己
想要编辑和浏览的文件添加即可,这样就建好了一个项目。
②
添加和删除项目文件
①
在添加删除文件前,可以先设置文件过滤器,菜单栏->选项->文档选项, 就可以看到文件过滤器了,怎么设置应该是一目了然的。
②
菜单栏->项目->添加或删除文件,即可打开添加和删除项目文件对话框。
quicker.em的使用
首先将这个文件加载到Base工程中,其次要定义一个快捷键调用
quicker.em中的宏 AutoExpand。
调用 AutoExpand 宏后,AutoExpand会根据当前文本内容自动调用
其他宏。
一般情况下都用快捷键 Ctrl + Enter 调用AutoExpand宏。 quicker.em 包括标准C语言扩展,标准说明生成,代码修改注释等。 quicker.em 的使用参考《Quicker使用说明.doc》
SourceInsight Macro
![SourceInsight Macro](https://img.taocdn.com/s3/m/493ef3c48bd63186bcebbcf8.png)
Source insight 宏的使用作者:颜庆打开source insight 的base工程(菜单Project -> Open Project),其中一个文件叫utils.em ,在这个文件里添加你自己的宏,然后在菜单option/key assignments中给相应的宏分配快捷键,就可以使用source insight 宏了。
下面是一些具体的宏的介绍。
autoexpand把下面的代码拷贝到source insight的base工程中的utils.em文件中,然后在你自己的工程中,打开option/key assignments, 为autoexpand 这个宏分配快捷键,这里用的是ctrl + 1使用:在source insight 中先键入一个关键字,比如for,然后按下你的快捷键,宏就会帮你展开相应的代码,如下图所示,这时你可以通过F3, F4跳到下一个“###”insheaderdef这个source insight宏可以自动给头文件加上头文件宏,它会自动获取文件名,自动添加与文件名对应的宏。
执行insheaderdef宏之前代码如下执行insheaderdef宏之后代码如下InsertIfdef这个source insight宏可以自动给一段选中的代码加上宏开关执行InsertIfdef宏之前选中若干行代码执行InsertIfdef宏之后会有提示框让你输入宏,我们输入AEE_SIMULATOR然后回车,代码如下:MakeCode2Comments把选中的代码前面加双斜杠“//”执行宏之后:MakeComments2Code与上面一个宏的作用刚好相反NeateanVarDeclaration整理变量声明,让变量对齐,先选中若干行:执行之后:注意:这个宏默认地通过空格作为分隔符来对齐每一部分;另外,你要保证你的source insight 使用的字体是等宽字体Courier New,才能让字符对齐修改字体方法:options -> Document options -> Screen Fontsinsfunheader这个宏可以给函数自动加函数头注释先让光标停留在某个函数体内:执行宏,会弹出输入框,让你输入函数描述:点OK之后:/*附上宏定义文件*//* t357.em - a small collection of useful editing macros *//****************************************************************************** * InsFileHeader -- insert the information of file** modification history* --------------------* 01a, 23mar2003, added DESCRIPTION by t357* 01a, 05mar2003, t357 written* --------------------******************************************************************************/ /*-------------------------------------------------------------------------I N S E R T H E A D E RInserts a comment header block at the top of the current function.This actually works on any type of symbol, not just functions.To use this, define an environment variable "szMyName" and set itto your email name. eg. set szMyName=raygr-------------------------------------------------------------------------*/macro InsFileHeader(){/*######################################################################################################################### Set szMyName variable to your name ############### for example szMyName = "t357" ##########################################################################################################################*/szMyName = ""// Get current timeszTime = GetSysTime(1)Day = szTime.DayMonth = szTime.MonthYear = szTime.Yearif (Day < 10)szDay = "0@Day@"elseszDay = DayszMonth = NumToName(Month)hBuf = GetCurrentBuf()szpathName = GetBufName(hBuf)szfileName = GetFileName(szpathName)nlength = StrLen(szfileName)szInf = Ask("Enter the information of file:")szDescription = Ask("Enter the description of file:")hbuf = GetCurrentBuf()// begin assembling the title stringInsBufLine(hbuf, 0,"/******************************************************************************") InsBufLine(hbuf, 1, " * @szfileName@ - @szInf@")InsBufLine(hbuf, 2, " * ")InsBufLine(hbuf, 3, " * Copyright 1998-2003 Guangzhou Gaoke Communication Technology Co.,Ltd.")InsBufLine(hbuf, 4, " * ")InsBufLine(hbuf, 5, " * DESCRIPTION: - ")InsBufLine(hbuf, 6, " * @szDescription@")InsBufLine(hbuf, 7, " * modification history")InsBufLine(hbuf, 8, " * --------------------")InsBufLine(hbuf, 9, " * 01a, @szDay@@szMonth@@Year@, @szMyName@ written") InsBufLine(hbuf, 10, " * --------------------")InsBufLine(hbuf, 11, "******************************************************************************/")// put the insertion point inside the header commentSetBufIns(hbuf, 1, nlength + strlen(szInf) + 8)}/****************************************************************************** * InsFunHeader -- insert function's information** modification history* --------------------* 01a, 23mar2003, added DESCRIPTION by t357* 01a, 05mar2003, t357 written* --------------------******************************************************************************/ macro InsFunHeader(){// Get the owner's name from the environment variable: szMyName.// If the variable doesn't exist, then the owner field is skipped./*######################################################################################################################### Set szMyName variable to your name ############### for example szMyName = "t357" ##########################################################################################################################*/szMyName = ""// 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)// Get current timeszTime = GetSysTime(1)Day = szTime.DayMonth = szTime.MonthYear = szTime.Yearif (Day < 10)szDay = "0@Day@"elseszDay = DayszMonth = NumToName(Month)szInf = Ask("Enter the information of function:")szDescription = Ask("Enter the description of function:")// begin assembling the title stringsz ="/******************************************************************************" InsBufLine(hbuf, ln, sz)InsBufLine(hbuf, ln + 1, " * @szFunc@ - @szInf@")InsBufLine(hbuf, ln + 2, " * DESCRIPTION: - ")InsBufLine(hbuf, ln + 3, " * @szDescription@ ")// remove by t357. CutWord(szDescription)InsBufLine(hbuf, ln + 4, " * Input: ")InsBufLine(hbuf, ln + 5, " * Output: ")InsBufLine(hbuf, ln + 6, " * Returns: ")InsBufLine(hbuf, ln + 7, " * ")InsBufLine(hbuf, ln + 8, " * modification history")InsBufLine(hbuf, ln + 9, " * --------------------")InsBufLine(hbuf, ln + 10, " * 01a, @szDay@@szMonth@@Year@, @szMyName@ written") InsBufLine(hbuf, ln + 11, " * --------------------")InsBufLine(hbuf, ln + 12, "******************************************************************************/")// put the insertion point inside the header commentSetBufIns(hbuf, ln + 1, strlen(szFunc) + strlen(szInf) + 8)}/****************************************************************************** * NumToName -- change the month number to name** modification history* --------------------* 01a, 05mar2003, t357 written* --------------------******************************************************************************/ macro NumToName(Month){if (Month == 1)return "jan"if (Month == 2)return "feb"if (Month == 3)return "mar"if (Month == 4)return "apr"if (Month == 5)return "may"if (Month == 6)return "jun"if (Month == 7)return "jul"if (Month == 8)return "aug"if (Month == 9)return "sep"if (Month == 10)return "oct"if (Month == 11)return "nov"if (Month == 12)return "dec"}/****************************************************************************** * CutWord -- auto newline** modification history* --------------------* 01a, 24mar2003, t357 fix some bug* 01a, 05mar2003, t357 written* --------------------******************************************************************************/ macro CutWord(ncurLine, szInf){LENGTH = 63nlength = StrLen(szInf)i = 0 /* loop control */begin = 0 /* first character's index of current line */pre = 0 /* preceding word's index */hbuf = GetCurrentBuf()// nline = GetBufLnCur()while (i < nlength){/* remove by t357nrow = 0sz = ""while (nrow < 80){if (nlength < 0)breaksz = Cat(sz, szInf[nrow])nrow = nrow + 1nlength = nlength - 1}InsBufLine(hbuf, nline, sz)szInf = szInf[nrow]}*/c = szInf[i]if (" " == @c@ && (i - b < LENGTH)){pre = i}else if (" " == @c@){szOutput = ""k = begin /* loop control */while (k < pre){szOutput = Cat(szOutput, szInf[k])k = k + 1}InsBufLine(hbuf, ncurLine, sz)ncurLine = ncurLine + 1begin = pre}i = i + 1}if (h != i - 1){szOutput = ""k = begin /* loop control */while (k < pre){szOutput = Cat(szOutput, szInf[k])k = k + 1}InsBufLine(hbuf, ncurLine, sz)ncurLine = ncurLine + 1}}/****************************************************************************** * GetFileName -- get the filename only from the path** modification history* --------------------* 01a, 05mar2003, t357 written* --------------------******************************************************************************/ macro GetFileName(pathName){nlength = strlen(pathName)i = nlength - 1name = ""while (i + 1){ch = pathName[i]if ("\\" == "@ch@")breaki = i - 1}i = i + 1while (i < nlength){name = cat(name, pathName[i])i = i + 1}return name}/****************************************************************************** * ReturnTrueOrFalse -- Inserts "Returns True or False" at the current line** modification history* --------------------* 01a, 05mar2003, t357 written* --------------------******************************************************************************/ macro ReturnTrueOrFalse(){szReturns = "return True if successful or False if errors."hbuf = GetCurrentBuf()ln = GetBufLnCur(hbuf)szCurLine = GetBufLine(hbuf, ln)DelBufLine(hbuf, ln)InsBufLine(hbuf, ln, "@szCurLine@@szReturns@")SetBufIns(hbuf, ln, StrLen(szReturns) + StrLen(szCurLine) + 3)}/****************************************************************************** * InsHeaderDef -- Inserts the header define in the headerfile** modification history* --------------------* 01a, 05mar2003, t357 written* --------------------******************************************************************************/ macro InsHeaderDef(){hBuf = GetCurrentBuf()szpathName = GetBufName(hBuf)szfileName = GetFileName(szpathName)szfileName = toupper(szfileName)nlength = StrLen(szfileName)i = 0 /* loop control */szdefineName = ""while (i < nlength){if (szfileName[i] == ".")szdefineName = Cat(szdefineName, "_")elseszdefineName = Cat(szdefineName, szfileName[i])i = i + 1}szdefineName = Cat("_", szdefineName)IfdefineSz(szdefineName)}/****************************************************************************** * PrintDate - print date on where the cursor point to* DESCRIPTION: -** Input:* Output:* Returns:** modification history* --------------------* 01a, 23mar2003, t357 written* --------------------******************************************************************************/ macro PrintDate(){szTime = GetSysTime(1)Day = szTime.DayMonth = szTime.MonthYear = szTime.Yearif (Day < 10)szDay = "0@Day@"elseszDay = DayszMonth = NumToName(Month)hbuf = GetCurrentBuf()ln = GetBufLnCur(hbuf)szCurLine = GetBufLine(hbuf, ln)DelBufLine(hbuf, ln)InsBufLine(hbuf, ln, "@szCurLine@ @szDay@@szMonth@@Year@")SetBufIns(hbuf, ln, StrLen(szCurLine) + 10)}// Ask user for ifdef condition and wrap it around current// selection.// 28mar2003, modified by t357.// 26mar2003, modified by t357.macro InsIfdef(){sz = Ask("Enter ifdef condition:")if (sz != ""){// IfdefSz(sz);hwnd = GetCurrentWnd()sel = GetWndSel(hwnd)hbuf = GetWndBuf(hwnd)// get line the selection (insertion point) is onszLine = GetBufLine(hbuf, sel.lnFirst - 1);chTab = CharFromAscii(9)// prepare a new indented blank line to be inserted.// keep white space on left and add a tab to indent.// this preserves the indentation level.i = 0 /* loop control */ich = ""while (szLine[i] == " " || szLine[i] == chTab){ich = Cat(ich, szLine[i])i = i + 1}InsBufLine(hbuf, sel.lnFirst, "")InsBufLine(hbuf, sel.lnFirst + 1, "@ich@#ifdef @sz@")InsBufLine(hbuf, sel.lnFirst + 2, "@ich@" # chTab)InsBufLine(hbuf, sel.lnFirst + 3, "@ich@#endif /* @sz@ */")SetBufIns(hbuf, sel.lnFirst + 2, StrLen(ich) + StrLen(chTab))}}// Wrap ifdeinef <sz> .. endif around the current selectionmacro IfdefineSz(sz){hwnd = GetCurrentWnd()lnFirst = GetWndSelLnFirst(hwnd)lnLast = GetWndSelLnLast(hwnd)hbuf = GetCurrentBuf()InsBufLine(hbuf, lnFirst, "#ifndef @sz@")InsBufLine(hbuf, lnFirst + 1, "#define @sz@")InsBufLine(hbuf, lnLast + 3, "#endif /* @sz@ */")SetBufIns(hbuf, lnFirst + 2, 0)}/* A U T O E X P A N D *//*------------------------------------------------------------------------- Automatically expands C statements like if, for, while, switch, etc..To use this macro,1. Add this file to your project or your Base project.2. Run the Options->Key Assignments command and assign aconvenient keystroke to the "AutoExpand" command.3. After typing a keyword, press the AutoExpand keystroke to have thestatement expanded. The expanded statement will contain a ### string which represents a field where you are supposed to type more.The ### string is also loaded in to the search pattern so you canuse "Search Forward" to select the next ### field.For example:1. you type "for" + AutoExpand key2. this is inserted:for (###; ###; ###){###}3. and the first ### field is selected.-------------------------------------------------------------------------*//****************************************************************************** * AutoExpand - Automatically expands C statements** DESCRIPTION: - Automatically expands C statements like if, for, while,* switch, etc..** Input:* Output:* Returns:** modification history* --------------------* 01a, 27mar2003, t357 modified* --------------------******************************************************************************/ macro AutoExpand(){// get window, sel, and buffer handleshwnd = GetCurrentWnd()if (hwnd == 0)stopsel = GetWndSel(hwnd)if (sel.ichFirst == 0)stophbuf = GetWndBuf(hwnd)// get line the selection (insertion point) is onszLine = GetBufLine(hbuf, sel.lnFirst);// parse word just to the left of the insertion pointwordinfo = GetWordLeftOfIch(sel.ichFirst, szLine)ln = sel.lnFirst;chTab = CharFromAscii(9)// prepare a new indented blank line to be inserted.// keep white space on left and add a tab to indent.// this preserves the indentation level.ich = 0while (szLine[ich] == ' ' || szLine[ich] == chTab) {ich = ich + 1}szLine = strmid(szLine, 0, ich)sel.lnFirst = sel.lnLastsel.ichFirst = wordinfo.ichsel.ichLim = wordinfo.ich// expand szWord keyword...if (wordinfo.szWord == "if" ||wordinfo.szWord == "while" ||wordinfo.szWord == "elseif"){SetBufSelText(hbuf, " (###)")InsBufLine(hbuf, ln + 1, "@szLine@" # "{");InsBufLine(hbuf, ln + 2, "@szLine@" # chTab);InsBufLine(hbuf, ln + 3, "@szLine@" # "}");}else if (wordinfo.szWord == "for"){SetBufSelText(hbuf, " (###)")InsBufLine(hbuf, ln + 1, "@szLine@" # "{");InsBufLine(hbuf, ln + 2, "@szLine@" # chTab);InsBufLine(hbuf, ln + 3, "@szLine@" # "}");}else if (wordinfo.szWord == "switch"){SetBufSelText(hbuf, " (###)")InsBufLine(hbuf, ln + 1, "@szLine@" # "{")InsBufLine(hbuf, ln + 2, "@szLine@" # "case ")InsBufLine(hbuf, ln + 3, "@szLine@" # chTab)InsBufLine(hbuf, ln + 4, "@szLine@" # chTab # "break;") InsBufLine(hbuf, ln + 5, "@szLine@" # "default:")InsBufLine(hbuf, ln + 6, "@szLine@" # chTab)InsBufLine(hbuf, ln + 7, "@szLine@" # "}")}else if (wordinfo.szWord == "do"){InsBufLine(hbuf, ln + 1, "@szLine@" # "{")InsBufLine(hbuf, ln + 2, "@szLine@" # chTab);InsBufLine(hbuf, ln + 3, "@szLine@" # "} while ();")}else if (wordinfo.szWord == "case"){SetBufSelText(hbuf, " ###")InsBufLine(hbuf, ln + 1, "@szLine@" # chTab)InsBufLine(hbuf, ln + 2, "@szLine@" # chTab # "break;")}elsestopSetWndSel(hwnd, sel)LoadSearchPattern("###", true, false, false);Search_Forward}/* G E T W O R D L E F T O F I C H *//*------------------------------------------------------------------------- Given an index to a character (ich) and a string (sz),return a "wordinfo" record variable that describes thetext word just to the left of the ich.Output:wordinfo.szWord = the word stringwordinfo.ich = the first ich of the wordwordinfo.ichLim = the limit ich of the word-------------------------------------------------------------------------*/ macro GetWordLeftOfIch(ich, sz){wordinfo = "" // create a "wordinfo" structurechTab = CharFromAscii(9)// scan backwords over white space, if anyich = ich - 1;if (ich >= 0)while (sz[ich] == " " || sz[ich] == chTab){ich = ich - 1;if (ich < 0)break;}// scan backwords to start of wordichLim = ich + 1;asciiA = AsciiFromChar("A")asciiZ = AsciiFromChar("Z")while (ich >= 0){ch = toupper(sz[ich])asciiCh = AsciiFromChar(ch)if ((asciiCh < asciiA || asciiCh > asciiZ) && !IsNumber(ch)) break // stop at first non-identifier character ich = ich - 1;}ich = ich + 1wordinfo.szWord = strmid(sz, ich, ichLim)wordinfo.ich = ichwordinfo.ichLim = ichLim;return wordinfo}。
sourceinsight宏配置与使用
![sourceinsight宏配置与使用](https://img.taocdn.com/s3/m/57a700f24693daef5ef73d0a.png)
sourceinsight宏配置与使用指引kaka/赵肖云blog: /tiananma深圳桑菲消费通信有限公司Source insight是一款常用的代码编辑查看管理工具,我们可以利用其本身提供的API函数编写自定义功能的宏,充分体会到它为我们的开发工作带来的便利。
在help,Macro Language Guide中可以看到相关的API:利用上面的API函数编写一些我们开发工作中常用的宏:1,打开基础工程,路径通常为:C:\Documents and Settings\tiananma\My Documents\Source Insight\Projects\Base 2,新建*.em文件,编写自定义的宏,如插入文件头,注释等rebuild projects3,执行project-Æ将自定义的宏加入菜单:optionÆMenu Assignments待加入菜单项或自定义宏准备加入的位置上面的画面中,点Keys…可以同时为其分配快捷键,当然也可以执行optionÆKey Assignments实现经上述两步操作后,我们自定义的宏已加入菜单并已分配快捷键了addNormalComment宏分配的快捷键接下来,我们可以根据个人喜好设置自己的颜色方案(是不是觉得白色的背景让人看得并不舒服)在代码查看主窗口点右键,选菜单Style Properties..,当然也可通过主菜单option ÆStyle Properties…进入如下画面调整各种项目如注释/普通文字的字体/背景色等等。
到此,基本配置过程已完毕,可以导出自己的配置分享给别人使用执行命令option--ÆSave configurations….,会生成一个后缀为CF3的文件。
使用时执行命令option--ÆLoad configurations….待设定项目字体属性加此环境变量。
Source Insight 宏功能快捷用法分享
![Source Insight 宏功能快捷用法分享](https://img.taocdn.com/s3/m/0292d8df6f1aff00bed51e81.png)
Source Insight宏功能使用分享说明:宏文件SO.em中实现了一些编码程中可能会到的功能,如添加文件头、函数说明和宏定义等,使用时能自动添加文件名、函数名和当前日期。
举例说明以上命令的用法:例如现在需要开发一款游戏叫做“Angry Bird”。
1、SO_Input_MyName——输入创建者名字。
点击此命令后弹出提示框,根据提示输入创建者的名字,例如输入“zhicheng”。
2、SO_Input_MyMode——输入模块名称(即所开发的游戏的名称)。
点击此命令弹出提示框,根据提示输入模块的名称,例如输入“Angry Bird”。
3、SO_Input_Macro——输入使用的宏。
根据提示框输入你想使用的宏,例如是初次开发,属于版本1,故输入V1,最终会产生“__SO_Angry Bird_V1__”这样的宏开关。
4、SO_Insert_File_Header_Info——插入头文件信息。
当创建了AngryBird.h和AngryBird.c空文件后,可以点击此命令产生文件相关信息。
对于“.c”文件会产生如下信息:对于“.h”文件则会产生如下这样的信息:5、SO_Insert_Function_Header_Info——插入函数信息。
当写函数时,选中函数名,点击此命令则会在函数头部产生如上信息,可以在描述部分写些描述。
6、SO_Insert_Simple_Comment——将选中的代码部分用“/* */”的方式注释。
当想要将自己写的内容采用“/* */”的方式注释,这选中这些部分并点击此命令。
7、SO_Code_Add——加入你自己的代码8、SO_Code_Remove——将选中的代码部分使用你自己的宏注释掉9、SO_Code_Replace_Or_Modify——将选中的代码部分替换成自己的代码10、SO_Comment_Mark——简单标记修改的记录11、SO_Comment_Block——采用“//”方式注释选中的代码12、SO_Comment_Unblock——取消“//”方式注释的代码在source insight中加入这些指令的步骤:1、打开source insight,Project->Open Project... 打开Base工程(该工程一般在"我的文档/Source Insight/Projects/Base"中),将附件SO.em放入这个目录下。
SourceInsight助手使用说明
![SourceInsight助手使用说明](https://img.taocdn.com/s3/m/6572b01b964bcf84b9d57b47.png)
SourceInsight助手使用说明SourceInsight助手包含了三个有用的Source Insight插件:CodeFavorite(代码收藏夹)、FileInfo(文件信息)、SearchExport(搜索导出). 助手程序下载地址:CodeFavorite(代码收藏夹)可以在代码收藏夹中收藏常用的函数名、宏值名、文件名等内容,并添加备注。
代码收藏夹是Source Insight的符号浏览、书签功能的有效补充。
常用操作:文件->加载:选择符号数据路径,并加载符号->添加符号:添加一条符号记录符号->跳到:在SourceInsight中定位当前选择的符号符号->复制:复制当前选择的符号名SourceInsight调用方法:宏SIH_CodeFavor:打开代码收藏夹软件宏SIH_AddCodeFavor:添加一条符号到代码收藏夹FileInfo(文件信息工具)FileInfo可以查看当前文件的信息,并支持对该文件进行相关的处理(比如调用SVN,ClearCase,BeyondCompare等处理)。
常用操作:浏览文件夹:打开当前文件所在的文件夹,并定位该文件。
文件菜单:调用该文件的资源管理器右键菜单。
SourceInsight调用方法:宏SIH_FileI nfo:打开FileI nfo程序SearchExport(搜索结果导出工具)本工具可以导出SourceInsight搜索结果中的所有文件,并保持文件目录结构。
可以借助本工具,对某个功能的代码进行导出。
常用操作:导出文件:将所有搜索结果中的文件,拷贝到目标目录打开目标目录:打开导出文件所在的目录SourceInsight调用方法:宏SIH_SearchExport:打开Sea rchExport程序。
SourceInsight注释宏及使用说明
![SourceInsight注释宏及使用说明](https://img.taocdn.com/s3/m/5dcc1799d4d8d15abe234eed.png)
SourceInsight注释宏使用说明一、范围限制本文件描述了如何在SourceInsight中通过快捷键自动添加文件头注释和函数头注释。
二、注释宏显示格式文件头注释,以下为自动生成的模板。
仅需文件创建者补充文件描述Description: -/******************************************************************************Copyright (C), 2010-2012, Skyworth Digital Tech. Co., Ltd.FileName: ca_card_info_window.cDescription: -modification history--------------------Ceci 2010/04/12 v1.0 create this file******************************************************************************/函数头注释,以下为自动生成的模板。
仅需函数创建者补充返回值含义@return和简要说明@brief -/***********************************************************//*** @param hWnd* @param message* @param wParam* @param lParam** @return* @brief -* @author Ceci @date 2010/04/12************************************************************/static LRESULT OnKeyDown(HWND hWnd, UINT message,WPARAM wParam,LPARAM lParam)三、使用说明1)导入宏。
Source_Insight教程及技巧
![Source_Insight教程及技巧](https://img.taocdn.com/s3/m/8b4dfb59312b3169a451a4a7.png)
Source Insight使用简单说明Source Insight是一个功能十分强大、使用也很方便的程序编辑器。
它内置对C/C++、Java 甚至x86汇编语言程序的解析,在你编程时提供有用的函数、宏、参数等提示,因而,Source Insight正在国际、国内众多的IT公司使用。
Source Insight功能强大,它的窗口、菜单初一看来似乎很多,所以刚刚开始使用Source Insight的朋友往往觉得很麻烦。
这里本人结合自己的使用经验,简单说说Source Insight的使用。
(本文以McuSystem为例,Source Insight 以3.0版本为例。
其他版本的Source Insight 大同小异)和众多程序编辑环境一样,Source Insight中也有Project。
建立工程的方法很简单:1.打开Source Insight,选择Project菜单->New Project;2.在出现的对话框中选择并选择存放工程文件的文件夹,输入工程名(比如McuSystem),点击“保存”;3.又出现一个对话框,在Configuration部分可以选择这个工程使用全局配置文件还是自己单独的配置文件,这个无所谓,(不过最好选择单独的配置文件),再点击“OK”;4.再次出现一个对话框,这是选择文件添加到Project中,通过左边的树状图找到你想添加的文件,点击Add就可以了(如图1)。
你可以将不通路径下的文件添加到同一个工程中,而不用拷贝源文件。
选择完后点击Close;图1这样工程就建立好了,文件列表就出现在Project Window中(如果Project Window被关闭了,可以选中View菜单->Project Window)。
点击Project Window中任意一个文件,文件的内容出现在中央的编辑区了。
(如图2)图2如果工程已经建立好了,想要打开、关闭、删除工程,直接点击Project菜单下相应的选项就可以了,这里就不多说了。
SourceInsight使用指南
![SourceInsight使用指南](https://img.taocdn.com/s3/m/8155de7002768e9951e7385e.png)
Source Insight使用指南目录1.Source Insight 基本设置 (3)1.1字体设置 (3)1.2自动缩进设置 (3)1.3其它设置 (4)2.Source Insight中的宏 (5)2.1使用宏 (5)2.2指定快捷键 (6)3.Source Insight中的自定义命令 (6)3.1如何自定义命令 (6)3.2指定快捷键 (7)3.3正则表达式语法 (7)3.4集成编译器 (8)3.5集成版本控制工具 (10)4.其它 (11)4.1特殊的注释 (11)1.Source Insight 基本设置1.1字体设置Option-〉Document Options 文档设置。
Screen Fonts 设置显示字体。
推荐使用等宽字体,如“Courier”,这样在代码对齐时容易处理,但中文字体显示有锯齿。
使用“宋体”字时,代码可能存在对齐问题。
1.2自动缩进设置Option-〉Document Options-〉Auto Indent 自动缩进设置。
详细缩进样式请参考Source Insight 帮助的Command Reference-> Document Options-〉Auto Indenting。
Auto Indent Type 选择 SmartSmart Indent Options 两个复选框都不要选择缩进后样式如:if(){}1.3其它设置Editing Options 编辑器设置Show line numbers 显示行号Show right margin 显示右边界线(边界线显示在Margin width 处)Tab width TAB键宽度,设置为 4Margin width 页空白宽度,页面右边界线的位置,设置为80。
选择后在编辑窗口右侧设置的宽度处出现分割线Show page breaks 显示页面分割线,选择后在编辑窗口出现打印页分割线●如果编辑窗口中的中文字符中间分割过大或者出现对齐问题时,请尝试如下设置:Options-> Preferences-> Display-> Spacing选择Layout tabstops using monospace calculations 和Layout spaces using monospace calculations●定制Open命令Options-> Preferences-> Files-〉Custom “Open” Command2.Source Insight中的宏2.1使用宏首先关闭当前使用中的Source Insight,然后复制macro\utils.em 到我的文档\SourceInsight\Projects\Base,覆盖原有的文件。
SourceInsightMacro
![SourceInsightMacro](https://img.taocdn.com/s3/m/8a367291bdeb19e8b8f67c1cfad6195f312be8a6.png)
Source insight 宏的使用作者:颜庆打开source insight 的base工程(菜单Project -> Open Project),其中一个文件叫utils.em ,在这个文件里添加你自己的宏,然后在菜单option/key assignments中给相应的宏分配快捷键,就可以使用source insight 宏了。
下面是一些具体的宏的介绍。
autoexpand把下面的代码拷贝到source insight的base工程中的utils.em文件中,然后在你自己的工程中,打开option/key assignments, 为autoexpand 这个宏分配快捷键,这里用的是ctrl + 1使用:在source insight 中先键入一个关键字,比如for,然后按下你的快捷键,宏就会帮你展开相应的代码,如下图所示,这时你可以通过F3, F4跳到下一个“###”insheaderdef这个source insight宏可以自动给头文件加上头文件宏,它会自动获取文件名,自动添加与文件名对应的宏。
执行insheaderdef宏之前代码如下执行insheaderdef宏之后代码如下InsertIfdef这个source insight宏可以自动给一段选中的代码加上宏开关执行InsertIfdef宏之前选中若干行代码执行InsertIfdef宏之后会有提示框让你输入宏,我们输入AEE_SIMULA TOR然后回车,代码如下:MakeCode2Comments把选中的代码前面加双斜杠“//”执行宏之后:MakeComments2Code与上面一个宏的作用刚好相反NeateanVarDeclaration整理变量声明,让变量对齐,先选中若干行:执行之后:注意:这个宏默认地通过空格作为分隔符来对齐每一部分;另外,你要保证你的source insight 使用的字体是等宽字体Courier New,才能让字符对齐修改字体方法:options -> Document options -> Screen Fontsinsfunheader这个宏可以给函数自动加函数头注释先让光标停留在某个函数体内:执行宏,会弹出输入框,让你输入函数描述:点OK之后:/*附上宏定义文件*//* t357.em - a small collection of useful editing macros *//****************************************************************************** * InsFileHeader -- insert the information of file** modification history* --------------------* 01a, 23mar2003, added DESCRIPTION by t357* 01a, 05mar2003, t357 written* --------------------******************************************************************************/ /*-------------------------------------------------------------------------I N S E R T H E A D E RInserts a comment header block at the top of the current function.This actually works on any type of symbol, not just functions.To use this, define an environment variable "szMyName" and set itto your email name. eg. set szMyName=raygr-------------------------------------------------------------------------*/macro InsFileHeader(){/*######################################################################################################################### Set szMyName variable to your name ############### for example szMyName = "t357" ##########################################################################################################################*/szMyName = ""// Get current timeszTime = GetSysTime(1)Day = szTime.DayMonth = szTime.MonthYear = szTime.Yearif (Day < 10)szDay = "0@Day@"elseszDay = DayszMonth = NumToName(Month)hBuf = GetCurrentBuf()szpathName = GetBufName(hBuf)szfileName = GetFileName(szpathName)nlength = StrLen(szfileName)szInf = Ask("Enter the information of file:")szDescription = Ask("Enter the description of file:")hbuf = GetCurrentBuf()// begin assembling the title stringInsBufLine(hbuf, 0,"/******************************************************************************") InsBufLine(hbuf, 1, " * @szfileName@ - @szInf@")InsBufLine(hbuf, 2, " * ")InsBufLine(hbuf, 3, " * Copyright 1998-2003 Guangzhou Gaoke Communication Technology Co.,Ltd.")InsBufLine(hbuf, 4, " * ")InsBufLine(hbuf, 5, " * DESCRIPTION: - ")InsBufLine(hbuf, 6, " * @szDescription@")InsBufLine(hbuf, 7, " * modification history")InsBufLine(hbuf, 8, " * --------------------")InsBufLine(hbuf, 9, " * 01a, @szDay@@szMonth@@Year@, @szMyName@ written") InsBufLine(hbuf, 10, " * --------------------")InsBufLine(hbuf, 11, "******************************************************************************/")// put the insertion point inside the header commentSetBufIns(hbuf, 1, nlength + strlen(szInf) + 8)}/****************************************************************************** * InsFunHeader -- insert function's information** modification history* --------------------* 01a, 23mar2003, added DESCRIPTION by t357* 01a, 05mar2003, t357 written* --------------------******************************************************************************/ macro InsFunHeader(){// Get the owner's name from the environment variable: szMyName.// If the variable doesn't exist, then the owner field is skipped./*######################################################################################################################### Set szMyName variable to your name ############### for example szMyName = "t357" ##########################################################################################################################*/szMyName = ""// 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)// Get current timeszTime = GetSysTime(1)Day = szTime.DayMonth = szTime.MonthYear = szTime.Yearif (Day < 10)szDay = "0@Day@"elseszDay = DayszMonth = NumToName(Month)szInf = Ask("Enter the information of function:")szDescription = Ask("Enter the description of function:")// begin assembling the title stringsz ="/******************************************************************************" InsBufLine(hbuf, ln, sz)InsBufLine(hbuf, ln + 1, " * @szFunc@ - @szInf@")InsBufLine(hbuf, ln + 2, " * DESCRIPTION: - ")InsBufLine(hbuf, ln + 3, " * @szDescription@ ")// remove by t357. CutWord(szDescription)InsBufLine(hbuf, ln + 4, " * Input: ")InsBufLine(hbuf, ln + 5, " * Output: ")InsBufLine(hbuf, ln + 6, " * Returns: ")InsBufLine(hbuf, ln + 7, " * ")InsBufLine(hbuf, ln + 8, " * modification history")InsBufLine(hbuf, ln + 9, " * --------------------")InsBufLine(hbuf, ln + 10, " * 01a, @szDay@@szMonth@@Year@, @szMyName@ written") InsBufLine(hbuf, ln + 11, " * --------------------")InsBufLine(hbuf, ln + 12, "******************************************************************************/")// put the insertion point inside the header commentSetBufIns(hbuf, ln + 1, strlen(szFunc) + strlen(szInf) + 8)}/****************************************************************************** * NumToName -- change the month number to name** modification history* --------------------* 01a, 05mar2003, t357 written* --------------------******************************************************************************/ macro NumToName(Month){if (Month == 1)return "jan"if (Month == 2)return "feb"if (Month == 3)return "mar"if (Month == 4)return "apr"if (Month == 5)return "may"if (Month == 6)return "jun"if (Month == 7)return "jul"if (Month == 8)return "aug"if (Month == 9)return "sep"if (Month == 10)return "oct"if (Month == 11)return "nov"if (Month == 12)return "dec"}/****************************************************************************** * CutWord -- auto newline** modification history* --------------------* 01a, 24mar2003, t357 fix some bug* 01a, 05mar2003, t357 written* --------------------******************************************************************************/ macro CutWord(ncurLine, szInf){LENGTH = 63nlength = StrLen(szInf)i = 0 /* loop control */begin = 0 /* first character's index of current line */pre = 0 /* preceding word's index */hbuf = GetCurrentBuf()// nline = GetBufLnCur()while (i < nlength){/* remove by t357nrow = 0sz = ""while (nrow < 80){if (nlength < 0)breaksz = Cat(sz, szInf[nrow])nrow = nrow + 1nlength = nlength - 1}InsBufLine(hbuf, nline, sz)szInf = szInf[nrow]}*/c = szInf[i]if (" " == @c@ && (i - b < LENGTH)){pre = i}else if (" " == @c@){szOutput = ""k = begin /* loop control */while (k < pre){szOutput = Cat(szOutput, szInf[k]) k = k + 1}InsBufLine(hbuf, ncurLine, sz)ncurLine = ncurLine + 1begin = pre}i = i + 1}if (h != i - 1){szOutput = ""k = begin /* loop control */while (k < pre){szOutput = Cat(szOutput, szInf[k])k = k + 1}InsBufLine(hbuf, ncurLine, sz)ncurLine = ncurLine + 1}}/****************************************************************************** * GetFileName -- get the filename only from the path** modification history* --------------------* 01a, 05mar2003, t357 written* --------------------******************************************************************************/ macro GetFileName(pathName){nlength = strlen(pathName)i = nlength - 1name = ""while (i + 1){ch = pathName[i]if ("\\" == "@ch@")breaki = i - 1}i = i + 1while (i < nlength){name = cat(name, pathName[i])i = i + 1}return name}/****************************************************************************** * ReturnTrueOrFalse -- Inserts "Returns True or False" at the current line** modification history* --------------------* 01a, 05mar2003, t357 written* --------------------******************************************************************************/ macro ReturnTrueOrFalse(){szReturns = "return True if successful or False if errors."hbuf = GetCurrentBuf()ln = GetBufLnCur(hbuf)szCurLine = GetBufLine(hbuf, ln)DelBufLine(hbuf, ln)InsBufLine(hbuf, ln, "@szCurLine@@szReturns@")SetBufIns(hbuf, ln, StrLen(szReturns) + StrLen(szCurLine) + 3)}/****************************************************************************** * InsHeaderDef -- Inserts the header define in the headerfile** modification history* --------------------* 01a, 05mar2003, t357 written* --------------------******************************************************************************/ macro InsHeaderDef(){hBuf = GetCurrentBuf()szpathName = GetBufName(hBuf)szfileName = GetFileName(szpathName)szfileName = toupper(szfileName)nlength = StrLen(szfileName)i = 0 /* loop control */szdefineName = ""while (i < nlength){if (szfileName[i] == ".")szdefineName = Cat(szdefineName, "_")elseszdefineName = Cat(szdefineName, szfileName[i])i = i + 1}szdefineName = Cat("_", szdefineName)IfdefineSz(szdefineName)}/****************************************************************************** * PrintDate - print date on where the cursor point to* DESCRIPTION: -** Input:* Output:* Returns:** modification history* --------------------* 01a, 23mar2003, t357 written* --------------------******************************************************************************/ macro PrintDate(){szTime = GetSysTime(1)Day = szTime.DayMonth = szTime.MonthYear = szTime.Yearif (Day < 10)szDay = "0@Day@"elseszDay = DayszMonth = NumToName(Month)hbuf = GetCurrentBuf()ln = GetBufLnCur(hbuf)szCurLine = GetBufLine(hbuf, ln)DelBufLine(hbuf, ln)InsBufLine(hbuf, ln, "@szCurLine@ @szDay@@szMonth@@Year@")SetBufIns(hbuf, ln, StrLen(szCurLine) + 10)}// Ask user for ifdef condition and wrap it around current// selection.// 28mar2003, modified by t357.// 26mar2003, modified by t357.macro InsIfdef(){sz = Ask("Enter ifdef condition:")if (sz != ""){// IfdefSz(sz);hwnd = GetCurrentWnd()sel = GetWndSel(hwnd)hbuf = GetWndBuf(hwnd)// get line the selection (insertion point) is onszLine = GetBufLine(hbuf, sel.lnFirst - 1);chTab = CharFromAscii(9)// prepare a new indented blank line to be inserted.// keep white space on left and add a tab to indent.// this preserves the indentation level.i = 0 /* loop control */ich = ""while (szLine[i] == " " || szLine[i] == chTab){ich = Cat(ich, szLine[i])i = i + 1}InsBufLine(hbuf, sel.lnFirst, "")InsBufLine(hbuf, sel.lnFirst + 1, "@ich@#ifdef @sz@")InsBufLine(hbuf, sel.lnFirst + 2, "@ich@" # chTab)InsBufLine(hbuf, sel.lnFirst + 3, "@ich@#endif /* @sz@ */")SetBufIns(hbuf, sel.lnFirst + 2, StrLen(ich) + StrLen(chTab))}}// Wrap ifdeinef <sz> .. endif around the current selectionmacro IfdefineSz(sz){hwnd = GetCurrentWnd()lnFirst = GetWndSelLnFirst(hwnd)lnLast = GetWndSelLnLast(hwnd)hbuf = GetCurrentBuf()InsBufLine(hbuf, lnFirst, "#ifndef @sz@")InsBufLine(hbuf, lnFirst + 1, "#define @sz@")InsBufLine(hbuf, lnLast + 3, "#endif /* @sz@ */")SetBufIns(hbuf, lnFirst + 2, 0)}/* A U T O E X P A N D *//*------------------------------------------------------------------------- Automatically expands C statements like if, for, while, switch, etc..To use this macro,1. Add this file to your project or your Base project.2. Run the Options->Key Assignments command and assign aconvenient keystroke to the "AutoExpand" command.3. After typing a keyword, press the AutoExpand keystroke to have thestatement expanded. The expanded statement will contain a ### stringwhich represents a field where you are supposed to type more.The ### string is also loaded in to the search pattern so you canuse "Search Forward" to select the next ### field.For example:1. you type "for" + AutoExpand key2. this is inserted:for (###; ###; ###){###}3. and the first ### field is selected.-------------------------------------------------------------------------*//****************************************************************************** * AutoExpand - Automatically expands C statements** DESCRIPTION: - Automatically expands C statements like if, for, while,* switch, etc..** Input:* Output:* Returns:** modification history* --------------------* 01a, 27mar2003, t357 modified* --------------------******************************************************************************/ macro AutoExpand(){// get window, sel, and buffer handleshwnd = GetCurrentWnd()if (hwnd == 0)stopsel = GetWndSel(hwnd)if (sel.ichFirst == 0)stophbuf = GetWndBuf(hwnd)// get line the selection (insertion point) is onszLine = GetBufLine(hbuf, sel.lnFirst);// parse word just to the left of the insertion pointwordinfo = GetWordLeftOfIch(sel.ichFirst, szLine)ln = sel.lnFirst;chTab = CharFromAscii(9)// prepare a new indented blank line to be inserted.// keep white space on left and add a tab to indent.// this preserves the indentation level.ich = 0while (szLine[ich] == ' ' || szLine[ich] == chTab){ich = ich + 1}szLine = strmid(szLine, 0, ich)sel.lnFirst = sel.lnLastsel.ichFirst = wordinfo.ichsel.ichLim = wordinfo.ich// expand szWord keyword...if (wordinfo.szWord == "if" ||wordinfo.szWord == "while" ||wordinfo.szWord == "elseif"){SetBufSelText(hbuf, " (###)")InsBufLine(hbuf, ln + 1, "@szLine@" # "{");InsBufLine(hbuf, ln + 2, "@szLine@" # chTab);InsBufLine(hbuf, ln + 3, "@szLine@" # "}");}else if (wordinfo.szWord == "for"){SetBufSelText(hbuf, " (###)")InsBufLine(hbuf, ln + 1, "@szLine@" # "{");InsBufLine(hbuf, ln + 2, "@szLine@" # chTab);InsBufLine(hbuf, ln + 3, "@szLine@" # "}");}else if (wordinfo.szWord == "switch"){SetBufSelText(hbuf, " (###)")InsBufLine(hbuf, ln + 1, "@szLine@" # "{")InsBufLine(hbuf, ln + 2, "@szLine@" # "case ")InsBufLine(hbuf, ln + 3, "@szLine@" # chTab)InsBufLine(hbuf, ln + 4, "@szLine@" # chTab # "break;") InsBufLine(hbuf, ln + 5, "@szLine@" # "default:")InsBufLine(hbuf, ln + 6, "@szLine@" # chTab)InsBufLine(hbuf, ln + 7, "@szLine@" # "}")}else if (wordinfo.szWord == "do"){InsBufLine(hbuf, ln + 1, "@szLine@" # "{")InsBufLine(hbuf, ln + 2, "@szLine@" # chTab);InsBufLine(hbuf, ln + 3, "@szLine@" # "} while ();")}else if (wordinfo.szWord == "case"){SetBufSelText(hbuf, " ###")InsBufLine(hbuf, ln + 1, "@szLine@" # chTab)InsBufLine(hbuf, ln + 2, "@szLine@" # chTab # "break;")}elsestopSetWndSel(hwnd, sel)LoadSearchPattern("###", true, false, false);Search_Forward}/* G E T W O R D L E F T O F I C H *//*------------------------------------------------------------------------- Given an index to a character (ich) and a string (sz),return a "wordinfo" record variable that describes thetext word just to the left of the ich.Output:wordinfo.szWord = the word stringwordinfo.ich = the first ich of the wordwordinfo.ichLim = the limit ich of the word-------------------------------------------------------------------------*/ macro GetWordLeftOfIch(ich, sz){wordinfo = "" // create a "wordinfo" structurechTab = CharFromAscii(9)// scan backwords over white space, if anyich = ich - 1;if (ich >= 0)while (sz[ich] == " " || sz[ich] == chTab){ich = ich - 1;if (ich < 0)break;}// scan backwords to start of wordichLim = ich + 1;asciiA = AsciiFromChar("A")asciiZ = AsciiFromChar("Z")while (ich >= 0){ch = toupper(sz[ich])asciiCh = AsciiFromChar(ch)if ((asciiCh < asciiA || asciiCh > asciiZ) && !IsNumber(ch)) break // stop at first non-identifier characterich = ich - 1;}ich = ich + 1wordinfo.szWord = strmid(sz, ich, ichLim)wordinfo.ich = ichwordinfo.ichLim = ichLim;return wordinfo}。
Source insight使用说明
![Source insight使用说明](https://img.taocdn.com/s3/m/68cbf0c184254b35eefd34d0.png)
上图为各个确认按钮 多文件替换 选择 Search/Replace Files 或按 Ctrl+Shift+H 组合键,在弹出的
Replace Files 窗口进行查找操作。 除了增加 New 框(替换后的内容) 外, 其余均与 Search Files 窗口相同, 可参照查找部分的说明进行操 作。
选上“View --> Draft View” ,就可以让每个字符的宽度一致了。快 捷键是 "Alt + F12" 由于 source insight 默认字体是 verdana 字体, 是一种不等宽字体,
推荐使用等宽字体 courier 和 courier new 两种。 (4) 解决缩进问题 不让{和}缩进:选择 Options->Document Options 页面,点击其内的 Auto Indent 按钮,在弹出的 Auto Indenting 窗口中,勾选 Simple 并 去掉 Indent Open Brace 和 Indent Close Brace。 Tab 缩进:Options-> Document Options->Editing Options,勾选 Expand tabs,并设置 Tab width。
4. Symbol Window:可以快速在本文件中定位某一个函数、变量、宏等 5. Project WWindow:自动显示选中变量、函数、宏定义或者多个定义列表 7. Relation Window:当编辑区中选中某个函数时,Relation Window 就 出现了该函数和该函数中被调用的其它函数的关系图,如下图所示。 8. 当编辑区中选中某个宏、变量时:Relation Window 就出现了该宏、变 量在整个工程中被引用的关系图 三、 新建工程与导入文件
SourceInsight的宏语言使用
![SourceInsight的宏语言使用](https://img.taocdn.com/s3/m/70d9d19851e79b89680226b5.png)
Source Insight使用进阶篇——宏语言使用Source Insight是阅读和编写代码的好东东,基本上也算得上是经典之作了,虽然还有一点点小bug,不过对于我们这些C程序员来说可是一旦拥有别无所求。
但是大家可能很少用到Source Insight的宏语言(Source Insight macro language)。
Source Insight中的宏语言类同于MS Office中的VBA,也具有程序化执行用户预定义操作的通用宏语言功能。
VBA功能的强大就不用多作说明了,而Source Insight的宏语言也不逊色。
以下就以项目中一次实际应用为例进行说明。
Source Insight宏语言语法和C语言类似,包括:顺序、分支和循环的程序结构。
同时宏语言可以实现字符操作、文件操作、控制Source Insight文件窗口、访问symbol列表和symbol类型、查找替换等访问控制操作。
在一个移植类项目中,遇到了一个代码整体移植的需求。
其中,有一项主要工作为代码复制及主要symbol替换。
即给绝大部分全局函数和全局变量追加前缀以便与移植前区别,例如:函数”extern void func();”替换为”extern void prefix_func();”,函数和变量的声明、定义和使用都需进行替换。
项目需求示意图如图1:原有代码需要新生成的代码图 1 项目需求示意图这项工作人工进行需要找出需替换的symbol,再做替换操作。
由于代码量较大(约几十万行代码总量,其中有5000多个symbol需要替换),人工替换非常繁琐,又易出错。
一时又找不到合适的工具,这时我们想到了Source Insight的宏语言。
通过Source Insight 的宏语言,访问Source Insight的symbol列表,可以区分函数,全局变量,局部变量等C语言语法上的类型,还可以自动执行替换操作。
及保证了效率,又保证了替换的准确度。
Source_Insight使用手册
![Source_Insight使用手册](https://img.taocdn.com/s3/m/c79445ca8bd63186bcebbc64.png)
另:1、使用锁定开关; 2、可定义Refresh快捷键(Alt+R)。
请看自定义快捷键演示。
Symbol Window
火龙果整理
该菜单点击后会将当前查看的工程文件中的符号表 显示到Relation Window窗口中。 这个一般建议按照Sort Symbols By Line来进行排 列,这样对大家培养函数功能的实现分配和接口规范性 的分块顺序设计思想比较有用。
请看演示。
hi
火龙果整理
该宏功能用于添加修改历史记录的注释。 使用方法: 在一个函数头注释的最后一个空白行首处输入hi后 使用Ctrl+Enter键进行自动扩展,则弹出对话框提示用 户输入修改内容。
请看演示。
HeaderFileCreate
该宏功能用于自动创建一个.C源文件的头文件。
火龙果整理 uml.Biblioteka
3.使用Chnchar.em
该文件主要解决了source insight软件本身对中国汉字 的支持问题,即:在我们的代码中添加了中文注释后, 若需要修改或者删除注释的汉字,左移右移或者使用退 格键delete键时,光标只能一次跳动一个字符,而汉字 都是两个字符的。有时很容易出现删除了半个汉字而导 致所有的注释都是乱码的情况。
火龙果整理
使用Source Insight提高工作效率
--让编程更简单更高效更规范
火龙果整理
序言(废话)
• 基于个人以前的工作经验,本篇从三个方面来简单和 大家交流一下Source Insight的一些功能。
• Source Insight是一个功能非常强大的软件开发工具, 使用该软件的这些功能可以极大的提高我们开发人员 的工作效率,而且在项目开发工程中可以提高我们的 代码质量的编程规范,同时有利于后期测试问题和网 上问题的BUG修改维护。
SourceInsight实用技巧
![SourceInsight实用技巧](https://img.taocdn.com/s3/m/72599b685901020207409ce0.png)
一、Source Insight实用技巧:Source Insight(下文的SI指的也是它)就是这样的一个东西:Windows下开发人员的至爱,功能强大,界面友好。
支持语法高亮、符号跳转,还支持函数调用关系图显示。
这是一个专业的编程环境,很多大公司都是使用它的。
这个编辑器除支持完善的自定义功能外,几乎所有配置都能作个性化配置。
除此之外,它本身带有一套功能强大的宏语言(Macro Language),借助这种语言可以很方便的编程实现各种特殊功能,非一般编辑器所能比拟。
查找功能支持得也很不错。
虽然在工程较大时,查找起来有点慢。
但是它除了一般编辑器所支持的普通字符串查找、正则表达式查找外,还能支持关键字查找-这种方式比前两者快得多,也算是一个弥补。
不足之处是列模式较弱,对中文支持有缺陷。
显然,它也像其它任何东西一样的,同时具有优点和缺点的本性的,究竟如何,且听我一一道来。
官网下载:序列号(Serial):(任选其一)SI3US-279028-11281SI3US-772862-51931SI3US-465643-84290SI3US-176526-66007SI3US-060062-282511??开胃菜-初级应用1.1??选择美丽的界面享受工作虽然不能以貌取人,但似乎从来没有人责备以貌取软件的。
SI的华丽界面,绝对符合现代花花世界的人的审美趣味。
在SI中,我们可以轻松地把各种类型关键字、变量、标志符、函数、宏、注释等定义为不同的颜色和显示方式(正体或斜体、加粗或正常、加下划线、放大显示等),总有一种方式能让我们一眼就能分辨出这个标识是什么。
1.1.1??字体选择在SI中样式是可以被继承,如果要从根本上改变字体,最简单的方式就是直接修改根样式中的字体,因为其它样式都会由此继承而来。
选择 Options/Document Options页面内的Font Options中的Screen Fonts字体,即可改变根样式中的字体。
SourceInsightComment使用说明
![SourceInsightComment使用说明](https://img.taocdn.com/s3/m/54c059ca08a1284ac8504321.png)
SourceInsightComment使用说明我们平时写程序或者修改代码的时候,经常为写注释而烦恼。
不写吧,别人看代码不容易理解,自己要不了多久也会忘记;写吧,又费时又费力,常常为统一、调整注释格式花费很多时间和精力。
其实,写注释是很好的编程习惯,它不仅可以使看程序的人容易理解,也会使我们写程序的人思路更加清晰。
当然,它的确需要我们多花一些时间,不过我们可以想办法尽量减少写注释的时间,达到事半功倍。
很多人写程序都喜欢用Source Insight。
利用Source Insight中的宏可以自动添加文件头、函数名、日期等,也可以自动插入我们希望的注释格式,大大减少我们写注释的时间。
使用说明:1.打开Source Insight的Base工程,通常在C:\Documents and Settings\用户名\MyDocuments\Source Insight\Projects\Base中。
2.将SourceInsightComment.em拷贝到Base所在目录中,并添加进Base工程。
SourceInsightComment.em中定义了一些宏操作,语法比较简单,大家可以根据自己的需要修改。
3.点击菜单Project->Rebuild Project,出现如下对话框,选择“Re-Create …”,按OK键,之后出现的对话框依次选择“是”、“确定”,就完成了Base工程的编译。
4.为了方便使用,我们可以将相关操作添加进菜单,如下图:●点击菜单Options->Menu Assignment,在出现的对话框中,在Menu中选择某个菜单(如Work),在Command中输入Macro,所有Base中定义了的宏都会出现在下面的列表中,包括SourceInsightComment.em中定义的宏。
●选中某个宏,然后在Menu Contents中选中”end of menu”,然后点击”Insert”。
Source Insight使用教程
![Source Insight使用教程](https://img.taocdn.com/s3/m/0229844dc850ad02de80418a.png)
Source_Insight使用教程作为一个开放源代码的操作系统,Linux附带的源代码库使得广大爱好者有了一个广泛学习、深入钻研的机会,特别是 Linux内核的组织极为复杂,同时,又不能像windows平台的程序一样,可以使用集成开发环境通过察看变量和函数,甚至设置断点、单步运行、调试等手段来弄清楚整个程序的组织结构,使得Linux内核源代码的阅读变得尤为困难。
当然Linux下的vim和emacs编辑程序并不是没有提供变量、函数搜索,彩色显示程序语句等功能。
它们的功能是非常强大的。
比如,vim和emacs就各自内嵌了一个标记程序,分别叫做ctag 和etag,通过配置这两个程序,也可以实现功能强大的函数变量搜索功能,但是由于其配置复杂,linux附带的有关资料也不是很详细,而且,即使建立好标记库,要实现代码彩色显示功能,仍然需要进一步的配置(在另一片文章,我将会讲述如何配置这些功能),同时,对于大多数爱好者来说,可能还不能熟练使用vim和 emacs那些功能比较强大的命令和快捷键。
为了方便的学习Linux源程序,我们不妨回到我们熟悉的window环境下,也算是“师以长夷以制夷”吧。
但是在Window平台上,使用一些常见的集成开发环境,效果也不是很理想,比如难以将所有的文件加进去,查找速度缓慢,对于非Windows 平台的函数不能彩色显示。
于是笔者通过在互联网上搜索,终于找到了一个强大的源代码编辑器,它的卓越性能使得学习Linux内核源代码的难度大大降低,这便是Source Insight3.0,它是一个Windows平台下的共享软件,由于Source Insight是一个Windows平台的应用软件,所以首先要通过相应手段把Linux系统上的程序源代码弄到Windows平台下,这一点可以通过在 linux平台上将/usr/src目录下的文件拷贝到Windows平台的分区上,或者从网上光盘直接拷贝文件到Windows平台的分区来实现。
sourceInsight使用大全
![sourceInsight使用大全](https://img.taocdn.com/s3/m/9f3f8fee5ebfc77da26925c52cc58bd6318693aa.png)
sourceInsight使用大全1、背景色选择要改变背景色Options->preference->windows background->color设置背景色2、解决字符等宽对齐问题。
SIS默认字体是VERDANA,很漂亮。
这网页上应该也是用的VERDANA字体。
但由于美观的缘故,VERDANA字体是不等宽的。
比如下面两行llllllllllMMMMMMMMMM同样10个字符,长度差多了.用VERDANA来看程序,有些本应该对齐的就歪了。
解放方法是使用等宽的字体,但肯定比较丑。
比较推荐的是用Courier New。
3、解决TAB键缩进问题Options-> Document Options里面的右下角Editing Options 栏里,把Expand tabs勾起来,然后确定。
OK,现在TAB键的缩进和四个空格的缩进在SIS里面看起来就对齐咯4、SI中的自动对齐设置:在C程序里, 如果遇到行末没有分号的语句,如IF, WHILE, SWITCH 等, 写到该行末按回车,则新行自动相对上一行缩进两列。
Option->Document option下的Auto Indient中Auto Indient Type有三种类型None,Simple,Smart。
个人推荐选用Simple类型。
5、向项目中添加文件时,只添加特定类型的文件(文件类型过滤器)编辑汇编代码时,在SIS里建立PROJECT并ADD TREE的时候,根据默认设置并不会把该TREE里面所有汇编文件都包含进来只加了.inc和.asm后缀的,.s后缀的没有。
而且用SIS打开.s的文件,一片黑白没有色彩,感觉回到DOS的EDIT时代了……解决方法是在Options->Document Options里面,点左上的Document Type下拉菜单,选择x86 Asm Source File,然后在右边的File filter里*.asm;*.inc;的后面加上*.s;接着CLOSE就可以了。
SOURCEINSIGHT应用技巧与宏功能
![SOURCEINSIGHT应用技巧与宏功能](https://img.taocdn.com/s3/m/c622442e3169a4517723a386.png)
目录1 简介 (3)2 搭建我们的SI环境 (3)2.1 搭建步骤 (3)2.2 说明 (4)3 应用技巧 (4)3.1 初级应用技巧 (4)3.1.1 解决字体不等宽与对齐的问题 (4)3.1.2 把TAB变成4个空格 (4)3.1.3 更改背景色 (5)3.1.4 自动对齐设置: (5)3.1.5 显示坐标 (5)3.1.6 创建快捷键快乐工作 (5)3.2 中级应用技巧 (6)3.2.1 查找 (6)3.2.2 替换 (7)3.2.3 列操作 (7)3.2.4 Edit Condition (7)3.3 高级应用技巧 (8)3.3.1 Source Link (8)3.3.2 智能重命名(Smart Rename) (9)3.3.3 Renumber (9)3.3.4 SI中正则表达式 (9)4 Quicker宏在SI中的使用 (10)4.1 如何配置 Quicker 宏 (11)4.2 几个常用的 Quicker 宏 (11)4.2.1 标准说明生成 (11)4.2.2 代码修改注释 (12)4.2.3 其余几个常用宏 (14)5 附录 (17)5.1 SI默认快捷键汇总 (17)5.2 推荐格式 (21)6 参考文献 (21)7 联系方式 (21)1 简介套用下网上有人对SI(即Source Insight)的评价:Windows下开发人员的至爱,功能强大,界面友好。
支持语法高亮、符号跳转,还支持函数调用关系图显示。
这是一个专业的编程环境,很多大公司都是使用它的。
这个编辑器除支持完善的自定义功能外,几乎所有配置都能作个性化配置。
除此之外,它本身带有一套功能强大的宏语言(Macro Language),借助这种语言可以很方便的编程实现各种特殊功能,非一般编辑器所能比拟。
查找功能支持得也很不错。
虽然在工程较大时,查找起来有点慢。
但是它除了一般编辑器所支持的普通字符串查找、正则表达式查找外,还能支持关键字查找-这种方式比前两者快得多,也算是一个弥补。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Source Insight使用进阶篇——宏语言使用Source Insight是阅读和编写代码的好东东,基本上也算得上是经典之作了,虽然还有一点点小bug,不过对于我们这些C程序员来说可是一旦拥有别无所求。
但是大家可能很少用到Source Insight的宏语言(Source Insight macro language)。
Source Insight中的宏语言类同于MS Office中的VBA,也具有程序化执行用户预定义操作的通用宏语言功能。
VBA功能的强大就不用多作说明了,而Source Insight的宏语言也不逊色。
以下就以项目中一次实际应用为例进行说明。
Source Insight宏语言语法和C语言类似,包括:顺序、分支和循环的程序结构。
同时宏语言可以实现字符操作、文件操作、控制Source Insight文件窗口、访问symbol列表和symbol类型、查找替换等访问控制操作。
在一个移植类项目中,遇到了一个代码整体移植的需求。
其中,有一项主要工作为代码复制及主要symbol替换。
即给绝大部分全局函数和全局变量追加前缀以便与移植前区别,例如:函数”extern void func();”替换为”extern void prefix_func();”,函数和变量的声明、定义和使用都需进行替换。
项目需求示意图如图1:
原有代码需要新生成的代码
图 1 项目需求示意图
这项工作人工进行需要找出需替换的symbol,再做替换操作。
由于代码量较大(约几十万行代码总量,其中有5000多个symbol需要替换),人工替换非常繁琐,又易出错。
一时又找不到合适的工具,这时我们想到了Source Insight的宏语言。
通过Source Insight 的宏语言,访问Source Insight的symbol列表,可以区分函数,全局变量,局部变量等C
语言语法上的类型,还可以自动执行替换操作。
及保证了效率,又保证了替换的准确度。
追加前缀的工作可以分4步来完成:
1、建立Source Insight工程,并整理全部文件的列表。
文件列表保存在文件"C:\\filelist.txt"中,列表包含路径。
这步不需要Source Insight的宏语言。
路径可以是绝对路径,也可以是Source Insight工程的相对路径。
2、抽出需加前缀的symbol。
对第1步整理的文件列表中的每一个文件,获取文件中所有的symbol,遇到symbol为变量或函数的声明则记录到文件"C:\\replacewhat"。
宏语言访问到的symbol类型与Source Insight中的symbol type一致。
完成此功能使用了自定义的宏SymbolCollect(源码见附录1)。
3、追加前缀。
对第1步整理的文件列表中的每一个文件,查找第2步抽出的symbol并追加前缀。
调用宏语言提供的函数ReplaceInBuf(Source Insight提供)追加前缀,设置为区分大小写,整个单词匹配。
完成此功能使用了自定义的宏replaceExe(源码见附录2)。
4、运行自定义的宏语言。
(1) 宏语言写在一个扩展名为em的文件里,将文件加入到Source Insight工程中,并进行同步。
(2) 选择菜单Options→Menu Assignments,在图 2 Menu Assignments对话框的Command中可以找到自定义的宏,并加入到菜单中。
然后就可以和其它菜单项一样使用了。
(3) 如图 3 增加宏命令后的菜单,首先选择Options→SymbolCollect抽出需追加前缀的symbol,然后选择Options→replaceExe执行替换操作。
图 2 Menu Assignments对话框
图 3 增加宏命令后的菜单
通过使用宏语言对应该项工作,一名担当从不了解宏语言,到试验、编写和调试脚本用了一天左右,再用一个多小时执行脚本,完成了估计约3人日的工作,而且原来枯燥的工作过程现在变得轻松愉快。
本文只是提到了Source Insight宏语言的一种应用实例。
使用宏语言可以自定义一些有用的小脚本, 插入某种格式的字符串(文件头,函数头), 自动执行编辑操作等。
大家说不定什么时候也能派上用场,到时可以参考Source Insight的帮助和网上相关资料。
最后,提醒大家使用宏语言时,建议把不要写太复杂的函数,宏语言的调试环境比不了VC的便捷,最好把复杂的步骤进行拆分,控制每一个宏的规模。