sourceinsight 中文支持 解决办法

2024-06-20 22:48

本文主要是介绍sourceinsight 中文支持 解决办法,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

功能描述:

一、解决sourceinsight 中,←、 →、 del、 backspace 中文半字的问题
二、解决sourceinsight 中,中文间距过大的问题

操作步骤

一、中文半字的问题

1、用everything搜索文件:utils.em(C:\Program Files (x86)\Source Insight 3)
2、用sourceinsight打开文件:utils.em
3、在文件末尾添加下面代码
4、Options→Key Assignments,将下面宏依次与相应按键绑定:
Macro: SuperBackspace绑定到BackSpace键,
Macro: SuperCursorLeft绑定到键,
Macro: SuperCursorRight绑定到键,
Macro: SuperShiftCursorLeft绑定到Shift+
Macro: SuperShiftCursorRight绑定到shift+
Macro: SuperDelete绑定到del

/*======================================================================
1、BackSpace后退键
======================================================================*/
macro SuperBackspace()
{hwnd = GetCurrentWnd();hbuf = GetCurrentBuf();if (hbuf == 0)stop; // empty buffer// get current cursor postionipos = GetWndSelIchFirst(hwnd);// get current line numberln = GetBufLnCur(hbuf);if ((GetBufSelText(hbuf) != "") || (GetWndSelLnFirst(hwnd) != GetWndSelLnLast(hwnd))) {// sth. was selected, del selectionSetBufSelText(hbuf, " "); // stupid & buggy sourceinsight// del the " "SuperBackspace(1);stop;}// copy current linetext = GetBufLine(hbuf, ln);// get string lengthlen = strlen(text);// if the cursor is at the start of line, combine with prev lineif (ipos == 0 || len == 0) {if (ln <= 0)stop; // top of fileln = ln - 1; // do not use "ln--" for compatibility with older versionsprevline = GetBufLine(hbuf, ln);prevlen = strlen(prevline);// combine two linestext = cat(prevline, text);// del two linesDelBufLine(hbuf, ln);DelBufLine(hbuf, ln);// insert the combined oneInsBufLine(hbuf, ln, text);// set the cursor positionSetBufIns(hbuf, ln, prevlen);stop;}num = 1; // del one charif (ipos >= 1) {// process Chinese characteri = 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 characternum = 2;// This idiot does not support mod and bitwise operatorsif ((count / 2 * 2 != count) && (ipos < len))ipos = ipos + 1; // adjust cursor position}}// keeping safeif (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 postionipos = GetWndSelIchFirst(hwnd);// get current line numberln = GetBufLnCur(hbuf);if ((GetBufSelText(hbuf) != "") || (GetWndSelLnFirst(hwnd) != GetWndSelLnLast(hwnd))) {// sth. was selected, del selectionSetBufSelText(hbuf, " "); // stupid & buggy sourceinsight// del the " "SuperDelete(1);stop;}// copy current linetext = GetBufLine(hbuf, ln);// get string lengthlen = strlen(text);if (ipos == len || len == 0) {
totalLn = GetBufLineCount (hbuf);
lastText = GetBufLine(hBuf, totalLn-1);
lastLen = strlen(lastText);if (ipos == lastLen)// end of filestop;ln = ln + 1; // do not use "ln--" for compatibility with older versionsnextline = GetBufLine(hbuf, ln);nextlen = strlen(nextline);// combine two linestext = cat(text, nextline);// del two linesDelBufLine(hbuf, ln-1);DelBufLine(hbuf, ln-1);// insert the combined oneInsBufLine(hbuf, ln-1, text);// set the cursor positionSetBufIns(hbuf, ln-1, len);stop;}num = 1; // del one charif (ipos > 0) {// process Chinese characteri = 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 characternum = 2;// This idiot does not support mod and bitwise operatorsif (((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;elsereturn 1;
}
return 0;
}
macro moveleft()
{
hwnd = GetCurrentWnd();
hbuf = GetCurrentBuf();
if (hbuf == 0)stop; // empty bufferln = 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.emmoveRight();
}
/*======================================================================
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;elsereturn 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;elsereturn 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---*/

