GtkSource.VimIMContext

g GObject.Object GObject.Object Gtk.IMContext Gtk.IMContext GObject.Object->Gtk.IMContext GtkSource.VimIMContext GtkSource.VimIMContext Gtk.IMContext->GtkSource.VimIMContext

Subclasses:

None

Methods

Inherited:

Gtk.IMContext (14), GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new ()

execute_command (command)

get_command_bar_text ()

get_command_text ()

Virtual Methods

Inherited:

Gtk.IMContext (19), GObject.Object (7)

Properties

Inherited:

Gtk.IMContext (2)

Name

Type

Flags

Short Description

command-bar-text

str

r

The text for the command bar

command-text

str

r

The text for the current command

Signals

Inherited:

Gtk.IMContext (6), GObject.Object (1)

Name

Short Description

edit

Requests the application open the file found at path.

execute-command

The signal is emitted when a command should be executed.

format-text

Requests that the application format the text between begin and end.

write

Requests the application save the file.

Fields

Inherited:

Gtk.IMContext (6), GObject.Object (1)

Class Details

class GtkSource.VimIMContext(**kwargs)
Bases:

Gtk.IMContext

Abstract:

No

Structure:

GtkSource.VimIMContextClass

Vim emulation.

The GtkSourceVimIMContext is a [class`Gtk`.IMContext] implementation that can be used to provide Vim-like editing controls within a [class`View`].

The GtkSourceViMIMContext will process incoming [class`Gdk`.KeyEvent] as the user types. It should be used in conjunction with a [class`Gtk`.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 [property`VimIMContext`:py:data::command-bar-text<GtkSource.VimIMContext.props.command_bar_text>] and [property`VimIMContext`:py:data::command-text<GtkSource.VimIMContext.props.command_text>] to the user as they represent the command-bar and current command preview found in Vim.

GtkSourceVimIMContext attempts to work with additional [class`Gtk`.IMContext] implementations such as IBus by querying the [class`Gtk`.TextView] before processing the command in states which support it (notably Insert and Replace modes).

```c Gtk.EventController *key; Gtk.IMContext *im_context; Gtk.Widget *view;

view = GtkSource.View.new (); im_context = GtkSource.VimIMContext.new (); key = Gtk.EventControllerKey.new ();

Gtk.EventControllerKey.set_im_context (GTK_EVENT_CONTROLLER_KEY (key), im_context); Gtk.EventController.set_propagation_phase (key, Gtk.PropagationPhase.CAPTURE); Gtk.Widget.add_controller (view, key); Gtk.IMContext.set_client_widget (im_context, view);

GObject.Object.bind_property (im_context, “command-bar-text”, command_bar_label, “label”, 0); GObject.Object.bind_property (im_context, “command-text”, command_label, “label”, 0); ```

New in version 5.4.

classmethod new()
Return type:

Gtk.IMContext

execute_command(command)
Parameters:

command (str) – the command text

Executes command as if it was typed into the command bar by the user except that this does not emit the [signal`VimIMContext`:py:func:::execute-command<GtkSource.VimIMContext.signals.execute_command>] signal.

New in version 5.4.

get_command_bar_text()
Returns:

A string containing the command-bar text

Return type:

str

Gets the current command-bar text as it is entered by the user.

New in version 5.4.

get_command_text()
Returns:

A string containing the command text

Return type:

str

Gets the current command text as it is entered by the user.

New in version 5.4.

Signal Details

GtkSource.VimIMContext.signals.edit(vim_i_m_context, view, path)
Signal Name:

edit

Flags:

RUN_LAST

Parameters:

Requests the application open the file found at path.

If path is None, then the current file should be reloaded from storage.

This may be executed in relation to the user running the :edit or :e commands.

New in version 5.4.

GtkSource.VimIMContext.signals.execute_command(vim_i_m_context, command)
Signal Name:

execute-command

Flags:

RUN_LAST

Parameters:
Returns:

True if handled; otherwise False.

Return type:

bool

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.

New in version 5.4.

GtkSource.VimIMContext.signals.format_text(vim_i_m_context, begin, end)
Signal Name:

format-text

Flags:

RUN_LAST

Parameters:

Requests that the application format the text between begin and end.

New in version 5.4.

GtkSource.VimIMContext.signals.write(vim_i_m_context, view, path)
Signal Name:

write

Flags:

RUN_LAST

Parameters:

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.

New in version 5.4.

Property Details

GtkSource.VimIMContext.props.command_bar_text
Name:

command-bar-text

Type:

str

Default Value:

None

Flags:

READABLE

The text for the command bar

GtkSource.VimIMContext.props.command_text
Name:

command-text

Type:

str

Default Value:

None

Flags:

READABLE

The text for the current command