Class VimIMContext
- All Implemented Interfaces:
Proxy
The GtkSourceVimIMContext
is a IMContext
implementation that can
be used to provide Vim-like editing controls within a View
.
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
VimIMContext:command-bar-text
and
VimIMContext: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).
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);
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
VimIMContext.Builder<B extends VimIMContext.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static interface
Functional interface declaration of theEditCallback
callback.static interface
Functional interface declaration of theExecuteCommandCallback
callback.static interface
Functional interface declaration of theFormatTextCallback
callback.static class
static interface
Functional interface declaration of theWriteCallback
callback.Nested classes/interfaces inherited from class org.gnome.gtk.IMContext
IMContext.CommitCallback, IMContext.DeleteSurroundingCallback, IMContext.IMContextClass, IMContext.IMContextImpl, IMContext.PreeditChangedCallback, IMContext.PreeditEndCallback, IMContext.PreeditStartCallback, IMContext.RetrieveSurroundingCallback
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionVimIMContext
(MemorySegment address) Create a VimIMContext proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected VimIMContext
asParent()
Returns this instance as if it were its parent type.static VimIMContext.Builder
<? extends VimIMContext.Builder> builder()
AVimIMContext.Builder
object constructs aVimIMContext
with the specified properties.void
Emits the "edit" signal.boolean
emitExecuteCommand
(String command) Emits the "execute-command" signal.void
emitFormatText
(TextIter begin, TextIter end) Emits the "format-text" signal.void
Emits the "write" signal.void
executeCommand
(String command) Executescommand
as if it was typed into the command bar by the user except that this does not emit theVimIMContext::execute-command
signal.Gets the current command-bar text as it is entered by the user.Gets the current command text as it is entered by the user.static Type
getType()
Get the GType of the VimIMContext classonEdit
(VimIMContext.EditCallback handler) Requests the application open the file found atpath
.The signal is emitted when a command should be executed.Requests that the application format the text betweenbegin
andend
.onWrite
(VimIMContext.WriteCallback handler) Requests the application save the file.Methods inherited from class org.gnome.gtk.IMContext
activateOsk, activateOsk, activateOskWithEvent, commit, deleteSurrounding, emitCommit, emitDeleteSurrounding, emitPreeditChanged, emitPreeditEnd, emitPreeditStart, emitRetrieveSurrounding, filterKey, filterKey, filterKeypress, focusIn, focusOut, getMemoryLayout, getPreeditString, getSurrounding, getSurroundingWithSelection, onCommit, onDeleteSurrounding, onPreeditChanged, onPreeditEnd, onPreeditStart, onRetrieveSurrounding, preeditChanged, preeditEnd, preeditStart, reset, retrieveSurrounding, setClientWidget, setCursorLocation, setSurrounding, setSurroundingWithSelection, setUsePreedit
Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
VimIMContext
Create a VimIMContext proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
VimIMContext
public VimIMContext()
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
executeCommand
Executescommand
as if it was typed into the command bar by the user except that this does not emit theVimIMContext::execute-command
signal.- Parameters:
command
- the command text
-
getCommandBarText
Gets the current command-bar text as it is entered by the user.- Returns:
- A string containing the command-bar text
-
getCommandText
Gets the current command text as it is entered by the user.- Returns:
- A string containing the command text
-
onEdit
Requests the application open the file found atpath
.If
path
isnull
, then the current file should be reloaded from storage.This may be executed in relation to the user running the
:edit
or:e
commands.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitEdit
Emits the "edit" signal. SeeonEdit(org.gnome.gtksourceview.VimIMContext.EditCallback)
. -
onExecuteCommand
public SignalConnection<VimIMContext.ExecuteCommandCallback> onExecuteCommand(VimIMContext.ExecuteCommandCallback handler) 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.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitExecuteCommand
Emits the "execute-command" signal. SeeonExecuteCommand(org.gnome.gtksourceview.VimIMContext.ExecuteCommandCallback)
. -
onFormatText
public SignalConnection<VimIMContext.FormatTextCallback> onFormatText(VimIMContext.FormatTextCallback handler) Requests that the application format the text betweenbegin
andend
.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitFormatText
Emits the "format-text" signal. SeeonFormatText(org.gnome.gtksourceview.VimIMContext.FormatTextCallback)
. -
onWrite
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.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitWrite
Emits the "write" signal. SeeonWrite(org.gnome.gtksourceview.VimIMContext.WriteCallback)
. -
builder
AVimIMContext.Builder
object constructs aVimIMContext
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withVimIMContext.Builder.build()
.
-