如何让source insight支持中文注释,解决回车删除,移动光标出现乱码的问题?下面是解决方案:
-------Source Insight3 中文操作(左右键、删除和后退键)支持宏-------
感谢丁兆杰(zhaojie.ding@gmail.com)及互联网上辛勤耕耘的朋友们!!!
Evan: sdcw@163.com
① Project→Open Project,打开Base项目,将文中代码框中的所有内容函数复制到utils.em文件的最后;
② 重启SourceInsight;
③ Options→Key Assignments,将下面宏依次与相应按键绑定:
Marco: SuperBackspace绑定到BackSpace键;
Marco: SuperCursorLeft绑定到<-键,
Marco: SuperCursorRight绑定到->键,
Marco: SuperShiftCursorLeft绑定到Shift+<-,
Macro: SuperShiftCursorRight绑定到shift+->,
Macro: SuperDelete绑定到del。
④ Enjoy
------------解决source insight 中文间距的方法:-----------------
默认情况下,往Source Insight里输入中文,字间距相当的大,要解决这个问题,具体设置如下:
1. Options->Style Properties
2. 在左边Style Name下找到Comment Multi Line和Comment.在其右边对应的Font属性框下的
Font Name中选“Pick...” 设置为宋体、常规、小四。确定,退回Style Properties界面,
Size设为10。最后设置Clolors框下Foreground,点“Pick...”选择一种自己喜欢的颜色就OK了。
代码:
  1. /*======================================================================
  2. 1、BackSpace后退键
  3. ======================================================================*/
  4. macro SuperBackspace()
  5. {
  6. hwnd = GetCurrentWnd();
  7. hbuf = GetCurrentBuf();
  8. if (hbuf == 0)
  9. stop; // empty buffer
  10. // get current cursor postion
  11. ipos = GetWndSelIchFirst(hwnd);
  12. // get current line number
  13. ln = GetBufLnCur(hbuf);
  14. if ((GetBufSelText(hbuf) != "") || (GetWndSelLnFirst(hwnd) != GetWndSelLnLast(hwnd))) {
  15. // sth. was selected, del selection
  16. SetBufSelText(hbuf, " "); // stupid & buggy sourceinsight
  17. // del the " "
  18. SuperBackspace(1);
  19. stop;
  20. }
  21. // copy current line
  22. text = GetBufLine(hbuf, ln);
  23. // get string length
  24. len = strlen(text);
  25. // if the cursor is at the start of line, combine with prev line
  26. if (ipos == 0 || len == 0) {
  27. if (ln <= 0)
  28. stop; // top of file
  29. ln = ln - 1; // do not use "ln--" for compatibility with older versions
  30. prevline = GetBufLine(hbuf, ln);
  31. prevlen = strlen(prevline);
  32. // combine two lines
  33. text = cat(prevline, text);
  34. // del two lines
  35. DelBufLine(hbuf, ln);
  36. DelBufLine(hbuf, ln);
  37. // insert the combined one
  38. InsBufLine(hbuf, ln, text);
  39. // set the cursor position
  40. SetBufIns(hbuf, ln, prevlen);
  41. stop;
  42. }
  43. num = 1; // del one char
  44. if (ipos >= 1) {
  45. // process Chinese character
  46. i = ipos;
  47. count = 0;
  48. while (AsciiFromChar(text[i - 1]) >= 160) {
  49. i = i - 1;
  50. count = count + 1;
  51. if (i == 0)
  52. break;
  53. }
  54. if (count > 0) {
  55. // I think it might be a two-byte character
  56. num = 2;
  57. // This idiot does not support mod and bitwise operators
  58. if ((count / 2 * 2 != count) && (ipos < len))
  59. ipos = ipos + 1; // adjust cursor position
  60. }
  61. }
  62. // keeping safe
  63. if (ipos - num < 0)
  64. num = ipos;
  65. // del char(s)
  66. text = cat(strmid(text, 0, ipos - num), strmid(text, ipos, len));
  67. DelBufLine(hbuf, ln);
  68. InsBufLine(hbuf, ln, text);
  69. SetBufIns(hbuf, ln, ipos - num);
  70. stop;
  71. }
  72. /*======================================================================
  73. 2、删除键——SuperDelete.em
  74. ======================================================================*/
  75. macro SuperDelete()
  76. {
  77. hwnd = GetCurrentWnd();
  78. hbuf = GetCurrentBuf();
  79. if (hbuf == 0)
  80. stop; // empty buffer
  81. // get current cursor postion
  82. ipos = GetWndSelIchFirst(hwnd);
  83. // get current line number
  84. ln = GetBufLnCur(hbuf);
  85. if ((GetBufSelText(hbuf) != "") || (GetWndSelLnFirst(hwnd) != GetWndSelLnLast(hwnd))) {
  86. // sth. was selected, del selection
  87. SetBufSelText(hbuf, " "); // stupid & buggy sourceinsight
  88. // del the " "
  89. SuperDelete(1);
  90. stop;
  91. }
  92. // copy current line
  93. text = GetBufLine(hbuf, ln);
  94. // get string length
  95. len = strlen(text);
  96. if (ipos == len || len == 0) {
  97. totalLn = GetBufLineCount (hbuf);
  98. lastText = GetBufLine(hBuf, totalLn-1);
  99. lastLen = strlen(lastText);
  100. if (ipos == lastLen)// end of file
  101. stop;
  102. ln = ln + 1; // do not use "ln--" for compatibility with older versions
  103. nextline = GetBufLine(hbuf, ln);
  104. nextlen = strlen(nextline);
  105. // combine two lines
  106. text = cat(text, nextline);
  107. // del two lines
  108. DelBufLine(hbuf, ln-1);
  109. DelBufLine(hbuf, ln-1);
  110. // insert the combined one
  111. InsBufLine(hbuf, ln-1, text);
  112. // set the cursor position
  113. SetBufIns(hbuf, ln-1, len);
  114. stop;
  115. }
  116. num = 1; // del one char
  117. if (ipos > 0) {
  118. // process Chinese character
  119. i = ipos;
  120. count = 0;
  121. while (AsciiFromChar(text[i-1]) >= 160) {
  122. i = i - 1;
  123. count = count + 1;
  124. if (i == 0)
  125. break;
  126. }
  127. if (count > 0) {
  128. // I think it might be a two-byte character
  129. num = 2;
  130. // This idiot does not support mod and bitwise operators
  131. if (((count / 2 * 2 != count) || count == 0) && (ipos < len-1))
  132. ipos = ipos + 1; // adjust cursor position
  133. }
  134. // keeping safe
  135. if (ipos - num < 0)
  136. num = ipos;
  137. }
  138. else {
  139. i = ipos;
  140. count = 0;
  141. while(AsciiFromChar(text) >= 160) {
  142. i = i + 1;
  143. count = count + 1;
  144. if(i == len-1)
  145. break;
  146. }
  147. if(count > 0) {
  148. num = 2;
  149. }
  150. }
  151. text = cat(strmid(text, 0, ipos), strmid(text, ipos+num, len));
  152. DelBufLine(hbuf, ln);
  153. InsBufLine(hbuf, ln, text);
  154. SetBufIns(hbuf, ln, ipos);
  155. stop;
  156. }
  157. /*======================================================================
  158. 3、左移键——SuperCursorLeft.em
  159. ======================================================================*/
  160. macro IsComplexCharacter()
  161. {
  162. hwnd = GetCurrentWnd();
  163. hbuf = GetCurrentBuf();
  164. if (hbuf == 0)
  165. return 0;
  166. //当前位置
  167. pos = GetWndSelIchFirst(hwnd);
  168. //当前行数
  169. ln = GetBufLnCur(hbuf);
  170. //得到当前行
  171. text = GetBufLine(hbuf, ln);
  172. //得到当前行长度
  173. len = strlen(text);
  174. //从头计算汉字字符的个数
  175. if(pos > 0)
  176. {
  177. i=pos;
  178. count=0;
  179. while(AsciiFromChar(text[i-1]) >= 160)
  180. {
  181. i = i - 1;
  182. count = count+1;
  183. if(i == 0)
  184. break;
  185. }
  186. if((count/2)*2==count|| count==0)
  187. return 0;
  188. else
  189. return 1;
  190. }
  191. return 0;
  192. }
  193. macro moveleft()
  194. {
  195. hwnd = GetCurrentWnd();
  196. hbuf = GetCurrentBuf();
  197. if (hbuf == 0)
  198. stop; // empty buffer
  199. ln = GetBufLnCur(hbuf);
  200. ipos = GetWndSelIchFirst(hwnd);
  201. if(GetBufSelText(hbuf) != "" || (ipos == 0 && ln == 0)) // 第0行或者是选中文字,则不移动
  202. {
  203. SetBufIns(hbuf, ln, ipos);
  204. stop;
  205. }
  206. if(ipos == 0)
  207. {
  208. preLine = GetBufLine(hbuf, ln-1);
  209. SetBufIns(hBuf, ln-1, strlen(preLine)-1);
  210. }
  211. else
  212. {
  213. SetBufIns(hBuf, ln, ipos-1);
  214. }
  215. }
  216. macro SuperCursorLeft()
  217. {
  218. moveleft();
  219. if(IsComplexCharacter())
  220. moveleft();
  221. }
  222. /*======================================================================
  223. 4、右移键——SuperCursorRight.em
  224. ======================================================================*/
  225. macro moveRight()
  226. {
  227. hwnd = GetCurrentWnd();
  228. hbuf = GetCurrentBuf();
  229. if (hbuf == 0)
  230. stop; // empty buffer
  231. ln = GetBufLnCur(hbuf);
  232. ipos = GetWndSelIchFirst(hwnd);
  233. totalLn = GetBufLineCount(hbuf);
  234. text = GetBufLine(hbuf, ln);
  235. if(GetBufSelText(hbuf) != "") //选中文字
  236. {
  237. ipos = GetWndSelIchLim(hwnd);
  238. ln = GetWndSelLnLast(hwnd);
  239. SetBufIns(hbuf, ln, ipos);
  240. stop;
  241. }
  242. if(ipos == strlen(text)-1 && ln == totalLn-1) // 末行
  243. stop;
  244. if(ipos == strlen(text))
  245. {
  246. SetBufIns(hBuf, ln+1, 0);
  247. }
  248. else
  249. {
  250. SetBufIns(hBuf, ln, ipos+1);
  251. }
  252. }
  253. macro SuperCursorRight()
  254. {
  255. moveRight();
  256. if(IsComplexCharacter()) // defined in SuperCursorLeft.em
  257. moveRight();
  258. }
  259. /*======================================================================
  260. 5、shift+右移键——ShiftCursorRight.em
  261. ======================================================================*/
  262. macro IsShiftRightComplexCharacter()
  263. {
  264. hwnd = GetCurrentWnd();
  265. hbuf = GetCurrentBuf();
  266. if (hbuf == 0)
  267. return 0;
  268. selRec = GetWndSel(hwnd);
  269. pos = selRec.ichLim;
  270. ln = selRec.lnLast;
  271. text = GetBufLine(hbuf, ln);
  272. len = strlen(text);
  273. if(len == 0 || len < pos)
  274. return 1;
  275. //Msg("@len@;@pos@;");
  276. if(pos > 0)
  277. {
  278. i=pos;
  279. count=0;
  280. while(AsciiFromChar(text[i-1]) >= 160)
  281. {
  282. i = i - 1;
  283. count = count+1;
  284. if(i == 0)
  285. break;
  286. }
  287. if((count/2)*2==count|| count==0)
  288. return 0;
  289. else
  290. return 1;
  291. }
  292. return 0;
  293. }
  294. macro shiftMoveRight()
  295. {
  296. hwnd = GetCurrentWnd();
  297. hbuf = GetCurrentBuf();
  298. if (hbuf == 0)
  299. stop;
  300. ln = GetBufLnCur(hbuf);
  301. ipos = GetWndSelIchFirst(hwnd);
  302. totalLn = GetBufLineCount(hbuf);
  303. text = GetBufLine(hbuf, ln);
  304. selRec = GetWndSel(hwnd);
  305. curLen = GetBufLineLength(hbuf, selRec.lnLast);
  306. if(selRec.ichLim == curLen+1 || curLen == 0)
  307. {
  308. if(selRec.lnLast == totalLn -1)
  309. stop;
  310. selRec.lnLast = selRec.lnLast + 1;
  311. selRec.ichLim = 1;
  312. SetWndSel(hwnd, selRec);
  313. if(IsShiftRightComplexCharacter())
  314. shiftMoveRight();
  315. stop;
  316. }
  317. selRec.ichLim = selRec.ichLim+1;
  318. SetWndSel(hwnd, selRec);
  319. }
  320. macro SuperShiftCursorRight()
  321. {
  322. if(IsComplexCharacter())
  323. SuperCursorRight();
  324. shiftMoveRight();
  325. if(IsShiftRightComplexCharacter())
  326. shiftMoveRight();
  327. }
  328. /*======================================================================
  329. 6、shift+左移键——ShiftCursorLeft.em
  330. ======================================================================*/
  331. macro IsShiftLeftComplexCharacter()
  332. {
  333. hwnd = GetCurrentWnd();
  334. hbuf = GetCurrentBuf();
  335. if (hbuf == 0)
  336. return 0;
  337. selRec = GetWndSel(hwnd);
  338. pos = selRec.ichFirst;
  339. ln = selRec.lnFirst;
  340. text = GetBufLine(hbuf, ln);
  341. len = strlen(text);
  342. if(len == 0 || len < pos)
  343. return 1;
  344. //Msg("@len@;@pos@;");
  345. if(pos > 0)
  346. {
  347. i=pos;
  348. count=0;
  349. while(AsciiFromChar(text[i-1]) >= 160)
  350. {
  351. i = i - 1;
  352. count = count+1;
  353. if(i == 0)
  354. break;
  355. }
  356. if((count/2)*2==count|| count==0)
  357. return 0;
  358. else
  359. return 1;
  360. }
  361. return 0;
  362. }
  363. macro shiftMoveLeft()
  364. {
  365. hwnd = GetCurrentWnd();
  366. hbuf = GetCurrentBuf();
  367. if (hbuf == 0)
  368. stop;
  369. ln = GetBufLnCur(hbuf);
  370. ipos = GetWndSelIchFirst(hwnd);
  371. totalLn = GetBufLineCount(hbuf);
  372. text = GetBufLine(hbuf, ln);
  373. selRec = GetWndSel(hwnd);
  374. //curLen = GetBufLineLength(hbuf, selRec.lnFirst);
  375. //Msg("@curLen@;@selRec@");
  376. if(selRec.ichFirst == 0)
  377. {
  378. if(selRec.lnFirst == 0)
  379. stop;
  380. selRec.lnFirst = selRec.lnFirst - 1;
  381. selRec.ichFirst = GetBufLineLength(hbuf, selRec.lnFirst)-1;
  382. SetWndSel(hwnd, selRec);
  383. if(IsShiftLeftComplexCharacter())
  384. shiftMoveLeft();
  385. stop;
  386. }
  387. selRec.ichFirst = selRec.ichFirst-1;
  388. SetWndSel(hwnd, selRec);
  389. }
  390. macro SuperShiftCursorLeft()
  391. {
  392. if(IsComplexCharacter())
  393. SuperCursorLeft();
  394. shiftMoveLeft();
  395. if(IsShiftLeftComplexCharacter())
  396. shiftMoveLeft();
  397. }
  398. /*---END---*/

