现在我们看先看一个

官方地址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. Hard commits, soft commits and transaction logs

    “Hard commits are about durability, soft commits are about visibility“  Transaction Logs 首先介绍下solrcl ...

  2. vue之v-for

    vue.js 的循环渲染是依赖于 v-for 指令,它能够根据 vue 的实例里面的信息,循环遍历所需数据,然后渲染出相应的内容.它可以遍历数组类型以及对象类型的数据,js 里面的数组本身实质上也是对 ...

  3. 配置Flink依赖的pom文件时报错:flink-clients_2.11 & flink-streaming-java_2.11

    在配置eclipse上的pom文件时,在配置到flink-clients_2.11 和 flink-streaming-java_2.11这两个jar包的时候不管怎么弄都报错而且包一大堆错. 最难受的 ...

  4. Tomcat Docker容器自动重启问题排查

    1. 问题 前两天发现 APP 刷新数据偶尔出现等半天没有响应的情况,感觉不像 APP 的问题,就查了下服务端的日志. 服务端用的是 Java,部署采用的 Docker 官方的 tomcat 镜像,并 ...

  5. 客户端负载均衡Feign之二:Feign 功能介绍

    一.Ribboon配置 在Spring cloud Feign中客户端负载均衡是通过Spring cloud Ribbon实现的,所以我们可以直接通过配置Ribbon客户端的方式来自定义各个服务客户端 ...

  6. 学习笔记之Visual Studio Code & Clang

    Mac上XCode太占空间,卸载然后安装VSCode和Clang.在VSCode中再安装extension C/C++和Code Runner,配置Tasks: Configure Task,就可以开 ...

  7. 如何做适合seo的404页面

    我补充一点,404页面对于seo来说也是比较重要的,之所以不让跳转到首页就是楼上说的,容易被误判,所以,一般404页面的作用是引导客户点击进入首页. 实践证明,做了比较好的404页面对网站整体流量和排 ...

  8. 在docker宿主机上查找指定容器内运行的所有进程的PID

    转载 https://www.cnblogs.com/keithtt/p/7591097.html 找到指定容器的所有进程的PID可以更方便的对容器进程进行管理,特别是在某些容器卡住无法连接的场景. ...

  9. jvm感知docker容器参数

    docker中的jvm检测到的是宿主机的内存信息,它无法感知容器的资源上限,这样可能会导致意外的情况. -m参数用于限制容器使用内存的大小,超过大小时会被OOMKilled. -Xmx:  默认为物理 ...

  10. html地址--待更新

    11.学习笔记: 视频直播技术:ijkplayer技术:jni技术: https://www.cnblogs.com/renhui/category/1011048.html: IM:环信, xmpp ...