Copyright | Will Thompson, Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (garetxe@gmail.com) |
Safe Haskell | None |
Language | Haskell2010 |
IMContext
defines the interface for GTK+ input methods. An input method
is used by GTK+ text input widgets like Entry
to map from key events to
Unicode character strings.
The default input method can be set programmatically via the
Settings
:gtk-im-module
GtkSettings property. Alternatively, you may set
the GTK_IM_MODULE environment variable as documented in
[Running GTK+ Applications][gtk-running].
The Entry
Entry
:im-module
and TextView
TextView
:im-module
properties may also be used to set input methods for specific widget
instances. For instance, a certain entry widget might be expected to contain
certain characters which would be easier to input with a certain input
method.
An input method may consume multiple key events in sequence and finally output the composed result. This is called preediting, and an input method may provide feedback about this process by displaying the intermediate composition states as preedit text. For instance, the default GTK+ input method implements the input of arbitrary Unicode code points by holding down the Control and Shift keys and then typing “U” followed by the hexadecimal digits of the code point. When releasing the Control and Shift keys, preediting ends and the character is inserted as text. Ctrl+Shift+u20AC for example results in the € sign.
Additional input methods can be made available for use by GTK+ widgets as
loadable modules. An input method module is a small shared library which
implements a subclass of IMContext
or IMContextSimple
and exports
these four functions:
C code
void im_module_init(GTypeModule *module);
This function should register the GType
of the IMContext
subclass which
implements the input method by means of typeModuleRegisterType
. Note
that typeRegisterStatic
cannot be used as the type needs to be
registered dynamically.
C code
void im_module_exit(void);
Here goes any cleanup code your input method might require on module unload.
C code
void im_module_list(const GtkIMContextInfo ***contexts, int *n_contexts) { *contexts = info_list; *n_contexts = G_N_ELEMENTS (info_list); }
This function returns the list of input methods provided by the module. The
example implementation above shows a common solution and simply returns a
pointer to statically defined array of IMContextInfo
items for each
provided input method.
C code
GtkIMContext * im_module_create(const gchar *context_id);
This function should return a pointer to a newly created instance of the
IMContext
subclass identified by contextId
. The context ID is the same
as specified in the IMContextInfo
array returned by im_module_list()
.
After a new loadable input method module has been installed on the system,
the configuration file gtk.immodules
needs to be
regenerated by [gtk-query-immodules-3.0][gtk-query-immodules-3.0],
in order for the new input method to become available to GTK+ applications.
- newtype IMContext = IMContext (ManagedPtr IMContext)
- class GObject o => IsIMContext o
- toIMContext :: IsIMContext o => o -> IO IMContext
- noIMContext :: Maybe IMContext
- data IMContextDeleteSurroundingMethodInfo
- iMContextDeleteSurrounding :: (HasCallStack, MonadIO m, IsIMContext a) => a -> Int32 -> Int32 -> m Bool
- data IMContextFilterKeypressMethodInfo
- iMContextFilterKeypress :: (HasCallStack, MonadIO m, IsIMContext a) => a -> EventKey -> m Bool
- data IMContextFocusInMethodInfo
- iMContextFocusIn :: (HasCallStack, MonadIO m, IsIMContext a) => a -> m ()
- data IMContextFocusOutMethodInfo
- iMContextFocusOut :: (HasCallStack, MonadIO m, IsIMContext a) => a -> m ()
- data IMContextGetPreeditStringMethodInfo
- iMContextGetPreeditString :: (HasCallStack, MonadIO m, IsIMContext a) => a -> m (Text, AttrList, Int32)
- data IMContextGetSurroundingMethodInfo
- iMContextGetSurrounding :: (HasCallStack, MonadIO m, IsIMContext a) => a -> m (Bool, Text, Int32)
- data IMContextResetMethodInfo
- iMContextReset :: (HasCallStack, MonadIO m, IsIMContext a) => a -> m ()
- data IMContextSetClientWindowMethodInfo
- iMContextSetClientWindow :: (HasCallStack, MonadIO m, IsIMContext a, IsWindow b) => a -> Maybe b -> m ()
- data IMContextSetCursorLocationMethodInfo
- iMContextSetCursorLocation :: (HasCallStack, MonadIO m, IsIMContext a) => a -> Rectangle -> m ()
- data IMContextSetSurroundingMethodInfo
- iMContextSetSurrounding :: (HasCallStack, MonadIO m, IsIMContext a) => a -> Text -> Int32 -> Int32 -> m ()
- data IMContextSetUsePreeditMethodInfo
- iMContextSetUsePreedit :: (HasCallStack, MonadIO m, IsIMContext a) => a -> Bool -> m ()
- data IMContextInputHintsPropertyInfo
- constructIMContextInputHints :: IsIMContext o => [InputHints] -> IO (GValueConstruct o)
- getIMContextInputHints :: (MonadIO m, IsIMContext o) => o -> m [InputHints]
- iMContextInputHints :: AttrLabelProxy "inputHints"
- setIMContextInputHints :: (MonadIO m, IsIMContext o) => o -> [InputHints] -> m ()
- data IMContextInputPurposePropertyInfo
- constructIMContextInputPurpose :: IsIMContext o => InputPurpose -> IO (GValueConstruct o)
- getIMContextInputPurpose :: (MonadIO m, IsIMContext o) => o -> m InputPurpose
- iMContextInputPurpose :: AttrLabelProxy "inputPurpose"
- setIMContextInputPurpose :: (MonadIO m, IsIMContext o) => o -> InputPurpose -> m ()
- type C_IMContextCommitCallback = Ptr () -> CString -> Ptr () -> IO ()
- type IMContextCommitCallback = Text -> IO ()
- data IMContextCommitSignalInfo
- afterIMContextCommit :: (GObject a, MonadIO m) => a -> IMContextCommitCallback -> m SignalHandlerId
- genClosure_IMContextCommit :: IMContextCommitCallback -> IO Closure
- mk_IMContextCommitCallback :: C_IMContextCommitCallback -> IO (FunPtr C_IMContextCommitCallback)
- noIMContextCommitCallback :: Maybe IMContextCommitCallback
- onIMContextCommit :: (GObject a, MonadIO m) => a -> IMContextCommitCallback -> m SignalHandlerId
- wrap_IMContextCommitCallback :: IMContextCommitCallback -> Ptr () -> CString -> Ptr () -> IO ()
- type C_IMContextDeleteSurroundingCallback = Ptr () -> Int32 -> Int32 -> Ptr () -> IO CInt
- type IMContextDeleteSurroundingCallback = Int32 -> Int32 -> IO Bool
- data IMContextDeleteSurroundingSignalInfo
- afterIMContextDeleteSurrounding :: (GObject a, MonadIO m) => a -> IMContextDeleteSurroundingCallback -> m SignalHandlerId
- genClosure_IMContextDeleteSurrounding :: IMContextDeleteSurroundingCallback -> IO Closure
- mk_IMContextDeleteSurroundingCallback :: C_IMContextDeleteSurroundingCallback -> IO (FunPtr C_IMContextDeleteSurroundingCallback)
- noIMContextDeleteSurroundingCallback :: Maybe IMContextDeleteSurroundingCallback
- onIMContextDeleteSurrounding :: (GObject a, MonadIO m) => a -> IMContextDeleteSurroundingCallback -> m SignalHandlerId
- wrap_IMContextDeleteSurroundingCallback :: IMContextDeleteSurroundingCallback -> Ptr () -> Int32 -> Int32 -> Ptr () -> IO CInt
- type C_IMContextPreeditChangedCallback = Ptr () -> Ptr () -> IO ()
- type IMContextPreeditChangedCallback = IO ()
- data IMContextPreeditChangedSignalInfo
- afterIMContextPreeditChanged :: (GObject a, MonadIO m) => a -> IMContextPreeditChangedCallback -> m SignalHandlerId
- genClosure_IMContextPreeditChanged :: IMContextPreeditChangedCallback -> IO Closure
- mk_IMContextPreeditChangedCallback :: C_IMContextPreeditChangedCallback -> IO (FunPtr C_IMContextPreeditChangedCallback)
- noIMContextPreeditChangedCallback :: Maybe IMContextPreeditChangedCallback
- onIMContextPreeditChanged :: (GObject a, MonadIO m) => a -> IMContextPreeditChangedCallback -> m SignalHandlerId
- wrap_IMContextPreeditChangedCallback :: IMContextPreeditChangedCallback -> Ptr () -> Ptr () -> IO ()
- type C_IMContextPreeditEndCallback = Ptr () -> Ptr () -> IO ()
- type IMContextPreeditEndCallback = IO ()
- data IMContextPreeditEndSignalInfo
- afterIMContextPreeditEnd :: (GObject a, MonadIO m) => a -> IMContextPreeditEndCallback -> m SignalHandlerId
- genClosure_IMContextPreeditEnd :: IMContextPreeditEndCallback -> IO Closure
- mk_IMContextPreeditEndCallback :: C_IMContextPreeditEndCallback -> IO (FunPtr C_IMContextPreeditEndCallback)
- noIMContextPreeditEndCallback :: Maybe IMContextPreeditEndCallback
- onIMContextPreeditEnd :: (GObject a, MonadIO m) => a -> IMContextPreeditEndCallback -> m SignalHandlerId
- wrap_IMContextPreeditEndCallback :: IMContextPreeditEndCallback -> Ptr () -> Ptr () -> IO ()
- type C_IMContextPreeditStartCallback = Ptr () -> Ptr () -> IO ()
- type IMContextPreeditStartCallback = IO ()
- data IMContextPreeditStartSignalInfo
- afterIMContextPreeditStart :: (GObject a, MonadIO m) => a -> IMContextPreeditStartCallback -> m SignalHandlerId
- genClosure_IMContextPreeditStart :: IMContextPreeditStartCallback -> IO Closure
- mk_IMContextPreeditStartCallback :: C_IMContextPreeditStartCallback -> IO (FunPtr C_IMContextPreeditStartCallback)
- noIMContextPreeditStartCallback :: Maybe IMContextPreeditStartCallback
- onIMContextPreeditStart :: (GObject a, MonadIO m) => a -> IMContextPreeditStartCallback -> m SignalHandlerId
- wrap_IMContextPreeditStartCallback :: IMContextPreeditStartCallback -> Ptr () -> Ptr () -> IO ()
- type C_IMContextRetrieveSurroundingCallback = Ptr () -> Ptr () -> IO CInt
- type IMContextRetrieveSurroundingCallback = IO Bool
- data IMContextRetrieveSurroundingSignalInfo
- afterIMContextRetrieveSurrounding :: (GObject a, MonadIO m) => a -> IMContextRetrieveSurroundingCallback -> m SignalHandlerId
- genClosure_IMContextRetrieveSurrounding :: IMContextRetrieveSurroundingCallback -> IO Closure
- mk_IMContextRetrieveSurroundingCallback :: C_IMContextRetrieveSurroundingCallback -> IO (FunPtr C_IMContextRetrieveSurroundingCallback)
- noIMContextRetrieveSurroundingCallback :: Maybe IMContextRetrieveSurroundingCallback
- onIMContextRetrieveSurrounding :: (GObject a, MonadIO m) => a -> IMContextRetrieveSurroundingCallback -> m SignalHandlerId
- wrap_IMContextRetrieveSurroundingCallback :: IMContextRetrieveSurroundingCallback -> Ptr () -> Ptr () -> IO CInt
Exported types
GObject IMContext Source # | |
IsObject IMContext Source # | |
IsIMContext IMContext Source # | |
((~) * info (ResolveIMContextMethod t IMContext), MethodInfo * info IMContext p) => IsLabel t (IMContext -> p) Source # | |
((~) * info (ResolveIMContextMethod t IMContext), MethodInfo * info IMContext p) => IsLabelProxy t (IMContext -> p) Source # | |
HasAttributeList * IMContext Source # | |
type AttributeList IMContext Source # | |
type SignalList IMContext Source # | |
class GObject o => IsIMContext o Source #
toIMContext :: IsIMContext o => o -> IO IMContext Source #
Methods
deleteSurrounding
data IMContextDeleteSurroundingMethodInfo Source #
((~) * signature (Int32 -> Int32 -> m Bool), MonadIO m, IsIMContext a) => MethodInfo * IMContextDeleteSurroundingMethodInfo a signature Source # | |
iMContextDeleteSurrounding Source #
:: (HasCallStack, MonadIO m, IsIMContext a) | |
=> a |
|
-> Int32 |
|
-> Int32 |
|
-> m Bool | Returns: |
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 nChars
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
iMContextGetSurrounding
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.
filterKeypress
data IMContextFilterKeypressMethodInfo Source #
((~) * signature (EventKey -> m Bool), MonadIO m, IsIMContext a) => MethodInfo * IMContextFilterKeypressMethodInfo a signature Source # | |
iMContextFilterKeypress Source #
:: (HasCallStack, MonadIO m, IsIMContext a) | |
=> a |
|
-> EventKey |
|
-> m Bool | Returns: |
Allow an input method to internally handle key press and release
events. If this function returns True
, then no further processing
should be done for this key event.
focusIn
data IMContextFocusInMethodInfo Source #
((~) * signature (m ()), MonadIO m, IsIMContext a) => MethodInfo * IMContextFocusInMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsIMContext a) | |
=> a |
|
-> m () |
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.
focusOut
data IMContextFocusOutMethodInfo Source #
((~) * signature (m ()), MonadIO m, IsIMContext a) => MethodInfo * IMContextFocusOutMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsIMContext a) | |
=> a |
|
-> m () |
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.
getPreeditString
data IMContextGetPreeditStringMethodInfo Source #
((~) * signature (m (Text, AttrList, Int32)), MonadIO m, IsIMContext a) => MethodInfo * IMContextGetPreeditStringMethodInfo a signature Source # | |
iMContextGetPreeditString Source #
:: (HasCallStack, MonadIO m, IsIMContext a) | |
=> a |
|
-> m (Text, AttrList, Int32) |
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.
getSurrounding
data IMContextGetSurroundingMethodInfo Source #
((~) * signature (m (Bool, Text, Int32)), MonadIO m, IsIMContext a) => MethodInfo * IMContextGetSurroundingMethodInfo a signature Source # | |
iMContextGetSurrounding Source #
:: (HasCallStack, MonadIO m, IsIMContext a) | |
=> a |
|
-> m (Bool, Text, Int32) | Returns: |
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
iMContextSetSurrounding
. 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.
reset
data IMContextResetMethodInfo Source #
((~) * signature (m ()), MonadIO m, IsIMContext a) => MethodInfo * IMContextResetMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsIMContext a) | |
=> a |
|
-> m () |
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.
setClientWindow
data IMContextSetClientWindowMethodInfo Source #
((~) * signature (Maybe b -> m ()), MonadIO m, IsIMContext a, IsWindow b) => MethodInfo * IMContextSetClientWindowMethodInfo a signature Source # | |
iMContextSetClientWindow Source #
:: (HasCallStack, MonadIO m, IsIMContext a, IsWindow b) | |
=> a |
|
-> Maybe b |
|
-> m () |
Set the client window for the input context; this is the
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.
setCursorLocation
data IMContextSetCursorLocationMethodInfo Source #
((~) * signature (Rectangle -> m ()), MonadIO m, IsIMContext a) => MethodInfo * IMContextSetCursorLocationMethodInfo a signature Source # | |
iMContextSetCursorLocation Source #
:: (HasCallStack, MonadIO m, IsIMContext a) | |
=> a |
|
-> Rectangle |
|
-> m () |
Notify the input method that a change in cursor position has been made. The location is relative to the client window.
setSurrounding
data IMContextSetSurroundingMethodInfo Source #
((~) * signature (Text -> Int32 -> Int32 -> m ()), MonadIO m, IsIMContext a) => MethodInfo * IMContextSetSurroundingMethodInfo a signature Source # | |
iMContextSetSurrounding Source #
:: (HasCallStack, MonadIO m, IsIMContext a) | |
=> a |
|
-> Text |
|
-> Int32 |
|
-> Int32 |
|
-> m () |
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.
setUsePreedit
data IMContextSetUsePreeditMethodInfo Source #
((~) * signature (Bool -> m ()), MonadIO m, IsIMContext a) => MethodInfo * IMContextSetUsePreeditMethodInfo a signature Source # | |
iMContextSetUsePreedit Source #
:: (HasCallStack, MonadIO m, IsIMContext a) | |
=> a |
|
-> Bool |
|
-> m () |
Sets whether the IM context should use the preedit string
to display feedback. If usePreedit
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.
Properties
inputHints
data IMContextInputHintsPropertyInfo Source #
constructIMContextInputHints :: IsIMContext o => [InputHints] -> IO (GValueConstruct o) Source #
getIMContextInputHints :: (MonadIO m, IsIMContext o) => o -> m [InputHints] Source #
iMContextInputHints :: AttrLabelProxy "inputHints" Source #
setIMContextInputHints :: (MonadIO m, IsIMContext o) => o -> [InputHints] -> m () Source #
inputPurpose
data IMContextInputPurposePropertyInfo Source #
constructIMContextInputPurpose :: IsIMContext o => InputPurpose -> IO (GValueConstruct o) Source #
getIMContextInputPurpose :: (MonadIO m, IsIMContext o) => o -> m InputPurpose Source #
iMContextInputPurpose :: AttrLabelProxy "inputPurpose" Source #
setIMContextInputPurpose :: (MonadIO m, IsIMContext o) => o -> InputPurpose -> m () Source #
Signals
commit
type IMContextCommitCallback = Text -> IO () Source #
afterIMContextCommit :: (GObject a, MonadIO m) => a -> IMContextCommitCallback -> m SignalHandlerId Source #
mk_IMContextCommitCallback :: C_IMContextCommitCallback -> IO (FunPtr C_IMContextCommitCallback) Source #
onIMContextCommit :: (GObject a, MonadIO m) => a -> IMContextCommitCallback -> m SignalHandlerId Source #
wrap_IMContextCommitCallback :: IMContextCommitCallback -> Ptr () -> CString -> Ptr () -> IO () Source #
deleteSurrounding
afterIMContextDeleteSurrounding :: (GObject a, MonadIO m) => a -> IMContextDeleteSurroundingCallback -> m SignalHandlerId Source #
mk_IMContextDeleteSurroundingCallback :: C_IMContextDeleteSurroundingCallback -> IO (FunPtr C_IMContextDeleteSurroundingCallback) Source #
onIMContextDeleteSurrounding :: (GObject a, MonadIO m) => a -> IMContextDeleteSurroundingCallback -> m SignalHandlerId Source #
wrap_IMContextDeleteSurroundingCallback :: IMContextDeleteSurroundingCallback -> Ptr () -> Int32 -> Int32 -> Ptr () -> IO CInt Source #
preeditChanged
type IMContextPreeditChangedCallback = IO () Source #
afterIMContextPreeditChanged :: (GObject a, MonadIO m) => a -> IMContextPreeditChangedCallback -> m SignalHandlerId Source #
mk_IMContextPreeditChangedCallback :: C_IMContextPreeditChangedCallback -> IO (FunPtr C_IMContextPreeditChangedCallback) Source #
onIMContextPreeditChanged :: (GObject a, MonadIO m) => a -> IMContextPreeditChangedCallback -> m SignalHandlerId Source #
wrap_IMContextPreeditChangedCallback :: IMContextPreeditChangedCallback -> Ptr () -> Ptr () -> IO () Source #
preeditEnd
type IMContextPreeditEndCallback = IO () Source #
afterIMContextPreeditEnd :: (GObject a, MonadIO m) => a -> IMContextPreeditEndCallback -> m SignalHandlerId Source #
mk_IMContextPreeditEndCallback :: C_IMContextPreeditEndCallback -> IO (FunPtr C_IMContextPreeditEndCallback) Source #
onIMContextPreeditEnd :: (GObject a, MonadIO m) => a -> IMContextPreeditEndCallback -> m SignalHandlerId Source #
wrap_IMContextPreeditEndCallback :: IMContextPreeditEndCallback -> Ptr () -> Ptr () -> IO () Source #
preeditStart
type IMContextPreeditStartCallback = IO () Source #
afterIMContextPreeditStart :: (GObject a, MonadIO m) => a -> IMContextPreeditStartCallback -> m SignalHandlerId Source #
mk_IMContextPreeditStartCallback :: C_IMContextPreeditStartCallback -> IO (FunPtr C_IMContextPreeditStartCallback) Source #
onIMContextPreeditStart :: (GObject a, MonadIO m) => a -> IMContextPreeditStartCallback -> m SignalHandlerId Source #
wrap_IMContextPreeditStartCallback :: IMContextPreeditStartCallback -> Ptr () -> Ptr () -> IO () Source #
retrieveSurrounding
afterIMContextRetrieveSurrounding :: (GObject a, MonadIO m) => a -> IMContextRetrieveSurroundingCallback -> m SignalHandlerId Source #
genClosure_IMContextRetrieveSurrounding :: IMContextRetrieveSurroundingCallback -> IO Closure Source #
mk_IMContextRetrieveSurroundingCallback :: C_IMContextRetrieveSurroundingCallback -> IO (FunPtr C_IMContextRetrieveSurroundingCallback) Source #
onIMContextRetrieveSurrounding :: (GObject a, MonadIO m) => a -> IMContextRetrieveSurroundingCallback -> m SignalHandlerId Source #
wrap_IMContextRetrieveSurroundingCallback :: IMContextRetrieveSurroundingCallback -> Ptr () -> Ptr () -> IO CInt Source #