Introducation to gcin & its internal

這是一份OOo 2.0格式的簡報
Introducation to gcin & its internal


底下是此簡報的文字部份

Introduction to gcin & its internal

Written by Edward Liu Presented by Candyz

摘要

gcin 特點 架構 Transmission Protocol 開發測試環境

未來展望

gcin 詞音主要特點

詞音

預選詞。1.1.4 開始也支援第一個字的預選詞。 可以把標點符號及數字定義成詞,可以當電話簿。

先用輸入姓名及標點符號接著用 (CapsLock) 切到英數,輸入電話號碼。把 cursor 移到姓名,按 shift-Enter 就可以了。

Features

可以用注音輸入標點符號,例如用「ㄉㄐ」輸入「,。」。這樣就不用移開手去按 Shift 鍵。 一般注音鍵盤也可以用「asdf」 選字 詞與字都會依使用頻率調整順序。 詞音會根據使用次數自動關閉/打開詞的功能,如果有詞沒有被使用(改字)超過一次,則以後就這個詞就不會被使用,但如果使用數次之後就會自動恢復。

Features of gtab(倉頡、行列…)

注音查詢:

按 Ctrl-Alt-3 切到注音就可以了。gcin 不像 Windows gtab 輸入法。

同音字查詢:

例如我想用「音」查「茵」的拆字。先按 ` (backquote 左上角的那一個),這樣就可以在 gtab 的拆字顯示中看到「茵」的拆字。

Features of gtab

.cin 裏面可以定義詞,而且連英數也可以。在 gcin 的倉頡、行列中,想輸入 Linux,只要直接輸入 linux,就可以了,不需要切換到英數輸入再切回來。

Super slim

- gcin server executable只有88k ( without XIM) - gcin 與 scim memory size 比較

Architecture

libgcin-im-client.so
GCIN_client_handle *gcin_im_client_open(Display *disp);
void gcin_im_client_close(GCIN_client_handle *handle);
void gcin_im_client_focus_in(GCIN_client_handle *handle);
void gcin_im_client_focus_out(GCIN_client_handle *handle);
void gcin_im_client_set_window(GCIN_client_handle *handle, Window win);
void gcin_im_client_set_cursor_location(GCIN_client_handle *handle,  int x, int y);
int gcin_im_client_forward_key_press(GCIN_client_handle *handle,  KeySym key, u_int state,  char **rstr);
int gcin_im_client_forward_key_release(GCIN_client_handle *handle, KeySym key, u_int state, char **rstr);

Advantage over XIM

當gcin server沒有在執行時會自動執行 gcin server 全部使用 UTF-8,不像 XIM 會在zh_TW.Big5 中無法使用 UTF-8 字集的問題。 有 KeyRelease 的 event,在詞音中用 Shift 切換就需要這個 event。 穩定性更高,在 terminal 中'pkill gcin',不會有 terminal 也跟著掛掉的問題。

gcin's Transmission Protocol

Text is in UTF-8 encoding The network byte order is little endian. Data are encrypted. Allow multiple gcin servers on single/multiple displays on a single host. 底下的圖是使用 Xnest 在 gnome 中 open 一個 KDE 的 desktop。(PS 要抓 gcin 的輸入視窗可以用在幾秒鐘後才開始抓圖的功能,這樣就不會有 mouse 移開後 window 不見的問題。)

Encryption of gcin

gcin client fetches a 31-byte random key and a random seed from gcin server with XGetWindowProperty(protected by ssh) client & server use the same random number generator/seed to choose a byte from the 31-byte key and xor this with the input/output data to encrypt/decrypt data. 每次傳送相同的資料在加密後會有不同的結果。

Why not SSL library

因為大部分的人用不到 remote display。直接用SSL(secure socket layer) 會增加 dependency 而且使用較多的 memory。 用 gcin 的 protocol + ssh X11 forwarding 應該是很安全的。

Debugging & Testing gcin

In source dir gcinx.x.x, some shell scripts gcinx.x.x/tenv: script to test your own gcin, use gcinx.x.x/data as table dir, instead of ~/.gcin. gcinx.x.x/tval.gdb: Run gcin with valgrind, execute gdb if any errors occur. 'valgrind' is a good memory check & profiling tool.

Debugging & Testing gcin

gcinx.x.x/gtk-im/tgedit: Test new gtk-im without installing it. Use LD_PRELOAD to do this.

To Do

gtab(倉頡…) 輸入法支援 buffer 的選詞方式,這樣第一個字也可以自動選詞,目前只支援第二個字及以後的選詞。不過用了 buffer以後,變成需要按 buffer 把內容送出,並不是每個人都喜歡這樣。 On-the-spot 詞音整句斷詞的選項,以增加準確度。不過對使用者來說,目前的由左而右的方式比較好控制。整句斷詞對使用者來說變化太大。

AP clients

目前還是很多程式並沒有全部把 keys 送給 IM server 去 translate,造成某些 keys 無法使用。例如gaim 在詞音中無法用 Enter 送出編輯區。OpenOffice 無法用 Shift 切換中英。gnome-terminal 中不能用 ctrl-alt 切換輸入法。 Firefox 1.5 現在還是需要一行 patch 才能over-spot 才會完全正常。不知為何 firefox 不能寫成主動回報 cursor position。目前的作法是在gtk-im module 動手腳,按鍵時叫firefox report position

Attachments