gi-gtksource-5.0.0: GtkSource bindings
CopyrightWill Thompson and Iñaki García Etxebarria
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.GtkSource.Objects.VimIMContext

Description

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

Exported types

newtype VimIMContext Source #

Memory-managed wrapper type.

Constructors

VimIMContext (ManagedPtr VimIMContext) 

Instances

Instances details
Eq VimIMContext Source # 
Instance details

Defined in GI.GtkSource.Objects.VimIMContext

GObject VimIMContext Source # 
Instance details

Defined in GI.GtkSource.Objects.VimIMContext

ManagedPtrNewtype VimIMContext Source # 
Instance details

Defined in GI.GtkSource.Objects.VimIMContext

Methods

toManagedPtr :: VimIMContext -> ManagedPtr VimIMContext

TypedObject VimIMContext Source # 
Instance details

Defined in GI.GtkSource.Objects.VimIMContext

Methods

glibType :: IO GType

HasParentTypes VimIMContext Source # 
Instance details

Defined in GI.GtkSource.Objects.VimIMContext

IsGValue (Maybe VimIMContext) Source #

Convert VimIMContext to and from GValue. See toGValue and fromGValue.

Instance details

Defined in GI.GtkSource.Objects.VimIMContext

Methods

gvalueGType_ :: IO GType

gvalueSet_ :: Ptr GValue -> Maybe VimIMContext -> IO ()

gvalueGet_ :: Ptr GValue -> IO (Maybe VimIMContext)

type ParentTypes VimIMContext Source # 
Instance details

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

Instances details
(GObject o, IsDescendantOf VimIMContext o) => IsVimIMContext o Source # 
Instance details

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

executeCommand

vimIMContextExecuteCommand Source #

Arguments

:: (HasCallStack, MonadIO m, IsVimIMContext a) 
=> a

self: a VimIMContext

-> Text

command: the command 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 #

Arguments

:: (HasCallStack, MonadIO m, IsVimIMContext a) 
=> a

self: a VimIMContext

-> 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 #

Arguments

:: (HasCallStack, MonadIO m, IsVimIMContext a) 
=> a

self: a VimIMContext

-> 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 #

Arguments

 = View

view: the View

-> Maybe Text

path: the path if provided, otherwise Nothing

-> IO () 

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 #

Arguments

 = Text

command: the command to execute

-> IO Bool

Returns: True if handled; otherwise False.

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 #

Arguments

 = TextIter

begin: the start location

-> TextIter

end: the end location

-> 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 #

Arguments

 = View

view: the View

-> Maybe Text

path: the path if provided, otherwise Nothing

-> IO () 

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