pub struct CskkContext { /* private fields */ }
Expand description
CSKK のメインの構造体。このcontextをに対しキー入力を行って変換された状態を得る。 元々C向けAPIを作ることを想定していた多くの関数が*_rsとして公開されている。
FIXME: Rustのインタフェースとしてあまり直感的ではないので*_rsのものはCSKKContextの関数にする。
TODO: Rustのstructまわりの一部分mutに変更があったら非mutでstateアクセスしているところを直す
Implementations§
Source§impl CskkContext
impl CskkContext
Sourcepub fn get_current_input_mode(&self) -> InputMode
pub fn get_current_input_mode(&self) -> InputMode
現在のInputModeを返す
Sourcepub fn get_current_composition_mode(&self) -> CompositionMode
pub fn get_current_composition_mode(&self) -> CompositionMode
現在のCompositionModeを返す
Sourcepub fn poll_output(&mut self) -> Option<String>
pub fn poll_output(&mut self) -> Option<String>
Retrieve and remove the current output string
Sourcepub fn get_preedit(&self) -> Option<String>
pub fn get_preedit(&self) -> Option<String>
pollされていない入力を状態に応じて修飾して返す。
libskk互換の素朴な修飾ではないものを作る場合は[get_preedit_detail]でIME側で修飾する。
TODO: 常に返るので、Optionである必要がなかった。caller側できちんとOption扱いするか、返り値の型を変えるか。
Sourcepub fn get_preedit_detail(&self) -> Vec<CskkStateInfo>
pub fn get_preedit_detail(&self) -> Vec<CskkStateInfo>
現在の状態スタック全ての表示要素リストを返す。 最初のものが一番外側の状態で、Registerモードの時には後にその内側の状態が続く。 [get_preedit]で素朴に修飾されたデータの元。
Sourcepub fn get_preedit_underline(&self) -> (isize, isize)
👎Deprecated since 1.0.0
pub fn get_preedit_underline(&self) -> (isize, isize)
UTF-8 character range of text to emphasize in preedit.
Currently we don’t have expand/shrink-preedit feature, thus we have no text we want to emphasize.
§Deprecated
Fancy formatting will be delegated to IMEs in favor of [get_preedit_detail]
pub fn get_version() -> String
Sourcepub fn process_key_event(&mut self, key_event: &CskkKeyEvent) -> bool
pub fn process_key_event(&mut self, key_event: &CskkKeyEvent) -> bool
process that key event and change the internal states. if key_event is not processable by current CSKK state, then return false
pub fn save_dictionary(&mut self)
pub fn reload_dictionary(&mut self)
pub fn set_dictionaries(&mut self, dicts: Vec<Arc<CskkDictionary>>)
Sourcepub fn will_process(&self, key_event: &CskkKeyEvent) -> bool
pub fn will_process(&self, key_event: &CskkKeyEvent) -> bool
Returns if that key event can be processed by current CSKK Only checking, doesn’t change internal states
Sourcepub fn process_key_events_string(&mut self, key_event_string: &str) -> bool
pub fn process_key_events_string(&mut self, key_event_string: &str) -> bool
Exposed for testing purpose. Recommended not to use.
Sourcepub fn set_rule(&mut self, rule: &str) -> Result<(), CskkError>
pub fn set_rule(&mut self, rule: &str) -> Result<(), CskkError>
Set to the specified rule. Rules will be read from XDG data directory which has libcskk/rules directory.
Sourcepub fn set_rule_from_directory(
&mut self,
rule: &str,
rule_dirpath: &str,
) -> Result<(), CskkError>
pub fn set_rule_from_directory( &mut self, rule: &str, rule_dirpath: &str, ) -> Result<(), CskkError>
Set to the specified rule from specified directory. For testing purpose. Use [set_rule] instead.
Sourcepub fn new(
input_mode: InputMode,
composition_mode: CompositionMode,
dictionaries: Vec<Arc<CskkDictionary>>,
) -> Result<Self, CskkError>
pub fn new( input_mode: InputMode, composition_mode: CompositionMode, dictionaries: Vec<Arc<CskkDictionary>>, ) -> Result<Self, CskkError>
Create a new cskk context. This doesn’t check if the initial state is sane. The caller must provide sane modes in params as an initial mode on use. e.g. Composition mode without any input doesn’t make sense, so the user might see some error depending on IM engines.
Sourcepub fn new_with_empty_fallback(
input_mode: InputMode,
composition_mode: CompositionMode,
dictionaries: Vec<Arc<CskkDictionary>>,
) -> Self
pub fn new_with_empty_fallback( input_mode: InputMode, composition_mode: CompositionMode, dictionaries: Vec<Arc<CskkDictionary>>, ) -> Self
Create a new cskk context. When setup fails, still returns an context that can convert nothing. This is for IMEs that cannot fail gracefully on creating a context.
Sourcepub fn new_empty(
input_mode: InputMode,
composition_mode: CompositionMode,
dictionaries: Vec<Arc<CskkDictionary>>,
) -> Self
pub fn new_empty( input_mode: InputMode, composition_mode: CompositionMode, dictionaries: Vec<Arc<CskkDictionary>>, ) -> Self
Creates a context that can convert nothing. Exposed only for test purpose. Users may not use this method.
Use [new] or [new_with_empty_fallback] instead.
Sourcepub fn new_from_specified_paths(
input_mode: InputMode,
composition_mode: CompositionMode,
dictionaries: Vec<Arc<CskkDictionary>>,
kana_form_changer_filepath: &str,
ascii_from_changer_filepath: &str,
rule_filepath: &str,
) -> Self
pub fn new_from_specified_paths( input_mode: InputMode, composition_mode: CompositionMode, dictionaries: Vec<Arc<CskkDictionary>>, kana_form_changer_filepath: &str, ascii_from_changer_filepath: &str, rule_filepath: &str, ) -> Self
This method is for e2e test purpose. Use [new] for your use.