转自:http://blog.chinaunix.net/uid-10540984-id-3214137.html

转载于:https://www.cnblogs.com/suiying/p/4631759.html

让Source Insight完美支持中文注释 (转)相关推荐

  1. Source Insight完美转换UTF-8 到 GB2312

    Source Insight完美转换UTF-8 到 GB2312 文/蒹葭 前言 很多人用source insight 打开某些源码文件时,汉字显示为一堆乱码.这个问题是因为编码方式不同.记事本和一些 ...

  2. PHP生成PDF完美支持中文,解决TCPDF乱码

    PHP生成PDF完美支持中文,解决TCPDF乱码 2011-09-26 09:04 418人阅读 评论(0) 收藏 举报 phpfontsheaderttfxhtml文档 PHP生成PDF完美支持中文 ...

  3. NDoc修改版,支持中文注释及中文界面。

    这几天正在做一个项目的开发文档,以前试用NDoc做开发文档时不支持中文,真是不爽.这几天看了源代码,修改了其中的一段源代码及配置文件后,支持中文注释及中文界面(目前只做了Msdn2003一种). 以下 ...

  4. [转载]tomcat的配置文件server.xml不支持中文注释的解决办法

    原文链接:http://tjmljw.iteye.com/blog/1500370 启动tomcat失败,控制台一闪而过,打开catalina的log发现错误指向了conf/server.xml,报错 ...

  5. ffmpeg中文开发手册_快速调用复杂命令,支持中文注释,命令行备忘工具navi两天就火了...

    晓查 发自 凹非寺 量子位 报道 | 公众号 QbitAI 刚学的一句新命令,才用完就忘了用法?通常情况下,命令后加一句-help就行了. 但是,命令的帮助文档往往内容太太太太多了,在里面找到自己关心 ...

  6. Hive表设置支持中文注释、中文表数据导入

    问题 1.创建表的时候,comment说明字段包含中文,表成功创建成功之后,中文说明显示乱 create table student_score( stu_id string comment '学生i ...

  7. Source Insight 4.0设置注释与反注释的快捷键

    之前有一篇详细的说明Source Insight 4.0:source insight教程:常用设置.快捷键.附带source insight3.5和4的对比 source insight查看函数调用 ...

  8. FL STUDIO 20.8中文汉化版完美支持中文语言

    FL Studio 简称FL,全称:Fruity Loops Studio,因此国人习惯叫它"水果".目前最新版本(包括测试版本)是FL studio 20.8,它让你的计算机就像 ...

  9. codelite14中文语言包_Windows下CodeLite完美支持中文的正确设置方法

    一.准备工作 1.下载CodeLite最新版本  官方下载 .建议用迅雷下载比较快 如果想检验本文内容的有效性,你必须下载Windows系统下的版本. 2.下载中文语言包 论坛下载 . 如果链接无效, ...

最新文章

  1. 【Android Gradle 插件】Android Plugin DSL Reference 离线文档下载 ( GitHub 下载文档 | 查看文档 )
  2. 七大排序算法的个人总结(三)
  3. 【腾讯Bugly干货分享】Android Linker 与 SO 加壳技术
  4. 学生成绩管理系统测试用例C语言,学生成绩管理系统测试用例.doc
  5. 将iOS默认上下文坐标系改变为Quartz通常坐标系
  6. 题库明细 使用java理解程序逻辑
  7. php更改txt文件,如何使用php对txt文件进行修改
  8. python可以用来写什么_对于一个OIer,Python能干些什么?
  9. Flink 1.10 和 Hive 3.0 性能对比(附 Demo 演示 PPT)
  10. 黑马vue实战项目-(二)用户列表开发
  11. python itchat_Python itchat模块在微信上的
  12. windows通过资源管理器访问服务器(samba服务),您需要权限来执行此操作
  13. 哈哈,美食是生活的重要组成啊,自己烹调鲍鱼
  14. ios mac使用mitmproxy抓包
  15. 知识共享有多难?做好这几点,问题统统解决
  16. [vijos P1391] 想越狱的小杉
  17. linux pcs 所有命令,BaiduPCS-Go Windows或linux下百度网盘cmd命令行详细使用方法
  18. 《OpenGL超级宝典》环境搭建
  19. 小学计算机教师教科研方面,小学信息技术教师先进事迹范文
  20. VSFTPD配置方法手册

热门文章

  1. AJAX 缓存问题的两种解决方法(IE
  2. Android自定义ScrollView
  3. iOS开发UI篇—手写控件,frame,center和bounds属性
  4. 调用API的SDK相关知识:实现回调函数.
  5. golang 中的sort 包
  6. ARM汇编:加载和存储指令集(六大类)---LDR(ADR)、LDRB、LDRH、STR、STRB、STRH
  7. 枚举enum与#define 宏的区别?
  8. linux:文件权限管理
  9. ubuntu下网页显示乱码的解决方法
  10. 黑客演示通过空中电视信号DVB-T攻击智能电视机