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.Interfaces.Indenter

Description

Auto-indentation interface.

By default, [classview] can auto-indent as you type when [propertyview:auto-indent] is enabled. The indentation simply copies the previous lines indentation.

This can be changed by implementing GtkSourceIndenter and setting the [propertyview:indenter] property.

Implementors of this interface should implement both [vfuncindenter.is_trigger] and [vfuncindenter.indent].

vfuncindenter.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
constgdk.KEY_Return
or [constgdk.KEY_KP_Enter] without ModifierTypeShiftMask set.
vfuncindenter.indent
is called after text has been inserted into [classbuffer] when
vfuncindenter.is_trigger
returned True. The [structgtk.TextIter] is placed directly after the inserted character or characters.

It may be beneficial to move the insertion mark using textBufferSelectRange 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.

Synopsis

Exported types

newtype Indenter Source #

Memory-managed wrapper type.

Constructors

Indenter (ManagedPtr Indenter) 

Instances

Instances details
Eq Indenter Source # 
Instance details

Defined in GI.GtkSource.Interfaces.Indenter

GObject Indenter Source # 
Instance details

Defined in GI.GtkSource.Interfaces.Indenter

ManagedPtrNewtype Indenter Source # 
Instance details

Defined in GI.GtkSource.Interfaces.Indenter

Methods

toManagedPtr :: Indenter -> ManagedPtr Indenter

TypedObject Indenter Source # 
Instance details

Defined in GI.GtkSource.Interfaces.Indenter

Methods

glibType :: IO GType

HasParentTypes Indenter Source # 
Instance details

Defined in GI.GtkSource.Interfaces.Indenter

IsGValue (Maybe Indenter) Source #

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

Instance details

Defined in GI.GtkSource.Interfaces.Indenter

Methods

gvalueGType_ :: IO GType

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

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

type ParentTypes Indenter Source # 
Instance details

Defined in GI.GtkSource.Interfaces.Indenter

type ParentTypes Indenter = '[Object]

class (GObject o, IsDescendantOf Indenter o) => IsIndenter o Source #

Type class for types which can be safely cast to Indenter, for instance with toIndenter.

Instances

Instances details
(GObject o, IsDescendantOf Indenter o) => IsIndenter o Source # 
Instance details

Defined in GI.GtkSource.Interfaces.Indenter

toIndenter :: (MonadIO m, IsIndenter o) => o -> m Indenter Source #

Cast to Indenter, for types for which this is known to be safe. For general casts, use castTo.

Methods

indent

indenterIndent Source #

Arguments

:: (HasCallStack, MonadIO m, IsIndenter a, IsView b) 
=> a

self: a Indenter

-> b

view: a View

-> TextIter

iter: the location of the indentation request

-> m TextIter 

This function should be implemented to alter the indentation of text within the view.

view is provided so that the indenter may retrieve settings such as indentation and tab widths.

iter is the location where the indentation was requested. This typically is after having just inserted a newline (\n) character but can be other situations such as a manually requested indentation or reformatting.

See Indenter.is_trigger for how to trigger indentation on various characters inserted into the buffer.

The implementor of this function is expected to keep iter valid across calls to the function and should contain the location of the insert mark after calling this function.

The default implementation for this virtual function will copy the indentation of the previous line.

isTrigger

indenterIsTrigger Source #

Arguments

:: (HasCallStack, MonadIO m, IsIndenter a, IsView b) 
=> a

self: a Indenter

-> b

view: a View

-> TextIter

location: the location where ch is to be inserted

-> [ModifierType]

state: modifier state for the insertion

-> Word32

keyval: the keyval pressed such as [constgdk.KEY_Return]

-> m Bool

Returns: True if indentation should be automatically triggered; otherwise False and no indentation will be performed.

This function is used to determine if a key pressed should cause the indenter to automatically indent.

The default implementation of this virtual method will check to see if keyval is [constgdk.KEY_Return] or [constgdk.KEY_KP_Enter] and state does not have ModifierTypeShiftMask set. This is to allow the user to avoid indentation when Shift+Return is pressed. Other indenters may want to copy this behavior to provide a consistent experience to users.