现在我们看先看一个

官方地址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的更多相关文章

  1. 【Source Insight 】之marco学习笔记1

    我们学习编程语言都是从Hello World!,现在我们学习marco也不例外 打开C:\Users\%USERPROFILE%\Documents\Source Insight 4.0\Projec ...

  2. 【转】Android source build/envsetup.sh学习笔记

    原文网址:http://blog.csdn.net/mliubing2532/article/details/7567164 如果你只需要修改某一个模块的内容,但是却每次都要执行make, 最后等待很 ...

  3. 烤鸭的Source Insight学习笔记

    如果你觉得这网页排版不好看,可以去下载我上传的word版:<烤鸭的Source Insight学习笔记.doc> http://download.csdn.NET/detail/benka ...

  4. JavaWeb和WebGIS学习笔记(七)——MapGuide Open Source安装、配置以及MapGuide Maestro发布地图——超详细!目前最保姆级的MapGuide上手指南!

    JavaWeb和WebGIS学习笔记(七)--MapGuide Open Source安装.配置以及MapGuide Maestro发布地图 超详细!目前最保姆级的MapGuide上手指南! 系列链接 ...

  5. Nginx学习笔记4 源码分析

    Nginx学习笔记(四) 源码分析 源码分析 在茫茫的源码中,看到了几个好像挺熟悉的名字(socket/UDP/shmem).那就来看看这个文件吧!从简单的开始~~~ src/os/unix/Ngx_ ...

  6. 【工利其器】必会工具之(一)Source Insight篇

    前言         “Source Insight(以下简称SI)是世界上最好的编辑器”,说这句话不知道会不会出门被打呢?-_- 中国古话说得好,“文无第一,武无第二”,所以不敢说SI是最好的,但是 ...

  7. delphi操作xml学习笔记 之一 入门必读

    Delphi 对XML的支持---TXMLDocument类       Delphi7 支持对XML文档的操作,可以通过TXMLDocument类来实现对XML文档的读写.可以利用TXMLDocum ...

  8. Hadoop学习笔记—22.Hadoop2.x环境搭建与配置

    自从2015年花了2个多月时间把Hadoop1.x的学习教程学习了一遍,对Hadoop这个神奇的小象有了一个初步的了解,还对每次学习的内容进行了总结,也形成了我的一个博文系列<Hadoop学习笔 ...

  9. 0035 Java学习笔记-注解

    什么是注解 注解可以看作类的第6大要素(成员变量.构造器.方法.代码块.内部类) 注解有点像修饰符,可以修饰一些程序要素:类.接口.变量.方法.局部变量等等 注解要和对应的配套工具(APT:Annot ...

随机推荐

  1. ALGO-151_蓝桥杯_算法训练_6-2递归求二进制表示位数

    记: 进制转换 AC代码: #include <stdio.h> #define K 2 int main(void) { ; scanf("%d",&n); ...

  2. 【Graphite】Graphite常用函数使用

    使用Graphite进行sort排名 限制返回条数 aliasByNode(limit(sortByMaxima(summarize(EPIC.bm.00*.memory.memory.buffere ...

  3. JSON 语法

    ylbtech-JSON: JSON 语法 JSON 语法是 JavaScript 语法的子集. 1. JSON 语法规则返回顶部 JSON 语法是 JavaScript 对象表示语法的子集. 1. ...

  4. selector的小箭头去除

    selector的小箭头去除 .not-arrow{ -webkit-appearance:none; -moz-appearance:none; appearance:none; /*去掉下拉箭头* ...

  5. python输出缓冲区的问题

    碰到的问题,一段代码,print在前,log的在后,查看日志中log的反而在前面.是python输出缓冲区的问题. python输出缓冲区要满 4k 才写入文件,除非禁用缓存或者强制输出或者程序结束. ...

  6. [UE4]GameInstance初始化

    GameInstance的生命周期跟游戏进程一样. 每一次进入游戏都会初始化一个GameInstance,直到退出游戏才会被销毁. 不会随着场景的变化而被销毁.

  7. MySQL 插件CONNECTION_CONTROL和CONNECTION_CONTROL_FAILED_LOGIN_ATTEMPTS

    mysql> show variables like 'plugin_dir';+---------------+------------------------------+| Variabl ...

  8. PostgreSQL手动主从切换

    主从切换操作: 1>主库宕机或者测试主备切换情况下停掉主库:systemctl stop postgres 从库会报日志错误信息:[root@db02 /]# cd /var/postgresq ...

  9. dropdownlist 绑定方法

    this.ddlUnit.SelectedValue = id; //注意大小写,如果选中失败会显示默认值. ListItem item=ddlUnit.Items.FindByValue(id); ...

  10. 第11章 拾遗5:IPv6和IPv4共存技术(2)_ISATAP隧道技术

    6.3 ISATAP隧道技术 (1)基本概念 ①在一个IPv4网络中主机与路由器之间创建一条ISATAP隧道,以便让该主机可以访问IPv6网络中的资源. ②条件:IPv4中的PC主机需要支持IPv4和 ...