【Mark】SourceInsight 删除汉字时半个汉字 乱码问题 的补丁

转载 2015年11月18日 09:30:24


*===========================  SuperBackspace.em ============================
* SuperBackspace Version 0.1beta
*
* 代替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;
}

*============================ SuperBackspace.em ============================ 



注意:按此方法配置sourceinsight成功后,会有三个小BUG(目前只发现这三个)

         1、Delete删除时,仍然是一次只能删除半个汉字,仍然会出现乱码;

         2、左右移动光标时,光标仍然会出现在汉字的中间;

         3、当输入法切换到输入汉字模式时,通过shift+符号键,输入符号时,乱码!

 


相关文章推荐

搞定SourceInsight的半个汉字的问题

搞定SourceInsight的半个汉字的问题 “SourceInsight是一个面向项目开发的程序编辑器和代码浏览器,它拥有内置的对C/C++, C#和Java等程序的分析。SourceIns...

source insight中文注释乱码问题的解决方案

最近使用source insight查看一些开源代码,显示中文就乱码,据说是因为source insight不支持utf-8编码,默认编码方式为ANSCII码。所以需要将utf-8等非ANSCII码的...

SourceInsight 3.5 多行注释和删除汉字乱码问题 解决方案

/*====================================================================== 0、单行、多行注释:设定快捷键 alt + / =...

解决SourceInsight的半个汉字的问题

通常安装完的SourceInsight一次只能删除半个汉字的问题 确实情况下,Source Insight删除汉字时是半个半个删除的,删除一半的汉字显示为乱码,在写注释时非常讨厌,最后在网上找到...

解决Source Insight半个汉字问题

  • 2011年02月08日 23:29
  • 3KB
  • 下载

解决Qt中文乱码以及汉字编码的问题(UTF-8/GBK)

一、Qt环境设置 Qt Creator,菜单->工具->选项->文本编辑器->行为->文件编码: 默认编码:System(简体中文windows系统默认指的是GBK编码,即下拉框选项里的GBK/win...

传递汉字丢失或乱码的问题

  • 2012年03月14日 16:30
  • 4KB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:【Mark】SourceInsight 删除汉字时半个汉字 乱码问题 的补丁
举报原因:
原因补充:

(最多只允许输入30个字)