source insight增加注释宏
打开base项目,下main.c文件里加入以下代码
对于在一行内的局部注释, 没有找到解除注释的宏,
macro Comments_orUn_gx()
{ //用杠星注释多行,或取消杠星注释 ,不选中多行时,只处理当前行
hwnd = GetCurrentWnd()
hbuf = GetCurrentBuf()
)
stop
// debugBuf只是为了调试
// debugBuf = NewBuf("debugBuf")
// ClearBuf(debugBuf)
lnSelFirst = GetWndSelLnFirst(hwnd) // 获得选中内容的第一行
lnSelLast = GetWndSelLnLast(hwnd) // 获得选中内容的最后一行
const_space = " " // 空格
const_comments_begin = "/*" // 多行注释符号-开始
const_comments_end = "*/" // 多行注释符号-结束
isCancelComments =
// 跳过开始的空行,否则下面报错
line_index = lnSelFirst
orig_text = GetBufLine(hbuf, line_index) // 获得第一行的text
)
{
line_index = line_index +
orig_text = GetBufLine(hbuf, line_index) // 获得下一行的text
}
// 根据第一行选中文本,确定是“注释”,还是“取消注释”
// 判断是否以“//”开始,如果是则认为是“取消注释”,首先需要去掉空格
subIndex =
) == const_space)
subIndex = subIndex +
) == const_comments_begin) // 以“/*”开头,取消注释
{
isCancelComments =
dest_text = strmid(orig_text, subIndex+, strlen(orig_text))
)
{
DelBufLine(hbuf, line_index) // 本行只有“/*”时,删除
}
else
{
PutBufLine (hbuf, line_index, dest_text) // 替换以前的text
}
line_index = line_index +
}
else // 进行注释
{
InsBufLine(hbuf, lnSelFirst, "/*")
InsBufLine(hbuf, lnSelLast+, "*/")
stop
}
// 遍历所有选中的行
// line_index = lnSelFirst // 前面已经跳过开头的空行
// while(line_index <= lnSelLast) // 对选中的内容进行操作
while(line_index < GetBufLineCount(hbuf)) //or 从当前行开始,查找到第一个“*/”为止或到结尾
{
orig_text = GetBufLine(hbuf, line_index) // 获得以前的text
) // 如果是空行或只有一个字符,则跳过
{
dest_text = ""
) // 取消注释
{
// 查找注释符“*/”
subIndex =
&& strmid(orig_text, subIndex, subIndex+) != const_comments_end)
subIndex = subIndex +
) == const_comments_end) // 找到“*/”,进行处理
{
prefixText = strmid(orig_text, , subIndex) // 前面的text
lastText = strmid(orig_text, subIndex+, strlen(orig_text)) // 后面的text
dest_text = cat(prefixText, lastText)
)
{
DelBufLine(hbuf, line_index) // 本行只有“*/”时,删除
}
else
{
PutBufLine (hbuf, line_index, dest_text) // 替换以前的text
}
break // 退出
}
}
}
line_index = line_index +
}
}
macro CommentSelecte_inOneLine()
{ //注释选中,只在单行中有效,不选中任何字符的话就在光标处插入一对杠星注释符
hbuf = GetCurrentBuf()
ln = GetBufLnCur(hbuf)
str = GetBufSelText(hbuf)
str = cat("/*",str)
str = cat(str,"*/")
SetBufSelText (hbuf, str)
}
macro _tsGetTabSize()
{ //只被Comment_gx() 宏调用
szTabSize = GetReg("TabSize");
if (szTabSize != "")
{
tabSize = AsciiFromChar(szTabSize[]) - AsciiFromChar(");
}
else
{
tabSize = ;
}
return tabSize;
}
macro Comment_gx()
{ //用杠星注释,不换行,至少注释一行,不推荐使用
hbuf = GetCurrentBuf();
hwnd = GetCurrentWnd();
sel = GetWndSel(hwnd);
iLine = sel.lnFirst;
// indicate the comment char according to the file type
// for example, using "#" for perl file(.pl) and "/* */" for C/C++.
filename = tolower(GetBufName(hbuf));
suffix = "";
len = strlen(filename);
i = len - ;
)
{
] == ".")
{
suffix = strmid(filename, i, len)
break;
}
i = i -;
}
if ( suffix == "pl" )
{
filetype = ; // PERL
}
else
{
filetype = ; // C
}
szLine = GetBufLine(hbuf, iLine);
) // C
{
szLine = cat("/*", szLine);
}
else // PERL
{
szLine = cat("# ", szLine);
}
PutBufLine(hbuf, iLine, szLine);
iLine = sel.lnLast;
szLine = GetBufLine(hbuf, iLine);
) // C
{
szLine = cat(szLine, "*/");
}
else // PERL
{
szLine = cat("# ", szLine);
}
PutBufLine(hbuf, iLine, szLine);
if (sel.lnFirst == sel.lnLast)
{
tabSize = _tsGetTabSize() - ;
sel.ichFirst = sel.ichFirst + tabSize;
sel.ichLim = sel.ichLim + tabSize;
}
SetWndSel(hwnd, sel);
}
macro Comment_gg()
{ //用杠杠注释,不选中多行的话,注释当前行
hwnd = GetCurrentWnd()
selection = GetWndSel( hwnd )
lnFirst = GetWndSelLnFirst( hwnd )
lnLast = GetWndSelLnLast( hwnd )
hbuf = GetCurrentBuf()
ln = lnFirst
buf = GetBufLine( hbuf, ln )
len = strlen( buf )
firststart = len
while( ln <= lnLast )
{
buf = GetBufLine( hbuf, ln )
len = strlen( buf )
start =
while( start < len )
{
) == CharFromAscii() || strmid( buf, start, start + ) == CharFromAscii() )
{
start = start +
if( start > len )
break
}
else
break
}
if( start < len && start < firststart )
{
firststart = start
}
ln = ln +
}
ln = lnFirst
while( ln <= lnLast )
{
buf = GetBufLine( hbuf, ln )
len = strlen( buf )
)
{
buf2 = cat( cat( strmid( buf, , firststart ), "//" ), strmid( buf, firststart, len ) )
PutBufLine ( hbuf, ln, buf2 )
}
ln = ln +
}
SetWndSel( hwnd, selection )
}
macro unComment_gg()
{ //取消杠杠注释,不选中多行的话,默认只处理当前行
hwnd = GetCurrentWnd()
selection = GetWndSel( hwnd )
lnFirst = GetWndSelLnFirst( hwnd )
lnLast = GetWndSelLnLast( hwnd )
hbuf = GetCurrentBuf()
ln = lnFirst
while( ln <= lnLast )
{
buf = GetBufLine( hbuf, ln )
len = strlen( buf )
)
{
start =
) == CharFromAscii() || strmid( buf, start, start + ) == CharFromAscii() )
{
start = start +
if( start >= len )
break
}
)
{
) == "//" )
{
buf2 = cat( strmid( buf, , start ), strmid( buf, start + , len ) )
PutBufLine( hbuf, ln, buf2 )
}
}
}
ln = ln +
}
SetWndSel( hwnd, selection )
}
增加后,通过在键分配中分配宏命令的按键
source insight增加注释宏的更多相关文章
- source insight 中文注释为乱码解决
1. source insight 中文注释为乱码解决 http://blog.csdn.net/bingfeng1210/article/details/7527059 2. Source Insi ...
- Source Insight中文注释乱码、字体大小、等宽解决方法
中文注释乱码解决方法: 用记事本打开源文件,然后,选择文件->另存为,编码选为”ANSI“ 字体的调整: Source Insight 菜单栏选择Options->Document O ...
- Source Insight 中文注释为乱码解决办法(完美解决,一键搞定)
我从网上查了一堆解决办法,但是都是2017年以前的解决方案,并且都是针对于source insight 3.5及以下版本的,目前SI软件版本都到4.0了,应该有新方法出现了. ------------ ...
- utf-8转换为ansi和修改文件名的批处理(可解决source insight中文注释乱码问题)
source insight中文乱码有两个原因,一个是source insight的设置不正确.另外一个原因是源文件是utf-8格式的. 最近在工作中用source insight 查看jsp文件.j ...
- 【转】Source Insight中文注释为乱码的解决办法
我网上查了一堆解决办法,但是都是2017年以前的,并且都是针对于source insight 3.5及以下版本的解决方案,软件版本都到4.0了,应该有新方法出现. 干货:Source Insight ...
- source insight增加tab标签页的方法之sihook
1.效果如下 2.方法见如下博客 http://www.cnblogs.com/Red_angelX/archive/2013/01/23/2873603.html
- Source Insight常用快捷键及注释快捷键设置
转:http://blog.csdn.net/tlaff/article/details/6536610 在使用SI过程中,我根据自己的使用习惯修改了它的默认快捷键,并且在配置文件中添加了一些人性化功 ...
- source insight之quicker.em宏的使用
source insight有很多宏可以用,这里介绍的宏是quicker.em这个宏,它是华为的一个员工写的,很实用. 1.安装quicker.em宏 一.打开base这个工程Project-> ...
- source insight 编程风格(持续更新)
1.字体Source Code Pro 出身于豪门Adobe,从名字上来看就知道是转为编码而生的.基本上也是拥有前面所提的编程字体的所有要素的.这个字体基本上具有编程字体所需的所有要素:等宽.支持Cl ...
随机推荐
- java5
1:final关键字(掌握) (1)是最终的意思,可以修饰类,方法,变量. (2)特点: A:它修饰的类,不能被继承. B:它修饰的方法,不能被重写. C:它修饰的变量,是一个常量. (3)面试相关: ...
- [Linux]系统调用理解(1)
本文是Linux系统调用专栏系列文章的第一篇,对Linux系统调用的定义.基本原理.使用方法和注意事项大概作了一个介绍,以便读者对Linux系统调用建立一个大致的印象. 什么是系统调用? Linux内 ...
- HDU 5102 The K-th Distance(模拟)
题意:输入一棵树,输出前k小的点对最短距离dis(i,j)的和. 模拟,官方题解说得很清楚了.不重复了. http://bestcoder.hdu.edu.cn/ 需要注意的是,复杂度要O(n+k), ...
- SpringMVC与Ajax交互
1 springmvc和ajax的交互 1.1 请求字符串响应json 客户端发送的数据:key=value&key1=value1 响应回来:json 1.1.1json的支持jar包 1 ...
- Mac Pro 16G 安装MyEclipse提示虚拟内存(为0)不够
百度一下很多人都说开多一点程序,让程序占满内存,使其虚拟内存使用就能通过这一步骤,但这里有个更好一点的方案 通过执行: memory_pressure -l critical 用系统内存压力测试进程占 ...
- ORACLE的DUAL表及DB2的SYSIBM.SYSDUMMY1
在ORACLE中,数据库用户通过访问DUAL表获取一些系统信息:DB2中,相应的表为SYSIBM.SYSDUMMY1表 ORACE中举例: SELECT SYSDATE FROM DUAL;获取当前日 ...
- Oracle资源管理器介绍(一)
数据库资源管理器通过控制数据库内部的执行调度来控制资源在各个会话之间的分布.通过控制所要运行的会话以及会话运行的时间长度,数据库资源管理器可以确保资源分布与计划指令相匹配,因此也符合业务目标. ...
- 适配器模式/adapter模式/结构型模式
定义 将类的接口转化为客户端希望的另外一个接口,使得原本由于接口不兼容而不能一起工作的类可以一起工作,别名Wrapper(包装器). 适配器模式,最终改变一个已有对象的接口. 使用场景 当有那么个类, ...
- iOS 启动画面 代码自定义
先来看一个可能会遇到的问题: 如果你已经删除了xcode为你的项目自动生成的LaunchScreen.storyboard, 然后你在测试你的app的时候发现,屏幕里出现了黑色的区域,如上图(画红线的 ...
- 编译原理-词法分析04-NFA & 代码实现
编译原理-词法分析04-NFA & 代码实现 0.术语 NFA 非确定性有穷自动机nondeterministic finite automation. ε-转换ε-transition 是无 ...