【Source Insight 】之marco学习笔记2
现在我们看先看一个
官方地址https://www.sourceinsight.com/download/macro-files/中的
autoexp.em Automatically expands C statements like if, for, while, switch, etc..
/* 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 a
convenient keystroke to the "AutoExpand" command. 3. After typing a keyword, press the AutoExpand keystroke to have the
statement 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 can
use "Search Forward" to select the next ### field. For example:
1. you type "for" + AutoExpand key
2. this is inserted:
for (###; ###; ###)
{
###
}
3. and the first ### field is selected.
-------------------------------------------------------------------------*/
macro AutoExpand()
{
// get window, sel, and buffer handles
hwnd = GetCurrentWnd()
if (hwnd == )
stop
sel = GetWndSel(hwnd)
if (sel.ichFirst == )
stop
hbuf = GetWndBuf(hwnd) // get line the selection (insertion point) is on
szLine = GetBufLine(hbuf, sel.lnFirst); // parse word just to the left of the insertion point
wordinfo = GetWordLeftOfIch(sel.ichFirst, szLine)
ln = sel.lnFirst; chTab = CharFromAscii() // 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 =
while (szLine[ich] == ' ' || szLine[ich] == chTab)
{
ich = ich +
} szLine = strmid(szLine, , ich) # chTab
sel.lnFirst = sel.lnLast
sel.ichFirst = wordinfo.ich
sel.ichLim = wordinfo.ich // expand szWord keyword... if (wordinfo.szWord == "if" ||
wordinfo.szWord == "while" ||
wordinfo.szWord == "elseif")
{
SetBufSelText(hbuf, " (###)")
InsBufLine(hbuf, ln + , "@szLine@" # "{");
InsBufLine(hbuf, ln + , "@szLine@" # "###");
InsBufLine(hbuf, ln + , "@szLine@" # "}");
}
else if (wordinfo.szWord == "for")
{
SetBufSelText(hbuf, " (###; ###; ###)")
InsBufLine(hbuf, ln + , "@szLine@" # "{");
InsBufLine(hbuf, ln + , "@szLine@" # "###");
InsBufLine(hbuf, ln + , "@szLine@" # "}");
}
else if (wordinfo.szWord == "switch")
{
SetBufSelText(hbuf, " (###)")
InsBufLine(hbuf, ln + , "@szLine@" # "{")
InsBufLine(hbuf, ln + , "@szLine@" # "case ###:")
InsBufLine(hbuf, ln + , "@szLine@" # chTab # "###")
InsBufLine(hbuf, ln + , "@szLine@" # chTab # "break;")
InsBufLine(hbuf, ln + , "@szLine@" # "}")
}
else if (wordinfo.szWord == "do")
{
InsBufLine(hbuf, ln + , "@szLine@" # "{")
InsBufLine(hbuf, ln + , "@szLine@" # "###");
InsBufLine(hbuf, ln + , "@szLine@" # "} while (###);")
}
else if (wordinfo.szWord == "case")
{
SetBufSelText(hbuf, " ###:")
InsBufLine(hbuf, ln + , "@szLine@" # "###")
InsBufLine(hbuf, ln + , "@szLine@" # "break;")
}
else
stop SetWndSel(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 the
text word just to the left of the ich. Output:
wordinfo.szWord = the word string
wordinfo.ich = the first ich of the word
wordinfo.ichLim = the limit ich of the word
-------------------------------------------------------------------------*/
macro GetWordLeftOfIch(ich, sz)
{
wordinfo = "" // create a "wordinfo" structure chTab = CharFromAscii() // scan backwords over white space, if any
ich = ich - ;
if (ich >= )
while (sz[ich] == " " || sz[ich] == chTab)
{
ich = ich - ;
if (ich < )
break;
} // scan backwords to start of word
ichLim = ich + ;
asciiA = AsciiFromChar("A")
asciiZ = AsciiFromChar("Z")
while (ich >= )
{
ch = toupper(sz[ich])
asciiCh = AsciiFromChar(ch)
if ((asciiCh < asciiA || asciiCh > asciiZ) && !IsNumber(ch))
break // stop at first non-identifier character
ich = ich - ;
} ich = ich +
wordinfo.szWord = strmid(sz, ich, ichLim)
wordinfo.ich = ich
wordinfo.ichLim = ichLim; return wordinfo
}
【Source Insight 】之marco学习笔记2的更多相关文章
- 【Source Insight 】之marco学习笔记1
我们学习编程语言都是从Hello World!,现在我们学习marco也不例外 打开C:\Users\%USERPROFILE%\Documents\Source Insight 4.0\Projec ...
- 【转】Android source build/envsetup.sh学习笔记
原文网址:http://blog.csdn.net/mliubing2532/article/details/7567164 如果你只需要修改某一个模块的内容,但是却每次都要执行make, 最后等待很 ...
- 烤鸭的Source Insight学习笔记
如果你觉得这网页排版不好看,可以去下载我上传的word版:<烤鸭的Source Insight学习笔记.doc> http://download.csdn.NET/detail/benka ...
- JavaWeb和WebGIS学习笔记(七)——MapGuide Open Source安装、配置以及MapGuide Maestro发布地图——超详细!目前最保姆级的MapGuide上手指南!
JavaWeb和WebGIS学习笔记(七)--MapGuide Open Source安装.配置以及MapGuide Maestro发布地图 超详细!目前最保姆级的MapGuide上手指南! 系列链接 ...
- Nginx学习笔记4 源码分析
Nginx学习笔记(四) 源码分析 源码分析 在茫茫的源码中,看到了几个好像挺熟悉的名字(socket/UDP/shmem).那就来看看这个文件吧!从简单的开始~~~ src/os/unix/Ngx_ ...
- 【工利其器】必会工具之(一)Source Insight篇
前言 “Source Insight(以下简称SI)是世界上最好的编辑器”,说这句话不知道会不会出门被打呢?-_- 中国古话说得好,“文无第一,武无第二”,所以不敢说SI是最好的,但是 ...
- delphi操作xml学习笔记 之一 入门必读
Delphi 对XML的支持---TXMLDocument类 Delphi7 支持对XML文档的操作,可以通过TXMLDocument类来实现对XML文档的读写.可以利用TXMLDocum ...
- Hadoop学习笔记—22.Hadoop2.x环境搭建与配置
自从2015年花了2个多月时间把Hadoop1.x的学习教程学习了一遍,对Hadoop这个神奇的小象有了一个初步的了解,还对每次学习的内容进行了总结,也形成了我的一个博文系列<Hadoop学习笔 ...
- 0035 Java学习笔记-注解
什么是注解 注解可以看作类的第6大要素(成员变量.构造器.方法.代码块.内部类) 注解有点像修饰符,可以修饰一些程序要素:类.接口.变量.方法.局部变量等等 注解要和对应的配套工具(APT:Annot ...
随机推荐
- Qt 使用QMovie加载gif图片实现动态等待窗口
import sys from PyQt4 import QtGui, QtCore from PyQt4.QtGui import QLabel app = QtGui.QApplication(s ...
- python 正则表达提取方法 (提取不来的信息print不出来 加个输出type 再print信息即可)
1,正则表达提取 (findall函数提取) import re a= "<div class='content'>你大爷</div>"x=re.finda ...
- Spring Cloud 各组件调优参数
Spring Cloud整合了各种组件,每个组件往往还有各种参数.本文来详细探讨Spring Cloud各组件的调优参数. Tomcat配置参数 1 server: 2 tomcat: 3 max-c ...
- stopPropagation()阻止事件的冒泡传递
<!doctype html><html><head><meta charset="utf-8"><title>无标题文 ...
- Jmeter(二十七)Jmeter Question 之“集成Ant+Jenkins自动化”
首先介绍一下Ant.Apache Ant,是一个将软件编译.测试.部署等步骤联系在一起加以自动化的一个工具,大多用于Java环境中的软件开发.由Apache软件基金会所提供. 是的.还是Apache家 ...
- [UE4]在C++中使用中文变量和中文注释
一.如果直接在C++中使用中文变量名称,在UE4中编译是会出错的,方法的中文注释也会在UE4中变成乱码 二.只要将h文件和cpp文件用记事本另存为utf-8编码就可以了. 也可以配置VS环境: 如何解 ...
- [UE4]IsValid方法妙用
由于UE4中各个对象的创建顺序无法保证,因此可以使用IsValid方法判断一个对象是否有效,如果无效则初始化,如果有效则直接可以使用.
- sas 获取字符串长度实例
data _null_;a='Dogcat';b=' Dog cat';c=' Dog cat ';Ra=length(a);Rb=length(b);Rc=length(c);put Ra=Rb ...
- remmina从linux远程桌面连接windows失败解决方法
删除如下文件,重新连接 rm ~/.freerdp/known_hosts
- json - 内容中需处理的特殊字符(转)
转 http://blog.csdn.net/icewizardry/article/details/17265267 protected string RemoveIllegalCharacterF ...