Shift-Space 除了切全/半形外, 游標還會多移動一個空格

20 views
Skip to first unread message

slchen

unread,
Jul 9, 2008, 9:53:20 PM7/9/08
to Chewing IM Development
Hi, all:

我不曉得這算是正常的行為還是 bug, 不過我 mark 掉 libchewing 中處理 shift-space 的 function 中其
中一行可以解決這個現象.

附上 diff 檔內容


--- libchewing-0.3.0/src/chewingio.c 2006-05-15 14:49:43.000000000
+0800
+++ libchewing-0.3.0.new/src/chewingio.c 2008-07-09 18:54:58.000000000
+0
800
@@ -1214,7 +1214,8 @@
rtn = SemiSymbolInput( key, pgdata );
}
CallPhrasing( pgdata );
- MakeOutputWithRtn( pgo, pgdata, keystrokeRtn );
+/* Mark the following line to aviod shift-space move cursor one step
*/
+/* MakeOutputWithRtn( pgo, pgdata, keystrokeRtn ); */
return 0;
}

slchen

unread,
Jul 11, 2008, 12:13:19 AM7/11/08
to Chewing IM Development
這樣好像會有 trouble =.=

slchen wrote:
> Hi, all:
>
> �ڤ���o�o��O���`���欰�٬O bug, ���L�� mark �� libchewing ���B�z shift-space �� function ����
> ���@��i�H�ѨM�o�Ӳ{�H.
>
> ���W diff �ɤ��e

Weizhong Yang

unread,
Jul 11, 2008, 2:52:52 AM7/11/08
to chewin...@googlegroups.com
Shift + Space 原來的用途是送出一個全型空白。所以你可以看到:

rtn = SemiSymbolInput( key, pgdata) 把全型空白加入到輸入緩衝區中。
MakeOutputWithRtn( pgo, pgdata, keystrokeRtn ); 重新整理輸入緩衝區。

我不清楚 libchewing 什麼時候有切換全型半
型這個功能的,剛剛打開 Ubuntu 看了一
下, scim 中酷音切換全型半型之後,好像也看不出有什麼差別。


On 2008/7/10, at 上午 9:53, slchen wrote:

>
> Hi, all:
>
> 我不曉得這算是正常的行為還是 bug, 不過

Kanru Chen

unread,
Jul 11, 2008, 3:56:32 AM7/11/08
to Chewing IM Development
根據紀錄,wiz 把 SemiSymbolInput 拿掉了 :-/

wiz 要不要說明一下?

wiz

unread,
Jul 13, 2008, 3:57:28 AM7/13/08
to Chewing IM Development
就我之前trace code 的結果, SemiSymbolInput, 是用來作"符號輸入"的workaround,
也就是說在之前要出入符號的時候, 會出現"符"這個字,簡言之, 就是要讓處理buffer的動作, 變得比較好處理.

不過這樣的動作, 造成一些問題, 因此後來我就把這樣的動作改掉.

目前libchewing 對於處理這些buffer (包含轉換 input buffer --> output buffer, ),
並沒有很明確的"一般化"處理流程.滿多地方都看得出來, 是為了要處理某種"狀況"所做的變通方式.
希望有機會(要有時間啦...^^"), 我再試著將這些東西整理好.

To slchen,
恩,你提到一個重點, 目前所有"符號輸入 (chewing 內建的)"都是bulit-in "全形", 除非你是從鍵盤輸入一些
符號(ex: type a,b,c,d)才會有差別.

BTW,
我有個問題, 就是windows platform 上面用的libchewing 好像是另外一個branch, 並且很多patch並沒有
merge 回trunk 上面, 像SemiSymbolInput這個問題, 很早之前在windows 上面就已經被解決了 (不過解決的手法和
我並不一樣), 我想表達的是對新酷音來說,windows platform 的開發者比較"積極", 開發者及測試者比較多. 很多前輩已經做了很
多努力, 讓libchewing 與平台無關, 所以若能讓開法者有相同的base source code, 而測試者/使用者, 也是用相同
base的程式, 這樣應該會對新酷音這個project很有幫助.

slchen

unread,
Jul 13, 2008, 10:20:06 PM7/13/08
to Chewing IM Development
Hi, 大家:
我目前的情形是因為公司其他人員回報 Shift-Space 及 Caps 按了之後會只能打英文, 並且不能用 ctrl-space 做中英文切
換. 這個部份的比較應該是以 windows 上的新注音為準的.

就這個 shift-space 的 case, 我最後是讓它不要 return 空值,
也就是把
CHEWING_API int chewing_handle_ShiftSpace( ChewingContext *ctx )
{
ChewingData *pgdata = ctx->data;
ChewingOutput *pgo = ctx->output;
int rtn, key = ' ';
int keystrokeRtn = KEYSTROKE_ABSORB;

if ( ! pgdata->bSelect ) {
CheckAndResetRange( pgdata );
rtn = SemiSymbolInput( key, pgdata );
}
CallPhrasing( pgdata );
MakeOutputWithRtn( pgo, pgdata, keystrokeRtn );
return 0;
}

中的 key 設成空字元'\0'

這樣因為 key 是'\0' , 所以 MakeOutputWithRtn() 傳給輸出緩衝區的也是 '\0' , 表面上看起來就不會有游標移
動一個空白字元的現象. 不過我並未仔細去了解這樣對組字會不會有什麼影響就是了.

我是看到 scim-chewing 在 shift-space 的 case 呼叫了這隻 api, 才開始看這個部份的

另外一旦shift-space 被按下, 切換成全形之後, 在酷音的英文模式時, 所打的英文字都是全形. 中文模式則仍是在等待注音組字的模
式.

如果在中文模式下, 切換成全形, 改成打全形符號, 不曉得大家絕得好不好用?

另外請教大家, bSelect, bCaseChange 是做什麼用的?
在 global.h 中的 ChewingData 這個 structure 裡宣告了, 但是並沒看到注解.

謝謝

wiz

unread,
Jul 15, 2008, 2:20:02 AM7/15/08
to Chewing IM Development
我覺得問題還是在 "SemiSymbolInput"這個function上面,

你可以先看看這個function是在做什麼事情,
原本trunk 上面的版本:
====================
int SemiSymbolInput(int key, ChewingData *pgdata)
{
static char keybuf[] = { ' ', '1' };
static char *chibuf[] = { " ", "符" };
static int nSpecial = 2;
return InternalSpecialSymbol( key, pgdata, nSpecial, keybuf,
chibuf );
}

=====================
我不太確定windows是用哪一個branch, 不過因為它不會出現"符"這個字, 所以我假設是這個版本
http://svn.csie.net/filedetails.php?repname=chewing&path=%2Flibchewing%2Fbranches%2Fwin32%2Fsrc%2Fchewingutil.c

int SemiSymbolInput(int key, ChewingData *pgdata)
{
static char keybuf[] = {' ', '1'} ;
static int nSpecial = 2 ;
return InternalSpecialSymbol( key, pgdata, nSpecial, keybuf,
chibuf );
}
=======================

當然我不確定, 改掉這個就是否解決你的問題, 因為兩邊的code 我並沒有去比較差多少
只是我覺得先把已經知道有問題的地方改好, 這樣才比較可抓到問題的根源.

-wiz

On 7月14日, 上午10時20分, slchen <drifthe...@gmail.com> wrote:
> Hi, 大家:
> 我目前的情形是因為公司其他人員回報 Shift-Space 及 Caps 按了之後會只能打英文, 並且不能用 ctrl-space 做中英文切
> 換. 這個部份的比較應該是以 windows 上的新注音為準的.
>
> 就這個 shift-space 的 case, 我最後是讓它不要 return 空值,
> 也就是把
> CHEWING_API int chewing_handle_ShiftSpace( ChewingContext *ctx )
> {
> ChewingData *pgdata = ctx->data;
> ChewingOutput *pgo = ctx->output;
> int rtn, key = ' ';
> int keystrokeRtn = KEYSTROKE_ABSORB;
>
> if ( ! pgdata->bSelect ) {
> CheckAndResetRange( pgdata );
> rtn = SemiSymbolInput( key, pgdata );
> }
> CallPhrasing( pgdata );
> MakeOutputWithRtn( pgo, pgdata, keystrokeRtn );
> return 0;
>
> }
>
> 中的 key 設成空字元'\0'
>
> 這樣因為 key 是'\0' , 所以 MakeOutputWithRtn() 傳給輸出緩衝區的也是 '\0' , 表面上看起來就不會有游標移
> 動一個空白字元的現象. 不過我並未仔細去瞭解這樣對組字會不會有什麼影響就是了.
>
> 我是看到 scim-chewing 在 shift-space 的 case 呼叫了這隻 api, 才開始看這個部份的
>
> 另外一旦shift-space 被按下, 切換成全形之後, 在酷音的英文模式時, 所打的英文字都是全形. 中文模式則仍是在等待注音組字的模
> 式.
>
> 如果在中文模式下, 切換成全形, 改成打全形符號, 不曉得大家絕得好不好用?
>
> 另外請教大家, bSelect, bCaseChange 是做什麼用的?
> 在 global.h 中的 ChewingData 這個 structure 裡宣告了, 但是並沒看到註解.
>
> 謝謝

slchen

unread,
Jul 17, 2008, 2:38:00 AM7/17/08
to Chewing IM Development
Hi,
這個 SemiSymbolInput 看起來是把 keybuf[] 定義的 ascii 符號, 轉成對應的 chibuf[] 裡定義的符號.

回到
CHEWING_API int chewing_handle_ShiftSpace( ChewingContext *ctx )
{
ChewingData *pgdata = ctx->data;
ChewingOutput *pgo = ctx->output;
int rtn, key = ' ';
int keystrokeRtn = KEYSTROKE_ABSORB;

if ( ! pgdata->bSelect ) {
CheckAndResetRange( pgdata );
rtn = SemiSymbolInput( key, pgdata );
}
CallPhrasing( pgdata );
MakeOutputWithRtn( pgo, pgdata, keystrokeRtn );
return 0;
}

從上面看到, 在 chewing_handle_ShiftSpace() 被呼叫時, 指定了 key= ' ' , 所以進到
SemiSymbolInput(key, pgdata) 之後, 其內部的 InternalSpecialSymbol 就把半形空白轉成全形空
白,然後透過 MakeOutputWithRtn() 將全形空白輸出. (ps. 若把 key = ' ' 改成 key = '1' , 的
確會看到切換 shift-space 時, 組字緩衝區輸出"符"這個字. )

所以我認為, 應該要弄清礎 shift-space 的功能定義. 如果只是要切換全形跟半形, 那是不是只要去更改 ChewingData 中記
錄全形/半形的 旗標就好? (ex. pgdata->bFullShape = FULLSHAPE_MODE;)

另外因為 pgdata->bSelect 要為 0 時才會去處理字元的全半形對應, 不曉得 bSelect 代表的義意為何?

目前要把 shift-space 會切換全半形, 並且多輸出一個全形的空白字元 , 改造成只切換全半形.
可以切入的方向有
1. 在 chewing_handle_ShiftSpac() 中, 不要設定 key, 或把 key 令成 null
2. 修改 int SemiSymbolInput() , 讓 keybuf 的 ' ' 不要對應到任何字元
3. 在呼叫 chewing_handle_ShiftSpac() 時, 不要呼叫 SemiSymbolInput()

不曉得大家覺得哪個比較好?

另外我覺得這個部份似乎是處理全形開啟並且同時是中文組字模式.
如果是 scim-chewing 中的 全形開啟並且為英文輸入模式, 新酷音的確會輸出英文字母的全形字.



On 7月15日, 下午2時20分, wiz <wiz.c...@gmail.com> wrote:
> 我覺得問題還是在 "SemiSymbolInput"這個function上面,
>
> 你可以先看看這個function是在做什麼事情,
> 原本trunk 上面的版本:
> ====================
> int SemiSymbolInput(int key, ChewingData *pgdata)
> {
> static char keybuf[] = { ' ', '1' };
> static char *chibuf[] = { " ", "符" };
> static int nSpecial = 2;
> return InternalSpecialSymbol( key, pgdata, nSpecial, keybuf,
> chibuf );
>
> }
>
> =====================
> 我不太確定windows是用哪一個branch, 不過因為它不會出現"符"這個字, 所以我假設是這個版本http://svn.csie.net/filedetails.php?repname=chewing&path=%2Flibchewin...
Reply all
Reply to author
Forward
0 new messages