让Source Insight完美支持中文注释 (转)
- /*======================================================================
- 1、BackSpace后退键
- ======================================================================*/
- macro SuperBackspace()
- {
- hwnd = GetCurrentWnd();
- hbuf = GetCurrentBuf();
- if (hbuf == 0)
- stop; // empty buffer
- // get current cursor postion
- ipos = GetWndSelIchFirst(hwnd);
- // get current line number
- ln = GetBufLnCur(hbuf);
- if ((GetBufSelText(hbuf) != "") || (GetWndSelLnFirst(hwnd) != GetWndSelLnLast(hwnd))) {
- // sth. was selected, del selection
- SetBufSelText(hbuf, " "); // stupid & buggy sourceinsight
- // del the " "
- SuperBackspace(1);
- stop;
- }
- // copy current line
- text = GetBufLine(hbuf, ln);
- // get string length
- len = strlen(text);
- // if the cursor is at the start of line, combine with prev line
- if (ipos == 0 || len == 0) {
- if (ln <= 0)
- stop; // top of file
- ln = ln - 1; // do not use "ln--" for compatibility with older versions
- prevline = GetBufLine(hbuf, ln);
- prevlen = strlen(prevline);
- // combine two lines
- text = cat(prevline, text);
- // del two lines
- DelBufLine(hbuf, ln);
- DelBufLine(hbuf, ln);
- // insert the combined one
- InsBufLine(hbuf, ln, text);
- // set the cursor position
- SetBufIns(hbuf, ln, prevlen);
- stop;
- }
- num = 1; // del one char
- if (ipos >= 1) {
- // process Chinese character
- i = ipos;
- count = 0;
- while (AsciiFromChar(text[i - 1]) >= 160) {
- i = i - 1;
- count = count + 1;
- if (i == 0)
- break;
- }
- if (count > 0) {
- // I think it might be a two-byte character
- num = 2;
- // This idiot does not support mod and bitwise operators
- if ((count / 2 * 2 != count) && (ipos < len))
- ipos = ipos + 1; // adjust cursor position
- }
- }
- // keeping safe
- if (ipos - num < 0)
- num = ipos;
- // del char(s)
- text = cat(strmid(text, 0, ipos - num), strmid(text, ipos, len));
- DelBufLine(hbuf, ln);
- InsBufLine(hbuf, ln, text);
- SetBufIns(hbuf, ln, ipos - num);
- stop;
- }
- /*======================================================================
- 2、删除键——SuperDelete.em
- ======================================================================*/
- macro SuperDelete()
- {
- hwnd = GetCurrentWnd();
- hbuf = GetCurrentBuf();
- if (hbuf == 0)
- stop; // empty buffer
- // get current cursor postion
- ipos = GetWndSelIchFirst(hwnd);
- // get current line number
- ln = GetBufLnCur(hbuf);
- if ((GetBufSelText(hbuf) != "") || (GetWndSelLnFirst(hwnd) != GetWndSelLnLast(hwnd))) {
- // sth. was selected, del selection
- SetBufSelText(hbuf, " "); // stupid & buggy sourceinsight
- // del the " "
- SuperDelete(1);
- stop;
- }
- // copy current line
- text = GetBufLine(hbuf, ln);
- // get string length
- len = strlen(text);
- if (ipos == len || len == 0) {
- totalLn = GetBufLineCount (hbuf);
- lastText = GetBufLine(hBuf, totalLn-1);
- lastLen = strlen(lastText);
- if (ipos == lastLen)// end of file
- stop;
- ln = ln + 1; // do not use "ln--" for compatibility with older versions
- nextline = GetBufLine(hbuf, ln);
- nextlen = strlen(nextline);
- // combine two lines
- text = cat(text, nextline);
- // del two lines
- DelBufLine(hbuf, ln-1);
- DelBufLine(hbuf, ln-1);
- // insert the combined one
- InsBufLine(hbuf, ln-1, text);
- // set the cursor position
- SetBufIns(hbuf, ln-1, len);
- stop;
- }
- num = 1; // del one char
- if (ipos > 0) {
- // process Chinese character
- i = ipos;
- count = 0;
- while (AsciiFromChar(text[i-1]) >= 160) {
- i = i - 1;
- count = count + 1;
- if (i == 0)
- break;
- }
- if (count > 0) {
- // I think it might be a two-byte character
- num = 2;
- // This idiot does not support mod and bitwise operators
- if (((count / 2 * 2 != count) || count == 0) && (ipos < len-1))
- ipos = ipos + 1; // adjust cursor position
- }
- // keeping safe
- if (ipos - num < 0)
- num = ipos;
- }
- else {
- i = ipos;
- count = 0;
- while(AsciiFromChar(text) >= 160) {
- i = i + 1;
- count = count + 1;
- if(i == len-1)
- break;
- }
- if(count > 0) {
- num = 2;
- }
- }
- text = cat(strmid(text, 0, ipos), strmid(text, ipos+num, len));
- DelBufLine(hbuf, ln);
- InsBufLine(hbuf, ln, text);
- SetBufIns(hbuf, ln, ipos);
- stop;
- }
- /*======================================================================
- 3、左移键——SuperCursorLeft.em
- ======================================================================*/
- macro IsComplexCharacter()
- {
- hwnd = GetCurrentWnd();
- hbuf = GetCurrentBuf();
- if (hbuf == 0)
- return 0;
- //当前位置
- pos = GetWndSelIchFirst(hwnd);
- //当前行数
- ln = GetBufLnCur(hbuf);
- //得到当前行
- text = GetBufLine(hbuf, ln);
- //得到当前行长度
- len = strlen(text);
- //从头计算汉字字符的个数
- if(pos > 0)
- {
- i=pos;
- count=0;
- while(AsciiFromChar(text[i-1]) >= 160)
- {
- i = i - 1;
- count = count+1;
- if(i == 0)
- break;
- }
- if((count/2)*2==count|| count==0)
- return 0;
- else
- return 1;
- }
- return 0;
- }
- macro moveleft()
- {
- hwnd = GetCurrentWnd();
- hbuf = GetCurrentBuf();
- if (hbuf == 0)
- stop; // empty buffer
- ln = GetBufLnCur(hbuf);
- ipos = GetWndSelIchFirst(hwnd);
- if(GetBufSelText(hbuf) != "" || (ipos == 0 && ln == 0)) // 第0行或者是选中文字,则不移动
- {
- SetBufIns(hbuf, ln, ipos);
- stop;
- }
- if(ipos == 0)
- {
- preLine = GetBufLine(hbuf, ln-1);
- SetBufIns(hBuf, ln-1, strlen(preLine)-1);
- }
- else
- {
- SetBufIns(hBuf, ln, ipos-1);
- }
- }
- macro SuperCursorLeft()
- {
- moveleft();
- if(IsComplexCharacter())
- moveleft();
- }
- /*======================================================================
- 4、右移键——SuperCursorRight.em
- ======================================================================*/
- macro moveRight()
- {
- hwnd = GetCurrentWnd();
- hbuf = GetCurrentBuf();
- if (hbuf == 0)
- stop; // empty buffer
- ln = GetBufLnCur(hbuf);
- ipos = GetWndSelIchFirst(hwnd);
- totalLn = GetBufLineCount(hbuf);
- text = GetBufLine(hbuf, ln);
- if(GetBufSelText(hbuf) != "") //选中文字
- {
- ipos = GetWndSelIchLim(hwnd);
- ln = GetWndSelLnLast(hwnd);
- SetBufIns(hbuf, ln, ipos);
- stop;
- }
- if(ipos == strlen(text)-1 && ln == totalLn-1) // 末行
- stop;
- if(ipos == strlen(text))
- {
- SetBufIns(hBuf, ln+1, 0);
- }
- else
- {
- SetBufIns(hBuf, ln, ipos+1);
- }
- }
- macro SuperCursorRight()
- {
- moveRight();
- if(IsComplexCharacter()) // defined in SuperCursorLeft.em
- moveRight();
- }
- /*======================================================================
- 5、shift+右移键——ShiftCursorRight.em
- ======================================================================*/
- macro IsShiftRightComplexCharacter()
- {
- hwnd = GetCurrentWnd();
- hbuf = GetCurrentBuf();
- if (hbuf == 0)
- return 0;
- selRec = GetWndSel(hwnd);
- pos = selRec.ichLim;
- ln = selRec.lnLast;
- text = GetBufLine(hbuf, ln);
- len = strlen(text);
- if(len == 0 || len < pos)
- return 1;
- //Msg("@len@;@pos@;");
- if(pos > 0)
- {
- i=pos;
- count=0;
- while(AsciiFromChar(text[i-1]) >= 160)
- {
- i = i - 1;
- count = count+1;
- if(i == 0)
- break;
- }
- if((count/2)*2==count|| count==0)
- return 0;
- else
- return 1;
- }
- return 0;
- }
- macro shiftMoveRight()
- {
- hwnd = GetCurrentWnd();
- hbuf = GetCurrentBuf();
- if (hbuf == 0)
- stop;
- ln = GetBufLnCur(hbuf);
- ipos = GetWndSelIchFirst(hwnd);
- totalLn = GetBufLineCount(hbuf);
- text = GetBufLine(hbuf, ln);
- selRec = GetWndSel(hwnd);
- curLen = GetBufLineLength(hbuf, selRec.lnLast);
- if(selRec.ichLim == curLen+1 || curLen == 0)
- {
- if(selRec.lnLast == totalLn -1)
- stop;
- selRec.lnLast = selRec.lnLast + 1;
- selRec.ichLim = 1;
- SetWndSel(hwnd, selRec);
- if(IsShiftRightComplexCharacter())
- shiftMoveRight();
- stop;
- }
- selRec.ichLim = selRec.ichLim+1;
- SetWndSel(hwnd, selRec);
- }
- macro SuperShiftCursorRight()
- {
- if(IsComplexCharacter())
- SuperCursorRight();
- shiftMoveRight();
- if(IsShiftRightComplexCharacter())
- shiftMoveRight();
- }
- /*======================================================================
- 6、shift+左移键——ShiftCursorLeft.em
- ======================================================================*/
- macro IsShiftLeftComplexCharacter()
- {
- hwnd = GetCurrentWnd();
- hbuf = GetCurrentBuf();
- if (hbuf == 0)
- return 0;
- selRec = GetWndSel(hwnd);
- pos = selRec.ichFirst;
- ln = selRec.lnFirst;
- text = GetBufLine(hbuf, ln);
- len = strlen(text);
- if(len == 0 || len < pos)
- return 1;
- //Msg("@len@;@pos@;");
- if(pos > 0)
- {
- i=pos;
- count=0;
- while(AsciiFromChar(text[i-1]) >= 160)
- {
- i = i - 1;
- count = count+1;
- if(i == 0)
- break;
- }
- if((count/2)*2==count|| count==0)
- return 0;
- else
- return 1;
- }
- return 0;
- }
- macro shiftMoveLeft()
- {
- hwnd = GetCurrentWnd();
- hbuf = GetCurrentBuf();
- if (hbuf == 0)
- stop;
- ln = GetBufLnCur(hbuf);
- ipos = GetWndSelIchFirst(hwnd);
- totalLn = GetBufLineCount(hbuf);
- text = GetBufLine(hbuf, ln);
- selRec = GetWndSel(hwnd);
- //curLen = GetBufLineLength(hbuf, selRec.lnFirst);
- //Msg("@curLen@;@selRec@");
- if(selRec.ichFirst == 0)
- {
- if(selRec.lnFirst == 0)
- stop;
- selRec.lnFirst = selRec.lnFirst - 1;
- selRec.ichFirst = GetBufLineLength(hbuf, selRec.lnFirst)-1;
- SetWndSel(hwnd, selRec);
- if(IsShiftLeftComplexCharacter())
- shiftMoveLeft();
- stop;
- }
- selRec.ichFirst = selRec.ichFirst-1;
- SetWndSel(hwnd, selRec);
- }
- macro SuperShiftCursorLeft()
- {
- if(IsComplexCharacter())
- SuperCursorLeft();
- shiftMoveLeft();
- if(IsShiftLeftComplexCharacter())
- shiftMoveLeft();
- }
- /*---END---*/
转自:http://blog.chinaunix.net/uid-10540984-id-3214137.html
转载于:https://www.cnblogs.com/suiying/p/4631759.html
让Source Insight完美支持中文注释 (转)相关推荐
- Source Insight完美转换UTF-8 到 GB2312
Source Insight完美转换UTF-8 到 GB2312 文/蒹葭 前言 很多人用source insight 打开某些源码文件时,汉字显示为一堆乱码.这个问题是因为编码方式不同.记事本和一些 ...
- PHP生成PDF完美支持中文,解决TCPDF乱码
PHP生成PDF完美支持中文,解决TCPDF乱码 2011-09-26 09:04 418人阅读 评论(0) 收藏 举报 phpfontsheaderttfxhtml文档 PHP生成PDF完美支持中文 ...
- NDoc修改版,支持中文注释及中文界面。
这几天正在做一个项目的开发文档,以前试用NDoc做开发文档时不支持中文,真是不爽.这几天看了源代码,修改了其中的一段源代码及配置文件后,支持中文注释及中文界面(目前只做了Msdn2003一种). 以下 ...
- [转载]tomcat的配置文件server.xml不支持中文注释的解决办法
原文链接:http://tjmljw.iteye.com/blog/1500370 启动tomcat失败,控制台一闪而过,打开catalina的log发现错误指向了conf/server.xml,报错 ...
- ffmpeg中文开发手册_快速调用复杂命令,支持中文注释,命令行备忘工具navi两天就火了...
晓查 发自 凹非寺 量子位 报道 | 公众号 QbitAI 刚学的一句新命令,才用完就忘了用法?通常情况下,命令后加一句-help就行了. 但是,命令的帮助文档往往内容太太太太多了,在里面找到自己关心 ...
- Hive表设置支持中文注释、中文表数据导入
问题 1.创建表的时候,comment说明字段包含中文,表成功创建成功之后,中文说明显示乱 create table student_score( stu_id string comment '学生i ...
- Source Insight 4.0设置注释与反注释的快捷键
之前有一篇详细的说明Source Insight 4.0:source insight教程:常用设置.快捷键.附带source insight3.5和4的对比 source insight查看函数调用 ...
- FL STUDIO 20.8中文汉化版完美支持中文语言
FL Studio 简称FL,全称:Fruity Loops Studio,因此国人习惯叫它"水果".目前最新版本(包括测试版本)是FL studio 20.8,它让你的计算机就像 ...
- codelite14中文语言包_Windows下CodeLite完美支持中文的正确设置方法
一.准备工作 1.下载CodeLite最新版本 官方下载 .建议用迅雷下载比较快 如果想检验本文内容的有效性,你必须下载Windows系统下的版本. 2.下载中文语言包 论坛下载 . 如果链接无效, ...
最新文章
- 【Android Gradle 插件】Android Plugin DSL Reference 离线文档下载 ( GitHub 下载文档 | 查看文档 )
- 七大排序算法的个人总结(三)
- 【腾讯Bugly干货分享】Android Linker 与 SO 加壳技术
- 学生成绩管理系统测试用例C语言,学生成绩管理系统测试用例.doc
- 将iOS默认上下文坐标系改变为Quartz通常坐标系
- 题库明细 使用java理解程序逻辑
- php更改txt文件,如何使用php对txt文件进行修改
- python可以用来写什么_对于一个OIer,Python能干些什么?
- Flink 1.10 和 Hive 3.0 性能对比(附 Demo 演示 PPT)
- 黑马vue实战项目-(二)用户列表开发
- python itchat_Python itchat模块在微信上的
- windows通过资源管理器访问服务器(samba服务),您需要权限来执行此操作
- 哈哈,美食是生活的重要组成啊,自己烹调鲍鱼
- ios mac使用mitmproxy抓包
- 知识共享有多难?做好这几点,问题统统解决
- [vijos P1391] 想越狱的小杉
- linux pcs 所有命令,BaiduPCS-Go Windows或linux下百度网盘cmd命令行详细使用方法
- 《OpenGL超级宝典》环境搭建
- 小学计算机教师教科研方面,小学信息技术教师先进事迹范文
- VSFTPD配置方法手册