Great Circle Associates

XCIN Mail-list
(July 2000)


Indexed By Date: [Previous] [Next] Indexed By Thread: [Previous] [Next]

Subject: Re: i'm writing a python input module for xcin...
From: thhsieh@linux.org.tw
Date: Thu, 27 Jul 2000 21:43:14 +0800
To: xcin@linux.org.tw
Reply-To: xcin@linux.org.tw

: Sorry I use GB2312 below... I should dig up my mail sub-system
: or better setup my zh_TW.Big locale lah... anyway...
:   
: Hi, Hello, Haalo, Hoolah...
:   
: 小弟正在寫一個 Input Module for XCIN, 是想要用 Python Script
: 來 Parse .cin file, 這樣就可以不再用 .tab file 啦... ;) 小弟
: 目前隻是想做到能 Parse .cin 就好了, 以後才會做一些更 Intelligent
: 的功能...
:   
: 請指教啦... :)

Hello, I see the Big5 in your mail. Are you sure you sent it in GB2312? :-))

Any way, I reply in English, and hope that this way is convinent to you :-))

: pep_inp_init, pep_inp_xim_init, pep_inp_xim_end
: pep_inp_keystroke, pep_inp_show_keystroke 接到 XCIN
: 的請求後, 就把請求轉發給 Python Module (在 pep_inp.py
: 中),
: 
: PyObject_CallMethod(cf->pep_inp, "xim_init", ...)
: 
: 其中 pep_inp 是 cf 中的一項, 是個 PyObject *,
: Python Module 維護自己的各種 Data, 如 不同 IC 的 Data,
: 但是, 並不把所有的 data 都和 pep_inp.c 傳來傳去,
: 
: 如 pep_inp_conf 就是不用傳的. (其實有兩個 pep_inp_conf,
: 一個是 Python 的, 一個是 C 的, C 的 cf 裡面隻有一個
: PyObject *.) <-- 不知道我這個理解對不對啊?
: Python 的 cf 裡面有 inp_cname, inp_ename, IC data, etc...

Sorry, I cannot understand your words very well. But from the point of 
view of the IM module, it will have 2 kinds of data structer:

1. The global data structer for this IM module. It can be used to
   keep the private data of this IM module, and it is global to
   every IC client (note that any IM module should serve many different
   IC client). This data structer is passed into the IM module interface
   function as "void *conf" pointer. For example,

	gen_inp_init(void *conf, char *objname, xcin_rc_t *xc);
	gen_inp_xim_init(void *conf, inpinfo_t *inpinfo);

   Note that the actual format of "void *conf" is completely designed
   by you.

2. The local data structer for each IC client. This kind is 
   "inpinfo_t *inpinfo". It contains some items like *inp_cname,
   *inp_ename, .... etc. So it also serves the interface of IM module
   and xcin/IC client.

   One perticular item of inpinfo_t is "void *iccf". It can be used
   as the private data structer of the IM module. Because sometimes
   IM module need a space to keep its private data for each IC client,
   so the place mentioned in 1 (the global data structer) is not
   enought to use. In this case you can use "void *iccf" in inpinfo_t.

   Again, the detailed format of "void *iccf" is completely determined
   by you.

:  小弟現在所頭疼的是, 不是特別清楚 inpinfo 中哪一些是
: 應該 pep_inp (gen_inp的地位) 來寫的, 哪一些是 XCIN 來寫的,
: (protocol between {gen,pep}_inp and XCIN? ;)

You should provide:

 1. inp_cname	(in xim_init())
 2. inp_ename	(in xim_init())
 3. area3_len	(in xim_init())
 4. iccf	(in xim_init(), but only when you really need it)
 5. guimode	(in xim_init() & keystroke(), you may need to update it
		 during the input from users)
 6. s_keystroke (in xim_init(), you should prepare buffer to it,
		 and in keystroke(), you may need to update it)
 7. suggest_skeystroke (the same as 6)
 8. n_selkey	(in xim_init())
 9. s_selkey	(in xim_init())
10. n_mcch	(in keystroke())
11. mcch	(the same as 6)
12. mcch_grouping (the same as 6)
13. mcch_pgstate (in keystroke())
14. n_lcch	(in keystroke(), if necessary)
15. lcch	(the same as 6, if necessary)
16. edit_pos	(in keystroke(), if necessary)
17. lcch_grouping (the same as 6, if necessary)
18. cch_publish	(in keystroke())
19. cch 	(the same as 6).

And the information from xcin to IM module (provided by xcin) are:

1. imid (you should not modify this)
2. zh_ascii
3. xcin_wlen

: 還有 wch_t 是怎麼一回事啊? 因為這個和 Python 混起來,
: 搞的我很頭疼啊... (maybe I shall read more documents, dizzy %-(

It is the unified format for each character:

typedef union { 
    unsigned char s[WCH_SIZE];
    wchar_t wch;
} wch_t;

For example, each Chinese character contains 2-byte, so you can do this:

	wch_t character;
	character.wch = (wchar_t)0;	/* initialize */
	strncpy(character.s, "您", WCH_SIZE);

so that "character" will contain one big5 character. Then when you want
to sort, compare, search .... the wch_t format character, you can just

	wch_t A, B;
	if (A.wch == B.wch) {
	    ........
	}

That is, just do integer compare instead of calling strcmp() ....


: 還有 ?_selkey, 因為小弟隻是用 pinyin.cin 所以不大清楚
: 這有什麼用呢? 為什麼要由 .cin 來定義 ?_selkey 呢?

Some input method use "1234567890" to select duplicated characters,
but some use "asdfgjkl;", or use "'[]-=" .... etc. So this depends
on the detailed definition of the input method.

: 此外,我可不可以把 keyinfo 簡化成 ascii string 傳給 Python
: (.cin) 呢? 其它的功能應該是由 pep_inp_keystroke() 自己處理的?

Yes. keyinfo_t contains the completed information of user's key-press.
The keyinfo_t->keystr is the ASCII representation of a key. But sometimes
the user may press function keys like Ctrl, Alt, F1, .... etc. If your
IM module need these keys to do some perticular actions, you need to
exam keyinfo_t->keysys or keyinfo_t->keystate, too.


T.H.Hsieh
To Unsubscribe: send mail to majordomo@linux.org.tw
with "unsubscribe xcin" in the body of the message


Follow-Ups:
Indexed By Date Previous: i'm writing a python input module for xcin...
From: zw@zhaoway.com
Next: Re: i'm writing a python input module for xcin...
From: zw@zhaoway.com
Indexed By Thread Previous: i'm writing a python input module for xcin...
From: zw@zhaoway.com
Next: Re: i'm writing a python input module for xcin...
From: zw@zhaoway.com