GtkSource.VimIMContext¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r |
The text for the command bar |
||
r |
The text for the current command |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
Requests the application open the file found at path. |
|
The signal is emitted when a command should be executed. |
|
Requests that the application format the text between begin and end. |
|
Requests the application save the file. |
Fields¶
- Inherited:
Class Details¶
- class GtkSource.VimIMContext(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
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:
- 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:
Gets the current command-bar 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:
- Parameters:
vim_i_m_context (
GtkSource.VimIMContext
) – The object which received the signalview (
GtkSource.View
) – theGtkSource.View
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:
- Parameters:
vim_i_m_context (
GtkSource.VimIMContext
) – The object which received the signalcommand (
str
) – the command to execute
- Returns:
- Return type:
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:
- Parameters:
vim_i_m_context (
GtkSource.VimIMContext
) – The object which received the signalbegin (
Gtk.TextIter
) – the start locationend (
Gtk.TextIter
) – the end location
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:
- Parameters:
vim_i_m_context (
GtkSource.VimIMContext
) – The object which received the signalview (
GtkSource.View
) – theGtkSource.View
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¶
-
The text for the command bar