最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501
当前位置: 首页 - 科技 - 知识百科 - 正文

SourceInsight技巧:头文件和实现文件快捷键打开的方式

来源:懂视网 责编:小采 时间:2020-11-09 07:29:09
文档

SourceInsight技巧:头文件和实现文件快捷键打开的方式

SourceInsight技巧:头文件和实现文件快捷键打开的方式:http://blog.chinaunix.net/uid-27213819-id-3810619.html source insight并没有提供这样的快捷键,有时候用着比较烦人。终于找到了方法:使用宏命令,并设置快捷键与之绑定。 1、打开source insight,Project - Open Proj
推荐度:
导读SourceInsight技巧:头文件和实现文件快捷键打开的方式:http://blog.chinaunix.net/uid-27213819-id-3810619.html source insight并没有提供这样的快捷键,有时候用着比较烦人。终于找到了方法:使用宏命令,并设置快捷键与之绑定。 1、打开source insight,Project - Open Proj

http://blog.chinaunix.net/uid-27213819-id-3810619.html source insight并没有提供这样的快捷键,有时候用着比较烦人。终于找到了方法:使用宏命令,并设置快捷键与之绑定。 1、打开source insight,Project - Open Project,打开Base项目,注:Base项目是

http://blog.chinaunix.net/uid-27213819-id-3810619.html

source insight并没有提供这样的快捷键,有时候用着比较烦人。终于找到了方法:使用宏命令,并设置快捷键与之绑定。

1、打开source insight,Project -> Open Project,打开Base项目,注:Base项目是source insight默认已经创建的。

2、打开Utils.em文件,在该文件的末尾加入如下内容:

/* 
 cpp和hpp文件互换(当前只支持同一目录下的文件互换) 
*/ 
macro switch_cpp_hpp() 
{ 
 hwnd = GetCurrentWnd() 
 hCurOpenBuf = GetCurrentBuf() 
 if (hCurOpenBuf == 0) 
 stop 
 curOpenFileName = GetBufName(hCurOpenBuf) 
 curOpenFileNameLen = strlen(curOpenFileName) 
 
 // 文件类型临时缓冲区 
 strFileExt = NewBuf("strFileExtBuf") 
 ClearBuf(strFileExt) 
 
 // 头文件类型 
 index_hpp_begin = 0 // 头文件开始索引 
 AppendBufLine(strFileExt, ".h") 
 AppendBufLine(strFileExt, ".hpp") 
 index_hpp_end = GetBufLineCount(strFileExt) // 头文件结束索引 
 
 // 源文件类型 
 index_cpp_begin = index_hpp_end // 源文件开始索引 
 AppendBufLine(strFileExt, ".c") 
 AppendBufLine(strFileExt, ".cpp") 
 AppendBufLine(strFileExt, ".cc") 
 AppendBufLine(strFileExt, ".cx") 
 AppendBufLine(strFileExt, ".cxx") 
 index_cpp_end = GetBufLineCount(strFileExt) // 源文件结束索引 
 
 isCppFile = 0 // 0:未知 1:头文件 2:源文件,默认未知扩展名 
 curOpenFileExt = "" // 当前打开文件的扩展名 
 index = index_hpp_begin 
 // 遍历头文件,判断是否当前打开文件是头文件类型 
 while(index < index_cpp_end) 
 { 
 curExt = GetBufLine(strFileExt, index) 
 curExtLen = strlen(curExt) 
 curOpenFileExt = strmid(curOpenFileName, curOpenFileNameLen-curExtLen, curOpenFileNameLen) // 当前打开文件的扩展名 
 
 // 调试 
 // AppendBufLine(debugBuf, curExt) 
 // AppendBufLine(debugBuf, curOpenFileExt) 
 
 
 if(curOpenFileExt == curExt) // 匹配成功 
 { 
 if (index < index_hpp_end) 
 isCppFile = 1 // 当前打开文件是头文件 
 else 
 isCppFile = 2 // 源文件 
 break 
 } 
 index = index + 1 
 }// while(index < index_cpp_end) 
 
 // 调试 
 // AppendBufLine(debugBuf, isCppFile) 
 
 index_replace_begin = index_hpp_begin 
 index_replace_end = index_hpp_end 
 
 if (isCppFile == 1) // 当前打开文件是头文件 
 { 
 index_replace_begin = index_cpp_begin 
 index_replace_end = index_cpp_end 
 } 
 else if(isCppFile == 2) // 当前打开文件是源文件 
 { 
 index_replace_begin = index_hpp_begin 
 index_replace_end = index_hpp_end 
 
 // 调试 
 // AppendBufLine(debugBuf, "cpp") 
 } 
 else // 未知类型 
 { 
 //CloseBuf(strFileExt) // 关闭缓冲区 
 
 //stop 
 
 index_replace_begin = 9999 
 index_replace_end = index_replace_begin // 下面循环不会执行 
 } 
 
 index = index_replace_begin 
 while(index < index_replace_end) 
 { 
 destExt = GetBufLine(strFileExt, index) 
 destFileName = strmid(curOpenFileName, 0, curOpenFileNameLen-strlen(curOpenFileExt)) // 不包括扩展名,绝对路径 
 
 // 尝试当前目标扩展名是否能够打开 
 destFilePath = cat(destFileName, destExt) // 文件名(包括扩展名) 
 
 hCurOpenBuf = OpenBuf(destFilePath) 
 if(hCurOpenBuf != 0) 
 { 
 SetCurrentBuf(hCurOpenBuf) 
 break 
 } 
 
 // 尝试进行目录替换,看能否打开文件(如何设计:支持多个目录) 
 // ...(赞不支持) 
 index = index + 1 
 } 
 CloseBuf(strFileExt) // 关闭缓冲区 
 // 调试 
 // AppendBufLine(debugBuf, "finished") 
 
}
3、关闭Base项目,重新打开Source Insight。

4、打开Option -> Key Assignments。在Command栏选中“Macro: switch_cpp_hpp”;点击Assign New Key按钮设置快捷键(Ctrl+·),点击OK,就设定好了。

5、再打开一个项目,试试你刚刚设定的快捷键吧!!!

声明:本网页内容旨在传播知识,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文档

SourceInsight技巧:头文件和实现文件快捷键打开的方式

SourceInsight技巧:头文件和实现文件快捷键打开的方式:http://blog.chinaunix.net/uid-27213819-id-3810619.html source insight并没有提供这样的快捷键,有时候用着比较烦人。终于找到了方法:使用宏命令,并设置快捷键与之绑定。 1、打开source insight,Project - Open Proj
推荐度:
标签: 文件 打开 技巧
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top