gtksource.indenter

Module for Indenter interface

Types 2

interfaceIndenter

Auto-indentation interface.

By default, gtksource.view.View can auto-indent as you type when gtksource.view.View.autoIndent is enabled. The indentation simply copies the previous lines indentation.

This can be changed by implementing gtksource.indenter.Indenter and setting the gtksource.view.View.indenter property.

Implementors of this interface should implement both vfunc@Indenter.is_trigger and vfunc@Indenter.indent.

vfunc@Indenter.is_trigger is called upon key-press to determine of the key press should trigger an indentation. The default implementation of the interface checks to see if the key was gdk.types.KEY_Return or gdk.types.KEY_KP_Enter without gdk.types.ModifierType.ShiftMask set.

vfunc@Indenter.indent is called after text has been inserted into gtksource.buffer.Buffer when vfunc@Indenter.is_trigger returned true. The gtk.text_iter.TextIter is placed directly after the inserted character or characters.

It may be beneficial to move the insertion mark using gtk.text_buffer.TextBuffer.selectRange depending on how the indenter changes the indentation.

All changes are encapsulated within a single user action so that the user may undo them using standard undo/redo accelerators.

Methods
void indent(gtksource.view.View view, gtk.text_iter.TextIter iter)This function should be implemented to alter the indentation of text within the view.
bool isTrigger(gtksource.view.View view, gtk.text_iter.TextIter location, gdk.types.ModifierType state, uint keyval)This function is used to determine if a key pressed should cause the indenter to automatically indent.

Fluent builder implementation template for gtksource.indenter.Indenter