【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 ...
随机推荐
- C/C++基础----动态内存
why 管理较难,忘记释放会内存泄漏,提早释放可能非法引用,重复释放. 为了更容易,更安全的使用动态内存,提供智能指针,其默认初始化保存一个空指针. what shared_ptr允许多个指针指向同一 ...
- Python——ipython(python programming)
Tab自动补充 Ctrl+c中断程序 ?帮助调出文档 _得到上次的结果 ,__的到上上次结果,___得到上上次结果 %开头的为魔术命令 %timeit 得到运算时间,多次求平均 %%time ...
- [转][MVC4]
<add key="vs:EnableBrowserLink" value="false"/> 把这个加到 <appSettings /> ...
- Scrapy学习篇(六)之Selector选择器
当我们取得了网页的response之后,最关键的就是如何从繁杂的网页中把我们需要的数据提取出来,python从网页中提取数据的包很多,常用的有下面的几个: BeautifulSoup它基于HTML代码 ...
- TextView-- 测量文字宽度
https://my.oschina.net/lengwei/blog/637380; http://blog.csdn.net/mare_blue/article/details/51388403; ...
- Rehash死锁的问题
为什么都说HashMap是线程不安全的呢?它在多线程环境下,又会发生什么情况呢? resize死循环 我们都知道HashMap的初始容量是16,一般来说,当插入数据时,都会检查容量有没有超过设定的th ...
- B-树和B+树的应用
1 .B-树定义 B-树是一种平衡的多路查找树,它在文件系统中很有用. 定义:一棵m 阶的B-树,或者为空树,或为满足下列特性的m 叉树:⑴树中每个结点至多有m 棵子树:⑵若根结点不是叶子结点,则至少 ...
- T-SQL 有参数存储过程的创建与执行
use StudentManager go if exists(select * from sysobjects where name='usp_ScoreQuery2') drop procedur ...
- linux下打开文件、编辑文本cat\gedit\nano
cat: 文本编辑器:gedit.nano,要获得根权限,在前面加上sudo
- CRM 2016 执行IFrame 子页面中函数
CRM代码: var iframe = Xrm.Page.getControl("IFRAME_xxx").getObject(); iframe.contentWindow.Re ...