让source insight更好的支持中文

From: http://blog.csdn.net/aylixuan/article/details/6066126

1.记事本录入以下文字:

/*  * 代替SourceInsight原有的Backspace功能(希望如此)  * 增加了对双字节汉字的支持,在删除汉字的时候也能同时删除汉字的高字节而缓解半个汉字问题  * 能够对光标在汉字中间的情况进行自动修正  *  * 安装:  * ① 复制入SourceInsight安装目录;  * ② Project→Open Project,打开Base项目;  * ③ 将复制过去的SuperBackspace.em添加入Base项目;  * ④ 重启SourceInsight;  * ⑤ Options→Key Assignments,将Marco: SuperBackspace绑定到BackSpace键;  * ⑥ Enjoy!!  *  * This program is free software; you can redistribute it and/or modify  * it under the terms of the GNU General Public License as published by  * the Free Software Foundation; either version 2 of the License, or  * (at your option) any later version.  *  * This program is distributed in the hope that it will be useful,  * but WITHOUT ANY WARRANTY; without even the implied warranty of  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  * GNU General Public License for more details.  *  * You should have received a copy of the GNU General Public License  * along with this program; if not, write to the Free Software  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA  */  
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;  
}  
/*参考上面以及SourceInsight中的chm帮助文档;  有缺点:(1)移动箭头也会记录到历史操作步骤,应该能够避免这些操作被记录;(2)函数没有整理,有冗余;  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[i]) >= 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();  
} 

2.保存为uperBackspace.em按说明进行操作

3.欣赏效果

PS:改变comment字体,可以使中文紧凑显示.



本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/404629.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

阿里云linux主机安装qt报错:缺少libxkbcommon-x11.so.0

ubuntu云主机安装xfce桌面后&#xff0c;下载qt5.12.10&#xff0c;开发桌面应用&#xff0c;安装qt时报错缺少libxkbcommon-x11.so.0。 由于xfce是轻量级桌面不带libxkbcommon-x11.so.0&#xff0c;而qt5.12.10默认系统已经自带&#xff0c;所以&#xff0c;报错。此时更新一下…

[react] 你知道的react性能优化有哪些方法?

[react] 你知道的react性能优化有哪些方法&#xff1f; shouldComponentUpdate PureComponent &#xff1a;Class ComponentReact.Memo &#xff1a;Function ComponentuseCallback &#xff1a;Memoized FunctionuseMemo &#xff1a;Memozied Value个人简介 我是歌谣&#…

【转】XP/2000无法使用“缩略图查看”、右键无“设置桌面背景”选项问题详解...

许多朋友在XP或2000系统下查看图片时&#xff0c;经常碰到以下几个问题&#xff1a; 1. 当我查看文件夹里面的图片&#xff0c;以缩略图方式查看时&#xff0c;却发现系统不能显示图片内容了&#xff0c;只是出来一个简单的图片图标&#xff08;就和我们以图标或平铺显示的…

PHP的curl实现get,post 和 cookie(几个实例)

类似于dreamhost这类主机服务商&#xff0c;是显示fopen 的使用 的。使用php的curl可以实现支持FTP、FTPS、HTTP HTPPS SCP SFTP TFTP TELNET DICT FILE和LDAP。curl 支持SSL证书、HTTP POST、HTTP PUT 、FTP 上传&#xff0c;kerberos、基于HTT格式的上传、代理、cookie、用户…

Qt treeWidget 查找指定字段内容的条目并跳转到该条目

遍历Qt treeWidget&#xff0c;查找指定字段内容的条目&#xff0c;并跳转到该条目。 void MainWindow::on_pushButton_sidFind_clicked() {QString sid ui->lineEdit_sidFind->text();QTreeWidgetItemIterator it(ui->treeWidget_sqItem);while (*it) {if ((*it)-&…

[react] 什么是浅层渲染?

[react] 什么是浅层渲染&#xff1f; 当为 React 写单元测试时&#xff0c;浅层渲染(Shallow Renderer) 会变得十分有用。浅层渲染使你可以渲染 “单层深度” 的组件&#xff0c;并且对组件的 render 方法的返回值进行断言&#xff0c;不用担心子组件的行为&#xff0c;组件并…

document.all和document.layers

document.all是IE 4.0及以上版本的专有属性&#xff0c;是一个表示当前文档的所有对象的娄组&#xff0c;不仅包括页面上可见的实体对象&#xff0c;还包括一些不可见的对象&#xff0c;比如html注释等等。在document.all数组里面&#xff0c;元素不分层次&#xff0c;是按照其…

strip and linux lib compile

From: http://www.360doc.com/content/11/0808/17/7472348_138951246.shtml strip经常用来去除目标文件中的一些符号表、调试符号表信息&#xff0c;以减小程序的大小&#xff0c;在rpmbuild包的最后就用到。 其支持的选项如下&#xff1a; >strip -h 用法&#xff1a;str…

SpringMVC之控制器的单例和多例管理

版权声明&#xff1a;本文为博主原创文章&#xff0c;未经博主允许不得转载。 在使用Spring3对控制器Controller进行bean管理时&#xff0c;如果要对控制器是否单例进行管理。 有两种方式配置多例模式&#xff1a; 1.springXML 2.注解本身的控制器类 [java] view plaincopyprin…

Python多个版本指定如何指定

1、指定python3 32bit 版本安装SciPy库 py -3-32 -m pip install SciPy 2、指定python2 64bit 版本安装SciPy库 py -2-64 -m pip install SciPy 3、进入指定版本根目录执行操作 D:\Tools\python37_32bit>python.exe -m pip list

[react] react16的reconciliation和commit分别是什么?

[react] react16的reconciliation和commit分别是什么&#xff1f; React 16 三个核心&#xff1a; Scheduler 调度器&#xff1a;决定什么时候调度 ReconcilerReconciler 协调器&#xff1a;进行 Fiber diff 及新的 Fiber 树的生成以及副作用记录Commit 将新的树应用到 DOM 中…

BZOJ 1997: [Hnoi2010]Planar( 2sat )

平面图中E ≤ V*2-6..一个圈上2个点的边可以是在外或者内, 经典的2sat问题..------------------------------------------------------------------------------------------#include<cstdio>#include<cstring>#include<algorithm>#include<stack>usin…

Qt6.2.1在线安装教程

1、Qt下载官网 Download Qt | Develop Desktop & Embedded Systems | Qt 2、下载后在线安装 安装时会要求登陆账号&#xff0c;这个可以去官网注册账号。 相关模块和版本按需选择。以下为我的项目开发需要安装的部分模块&#xff1a; 然后漫长等待安装结束即可。

Vxworks增加system call

Vxworks中增加system call的伪代码.比如用户层可以获取kernel中的time tick.#include <syscall.h>#include<syscallLib.h>unsignedshortgettimdsp(void);SYSCALL_RTN_TBL_ENTRYmsGetTbl[] {{(FUNCPTR) gettimdsp, 1,"gettimdsp", 0}};unsignedshortgetti…

[react] 使用react写一个todo应用,说说你的思路

[react] 使用react写一个todo应用&#xff0c;说说你的思路 拆分组件&#xff1a;应用 表单部分&#xff08;input button&#xff09;、列表部分&#xff08;checkbox ul>li delete button&#xff09;数据设计&#xff1a;表单的待输入字段 列表中的List数据&#x…

第一次写博客

学习关于前端的知识也有些时间了&#xff0c;从一点不懂到现在的了解到很多关于前端各方面的知识&#xff0c;也算是收获了许多吧&#xff0c;学习了HTML,CSS,JavaScript,PHP,ajax,jQuery,等等许多东西&#xff0c;还有一些框架结构和关于函数的封装&#xff0c;可是关于所学的…

shell除去重复的行——uniq命令

From: http://blog.163.com/redhumor126/blog/static/1955478420123119218332/ 进行排序之后&#xff0c;您会发现有些行是重复的。有时候该重复信息是不需要的&#xff0c;可以将它除去以节省磁盘空间。不必对文本行进行排序&#xff0c;但是您应当记住 uniq 在读取行时会对…

Qt6.2.1使用clang格式化代码

1、环境说明 Qt6.2.1 64bit, windows环境, 安装链接&#xff1a;Download Qt | Develop Desktop & Embedded Systems | Qt llvm 10.0.0 64bit windows环境&#xff0c;安装链接&#xff1a; LLVM Download Page 2、启用Beautifer 帮助--关于插件&#xff0c;勾选Beautif…

为何加入了AddType就无法启动Apache

AddType application/x-compress .Z AddType application/x-gzip .gz .tgz AddType application/x-httpd-php.php 如上面第3句加入了就无法启动apache。这是为什么&#xff1f; 其实我一直都没有错误。后来在网络上找了下&#xff0c;原来addtype这种值只有通过拷贝&#xff0c…

[react] 请说说你对react的render方法的理解

[react] 请说说你对react的render方法的理解 render是class组件中必须被重载的方法&#xff0c;组件执行render方法的条件如下&#xff1a; 初始渲染this.setState方法&#xff0c;参数不能为null,及时this.setState({}),或者setState一个相同的值&#xff0c;也会导致render…