二、间距过大的问题
1. Options->Style Properties
2. 在左边Style Name下找到Comment Multi LineComment.在其右边对应的Font属性框下的
Font Name中选“Pick...” 设置为宋体、常规、小四。确定,退回Style Properties界面,
Size设为10。最后设置Clolors框下Foreground,点“Pick...”选择一种自己喜欢的颜色就OK了。
间距修改之后的效果如下
间距修改之后

中文半字效果如下

这篇关于sourceinsight 中文支持 解决办法的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1079478

相关文章

Go标准库常见错误分析和解决办法

《Go标准库常见错误分析和解决办法》Go语言的标准库为开发者提供了丰富且高效的工具,涵盖了从网络编程到文件操作等各个方面,然而,标准库虽好,使用不当却可能适得其反,正所谓工欲善其事,必先利其器,本文将... 目录1. 使用了错误的time.Duration2. time.After导致的内存泄漏3. jsO

springboot循环依赖问题案例代码及解决办法

《springboot循环依赖问题案例代码及解决办法》在SpringBoot中,如果两个或多个Bean之间存在循环依赖(即BeanA依赖BeanB,而BeanB又依赖BeanA),会导致Spring的... 目录1. 什么是循环依赖?2. 循环依赖的场景案例3. 解决循环依赖的常见方法方法 1:使用 @La

SpringKafka消息发布之KafkaTemplate与事务支持功能

《SpringKafka消息发布之KafkaTemplate与事务支持功能》通过本文介绍的基本用法、序列化选项、事务支持、错误处理和性能优化技术,开发者可以构建高效可靠的Kafka消息发布系统,事务支... 目录引言一、KafkaTemplate基础二、消息序列化三、事务支持机制四、错误处理与重试五、性能优

MySQL错误代码2058和2059的解决办法

《MySQL错误代码2058和2059的解决办法》:本文主要介绍MySQL错误代码2058和2059的解决办法,2058和2059的错误码核心都是你用的客户端工具和mysql版本的密码插件不匹配,... 目录1. 前置理解2.报错现象3.解决办法(敲重点!!!)1. php前置理解2058和2059的错误

Docker镜像pull失败两种解决办法小结

《Docker镜像pull失败两种解决办法小结》有时候我们在拉取Docker镜像的过程中会遇到一些问题,:本文主要介绍Docker镜像pull失败两种解决办法的相关资料,文中通过代码介绍的非常详细... 目录docker 镜像 pull 失败解决办法1DrQwWCocker 镜像 pull 失败解决方法2总

关于Docker Desktop的WSL报错问题解决办法

《关于DockerDesktop的WSL报错问题解决办法》:本文主要介绍关于DockerDesktop的WSL报错问题解决办法的相关资料,排查发现是因清理%temp%文件夹误删关键WSL文件,... 目录发现问题排查过程:解决方法其实很简单:重装之后再看就能够查到了:最后分享几个排查这类问题的小www.cp

电脑开机提示krpt.dll丢失怎么解决? krpt.dll文件缺失的多种解决办法

《电脑开机提示krpt.dll丢失怎么解决?krpt.dll文件缺失的多种解决办法》krpt.dll是Windows操作系统中的一个动态链接库文件,它对于系统的正常运行起着重要的作用,本文将详细介绍... 在使用 Windows 操作系统的过程中,用户有时会遇到各种错误提示,其中“找不到 krpt.dll”

Pycharm安装报错:Cannot detect a launch configuration解决办法

《Pycharm安装报错:Cannotdetectalaunchconfiguration解决办法》本文主要介绍了Pycharm安装报错:Cannotdetectalaunchconfigur... 本文主要介绍了Pycharm安装报错:Cannot detect a launch configuratio

一文教你解决Python不支持中文路径的问题

《一文教你解决Python不支持中文路径的问题》Python是一种广泛使用的高级编程语言,然而在处理包含中文字符的文件路径时,Python有时会表现出一些不友好的行为,下面小编就来为大家介绍一下具体的... 目录问题背景解决方案1. 设置正确的文件编码2. 使用pathlib模块3. 转换路径为Unicod

Python爬虫selenium验证之中文识别点选+图片验证码案例(最新推荐)

《Python爬虫selenium验证之中文识别点选+图片验证码案例(最新推荐)》本文介绍了如何使用Python和Selenium结合ddddocr库实现图片验证码的识别和点击功能,感兴趣的朋友一起看... 目录1.获取图片2.目标识别3.背景坐标识别3.1 ddddocr3.2 打码平台4.坐标点击5.图