Chinaunix首页 | 论坛 | 博客
  • 博客访问: 320960
  • 博文数量: 86
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 185
  • 用 户 组: 普通用户
  • 注册时间: 2014-11-25 17:14
个人简介

代码才是最叼的

文章分类

全部博文(86)

文章存档

2019年(1)

2018年(1)

2017年(9)

2016年(19)

2015年(55)

2014年(1)

分类: WINDOWS

2016-05-25 10:45:31

一、解决汉字乱码的问题。要解决这个问题,就是要调整字体为宋体。方法如下
    选择【Options】→【Styles Properties...】,打开设置对话框,在左边栏找到【Comment】,设置【Font Name】的值为"宋体"即可。Szie的值根据实际需要自由设置。
    设置后之后再注释中就可以正常输入中文了,字距也显示正常。

二、解决按"Backspace"键是,只能删除半个汉字的问题。通过定义一个宏文件实现。
    先关闭当前项目,选择【project】→【Open project...】,打开项目对话框,选择"Base"工程并打开。新建一个SuperBackSpace.em的宏定义文件内容如下,这个宏定义文件的内容是网友提供的。
  1. macro SuperBackspace()
  2. {
  3.     hwnd = GetCurrentWnd();
  4.     hbuf = GetCurrentBuf();

  5.     if (hbuf == 0)
  6.         stop; // empty buffer

  7.     // get current cursor postion
  8.     ipos = GetWndSelIchFirst(hwnd);

  9.     // get current line number
  10.     ln = GetBufLnCur(hbuf);

  11.     if ((GetBufSelText(hbuf) != "") || (GetWndSelLnFirst(hwnd) != GetWndSelLnLast(hwnd))) {
  12.         // sth. was selected, del selection
  13.         SetBufSelText(hbuf, " "); // stupid & buggy sourceinsight :(
  14.         // del the " "
  15.         SuperBackspace(1);
  16.         stop;
  17.     }

  18.     // copy current line
  19.     text = GetBufLine(hbuf, ln);

  20.     // get string length
  21.     len = strlen(text);

  22.     // if the cursor is at the start of line, combine with prev line
  23.     if (ipos == 0 || len == 0) {
  24.         if (ln <= 0)
  25.             stop; // top of file
  26.         ln = ln - 1; // do not use "ln--" for compatibility with older versions
  27.         prevline = GetBufLine(hbuf, ln);
  28.         prevlen = strlen(prevline);
  29.         // combine two lines
  30.         text = cat(prevline, text);
  31.         // del two lines
  32.         DelBufLine(hbuf, ln);
  33.         DelBufLine(hbuf, ln);
  34.         // insert the combined one
  35.         InsBufLine(hbuf, ln, text);
  36.         // set the cursor position
  37.         SetBufIns(hbuf, ln, prevlen);
  38.         stop;
  39.     }

  40.     num = 1; // del one char
  41.     if (ipos >= 1) {
  42.         // process Chinese character
  43.         i = ipos;
  44.         count = 0;
  45.         while (AsciiFromChar(text[i - 1]) >= 160) {
  46.             i = i - 1;
  47.             count = count + 1;
  48.             if (i == 0)
  49.                 break;
  50.         }
  51.         if (count > 0) {
  52.             // I think it might be a two-byte character
  53.             num = 2;
  54.             // This idiot does not support mod and bitwise operators
  55.             if ((count / 2 * 2 != count) && (ipos < len))
  56.                 ipos = ipos + 1; // adjust cursor position
  57.         }
  58.     }

  59.     // keeping safe
  60.     if (ipos - num < 0)
  61.         num = ipos;

  62.     // del char(s)
  63.     text = cat(strmid(text, 0, ipos - num), strmid(text, ipos, len));
  64.     DelBufLine(hbuf, ln);
  65.     InsBufLine(hbuf, ln, text);
  66.     SetBufIns(hbuf, ln, ipos - num);
  67.     stop;
  68. }
    把SuperBackSpace.em文件复制到Base工程的工程目录下。选择【Project】→【Add and Remove Project Files...】打开对话框,加入SuperBackSpace.em文件。
    选择【Options】→【Key Assigments...】打开按键分配对话框,找到宏定义中的"Macro:SuperBackSpace"并用鼠标单击选中,按下【Assign New Key...】按钮,在弹出了一个新的对话框后按照提示,在键盘上按下"←Backspace"键即可。
    此时再按一下退格键,可以成功删除一个汉字了。但是用数遍选择注释中的汉字时,仍然可以选中半个汉字,此时显示为乱码。而用左右箭头键移动光标时,仍然可以移动到一个汉字的半中间,就是说移动光标仍然是半个汉字为单位。
    另外。在base 项目中选中 SuperBackspace.em 本身,在下面的Context窗口中可以看到该文件的内容,这个文件开头的部分是中文注释,显示为乱码,在Context中右键单击,改变字体为宋体,仍然会显示乱码,汉字有的能正常显示,有的则不能。所以经过以上努力,Source Insight对汉字的支持有所改进,但是还是不太如人意。

三、在Souce Insight加入".S"汇编文件。
    在【Options】→【Document Options...】里面,点左上的【Document Type】下拉菜单,选择【x86 Asm Source File】,然后在右边的【File filter】里*.asm;*.inc;的后面加上*.s;*.S 接着CLOSE就可以了。这样就可以ADD TREE时把这些汇编加到PROJECT里面。
    在【Options】→【Document Options...】里面,点左上的【Document Type】下拉菜单,选择【C Source File】,然后在右边的File filter里补上*.s,*.S就可以像看C一样看汇编,显示高亮了。

阅读(1151) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~