Trait gtk::prelude::IMContextExt [−][src]
pub trait IMContextExt: 'static {}Show methods
fn delete_surrounding(&self, offset: i32, n_chars: i32) -> bool; fn filter_keypress(&self, event: &EventKey) -> bool; fn focus_in(&self); fn focus_out(&self); fn preedit_string(&self) -> (GString, AttrList, i32); fn surrounding(&self) -> Option<(GString, i32)>; fn reset(&self); fn set_client_window(&self, window: Option<&Window>); fn set_cursor_location(&self, area: &Rectangle); fn set_surrounding(&self, text: &str, cursor_index: i32); fn set_use_preedit(&self, use_preedit: bool); fn input_hints(&self) -> InputHints; fn set_input_hints(&self, input_hints: InputHints); fn input_purpose(&self) -> InputPurpose; fn set_input_purpose(&self, input_purpose: InputPurpose); fn connect_commit<F: Fn(&Self, &str) + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_delete_surrounding<F: Fn(&Self, i32, i32) -> bool + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_preedit_changed<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_preedit_end<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_preedit_start<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_retrieve_surrounding<F: Fn(&Self) -> bool + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_input_hints_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_input_purpose_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
Expand description
Required methods
fn delete_surrounding(&self, offset: i32, n_chars: i32) -> bool
fn delete_surrounding(&self, offset: i32, n_chars: i32) -> bool
Asks the widget that the input context is attached to to delete
characters around the cursor position by emitting the
GtkIMContext::delete_surrounding signal. Note that offset
and n_chars
are in characters not in bytes which differs from the usage other
places in IMContext
.
In order to use this function, you should first call
surrounding()
to get the current context, and
call this function immediately afterwards to make sure that you
know what you are deleting. You should also account for the fact
that even if the signal was handled, the input context might not
have deleted all the characters that were requested to be deleted.
This function is used by an input method that wants to make subsitutions in the existing text in response to new input. It is not useful for applications.
offset
offset from cursor position in chars; a negative value means start before the cursor.
n_chars
number of characters to delete.
Returns
true
if the signal was handled.
fn filter_keypress(&self, event: &EventKey) -> bool
fn filter_keypress(&self, event: &EventKey) -> bool
Notify the input method that the widget to which this input context corresponds has gained focus. The input method may, for example, change the displayed feedback to reflect this change.
Notify the input method that the widget to which this input context corresponds has lost focus. The input method may, for example, change the displayed feedback or reset the contexts state to reflect this change.
Retrieve the current preedit string for the input context, and a list of attributes to apply to the string. This string should be displayed inserted at the insertion point.
Returns
str
location to store the retrieved
string. The string retrieved must be freed with g_free()
.
attrs
location to store the retrieved
attribute list. When you are done with this list, you
must unreference it with pango_attr_list_unref()
.
cursor_pos
location to store position of cursor (in characters) within the preedit string.
Retrieves context around the insertion point. Input methods typically want context in order to constrain input text based on existing text; this is important for languages such as Thai where only some sequences of characters are allowed.
This function is implemented by emitting the
GtkIMContext::retrieve_surrounding signal on the input method; in
response to this signal, a widget should provide as much context as
is available, up to an entire paragraph, by calling
set_surrounding()
. Note that there is no obligation
for a widget to respond to the ::retrieve_surrounding signal, so input
methods must be prepared to function without context.
Returns
true
if surrounding text was provided; in this case
you must free the result stored in *text.
text
location to store a UTF-8 encoded
string of text holding context around the insertion point.
If the function returns true
, then you must free the result
stored in this location with g_free()
.
cursor_index
location to store byte index of the insertion
cursor within text
.
Notify the input method that a change such as a change in cursor position has been made. This will typically cause the input method to clear the preedit state.
fn set_client_window(&self, window: Option<&Window>)
fn set_client_window(&self, window: Option<&Window>)
Set the client window for the input context; this is the
gdk::Window
in which the input appears. This window is
used in order to correctly position status windows, and may
also be used for purposes internal to the input method.
window
the client window. This may be None
to indicate
that the previous client window no longer exists.
fn set_cursor_location(&self, area: &Rectangle)
fn set_cursor_location(&self, area: &Rectangle)
Notify the input method that a change in cursor position has been made. The location is relative to the client window.
area
new location
fn set_surrounding(&self, text: &str, cursor_index: i32)
fn set_surrounding(&self, text: &str, cursor_index: i32)
Sets surrounding context around the insertion point and preedit string. This function is expected to be called in response to the GtkIMContext::retrieve_surrounding signal, and will likely have no effect if called at other times.
text
text surrounding the insertion point, as UTF-8.
the preedit string should not be included within
text
.
len
the length of text
, or -1 if text
is nul-terminated
cursor_index
the byte index of the insertion cursor within text
.
fn set_use_preedit(&self, use_preedit: bool)
fn set_use_preedit(&self, use_preedit: bool)
Sets whether the IM context should use the preedit string
to display feedback. If use_preedit
is FALSE (default
is TRUE), then the IM context may use some other method to display
feedback, such as displaying it in a child of the root window.
use_preedit
whether the IM context should use the preedit string.
fn input_hints(&self) -> InputHints
fn set_input_hints(&self, input_hints: InputHints)
fn input_purpose(&self) -> InputPurpose
fn set_input_purpose(&self, input_purpose: InputPurpose)
fn connect_commit<F: Fn(&Self, &str) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_commit<F: Fn(&Self, &str) + 'static>(&self, f: F) -> SignalHandlerId
The ::commit signal is emitted when a complete input sequence has been entered by the user. This can be a single character immediately after a key press or the final result of preediting.
str
the completed character(s) entered by the user
fn connect_delete_surrounding<F: Fn(&Self, i32, i32) -> bool + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_delete_surrounding<F: Fn(&Self, i32, i32) -> bool + 'static>(
&self,
f: F
) -> SignalHandlerId
The ::delete-surrounding signal is emitted when the input method needs to delete all or part of the context surrounding the cursor.
offset
the character offset from the cursor position of the text to be deleted. A negative value indicates a position before the cursor.
n_chars
the number of characters to be deleted
Returns
true
if the signal was handled.
fn connect_preedit_changed<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_preedit_changed<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
The ::preedit-changed signal is emitted whenever the preedit sequence
currently being entered has changed. It is also emitted at the end of
a preedit sequence, in which case
preedit_string()
returns the empty string.
fn connect_preedit_end<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_preedit_end<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
The ::preedit-end signal is emitted when a preediting sequence has been completed or canceled.
fn connect_preedit_start<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_preedit_start<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
The ::preedit-start signal is emitted when a new preediting sequence starts.
fn connect_retrieve_surrounding<F: Fn(&Self) -> bool + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_retrieve_surrounding<F: Fn(&Self) -> bool + 'static>(
&self,
f: F
) -> SignalHandlerId
The ::retrieve-surrounding signal is emitted when the input method
requires the context surrounding the cursor. The callback should set
the input method surrounding context by calling the
set_surrounding()
method.
Returns
true
if the signal was handled.
fn connect_input_hints_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_input_purpose_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId