Profiel van 猪哥猪哥的BlogWeblogLijstenGastenboek Extra Help

Weblog


    5-8-2009

    解决SlickEdit中版本控制工具的中文问题

    Windows下的SlickEdit中,如果用SE内置的Subversion/CVS前端来操作代码库的话会发现所有的中文都被显示为乱码,而英文都正常。造成这个问题的主要原因就是SE在内部处理字符串用的是UTF8编码,而控制台端的svn/cvs工具在通过Shell与SE交互时用的实际上都是多字节码。这样就造成了乱码问题。

    解决的方法很简单,只要在调用命令的前后各做一次编码转换即可。找到SE的底层CVS/SVN命令操作函数:cvsutil.e::_CVSPipeProcess()

    在入口处把SE准备传递给Shell的命令由UTF8转换为多字节编码,代码页使用系统默认(也可以自己指定一个代码页,在第二个参数指定即可。如强制转换为简体中文:_UTF8ToMultiByte(command, 936)):
    command = _UTF8ToMultiByte(command);

    这样就可以让SE正确地把包含中文的文件名等参数传递给CVS/SVN,解决不能checkout中文名文件的问题(表现为操作时返回svn缺少参数之类的错误)。

    在这个函数末尾return之前,再做一次逆向转换:
    StdOutData = _MultiByteToUTF8(StdOutData);
    StdErrData = _MultiByteToUTF8(StdErrData);


    这里把完成命令调用后的stdout和stderr由多字节编码转换为UTF8,供SE继续处理。解决SE的VCS图形界面显示中文乱码的问题。

    经过上述改进以后,SE内置的Subversion Browser已经可以正常浏览中文目录:
    sshot-2
    在版本控制的History里也能看到文件的中文注释:
    sshot-4
    修改好的cvsutil.e已经传到盒子里了。
    3-8-2009

    SlickEdit华丽修改:双击括号自动选中匹配括号

    SourceInsight有个功能,就是在双击一个括号的时候能选中匹配的括号。N年前用SourceInsight的时候这个功能用得很High——因为SI竟然无法高亮显示匹配括号( ̄口 ̄)!!,所以非靠这个功能识别嵌套括号不可。

    用了SlickEdit以后,心想这玩意好歹支持括号高亮,双击选中这种功能应该不需要了吧。结果最近在看一个包含了横跨N屏的括号套括号的代码时还是被囧到了:得跨越万水千山才能找到另一个被高亮的括号,经常看走眼看错嵌套层次。而那个select-paren-block命令又没法同时整合到双击选中word中奇不好用,所以又想念起SI的这个功能来了。于是操刀对SE做了个华丽的修改,硬是把这个功能加上了。
    sshot-2
    加上后,发现效果居然非常好,比SI还要好。因为SE在选中的情况下彩色高亮还能保持,所以选区仍然有很好的可读性,可以把选区当作是个block高亮功能来用,完美防止看走眼。

    Patch过的宏在盒子里,mouse.e。

    SlickEdit的Defs函数列表之华丽修改

    用SlickEdit看了N年代码以后,对那个函数列表有点忍无可忍,终于爆发。SE总是在列表里面显示整个函数的声明包括参数列表,所以无论何时看这个列表总是黑压压的一片看了头疼,基本没希望一眼定位到某个函数:

    sshot-3

    之前想改这个列表很久,但是由于这个列表实际上是由DLL生成的并非通过宏,所以没有办法直接修改。被逼得没办法,只好用猥琐办法强制滤掉了所有括号里面的东西:

    sshot-4

    这样世界一下子清净了(# ̄▽ ̄#)。当然,副作用还是有的,比如Show Statements时if和for啥的里面的表达式会没掉。不过个人感觉会嫌原装列表太花的人没有道理会开Show Statements,因此这个缺陷可以忽略不计。另外可能的问题是不清楚把函数参数滤掉SE会不会傻掉,难保这家伙会不会用这些函数名做一些显示以外的其他用途。不过就我自己用的几周来看,貌似没啥问题。

    东西在盒子里,proctree.e。

    ★ 2009年8月5日:安装后要用toggle-hide-defs-param命令切换是否显示参数。
    10-7-2009

    升级到SlickEdit 2009 v14.0.2.2

    SlickEdit v14.0.2.2经过极其短暂的RC以后就发布了。早上Down下来,利用中午的时间装上。升级非常平滑,只花了10分钟就merge完我所有的Mod和配置了。想起之前用v9的时候每次升级都要大动干戈地搞上1~2小时的,真是激动得眼泪哗哗的。
    sshot-1
    看了半天更新列表,几乎没啥可见更新主要都是各类BUG修订。值得一提的更新如下:
    • Fixed problem with std:: namespaces and completions. 
      这个我没有试过,不过看样子是解决了之前string类自动完成的问题了吧。
    • Made the color for modified items in the debugger configurable. Previous it reused a color assigned to something else. 
      这个解决了SE自带的GDB前端一个很恶心的问题,就是单步时修改了的变量居然用的是Modified Line颜色来显示。恼了大伙很久以后,这回终于决定改了~~在Color中出现了专门的牌位:
      sshot-2
    For v14.0.2.2的宏已经上传到我的盒子里,请各位用代码比较工具merge自己所需的修订。盒子已被坝但我实在是懒得再挪窝了,请想下载的各显神通自己翻墙吧~~
    20-5-2009

    SlickEdit 2009 v14.0.1更新

    昨天SE网站放出了正式发布的v14.0.1修订版。Down下来安装后看了看Release Note,发现基本上全是BUG修订,有改进也是鸡毛蒜皮的所以就懒得在这里列了。不过鉴于SE一贯的风格,往往在正式版以后的第一个修订版质量才能达到一般意义上“正式版”的水平,所以还是建议更新到这个版本:

    sshot-1

    升级过程非常容易,从14.0.0到14.0.1是完全平滑的,除了自己对某些窗体和宏的修订需要手工merge以外,其余所有的配置包括热键和自定义菜单都能顺利继承下来。

    我对SE宏的修订(包括一些修正中文问题和添加一些小功能)for 14.0.0.1的全集可以在我的盒子里面打包下载。再三强调:下载到的宏请各位一定自己手工用代码比较工具撷取其中需要的修订合并到SE的宏里面,不要一股脑儿全覆盖过去。要不然跑不起来或者和你原来的修订冲突了我可不管~~
    30-3-2009

    Slickedit 2009 Linux版在ubuntu 8.04上的安装

    题外话:为了不让某猥琐男的预言得逞,俺决定再插队增加一篇Blog~~

    Linux版的安装界面是命令行的,依稀记得v11还是v12的时候还是和Windows版一样的图形化安装界面。可能SE那帮人自己也觉得无聊Linux下面搞什么GUI安装的,就从2008以后都随大流用命令行安装了。安装的时候要用sudo,Yes一下License,改改安装目录不要覆盖原来的老版本即可。

    完成后就会提示导入License。注意最好也是在root权限下面搞,不然会要求你sudo cp一把手工把License File拷贝到安装目录下:

    导入了License以后就可用了,发现Build日期和Win版相同:

    Linux版依然是基于X Window的,非常非常丑陋的Motif风格实在是恶心得不行了。不过在Linux上面看Motif感觉勉强了,想想那些用Mac OSX的人吧~~在美丽的Aqua界面上露出一个可怕的Motif风格窗体……真是一坨牛粪插在了鲜花上啊~~我以前一直认为最老的那种JRE 1.4之前的Metal风格是世界上最难看的GUI外观,后来看了Motif才知道之前我真是孤陋寡闻了(﹀_﹀")。

    要想输入中文,先要在这里设置一下:

    选中该选项后下面的提示框还会告诉你要配置另外两个环境变量~~照做即可。搞定后SCIM可输入中文。不过不得不再说一下,即使是这样设置了以后SlickEdit在Linux下面用中文感觉依然是非常不好,还是尽量用Win版吧~~

    注意:2009以后SlickEdit增加了配置Import/Export功能,可以利用这个功能把配置页面中所有的配置从Windows版迁移到Linux版去(2009之前的版本是没法这么搞的)。不过只能迁移可以在配置对话框中设置的那些内容,对宏和窗体什么的修改还是要自己手工搞定。
    27-3-2009

    SlickEdit 2009新功能简单体验

    最近感冒,刚开始还成只是流流鼻涕的,到了今天居然发展成咳嗽了。咳了一天咳得我腹部肌肉痛的要死,不知道咳嗽能不能顺便锻炼腹肌。咳着咳着偶尔脑子里还闪出星爷电影里面那个把肺也咳出来的衰鬼,唉。

    SlickEdit 2009最终发布的版本是14.0.0.7(之前的14.0.0.5发布了又被撤掉了)。3月25日Build的,26日就能通过2008版的下载链接下到了。今天官网的首页才改成2009。

    装上后发现这回居然连我的菜单配置都给保留了,这点不错。我的右键菜单都是自己定制的,每次升级所有的菜单配置都会丢失弄得我还要搞个宏专门来自动改我的菜单。这回终于不用那么麻烦了。经过极短暂简单的试用后,体会汇报如下:

    Symbol Coloring
    这个应该是最能引人注意的新改进。SlickEdit空有强大的Context Tagging引擎但是代码着色居然是基于弱智的关键字匹配实在是说不过去。经过大堆用户的牢骚以后,这回终于做出了正式回应,结果就是2009里面的Symbol Coloring:

    可以先直观感受一下新的符号着色效果:这是打开符号着色之前的:

    这是打开符号着色之后的:

    可以看到全局函数和宏定义的颜色都发生了变化。至于颜色好看与否这个就暂时不评论了。因为Symbol Coloring的颜色设置界面比SourceInsight的Color设置还要吓人,所以我直接用的是官方默认的色彩主题:

    不过SourceInsight设置基础配色主题困难的问题倒是在SE里面有所缓解。因为SE的Code Coloring和Symbol Coloring颜色设置是分开的,并且能够控制要不要用Symbol Coloring。所以在Color里面的着色项还是相对少的,配置新的颜色风格的工作量也不会像SourceInsight那样庞大:

    有灭注意到Comments里面的颜色配置变多了?Yes,这回也是在众人的强烈要求下,增加了类似SourceInsight的Inactive Code着色了。各位在看我前面贴的代码截图是应该就能发现了。只是在使用前注意要把C/C++里面的Color inactive regions功能打开喔:

    另一个新的着色项就是可以为文档化注释的关键字着色(Doxygen、Javadoc):

    可以看到Doxygen的关键字被加粗着色。这回我对SE在代码着色上的改进确实觉得满足了,没啥追求了。

    Doxygen注释渲染

    其实就是把我原来写的那个宏给Merge进去了,不过还挺厚道的,作者名上面还是写着我的名字。不像SourceInsight那么无耻(这厮把我解决删半个汉字问题的宏拿去后删了我的名字贴在它网站上)。

    只不过比较郁闷的是,SE的人改了我一些东西,不过看起来他们没有完全明白我原来的本意,所以改了以后处理中文注释中的Doxygen超链接就出问题了(鬼佬产品的通病)。因此我自己又把它改回去了,在我的盒子里能找到最新的codehelp.e,覆盖即可。另外需要说明的是,为了方便起见,最好强制SE总是用Doxygen来渲染(除非你用的是Javadoc~~):

    Smart Open

    原来一直是很鄙视SE的Open工具框的。简直是一点用也没有,Win 3.2时代的风格,用起来也是非常难受。在我的SE界面上压根没它的位置。不过这回2009的Open工具框做了彻底修改,用起来非常赞。

    初一看好像觉得貌似变化不大,不过在File name里面随便敲几个字那就会觉得它的好了:

    它可以像Files Toolbar一样即时匹配当前目录和子目录下的所有文件,而且匹配的速度也非常快,找文件非常方便。其实这点和前面的Symbol Coloring也都是参考SourceInsight的,看来在我等大批SourceInsight前用户的煽动下,SE的人开始认真考虑要取长补短了。

    Code Diff

    内置的比较工具DiffZilla的新功能:Code Diff。不过说实话自从BeyondCompare 3出来以后我已经极少再用DiffZilla和Araxis Merge了。简单说来这东西就是能够让你忽略代码风格的变化,关注于代码中真正有效的改动。比如没有打开Code Diff功能前,对两个代码文件的比较结果是这样的:

    实际上花花绿绿的里面大部分都是编码风格的差异,这就分散了我们的注意力。打开Code Diff以后,真正要抓的差异就一目了然了:

    打开Code Diff后SlickEdit实际上是把右边那个代码调整到与左边一致的风格后再进行比较。所以恼人的风格差异就不会再把结果搅得杂乱不堪了。这点要比其他的代码比较工具来的好,因为其他工具最多只能忽略注释和空白的差异。换行的差异好像没有看到可以搞定的。

    Backup History Comment


    最后一个令我感兴趣的功能:自动备份增加了注释。这个功能非常实用,虽然不可能BT到每次按Ctrl+S的时候都去写个无聊的说明。但是用它在自动备份历史记录上标注一些关键点(比如调试前啊、某个功能修订前之类的)还是非常好用的。不然之前我只能通过备份的日期来估摸到底哪个备份是我调试前的版本。

    不过需要特别说明的是,官方原厂的注释功能不支持中文,只要写了中文就变成方框了。当然看了截图就知道我已经搞定中文问题了(# ̄▽ ̄#),可以在我的盒子下载解决中文问题的宏文件。感觉SE最近对中文支持越来越差,不知道是不是公司里面的原先很顾全大局的那批开发者都升官了还是跑掉了,反正现在很多新开发的功能对DBCS支持都有点问题,比如那个SE 2008新增加的剪贴板窗口,在2009里面依然还是中文乱码的,也是要下载我的补丁才能搞定中文。

    最后不得不说一个比较不爽的“改进”,就是这回SE的各可执行文件和动态链接库都加上了数字签名,而且在启动时还会检查数字签名,发现不对的就不能运行了。所以原来通过修改vsapi.dll解决调试界面Memory字体糊成一团问题的办法也不能用了。不过我基本没用SE内置的调试器所以也不care了,有这需求的人可以mail骚扰SE的家伙叫他们解决。

    下篇日志预告

    本来想今晚写的,但是今晚最终还是没有写忙其他去了~~不过为了坚定自己写它的决心,放出两张Preview,下篇日志再讲这个东西。


    29-1-2009

    IDA-like Highlight更新

    用过IDA Pro的应该都明白,这个宏就是让SlickEdit实现和IDA Pro类似的自动高亮功能,自动全文高亮当前光标处的单词。本次更新:增加支持选区高亮(和IDA Pro的表现一致)。如果选区不超过一行,则自动在当前文档中高亮所有相同的文字。

    这个功能只建议在分析代码的时候打开。如果在写代码的时候开那是相当烦人。另外每次启动SlickEdit的时候都会自动关闭此功能,防止忘记关掉在写代码的时候囧人。我个人的使用偏好是在浏览代码的时候使用ida-like-highlight进行快速高亮,在想集中注意力分析一小个部分的时候关掉改用我之前发布的那个hl-word来进行多单词高亮。

    还是在盒子里下载,v13目录下。
    19-1-2009

    修改SlickEdit for Linux的脑残Buffer Tabs排序方式

    发现Linux版的SlickEdit在给文件标签页排序时,很入乡随俗地按照Linux下文件名区分大小写的规则进行排序:

    这种区分大小写的排序方式是违背人的习惯的。如果文件名的大小写情况比较复杂(比如有人喜欢用单词首字母大写的形式给文件命名),多开几个文件以后文件标签栏几乎就杂乱无章无法检索了。很是怀疑SE的家伙自己到底有没有在Linux下用过这个标签栏的。

    不过修改起来也很是简单。打开bufftabs.e,找到“temp_data._sort('F'_fpos_case)”这行,把它改成“temp_data._sort('I')”即可。效果如下:

    文件标签的排序已经和Windows下的一致了。
    18-12-2008

    SlickEdit高亮宏更新

    原来从老外的基础上修改的hlWord已经破旧不堪,实在不堪再用。所以这回另起炉灶彻底重写了这个宏,功能增强,代码精简。全面替换阳春的quick-highlight命令。另外即使是不支持quick-highlight的老版本SE也可以使用。

    主要功能:

    • 支持快速在所有打开的buffer中高亮光标处单词
    • 支持多种颜色(可以自己在代码的颜色表里面加颜色),方便关注多个关键词。目前预置的颜色是Colors里面的Highlight、I-Search Highlight、Symbol Highlight。
    • 支持解除某个单词的所有高亮(quick-highlight只能一次擦掉所有单词的所有高亮)
    效果截图:

    安装方法:
    1. 加载highlight.e
    2. 如果你想用clear-highlights命令清除这个宏添加的高亮的话,需要多做如下步骤:
      1. 打开tbfind.e,在文件头部#import "highlight.e"
      2. 在clear_highlights()函数的末尾添加:hl_reset();
      3. 重新加载tbfind.e
    3. 将hl-word命令bind到热键或者菜单项上面。
    使用方法:
    • 调用一次hl-word是加亮,再调用一次取消加亮。加亮的颜色为循环使用颜色表数组中配置的颜色
    • 可以使用clear-hilights命令一下清除所有的高亮
    下载:在我的盒子里,自己找(for v13)。
    4-11-2008

    让SlickEdit支持多Profile

    如果你对代码编辑器的要求极为苛刻(就像我这样),自然而然会想要一个支持多Profile的编辑器。这个多Profile不是仅仅支持多用户那样的水平,而是说在干不同的事情时用不同的界面布局甚至热键方案。比如我在阅读Linux内核代码、写公司的代码、写自己的代码和写Docbook XML文档时需要的布局方案都是不一样的。所以让万金油一般的主力编辑器SlickEdit具备多Profile支持能力也是极有必要。

    其实SlickEdit很早以前就支持多Profile了。只不过它的多Profile功能隐藏在命令行参数里面藏得比较严实。具体方法是加上-sc参数。比如你想为阅读代码专门建立一个Profile,那就把My Documents\My SlickEdit Config另外拷贝一份成比如CodeReading这样(我是习惯弄到SE的安装目录里面去)。然后为SlickEdit另外创建一个快捷方式,命令行里面加上参数:

    vs.exe +new -sc ".\Profiles\CodeReading"

    这样就完事了。使用这个快捷方式启动的SlickEdit就会以CodeReading作为配置目录,所有的配置与原始版本独立。不过需要注意的是,如果你配置了很多Profile,在打开多个SE以后自己绝对会搞糊涂掉。对于这个小问题可以用一些比较猥琐的办法来给不同Profile的SE界面打上标记。比如我用的办法就是在_mdi_menu(就是主菜单栏)末尾添加一个空的菜单项,上面写上这个Profile的名字。这样就不会弄混了。

    3-11-2008

    修正SlickEdit 2008的默认生成Reference问题

    最近又开始写代码了,所以突然发现SE 2008用起来有点怪怪的。每次新建的Project的Tagfile都没有生成Reference,总是在首次查找Reference的时候特囧地跳出生成Reference的对话框。印象中Slickedit 2007似乎没有这种问题。只好利用周末的时间又跟踪了一下源码,nnd又发现一个低级错误:

    如果在选项里面把“Build workspace tag file with references”设置为true,那么它就会将“def_references_options”变量的VSREF_NO_WORKSPACE_REFS位置位。这个宏看名字就知道了,是告诉Context Tagging别给这个tagfile生成reference的,意义正好相反。

    至于怎么解决,我也不是很清楚。因为SE 2008彻底换了一种配置机制,估计也就是因为这样才马大哈地引入了这种低级问题。实际上如果你只讲究结果的话,只要知道“Build workspace tag file with references”设置成false才会默认生成references就成了。如果你实在是个像我这样的完美主义者……一个最简单猥琐的办法就是修改options.xml,把“Build workspace tag file with references”相关标题和描述里面的“with”改成“without”(# ̄▽ ̄#)。

    另一个问题是发现从v13.01采用了那个无聊的自动组合相关文件的buffer tabs以后,好像文件标签就开始出了一些小毛病。我偶尔会遇到文件标签双击它关不掉,或者是更严重的标签错位的问题。估计又是那个无聊的新功能引入的bug。所以我干脆把老的传统的v13.00那个bufftabs.e给弄回来了。不过还是小改了一把,增加了对v13.01新增的Modified file tab(s)颜色的支持。在load bufftabs.e以后,使用toggle-mark-with-star命令可以让修改的文件的标签显示方式在和UE一样的加“*”传统方式和使用SE传统的文字变色方式之间切换。修改后的宏在我的盒子里面下载,还是在老地方。

    ★ 2008年11月4日更新:大囧,BUG提给SE以后,SE的开发者说打算在v14搞定。但是不准备发行新的v13的hotfix来修正它——因为我给出了“an obvious workaround”( ̄口 ̄)!! 。所以把with改成without,也就是v13最终的workaround了~~

    另外得到一个关于SourceInsight的小道消息:“I did however get a reply back from Source Dynamics recently when asking what was going on over there and "Ray Gram (the owner)" replied that they were busy trying to get version 4.0 out the door. So it sounds like it may not be dead yet.”

    25-7-2008

    自己定制一个SlickEdit的代码导航菜单

    在浏览代码的时候,我一般是喜欢只用鼠标不用键盘的。鼠标有个麻烦就是按键太少了,不能bind多少command上去。所以可以考虑做一个很小的菜单bind到鼠标中键上,把代码导航时最常用的几个功能加进去。这样用起来有点像以前多键鼠标流行的那个鼠标中键菜单。比如在我的SE中,浏览代码时只要点一下鼠标中键就能出来这样的菜单:

    里面有最常用的代码导航所需要的功能,鼠标不费吹灰之力就能点到。这样仅用鼠标操作时在代码里面跳来跳去就爽多了。具体实现方法如下:

    ① 用SlickEdit的菜单编辑器编辑一个自己的菜单。我的菜单代码如下:
    _menu nav_pop_menu {
       "Go to &Definition","push-tag","","","";
       "Pop Bookmark","pop-bookmark","","","";
       "-","","","","";
       "Back","back","","","";
       "Forward","forward","","","";
       "-","","","","";
       "Go to &Reference","push-ref","","","";
       "-","","","","";
       "Edit This Menu","open-menu nav_pop_menu","","","";
    }


    ② 写一个简单的呼出这个菜单的宏:
    _command void
    mou_nav_menu() name_info(','VSARG2_REQUIRES_EDITORCTL)
    {
        mou_click();
        mou_show_menu('nav_pop_menu', 'R');
    }


    ③ 把这个宏bind到鼠标中键或者其他合适的键上(如果你用罗技G1这种类型的鼠标,上面一般有个小小的Back键,这个键SlickEdit也是可以认得的,你能往上边绑命令~~)
    24-7-2008

    让SlickEdit的搜索结果列表在完成搜索后自动得到焦点

    最近在分析内核代码,发现即使是1400×1050和1680×1050两个显示器左右开弓同时上,还是觉得不够巴不得能再多一些显示代码的空间。所以我就把平时基本上一直Dock的Search Results Window给设置成Auto-Hide了。这回搜索的时候就发现有点不对劲:搜索结束以后这个Results Window一闪而过没法得到焦点停住让你看结果。被搞了几次烦死了以后出手改了它,顺便给SE的家伙提了个BUG。结果SE的开发答复说那个不是BUG,其实是故意的想让人完成搜索后能回到上次编辑的地方去( ̄口 ̄)!!。难道真的有人希望在完成搜索后连结果都不看就当什么事也没发生过嘛?!个人认为这个设计有点脑残,还是按照我的Patch修改比较符合常理~~

    这个修订对V12和V13都适用(顺便提一下,SE的家伙说v13.0.1是v13的Final版本了,下个版本是明年春季发布的v14。不过说实话,我觉得v13质量很差,我现在使用的主力编辑器还是v12.0.3)。修改方法如下:

    打开tbfind.e(注意如果你打了hotfix,得从你config的hotfix目录找到最新的宏文件才行),找到_show_current_search_window,改成这样:
    static void _show_current_search_window(boolean show_res)
    {
       if (show_res) {
           activate_search();
       }
    }


    然后在_tbfind_form.ESC()里面去掉对_show_current_search_window的调用(注释掉那行即可,否则在你取消搜索以后Result还是会弹出来)。

    最后找到这个函数的两个调用者_begin_find和_begin_replace,都改成这样:
    ...
    //int current_wid = _get_current_search_wid();
    boolean show_res = (_findlist_all.p_value && _findlist_all.p_enabled);
    ...
    _show_current_search_window(show_res);

    Load tbfind.e,完事收工。

    这样修订完成以后的效果是:如果你平时隐藏了Search Results,在你进行搜索并且搜索的选项设置为“List all occurrences”的时候搜索结果列表会自动显示出来而不会露个脸就跑掉。
    23-7-2008

    利用SlickEdit的Alias+SlickC功能

    SlickEdit的Alias(AKA Snippet)功能本身已经做得不错,能够在Alias模板里面插入当前日期和文件名等,无论你用来自动插入文件头部的Copyright声明、Revision History还是插入一些你自定义的代码片段都还挺得心应手的。不过如果你希望插入一些更高级的东西,那就注意看了:实际上SE的Alias是支持在模板里面调用SE的宏函数的。所以你可以再配合SE强大的SlickC实现非常好用的动态Alias功能。

    我这里只举一个非常简单的小例子演示一下如何编写一个调用SlickC函数的Alias。这个Alias的功能就是为头文件自动生成#ifndef...这组防止头文件被重复包含的条件编译宏。

    假设有个文件叫做list.h。在这个头文件里面我们肯定都会要加上类似这样的宏:

    #ifndef __LIST_H__
    #define __LIST_H__
    ...
    #endif /* __LIST_H__ */


    这个工作重复的多了,自然就想用Alias实现。但是尽管用了Alias自动插入了固定部分,里面的条件编译开关名字(__LIST_H__之类的)还是要自己根据文件名起不能完全自动化。对于这种会变化的部分可以写个简单的SlickC函数来搞定,这个函数的功能就是以“__FILENAME_EXT__”的规则自动根据当前文件名生成条件编译开关名:

    _str _gen_head_def()
    {
        _str buffer_name = strip_filename(p_buf_name,'PD');
        return ('__' :+ stranslate(upcase(buffer_name), '_', '.') :+ '__');
    }


    然后编写一个这样的Alias模板(被我裁过了,实际上我里面还有版权声明什么N多东西),其中用%\m funtion_name%的形式调用这个函数:

    #ifndef %\m _gen_head_def% 
    #define %\m _gen_head_def%

    %\c

    #endif /* %\m _gen_head_def% */


    这样就OK喽。上面这个Alias我起名为“h”,展开Alias的热键我是绑定到Ctrl+Tab上。这样假设你要给processor.h文件添加防止重复包含的条件编译宏,只要敲一个‘h’,然后按Ctrl+Tab展开,就会展开成如下的东西:

    #ifndef __PROCESSOR_H__ 
    #define __PROCESSOR_H__

    [光标位置]

    #endif /* __PROCESSOR_H__ */

    这样用起来就很安逸了。不过用Alias+SlickC做这么简单的事情真是杀鸡用牛刀,还有更多的用处可以自己发掘。
    11-7-2008

    在俺的Blog讨论的时候用词请注意和谐

    俗话说树大招风~~没想到俺的blog这株小野草也招风。各位在我这讨论某软件的某种修订版的时候请勿直接使用直白的英文单词描述,也别用直白的中文描述(不然Google网页翻译还是能凑合让鬼佬看出来)。建议用一些只有真正的天朝子民才能明白的名词(如称为“和谐版”、“共同富裕版”、“中国特色版”等等),让我也避避风头(╥﹏╥)。
    26-6-2008

    SlickEdit 2008 v13.0.1升级简单体会

    终于把SlickEdit升级到v13.0.1。升级后又是丢了我所有的自定义菜单和Workspace分类,重整这些分类并merge之前的patch忙乎了我一个多小时。每次升级都这么伤筋动骨真是郁闷~~

    总的说来,v13.0.1并不值得耗费这么多精力升级(不过如果你没有改过SE什么东西的话那是无所谓了要升就升了)。主要的外在功能改进为如下几点:

    多了个在Project文件树中定位当前编辑的文件的功能。我主要是因为这个功能呢才升级的,因为经常查代码打开大量的文件,常常需要看看某个文件同目录下的其他文件,这个功能比较有用。其实这东西UE、E+什么的小编辑器也早就有了,SE到现在才加上……

    原来神秘消失的Load Hot Fix菜单又回来了~~估计是被那些从来没摸过command line的newbie用户问怕了,只好把GUI的菜单项加回去~~实际上还是敲命令来得安逸~~

    自动完成增加了区分大小写的选项,可以减少候选项提高命中率~~

    语言设置里面增加了个View页面,可以选择针对这种类型的语言是否显示特殊字符和行号宽度等等。这个玩意对我来说没啥用,因为我以前就自己写了宏实现了这种功能。不过好歹这也成了官方支持的功能,应该比自己业余弄出来的玩意好使~~

    文件Tab中未存盘Tab的文字颜色终于可以定制了。以前总是和Diff共用一种颜色非常难兼顾界面和文本显示,搞得我不得不又是一通华丽修改弄成UE那样的加*号不变颜色的显示。这回能分出来自己设定颜色,就好多了。我用不着再merge那个*号patch了:

    另外一个是我觉得非常无聊的功能:在文件标签上聚合类似文件:

    这个功能在使用前是这样的:

    打开此功能以后,位于同一路径下文件名相同但扩展名不同的文件会被整理显示成这样:

    就是c文件和头文件的标签被聚合到一块了,头文件的文件名隐藏仅显示一个扩展名。这样能节省一些标签栏的空间。

    但是这个功能我觉得是很没用。第一:其实真的也省不了多少空间,现在显示器分辨率都很高了少个文件名意义不大,看了还不太习惯的。第二:这个功能真是Buggy。SE的品质控制真是有点问题每次只要是刚推出的功能就是比较Buggy。我反复开开关关这个功能几次,标签栏就傻了。就看前面一个图:tipc_addr变成显示头文件的全名而隐藏了c文件的文件名了。并且在我关了这个头文件以后,那个c文件还是显示为.c没有恢复过来,重启了一把SE才正常。我也忘了是怎么弄出来的了,因为我是不会去用这种无聊的功能所以也懒得提BUG省的写鸟语信费劲。
    20-6-2008

    SlickEdit 2008 13.0.1更新

    装上看了一眼,主要还是BUG fix。少量感兴趣的更新如下:
    • 行号支持自动宽度(唉,这么基础的玩意……还总算支持了汗)
    • 寻找Reference的时候能够限制搜索数目(防止被太大的project撑爆)
    • Current Context列表允许改成按照行号排序
    • 新增一个右键菜单“Show file in Projects”,可以在Project文件树上定位到当前正在编辑的文件(唉,也是早该有了的功能)
    • Code Annotation的日期终于……终于用日期选择器来输入了~~
    还有大片更新跟我关系不大实在懒得看,贴在后面有兴趣的自己去翻。BUG Fixe部分太长了我就删掉了。另外据称此版本有修订License部分去掉了激活啥的,具体没细看~~试了试,用13.0.0的vs.exe替换后无法工作,没戏。

    Appearance
    • Language-specific View options have been added to the Options dialog (Special Characters, line numbers, Hex, etc.). These match the view settings that formerly could only be set per-document (View menu items). To get to the language-specific options, from the main menu, click Tools > Options > Languages > [LanguageCategory] > [Language] > View. Additionally, a new language-specific View option has been added for setting the line number area width. You can set this a fixed with (the default is 6), or, you can use "Automatic" mode, which will adjust the amount of space in the prefix area based on what line in the file you are in. So if you're on line 4764, you'll have room for 4 digits. You can set a minimum width for this feature, so if you want to keep the margin from bouncing around, you can set a minimum and have it not go lower than that. The View > Line Numbers menu item has also been updated. When you turn on line numbers via this switch, SlickEdit checks for and uses your language settings. If you either have no language settings or your language settings are set to no line numbers, SlickEdit uses the default - fixed width line numbers. 
    • HTML Clipboard formats have been enhanced for background colors and color schemes with non-white backgrounds for pasting into documents with white backgrounds. 
    • The New Window Size dialog formerly accessed through the menu item Window > New Window Size, is no longer available and the options have been moved to the Options dialog (Tools > Options > Editing > Editor Windows). 
    Building/Compiling/Running/Debugging
    • SlickEdit version 13.0.1 uses GDB 6.8. You can get the tarball from our Web site here: http://www.slickedit.com/gdb. A patch file is also available on the site that contains a performance optimization we have added to GDB that you can optionally use if you are attempting to build GDB 6.8 for yourself identical to the one we have built. The optimization has been submitted to GDB. 
    • In addition to Apache Ant, SlickEdit now supports NAnt, a .NET build tool similar to Ant. See "NAnt" in the Help > Index for more information. 
    • Added "-doNotCreateObjectDir" option to vsbuild. 
    • The Configure Error Parsing dialog, accessed from the menu item Build > Configure Error Parsing, is still available but the same fields and options are now also located on the Options dialog (Tools > Options > Tools > Configure Error Parsing). 
    • The C/C++ and Java Compiler Properties dialogs, accessed from Project > Project Properties > Compile tab > Ellipses button, are both still available but the same fields and options are now also located on the Options dialog (Tools > Options > Languages > [LanguageCategory] > [Language] > Compiler Properties). 
    • The make program used on Execute Makefile Target is now customizable, so that users with custom make utilities can use standard makefiles. Formerly it was hardcoded to be "make". The fix was to add def_default_make_program and also refactor out the function build_make_command. 
    • Debugger options have been moved to the Options dialog (Tools > Options > Debugger). Formerly, a tabbed dialog was displayed when you use the menu item Debug > Debugger Options or the debug_props command. Now, this menu item/command displays the information about your debugger and provides a button to access the options, which can also be accessed through a new command, debugger_options. A Debugger Info menu item has also been added, right after Detach, since it is associated with a running debugger. This menu item is disabled when the debugger is not running. 
    • The Debugger Options dialog is now resizeable. 
    Context Tagging
    • An option has been added to control the max number of references found in a references search. 
    • Some optimizations have been added to debug_get_mouse_expr() to cache previous result. This will increase performance when the option Show info for symbol under mouse enabled. Note that searching through huge workspaces still takes time, but it is faster than before. 
    • Support has been added for managed C++ ^ (^ is equivalent to __gc*). 
    • Tagging now supports new managed C++ keywords: ref class Name { ... }, value class Name { ... } and interface class Name { ... }. 
    • Tagging now recognizes files that start with "process" as COBOL. 
    • The Select a Tag dialog has been renamed to Select Symbol, and the size is now remembered. 
    • Adding or removing files from the workspace tag file is no longer allowed. 
    • Support has been enhanced for Visual Basic for Applications. 
    • An option has been added to make codehelp_complete (Ctrl+Space) case-sensitive (see Tools > Options > Languages > [LanguageCategory] > [Language] > Context Tagging). 
    • The Current Context tool window now shows the function even if the cursor is in a preceding comment. 
    • A new configuration variable is available to sort the Current Context tool window by line number instead of strictly by tag names. 
    • Context Tagging now supports List Members for C99-style designated initializers, provided you do not mix them with positional initializers. 
    • The Class browser find (cb_find) now screens out definitions, and now when you are prompted for duplicate symbols, you are prompted using the standard "Select Symbol" dialog instead of sellist. Also, if there are no matches, it will just give you a message box saying the declaration was not found; it will not take you to the old Find Tag (_pushtagbookmark_form) dialog. 
    • SlickEdit can now parse "implements" clause in PHP. 
    Documentation
    • Many sections in the documentation have been expanded and improved. Notably, the "Working With Files" section has been improved and includes a new section about the working directory (see Help > Index keyword: "files"), more information has been added and terminology defined in the "Programmable Macros" section (see Help > Index keyword "programmable macros"), the language-specific documentation for Java has been improved and expanded, and the Slick-C Macro Programming Guide has been enhanced to cover recent code enhancements and changes. 
    Editing
    • Language support has been added for Windows PowerShell, found under Tools > Options > Languages > Scripting Languages. Support includes Color Coding, Syntax Indent, Syntax Expansion, and Context Tagging for functions, filters, and aliases. 
    • Language support has been added for SystemVerilog (an extension of Verilog) and Vera. Support includes Color Coding, Syntax Indent, and Syntax Expansion (note that support for projects and Context Tagging have not yet been implemented). To set options for these languages, go to Tools > Options > Languages > Hardware Description Languages. 
    • The option Automatically close visited files formerly located at Tools > Options > Appearance > General has been moved to Tools > Options > Editing > Search > Bookmarks. 
    • You can now create a new lexer when adding a new language (Tools > Options > Languages > Language Manager). 
    • The commands goto_bookmark/gb and delete_bookmark now support command line completion. 
    • Support for the vimtutor command in Vim emulation has been added. This command opens a tutorial file that you can edit as you learn Vim commands. 
    • A Search option has been added to the Option dialog to push a bookmark when using top_of_buffer/bottom_of_buffer (Tools > Options > Editing > Search). Formerly only the def_top_bottom_push_bookmark configuration variable was available to set this option. 
    • Project support has been enhanced and results of GetProjectFiles() cached for better performance. 
    • Syntax Expansion has been enhanced to be more tagging-aware. 
    • A new item has been added to the editor's right-click context menu: Show file in Projects. This shows the current file in the Projects tool window. If the file is in a collapsed node, the node is expanded to show the file. If the file occurs in multiple projects, you are prompted to select which one(s) to expand. A check box in the prompt allows you to just expand all relevant projects. 
    • A new configuration variable is available: def_max_mffind_output def-var. This sets the maximum size for search results before switching to listing matching files only. 
    • A new Search option is available on the Options dialog (Tools > Options > Editing > Search): Maximum search results output (KB). Use this option to specify the maximum amount of search results, in kilobytes, to return after a search operation. 
    • New escape sequences have been added for Aliases: %\un (line not included if function params are expanded; included if function params are not expanded), %\vn (line not included if return types are expanded; included if return types are not expanded), and %(), used to separate identifier characters: for example, %\u%()n has the effect of the %\u option followed by a literal "n". It is recommended that %() be used to separate alias escape sequences ending with a letter from other identifier characters so that new aliases escape sequences won't break existing aliases you have. Don't write %\dx. Write %\d%()x instead. 
    • Annotation dates are now entered and changed using a calendar dialog. The displayed date is no longer hand-editable. 
    • The .i extension is now associated with C/C++. 
    • The Auto-Complete options Auto select unique items and Insert selected are now mutually exclusive. 
    • Enhanced removeDuplicateFunctions to support more style signatures. 
    • The Alias escape sequence %\o now returns full signature. 
    • The %\n and %\o escape sequences now work inside doc comment alias expansions. 
    Files
    • File tabs have been enhanced so that, when adjacent files differ only by file extension, the name of the file on the tab is abbreviated to only show the extension. This saves space and provides better visibility for associated files. For file names to be abbreviated in this style, their paths and base file name must match exactly. For example, C:\rectangles\BorderRectangle.cpp would not abbreviate with C:\src\include\BorderRectangle.h. You can turn this feature on and off for all file tabs by right-clicking in the File Tabs tool window and selecting Abbreviate similar files from the context menu. 
    • A close_others command has been added and available on the right-click context menu of file tabs. This closes all other files except the one you've clicked on. 
    • Some file tabs, like those for search results buffers, build output, and File Manager operations, display a picture in their file tabs by default. An option has been added to the right-click context menu of file tabs to show or hide these pictures. 
    • Backup History options (Tools > Options > File Options > Backup) have changed: 1) The option Make backup files now has three available settings: Select Create backup history on save to use Backup History. This creates a version of the file each time you save, allowing you to compare and restore to earlier versions. Select Create backup file on first save to create a single backup file that preserves the file contents prior to editing. Or select None for no backup history. 2) The option formerly named Backup directory option has been renamed as Backup location. This specifies where the backup files will be created. This option is not available when using Create backup history on save. If you select Global directory or Global nested directories you will need to provide a value for Backup directory path. 3) The option Backup directory path is used to specify the full path to the location used for creating backup files. This is used only when the value for Backup location is Global directory or Global nested directories or when the value for Make backup files is set to Create backup history on save. Press Delete to clear the value and use the default. 
    • The Save configuration option (Tools > Options > Application Options > Exit) now has an additional choice: Save configuration immediately. When this value is set, configuration changes are immediately saved when they are detected.
    Keyboard
    • New key bindings have been added for Emacs-like S-expression navigation that work in all emulations: next_sexp (Ctrl+Alt+Right) and prev_sexp (Ctrl+Alt+Left) can be compared to next_word and prev_word, except that they treat blocks as words. backward_up_sexp (Ctrl+Alt+Up) is the shortcut for navigating to the start of the immediately enclosing block (in Lisp, this would be the open paren). forward_down_sexp (Ctrl+Alt+Down) is used to drill into a block. If the cursor is at the start of a block, it moves the cursor to the first S-expression within the block; otherwise, it behaves like next_sexp. select_prev_sexp (Ctrl+Alt+Shift+Left) and select_next_sexp (Ctrl+Alt+Shift+Right) extend a character selection from the cursor position to the start of the next or previous S-expression, respectively. Like the Shift+Cursor commands do to CUA style selections, if executed repeatedly, they will extend the current character selection. cut_prev_sexp (Ctrl+Alt+Backspace) will delete the S-expression to the left of the cursor and copy it to the clipboard. Again, if called repeatedly, this will prepend the subsequent deletions to the clipboard. 
    Miscellaneous
    • You can now generate GUIDs in SlickEdit. A menu item has been added to the Tools menu: Tools > GUID Generator (gui_insert_guid command) or you can use a command line version of the tool with the insert_guid command. Select from seven formats to generate the new GUID and optionally insert it at the cursor location. 
    Options Dialog Changes
    • All of the Advanced language-specific options have been moved to the General language-specific option node (Tools > Options > Languages > [LanguageCategory] > [Language] > General). 
    • An Expand All Children option has been added to the right-click context menu of the Options dialog tree. This only acts on the current node. 
    • Many keyboard navigation shortcuts have been added to the Options dialog, and the documentation has been updated (see Help > Index keyword "Options dialog shortcuts"). Also, Tab now works better for keyboard navigation. 
    • A new category, Hardware Description Languages, has been created under the Languages node of the Options dialog. This category now contains Verilog and VHDL (moved from the Application Languages category) as well as the newly supported SystemVerilog and Vera. 
    Slick-C
    • New class introspection functions have been added to Slick-C (_typename, _instanceof, etc.) See "Classes > Introspection" in the "Types" chapter of the Slick-C Macro Programming Guide (Help > Contents) for more information. 
    • Many #pragma options (such as strictnames) have been added in Slick-C. See "#pragma" in the "Preprocessing" chapter of the Slick-C Macro Programming Guide (Help > Contents) for more information. 
    • An _insertel() method for arrays and corresponding C API functions vsHvarArrayInsertEl() and vsHvarHashtabInsertEl() have been added to Slick-C. 
    • Added support for #! in Slick-C code - Slick-C does not have to do anything with #!, but it now allows you to have a #! at the top of the file without having an error. 
    • The following keywords are not used in Slick-C and have been removed: by, end, endif, extproc, fkeytext, include, then, to. Note that end is still an event name. 
    18-6-2008

    华丽Slickedit的Doxygen支持更新

    一个中午的进展:发现SE的正则表达式还是有点BUG,所以修改了几处可能引起严重性能问题的地方。
    另外修订了几处Tag解析BUG,增加了@param[in/out]的支持。基本上已经满足我本人的Doxygen文档显示要求。

    目前效果个人比较满意,原始Doxygen注释如下:

    /**
     * 注册TIPC用户
     *
     * 在实际使用中,程序将作为一个@b user注册到TIPC中。此时会得到一个
     * @a userref(唯一的用户标识)。在注册了用户以后,才可以为用户创
     * 建各个服务端口(#tipc_createport)。
     *
     * @param[out] userref      返回创建的用户标识
     * @param[in] cb            用于获取TIPC状态通告的回调函数,@c NULL为不接收状态通告
     * @param[in] usr_handle    在状态通告回调函数被调用时需要传入回调函数的参数
     *
     * @return int          标准错误代码,0表成功
     *
     * @note
     * 示例代码如下:
     * @code
     * static u32 user_ref;
     * tipc_attach(&user_ref, NULL, NULL);
     * @endcode
     *
     * @pre
     * 仅允许在线程中调用,函数本身不会挂起。
     *
     * @see tipc_detach
     */


    用原版的Slickedit显示效果如下:



    可见参数[in/out]、@a @b @c等格式tag、#XXX自动链接、@code等都无法正确解析显示。再看今天中午我完成修订之后的样子:



    好多啦~~已经达到可用水平。

    目前实现的Doxygen扩展为:
    • 支持@param[in, out] @note @pre @post @code @endcode @# @@ @& @% @< @> @~ @\ @a @b @c @e @em @p @n;
    • 支持Auto Link格式:#xxxx;
    • 解决后置单行注释残留“< */”的问题;
    • 支持空行分段。
    更新以后的codehelp.e在我的盒子下载,有v12.0.3和v13.0.0两个版本。
     
    *