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 |
Vim emulation.
The GtkSourceVimIMContext
is a IMContext
implementation that can
be used to provide Vim-like editing controls within a [classview
].
The GtkSourceViMIMContext
will process incoming KeyEvent
as the
user types. It should be used in conjunction with a EventControllerKey
.
Various features supported by GtkSourceVimIMContext
include:
- Normal, Insert, Replace, Visual, and Visual Line modes
- Support for an integrated command bar and current command preview
- Search and replace
- Motions and Text Objects
- History replay
- Jumplists within the current file
- Registers including the system and primary clipboards
- Creation and motion to marks
- Some commonly used Vim commands
It is recommended that applications display the contents of
[propertyvimIMContext
:command-bar-text] and
[propertyvimIMContext
:command-text] to the user as they represent the
command-bar and current command preview found in Vim.
GtkSourceVimIMContext
attempts to work with additional IMContext
implementations such as IBus by querying the TextView
before processing
the command in states which support it (notably Insert and Replace modes).
c code
GtkEventController *key; GtkIMContext *im_context; GtkWidget *view; view = gtk_source_view_new (); im_context = gtk_source_vim_im_context_new (); key = gtk_event_controller_key_new (); gtk_event_controller_key_set_im_context (GTK_EVENT_CONTROLLER_KEY (key), im_context); gtk_event_controller_set_propagation_phase (key, GTK_PHASE_CAPTURE); gtk_widget_add_controller (view, key); gtk_im_context_set_client_widget (im_context, view); g_object_bind_property (im_context, "command-bar-text", command_bar_label, "label", 0); g_object_bind_property (im_context, "command-text", command_label, "label", 0);
Since: 5.4
Synopsis
- newtype VimIMContext = VimIMContext (ManagedPtr VimIMContext)
- class (GObject o, IsDescendantOf VimIMContext o) => IsVimIMContext o
- toVimIMContext :: (MonadIO m, IsVimIMContext o) => o -> m VimIMContext
- vimIMContextExecuteCommand :: (HasCallStack, MonadIO m, IsVimIMContext a) => a -> Text -> m ()
- vimIMContextGetCommandBarText :: (HasCallStack, MonadIO m, IsVimIMContext a) => a -> m Text
- vimIMContextGetCommandText :: (HasCallStack, MonadIO m, IsVimIMContext a) => a -> m Text
- vimIMContextNew :: (HasCallStack, MonadIO m) => m VimIMContext
- getVimIMContextCommandBarText :: (MonadIO m, IsVimIMContext o) => o -> m Text
- getVimIMContextCommandText :: (MonadIO m, IsVimIMContext o) => o -> m Text
- type VimIMContextEditCallback = View -> Maybe Text -> IO ()
- afterVimIMContextEdit :: (IsVimIMContext a, MonadIO m) => a -> ((?self :: a) => VimIMContextEditCallback) -> m SignalHandlerId
- onVimIMContextEdit :: (IsVimIMContext a, MonadIO m) => a -> ((?self :: a) => VimIMContextEditCallback) -> m SignalHandlerId
- type VimIMContextExecuteCommandCallback = Text -> IO Bool
- afterVimIMContextExecuteCommand :: (IsVimIMContext a, MonadIO m) => a -> ((?self :: a) => VimIMContextExecuteCommandCallback) -> m SignalHandlerId
- onVimIMContextExecuteCommand :: (IsVimIMContext a, MonadIO m) => a -> ((?self :: a) => VimIMContextExecuteCommandCallback) -> m SignalHandlerId
- type VimIMContextFormatTextCallback = TextIter -> TextIter -> IO ()
- afterVimIMContextFormatText :: (IsVimIMContext a, MonadIO m) => a -> ((?self :: a) => VimIMContextFormatTextCallback) -> m SignalHandlerId
- onVimIMContextFormatText :: (IsVimIMContext a, MonadIO m) => a -> ((?self :: a) => VimIMContextFormatTextCallback) -> m SignalHandlerId
- type VimIMContextWriteCallback = View -> Maybe Text -> IO ()
- afterVimIMContextWrite :: (IsVimIMContext a, MonadIO m) => a -> ((?self :: a) => VimIMContextWriteCallback) -> m SignalHandlerId
- onVimIMContextWrite :: (IsVimIMContext a, MonadIO m) => a -> ((?self :: a) => VimIMContextWriteCallback) -> m SignalHandlerId
Exported types
newtype VimIMContext Source #
Memory-managed wrapper type.
VimIMContext (ManagedPtr VimIMContext) |
Instances
Eq VimIMContext Source # | |
Defined in GI.GtkSource.Objects.VimIMContext (==) :: VimIMContext -> VimIMContext -> Bool # (/=) :: VimIMContext -> VimIMContext -> Bool # | |
GObject VimIMContext Source # | |
Defined in GI.GtkSource.Objects.VimIMContext | |
ManagedPtrNewtype VimIMContext Source # | |
Defined in GI.GtkSource.Objects.VimIMContext toManagedPtr :: VimIMContext -> ManagedPtr VimIMContext | |
TypedObject VimIMContext Source # | |
Defined in GI.GtkSource.Objects.VimIMContext | |
HasParentTypes VimIMContext Source # | |
Defined in GI.GtkSource.Objects.VimIMContext | |
IsGValue (Maybe VimIMContext) Source # | Convert |
Defined in GI.GtkSource.Objects.VimIMContext gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe VimIMContext -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe VimIMContext) | |
type ParentTypes VimIMContext Source # | |
Defined in GI.GtkSource.Objects.VimIMContext type ParentTypes VimIMContext = '[IMContext, Object] |
class (GObject o, IsDescendantOf VimIMContext o) => IsVimIMContext o Source #
Type class for types which can be safely cast to VimIMContext
, for instance with toVimIMContext
.
Instances
(GObject o, IsDescendantOf VimIMContext o) => IsVimIMContext o Source # | |
Defined in GI.GtkSource.Objects.VimIMContext |
toVimIMContext :: (MonadIO m, IsVimIMContext o) => o -> m VimIMContext Source #
Cast to VimIMContext
, for types for which this is known to be safe. For general casts, use castTo
.
Methods
Click to display all available methods, including inherited ones
Methods
bindProperty, bindPropertyFull, deleteSurrounding, executeCommand, filterKey, filterKeypress, focusIn, focusOut, forceFloating, freezeNotify, getv, isFloating, notify, notifyByPspec, ref, refSink, reset, runDispose, stealData, stealQdata, thawNotify, unref, watchClosure.
Getters
getCommandBarText, getCommandText, getData, getPreeditString, getProperty, getQdata, getSurrounding, getSurroundingWithSelection.
Setters
setClientWidget, setCursorLocation, setData, setDataFull, setProperty, setSurrounding, setSurroundingWithSelection, setUsePreedit.
executeCommand
vimIMContextExecuteCommand Source #
:: (HasCallStack, MonadIO m, IsVimIMContext a) | |
=> a |
|
-> Text |
|
-> m () |
Executes command
as if it was typed into the command bar by the
user except that this does not emit the
signalvimIMContext
[executeCommand] signal.
Since: 5.4
getCommandBarText
vimIMContextGetCommandBarText Source #
:: (HasCallStack, MonadIO m, IsVimIMContext a) | |
=> a |
|
-> m Text | Returns: A string containing the command-bar text |
Gets the current command-bar text as it is entered by the user.
Since: 5.4
getCommandText
vimIMContextGetCommandText Source #
:: (HasCallStack, MonadIO m, IsVimIMContext a) | |
=> a |
|
-> m Text | Returns: A string containing the command text |
Gets the current command text as it is entered by the user.
Since: 5.4
new
vimIMContextNew :: (HasCallStack, MonadIO m) => m VimIMContext Source #
No description available in the introspection data.
Properties
commandBarText
No description available in the introspection data.
getVimIMContextCommandBarText :: (MonadIO m, IsVimIMContext o) => o -> m Text Source #
Get the value of the “command-bar-text
” property.
When overloading is enabled, this is equivalent to
get
vimIMContext #commandBarText
commandText
No description available in the introspection data.
getVimIMContextCommandText :: (MonadIO m, IsVimIMContext o) => o -> m Text Source #
Get the value of the “command-text
” property.
When overloading is enabled, this is equivalent to
get
vimIMContext #commandText
Signals
edit
type VimIMContextEditCallback Source #
Requests the application open the file found at path
.
If path
is Nothing
, then the current file should be reloaded from storage.
This may be executed in relation to the user running the
:edit
or :e
commands.
Since: 5.4
afterVimIMContextEdit :: (IsVimIMContext a, MonadIO m) => a -> ((?self :: a) => VimIMContextEditCallback) -> m SignalHandlerId Source #
Connect a signal handler for the edit signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
vimIMContext #edit 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.
onVimIMContextEdit :: (IsVimIMContext a, MonadIO m) => a -> ((?self :: a) => VimIMContextEditCallback) -> m SignalHandlerId Source #
Connect a signal handler for the edit signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
vimIMContext #edit callback
executeCommand
type VimIMContextExecuteCommandCallback Source #
The signal is emitted when a command should be
executed. This might be something like :wq
or :e <path>
.
If the application chooses to implement this, it should return
True
from this signal to indicate the command has been handled.
Since: 5.4
afterVimIMContextExecuteCommand :: (IsVimIMContext a, MonadIO m) => a -> ((?self :: a) => VimIMContextExecuteCommandCallback) -> m SignalHandlerId Source #
Connect a signal handler for the executeCommand signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
vimIMContext #executeCommand 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.
onVimIMContextExecuteCommand :: (IsVimIMContext a, MonadIO m) => a -> ((?self :: a) => VimIMContextExecuteCommandCallback) -> m SignalHandlerId Source #
Connect a signal handler for the executeCommand signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
vimIMContext #executeCommand callback
formatText
type VimIMContextFormatTextCallback Source #
= TextIter |
|
-> TextIter |
|
-> IO () |
Requests that the application format the text between
begin
and end
.
Since: 5.4
afterVimIMContextFormatText :: (IsVimIMContext a, MonadIO m) => a -> ((?self :: a) => VimIMContextFormatTextCallback) -> m SignalHandlerId Source #
Connect a signal handler for the formatText signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
vimIMContext #formatText 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.
onVimIMContextFormatText :: (IsVimIMContext a, MonadIO m) => a -> ((?self :: a) => VimIMContextFormatTextCallback) -> m SignalHandlerId Source #
Connect a signal handler for the formatText signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
vimIMContext #formatText callback
write
type VimIMContextWriteCallback Source #
Requests the application save the file.
If a filename was provided, it will be available to the signal handler as path
.
This may be executed in relation to the user running the :write
or :w
commands.
Since: 5.4
afterVimIMContextWrite :: (IsVimIMContext a, MonadIO m) => a -> ((?self :: a) => VimIMContextWriteCallback) -> m SignalHandlerId Source #
Connect a signal handler for the write signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
vimIMContext #write 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.
onVimIMContextWrite :: (IsVimIMContext a, MonadIO m) => a -> ((?self :: a) => VimIMContextWriteCallback) -> m SignalHandlerId Source #
Connect a signal handler for the write signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
vimIMContext #write callback