Insight對漢字的支持"src="http://img.it610.com/image/product/615f778c75" />

亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

改進Source Insight對漢字的支持

系統 2003 0

轉自:http://blog.chinaunix.net/u/8681/showart_1356633.html
http://blog.163.com/zhuzhihuacan@126/blog/static/12757945420102123576521/???????????????????????????
我的版本:
改進Source?<wbr>Insight對漢字的支持
解決漢字亂碼的問題,一句話說就是調整字體為宋體
改進Source?<wbr>Insight對漢字的支持
之 后會打開對話框:
改進Source?<wbr>Insight對漢字的支持 之 后注釋中就可以正常輸入中文了,字距正常。< br>
下面是一個宏定義文件,綁定了Backspace,讓它能正確刪除一個漢字。
需要先關閉當前項目,打開Base項目,這個Base項目是Source Insight為你自帶的,代表項目的項目設置,你的其它自建項目應該是以它為基礎。
改進Source?<wbr>Insight對漢字的支持
會 打開下面的對話框,在其中選擇Base項目打開。
改進Source?<wbr>Insight對漢字的支持
在Base Project中,新建一個SuperBackSpace.em文件,把下面所給出的代碼寫到文件中保存到 Base 項目中:
在項目文件列表中用右鍵單擊:
改進Source?<wbr>Insight對漢字的支持 然 后,打開鍵綁定對話框:
改進Source?<wbr>Insight對漢字的支持 會 打開下面的對話框:剛才添加進來的宏定義文件中新定義的宏 SuperBackspace就列在下面 Command 一欄。
改進Source?<wbr>Insight對漢字的支持
在 Command:下面的字體框中輸入Mac, 下面的列表會只顯示以Mac開頭的項。這樣很容易就選擇到了這個宏,然后點擊"Assign New Key..."按鈕, 改進Source Insight對漢字的支持 改進Source Insight對漢字的支持 彈出下面的對話框, 改進Source?<wbr>Insight對漢字的支持
改進Source Insight對漢字的支持 此時按下退格鍵(Backspace),"確定" 退出即可。設置成功后該對話框顯示為:
改進Source?<wbr>Insight對漢字的支持
此 時再試一下退格鍵,可以成功刪除一整個漢字了。但是:
用鼠標選擇注釋中的漢字部分,仍然可以選中“半個“漢字,此時顯示為亂碼。
而 用左右箭頭鍵移動光標時,仍然可以移動到一個漢字的半中間,就是說移動光標仍然是半個漢字為單位。
改進Source?<wbr>Insight對漢字的支持
上面 一行是鼠標選中半個漢字的情況,下面的那行是光標移到漢字“中”的半中間時,光標閃爍至剛好顯示那個小棍棍時的截截。
另外。在base 項目中選中 SuperBackspace.em 本身,在下面的Context窗口中可以看到該文件的內容,這個文件開頭的部分是中文注釋,顯示為亂碼,在Context中右鍵單擊,改變字體為宋體,仍 然會顯示亂碼,漢字有的能正常顯示,有的則不能。
改進Source?<wbr>Insight對漢字的支持
Source Insight對漢字的支持,說一句糟糕真不過分。

使用下面的一個宏,即 Project→Open Project,

打開Base項目;

新建一個SuperBackSpace.em文件,將下面的代碼加入進去并保存,

把SuperBackSpace.em文件復制到Base工程的工程目錄下。選擇【Project】→【Add and Remove Project Files...】打開對話框,加入SuperBackSpace.em文件 ;重啟 SourceInsight;

打開Options→Key Assignments(對話框)

將Marco: SuperBackspace綁定到BackSpace鍵(在Key Assignments 對話框中先選中Commant 一欄的Marco:SuperBackspace,然后點擊按鈕“Assign New Key” 會彈出一個提示框,接著用手指按下鍵盤上的“Backspace”鍵,然后再點擊“是/YES”,最后在點擊“OK/確認”這樣 就可以了,下面類似)

Marco: SuperCursorLeft綁定到 <-鍵

Marco: SuperCursorRight綁定到 ->鍵

Marco: SuperShiftCursorLeft綁定到 Shift +<-

macro,SuperShiftCursorRight綁定到 shift +->

Macro:SuperDelete綁定到del。

代碼:

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;
}
//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();
}

注:如果加入SuperBackSpace.em 后出現非法關閉sourceinsight 則需要把原先自帶的utils.em從base項目中去掉才行,去掉不影響使用,我的就是出現了這個問題,結果異常關閉之后,每次再打開都是自動異常關閉,最后不得已刪除我的文檔中的sourceinsight目錄,然后重裝才搞定,所以最好在Add and Remove Project Files...】SuperBackSpace.em 時,把utils.em給去除掉。

改進Source Insight對漢字的支持


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 日本h片a毛片在线播放 | 亚洲视频一二 | 日韩中文字幕精品免费一区 | 亚洲男人的天堂久久香蕉 | 欧美日韩不卡在线 | 夜夜爱夜夜爽 | 天天操伊人 | 欧美成人免费tv在线播放 | 在线观看中文字幕第一页 | 久久亚洲伊人 | 久久久久久久久毛片精品 | 久久日韩精品 | 老妇激情毛片免费中国 | 亚洲视频中文字幕在线 | 老司机午夜免费视频 | 国产精品毛片 | 奇米影视第四色在线 | 欧美视频一区在线 | 亚洲综合伊人 | 99re这里只有精品在线 | 精品久久久久久中文字幕欧美 | 欧美亚洲国产另类在线观看 | 日韩精品欧美成人 | 欧美日韩亚洲国产 | 日韩欧美高清在线观看 | 97精品在线 | 欧美va亚洲va在线观看蝴蝶网 | 女人18一级毛片免费观看 | 久久精品国产eeuss | 国产精品国产三级国产普通话 | 男女午夜激情 | 欧美日韩在线免费观看 | 香蕉人人超人人超免费看视频 | 日日摸夜夜摸无需播放器 | 波多野结衣中文字幕久久 | 免费精品99久久国产综合精品 | 久久精品亚洲综合 | 丁香婷婷六月 | 国产精品欧美亚洲 | 欧美福利精品福利视频在线观看 | 91精品自在拍精选久久 |