How Fcitx works

From Fcitx
Revision as of 21:15, 28 November 2012 by Weng Xuetian (talk | contribs) (Created page with "<languages /> <translate> == What is Fcitx? == Fcitx is a program that let you communicate with other program with input device and '''help you typing text'''. So you don't n...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Other languages:

What is Fcitx?

Fcitx is a program that let you communicate with other program with input device and help you typing text. So you don't need to restrict your idea that you must use fcitx to type some specific language, no, it can go far away from that. Everything that is related to typing text can make use of fcitx framework.

Basic workflow

Due to keyboard is still a irreplaceable part of nowadays computer/device, so the workflow of Fcitx is still key-centric. It can be separated into seven phase, Pre-Filter, Do-Input, Get-Candidate, Paging, Post-Filter, and Hotkey, KeyBlocker. It works like a waterfall, that key goes in from Pre-Filter, and goes out from Hotkey. It looks quite complicated right? Let us start from some example.

Input Method

If you want to implement an input method, the things you need to care about is the "Do-Input" Phase and "Get-Candidate" Phase, usually, we put code that are related to update UI into "Get-Candidate". For input methods in Fcitx, we require input method to return all the candidate at once. Some other framework maybe just return by page, fcitx didn't prevent that, but return all candidate at once have some obvious benefit. If we doing so, we don't need to keep every page for the same size, we can split into different page by the "length" of candidate. This would be especially important if you are working a small device (phone, for instance).

Some input methods mean to manage all the key, in that case, you only need to implement Do-Input, and leave Get-Candiate empty. Some other input method may want to cooperate with other module. For example, you now have a Pinyin library, but that library can only convert pinyin to Hanzi, so you might want to use Punctuation module of Fcitx. Make sure you know what module you want to cooperate with.

Temporary input mode

If you want to implement something global, independent with input method, for example, press "Ctrl+Shift+Alt+U" and type hexcode to input Unicode character, then what you want to do is something we called "Temporary input mode". It works just like a input method, but it only provides limited function for special use. In this case, we need to care about "Pre-Filter". As you can see, "Pre-Filter" can filter the key before it goes into real input method, so we simply process everything here.