Struct CskkContext

Source
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

Source

pub fn get_current_input_mode(&self) -> InputMode

現在のInputModeを返す

Source

pub fn get_current_composition_mode(&self) -> CompositionMode

現在のCompositionModeを返す

Source

pub fn poll_output(&mut self) -> Option<String>

Retrieve and remove the current output string

Source

pub fn get_preedit(&self) -> Option<String>

pollされていない入力を状態に応じて修飾して返す。

libskk互換の素朴な修飾ではないものを作る場合は[get_preedit_detail]でIME側で修飾する。

TODO: 常に返るので、Optionである必要がなかった。caller側できちんとOption扱いするか、返り値の型を変えるか。

Source

pub fn get_preedit_detail(&self) -> Vec<CskkStateInfo>

現在の状態スタック全ての表示要素リストを返す。 最初のものが一番外側の状態で、Registerモードの時には後にその内側の状態が続く。 [get_preedit]で素朴に修飾されたデータの元。

Source

pub fn get_preedit_underline(&self) -> (isize, isize)

👎Deprecated since 1.0.0

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]

Source

pub fn get_version() -> String

Source

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

Source

pub fn save_dictionary(&mut self)

Source

pub fn reload_dictionary(&mut self)

Source

pub fn set_dictionaries(&mut self, dicts: Vec<Arc<CskkDictionary>>)

Source

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

Source

pub fn process_key_events_string(&mut self, key_event_string: &str) -> bool

Exposed for testing purpose. Recommended not to use.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.