【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 ...
随机推荐
- pdo连接数据
<?php //1.操作其它数据库//2.事务功能//3.防止SQL注入攻击 //造PDO对象//$dsn = "mysql:dbname=mydb;host=localhost&qu ...
- 函数节流和防抖(todo)
一.什么是函数节流和函数防抖 函数节流和函数防抖目的都是避免同时多次执行函数. 函数防抖是将多次执行变成一次执行,函数节流是将多次执行变成每隔一定时间执行一次. 二.具体实现 三.什么时候需要节流,什 ...
- bzoj4940: [Ynoi2016]这是我自己的发明
用dfs序把询问表示成询问dfs序的两个区间中的信息 拆成至多9个询问(询问dfs序的两个前缀),对这些询问用莫队处理,时间复杂度$O(n\sqrt{m})$ #include<bits/std ...
- Null hypothesis TypeⅠerror Type Ⅱ error
Null hypothesis usually express the phenomenon of no effect or no difference. TypeⅠerror is the inco ...
- R语言学习——根据信息熵建决策树KD3
R语言代码 决策树的构建 rm(list=ls()) setwd("C:/Users/Administrator/Desktop/R语言与数据挖掘作业/实验3-决策树分类") #s ...
- stopPropagation()阻止事件的冒泡传递
<!doctype html><html><head><meta charset="utf-8"><title>无标题文 ...
- 云区域(region),可用区(AZ),跨区域数据复制(Cross-region replication)与灾备(Disaster Recovery)(部分1)
本文分两部分:部分1 和 部分2.部分1 介绍 AWS,部分2 介绍阿里云和OpenStack云. 1. AWS 1.1 AWS 地理组件概况 AWS 提供三种地理性组件: Regions:区域,即A ...
- [UE4]Grid Panel
一.使用Grid Panel可以做出类似暗黑3一样的物品栏:不同的物品栏占据的物品栏格子不一样. 二.GridPanel.FillRules,可以设置每个单元格内的控件是否是拉伸比重.注意:这个是Gr ...
- 修改IP和DNS的dos命令
修改IP,掩码,网关命令: netsh interface ip set address "本地连接" static 192.168.3.188 255.255.255.0 192 ...
- C# DataGirdview手动添加数据,导出txt文件并自动对齐
//DataGirdview手动添加数据 private void btnDataGirdView_Click(object sender,EventArgs e) { dataGridV ...