Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
GtkIMContext
defines the interface for GTK input methods.
GtkIMContext
is used by GTK text input widgets like GtkText
to map from key events to Unicode character strings.
An input method may consume multiple key events in sequence before finally
outputting 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. To do so, the GtkIMContext
will emit
IMContext::preeditStart, IMContext::preeditChanged
and IMContext::preeditEnd signals.
For instance, the built-in GTK input method IMContextSimple
implements the input of arbitrary Unicode code points by holding down the
<kbd>Control</kbd> and <kbd>Shift</kbd> keys and then typing <kbd>u</kbd>
followed by the hexadecimal digits of the code point. When releasing the
<kbd>Control</kbd> and <kbd>Shift</kbd> keys, preediting ends and the
character is inserted as text. For example,
Ctrl+Shift+u 2 0 A C
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
provides a GIOExtension
for the extension point named "gtk-im-module".
To connect a widget to the users preferred input method, you should use
IMMulticontext
.
Synopsis
- newtype IMContext = IMContext (ManagedPtr IMContext)
- class (GObject o, IsDescendantOf IMContext o) => IsIMContext o
- toIMContext :: (MonadIO m, IsIMContext o) => o -> m IMContext
- iMContextDeleteSurrounding :: (HasCallStack, MonadIO m, IsIMContext a) => a -> Int32 -> Int32 -> m Bool
- iMContextFilterKey :: (HasCallStack, MonadIO m, IsIMContext a, IsSurface b, IsDevice c) => a -> Bool -> b -> c -> Word32 -> Word32 -> [ModifierType] -> Int32 -> m Bool
- iMContextFilterKeypress :: (HasCallStack, MonadIO m, IsIMContext a, IsEvent b) => a -> b -> m Bool
- iMContextFocusIn :: (HasCallStack, MonadIO m, IsIMContext a) => a -> m ()
- iMContextFocusOut :: (HasCallStack, MonadIO m, IsIMContext a) => a -> m ()
- iMContextGetPreeditString :: (HasCallStack, MonadIO m, IsIMContext a) => a -> m (Text, AttrList, Int32)
- iMContextGetSurrounding :: (HasCallStack, MonadIO m, IsIMContext a) => a -> m (Bool, Text, Int32)
- iMContextGetSurroundingWithSelection :: (HasCallStack, MonadIO m, IsIMContext a) => a -> m (Bool, Text, Int32, Int32)
- iMContextReset :: (HasCallStack, MonadIO m, IsIMContext a) => a -> m ()
- iMContextSetClientWidget :: (HasCallStack, MonadIO m, IsIMContext a, IsWidget b) => a -> Maybe b -> m ()
- iMContextSetCursorLocation :: (HasCallStack, MonadIO m, IsIMContext a) => a -> Rectangle -> m ()
- iMContextSetSurrounding :: (HasCallStack, MonadIO m, IsIMContext a) => a -> Text -> Int32 -> Int32 -> m ()
- iMContextSetSurroundingWithSelection :: (HasCallStack, MonadIO m, IsIMContext a) => a -> Text -> Int32 -> Int32 -> Int32 -> m ()
- iMContextSetUsePreedit :: (HasCallStack, MonadIO m, IsIMContext a) => a -> Bool -> m ()
- constructIMContextInputHints :: (IsIMContext o, MonadIO m) => [InputHints] -> m (GValueConstruct o)
- getIMContextInputHints :: (MonadIO m, IsIMContext o) => o -> m [InputHints]
- setIMContextInputHints :: (MonadIO m, IsIMContext o) => o -> [InputHints] -> m ()
- constructIMContextInputPurpose :: (IsIMContext o, MonadIO m) => InputPurpose -> m (GValueConstruct o)
- getIMContextInputPurpose :: (MonadIO m, IsIMContext o) => o -> m InputPurpose
- setIMContextInputPurpose :: (MonadIO m, IsIMContext o) => o -> InputPurpose -> m ()
- type IMContextCommitCallback = Text -> IO ()
- afterIMContextCommit :: (IsIMContext a, MonadIO m) => a -> ((?self :: a) => IMContextCommitCallback) -> m SignalHandlerId
- onIMContextCommit :: (IsIMContext a, MonadIO m) => a -> ((?self :: a) => IMContextCommitCallback) -> m SignalHandlerId
- type IMContextDeleteSurroundingCallback = Int32 -> Int32 -> IO Bool
- afterIMContextDeleteSurrounding :: (IsIMContext a, MonadIO m) => a -> ((?self :: a) => IMContextDeleteSurroundingCallback) -> m SignalHandlerId
- onIMContextDeleteSurrounding :: (IsIMContext a, MonadIO m) => a -> ((?self :: a) => IMContextDeleteSurroundingCallback) -> m SignalHandlerId
- type IMContextPreeditChangedCallback = IO ()
- afterIMContextPreeditChanged :: (IsIMContext a, MonadIO m) => a -> ((?self :: a) => IMContextPreeditChangedCallback) -> m SignalHandlerId
- onIMContextPreeditChanged :: (IsIMContext a, MonadIO m) => a -> ((?self :: a) => IMContextPreeditChangedCallback) -> m SignalHandlerId
- type IMContextPreeditEndCallback = IO ()
- afterIMContextPreeditEnd :: (IsIMContext a, MonadIO m) => a -> ((?self :: a) => IMContextPreeditEndCallback) -> m SignalHandlerId
- onIMContextPreeditEnd :: (IsIMContext a, MonadIO m) => a -> ((?self :: a) => IMContextPreeditEndCallback) -> m SignalHandlerId
- type IMContextPreeditStartCallback = IO ()
- afterIMContextPreeditStart :: (IsIMContext a, MonadIO m) => a -> ((?self :: a) => IMContextPreeditStartCallback) -> m SignalHandlerId
- onIMContextPreeditStart :: (IsIMContext a, MonadIO m) => a -> ((?self :: a) => IMContextPreeditStartCallback) -> m SignalHandlerId
- type IMContextRetrieveSurroundingCallback = IO Bool
- afterIMContextRetrieveSurrounding :: (IsIMContext a, MonadIO m) => a -> ((?self :: a) => IMContextRetrieveSurroundingCallback) -> m SignalHandlerId
- onIMContextRetrieveSurrounding :: (IsIMContext a, MonadIO m) => a -> ((?self :: a) => IMContextRetrieveSurroundingCallback) -> m SignalHandlerId
Exported types
Memory-managed wrapper type.
Instances
Eq IMContext Source # | |
GObject IMContext Source # | |
Defined in GI.Gtk.Objects.IMContext | |
ManagedPtrNewtype IMContext Source # | |
Defined in GI.Gtk.Objects.IMContext toManagedPtr :: IMContext -> ManagedPtr IMContext | |
TypedObject IMContext Source # | |
Defined in GI.Gtk.Objects.IMContext | |
HasParentTypes IMContext Source # | |
Defined in GI.Gtk.Objects.IMContext | |
IsGValue (Maybe IMContext) Source # | Convert |
Defined in GI.Gtk.Objects.IMContext gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe IMContext -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe IMContext) | |
type ParentTypes IMContext Source # | |
Defined in GI.Gtk.Objects.IMContext type ParentTypes IMContext = '[Object] |
class (GObject o, IsDescendantOf IMContext o) => IsIMContext o Source #
Type class for types which can be safely cast to IMContext
, for instance with toIMContext
.
Instances
(GObject o, IsDescendantOf IMContext o) => IsIMContext o Source # | |
Defined in GI.Gtk.Objects.IMContext |
toIMContext :: (MonadIO m, IsIMContext o) => o -> m IMContext Source #
Methods
Click to display all available methods, including inherited ones
Methods
bindProperty, bindPropertyFull, deleteSurrounding, filterKey, filterKeypress, focusIn, focusOut, forceFloating, freezeNotify, getv, isFloating, notify, notifyByPspec, ref, refSink, reset, runDispose, stealData, stealQdata, thawNotify, unref, watchClosure.
Getters
getData, getPreeditString, getProperty, getQdata, getSurrounding, getSurroundingWithSelection.
Setters
setClientWidget, setCursorLocation, setData, setDataFull, setProperty, setSurrounding, setSurroundingWithSelection, setUsePreedit.
deleteSurrounding
iMContextDeleteSurrounding Source #
:: (HasCallStack, MonadIO m, IsIMContext a) | |
=> a |
|
-> Int32 |
|
-> Int32 |
|
-> m Bool | Returns: |
Asks the widget that the input context is attached to delete
characters around the cursor position by emitting the
::delete_surrounding
signal.
Note that offset
and nChars
are in characters not in bytes
which differs from the usage other places in GtkIMContext
.
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 substitutions in the existing text in response to new input. It is not useful for applications.
filterKey
:: (HasCallStack, MonadIO m, IsIMContext a, IsSurface b, IsDevice c) | |
=> a |
|
-> Bool |
|
-> b |
|
-> c |
|
-> Word32 |
|
-> Word32 |
|
-> [ModifierType] |
|
-> Int32 |
|
-> m Bool | Returns: |
Allow an input method to forward key press and release events
to another input method without necessarily having a GdkEvent
available.
filterKeypress
iMContextFilterKeypress Source #
:: (HasCallStack, MonadIO m, IsIMContext a, IsEvent b) | |
=> a |
|
-> b |
|
-> 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
:: (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
:: (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
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
iMContextGetSurrounding Source #
:: (HasCallStack, MonadIO m, IsIMContext a) | |
=> a |
|
-> m (Bool, Text, Int32) | Returns: |
Deprecated: (Since version 4.2)Use iMContextGetSurroundingWithSelection
instead.
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
IMContext::retrieveSurrounding 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.
getSurroundingWithSelection
iMContextGetSurroundingWithSelection Source #
:: (HasCallStack, MonadIO m, IsIMContext a) | |
=> a |
|
-> m (Bool, Text, Int32, 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
IMContext::retrieveSurrounding 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
iMContextSetSurroundingWithSelection
.
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.
Since: 4.2
reset
:: (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.
setClientWidget
iMContextSetClientWidget Source #
:: (HasCallStack, MonadIO m, IsIMContext a, IsWidget b) | |
=> a |
|
-> Maybe b |
|
-> m () |
Set the client widget for the input context.
This is the GtkWidget
holding the input focus. This widget is
used in order to correctly position status windows, and may
also be used for purposes internal to the input method.
setCursorLocation
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 widget.
setSurrounding
iMContextSetSurrounding Source #
:: (HasCallStack, MonadIO m, IsIMContext a) | |
=> a |
|
-> Text |
|
-> Int32 |
|
-> Int32 |
|
-> m () |
Deprecated: (Since version 4.2)Use iMContextSetSurroundingWithSelection
instead
Sets surrounding context around the insertion point and preedit string.
This function is expected to be called in response to the IMContext::retrieveSurrounding signal, and will likely have no effect if called at other times.
setSurroundingWithSelection
iMContextSetSurroundingWithSelection Source #
:: (HasCallStack, MonadIO m, IsIMContext a) | |
=> a |
|
-> Text |
|
-> Int32 |
|
-> Int32 |
|
-> Int32 |
|
-> m () |
Sets surrounding context around the insertion point and preedit
string. This function is expected to be called in response to the
signalgtk
.IMContext[retrieve_surrounding] signal, and will likely
have no effect if called at other times.
Since: 4.2
setUsePreedit
iMContextSetUsePreedit Source #
:: (HasCallStack, MonadIO m, IsIMContext a) | |
=> a |
|
-> Bool |
|
-> m () |
Properties
inputHints
Additional hints that allow input methods to fine-tune their behaviour.
constructIMContextInputHints :: (IsIMContext o, MonadIO m) => [InputHints] -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “input-hints
” property. This is rarely needed directly, but it is used by new
.
getIMContextInputHints :: (MonadIO m, IsIMContext o) => o -> m [InputHints] Source #
Get the value of the “input-hints
” property.
When overloading is enabled, this is equivalent to
get
iMContext #inputHints
setIMContextInputHints :: (MonadIO m, IsIMContext o) => o -> [InputHints] -> m () Source #
Set the value of the “input-hints
” property.
When overloading is enabled, this is equivalent to
set
iMContext [ #inputHints:=
value ]
inputPurpose
The purpose of the text field that the `GtkIMContext is connected to.
This property can be used by on-screen keyboards and other input methods to adjust their behaviour.
constructIMContextInputPurpose :: (IsIMContext o, MonadIO m) => InputPurpose -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “input-purpose
” property. This is rarely needed directly, but it is used by new
.
getIMContextInputPurpose :: (MonadIO m, IsIMContext o) => o -> m InputPurpose Source #
Get the value of the “input-purpose
” property.
When overloading is enabled, this is equivalent to
get
iMContext #inputPurpose
setIMContextInputPurpose :: (MonadIO m, IsIMContext o) => o -> InputPurpose -> m () Source #
Set the value of the “input-purpose
” property.
When overloading is enabled, this is equivalent to
set
iMContext [ #inputPurpose:=
value ]
Signals
commit
type IMContextCommitCallback Source #
The commit signal is emitted when a complete input sequence has been entered by the user.
If the commit comes after a preediting sequence, the commit signal is emitted after preeditEnd.
This can be a single character immediately after a key press or the final result of preediting.
afterIMContextCommit :: (IsIMContext a, MonadIO m) => a -> ((?self :: a) => IMContextCommitCallback) -> m SignalHandlerId Source #
Connect a signal handler for the commit signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
iMContext #commit callback
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onIMContextCommit :: (IsIMContext a, MonadIO m) => a -> ((?self :: a) => IMContextCommitCallback) -> m SignalHandlerId Source #
Connect a signal handler for the commit signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
iMContext #commit callback
deleteSurrounding
type IMContextDeleteSurroundingCallback Source #
= Int32 |
|
-> Int32 |
|
-> IO Bool | Returns: |
The deleteSurrounding signal is emitted when the input method needs to delete all or part of the context surrounding the cursor.
afterIMContextDeleteSurrounding :: (IsIMContext a, MonadIO m) => a -> ((?self :: a) => IMContextDeleteSurroundingCallback) -> m SignalHandlerId Source #
Connect a signal handler for the deleteSurrounding signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
iMContext #deleteSurrounding callback
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onIMContextDeleteSurrounding :: (IsIMContext a, MonadIO m) => a -> ((?self :: a) => IMContextDeleteSurroundingCallback) -> m SignalHandlerId Source #
Connect a signal handler for the deleteSurrounding signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
iMContext #deleteSurrounding callback
preeditChanged
type IMContextPreeditChangedCallback = IO () Source #
The preeditChanged 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
iMContextGetPreeditString
returns the empty string.
afterIMContextPreeditChanged :: (IsIMContext a, MonadIO m) => a -> ((?self :: a) => IMContextPreeditChangedCallback) -> m SignalHandlerId Source #
Connect a signal handler for the preeditChanged signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
iMContext #preeditChanged callback
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onIMContextPreeditChanged :: (IsIMContext a, MonadIO m) => a -> ((?self :: a) => IMContextPreeditChangedCallback) -> m SignalHandlerId Source #
Connect a signal handler for the preeditChanged signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
iMContext #preeditChanged callback
preeditEnd
type IMContextPreeditEndCallback = IO () Source #
The preeditEnd signal is emitted when a preediting sequence has been completed or canceled.
afterIMContextPreeditEnd :: (IsIMContext a, MonadIO m) => a -> ((?self :: a) => IMContextPreeditEndCallback) -> m SignalHandlerId Source #
Connect a signal handler for the preeditEnd signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
iMContext #preeditEnd callback
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onIMContextPreeditEnd :: (IsIMContext a, MonadIO m) => a -> ((?self :: a) => IMContextPreeditEndCallback) -> m SignalHandlerId Source #
Connect a signal handler for the preeditEnd signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
iMContext #preeditEnd callback
preeditStart
type IMContextPreeditStartCallback = IO () Source #
The preeditStart signal is emitted when a new preediting sequence starts.
afterIMContextPreeditStart :: (IsIMContext a, MonadIO m) => a -> ((?self :: a) => IMContextPreeditStartCallback) -> m SignalHandlerId Source #
Connect a signal handler for the preeditStart signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
iMContext #preeditStart callback
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onIMContextPreeditStart :: (IsIMContext a, MonadIO m) => a -> ((?self :: a) => IMContextPreeditStartCallback) -> m SignalHandlerId Source #
Connect a signal handler for the preeditStart signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
iMContext #preeditStart callback
retrieveSurrounding
type IMContextRetrieveSurroundingCallback Source #
The retrieveSurrounding 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 iMContextSetSurrounding
method.
afterIMContextRetrieveSurrounding :: (IsIMContext a, MonadIO m) => a -> ((?self :: a) => IMContextRetrieveSurroundingCallback) -> m SignalHandlerId Source #
Connect a signal handler for the retrieveSurrounding signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
iMContext #retrieveSurrounding callback
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onIMContextRetrieveSurrounding :: (IsIMContext a, MonadIO m) => a -> ((?self :: a) => IMContextRetrieveSurroundingCallback) -> m SignalHandlerId Source #
Connect a signal handler for the retrieveSurrounding signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
iMContext #retrieveSurrounding callback