Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
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].
- 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
- const
gdk
.KEY_Return - or [const
gdk
.KEY_KP_Enter] withoutModifierTypeShiftMask
set. - vfunc
indenter
.indent - is called after text has been
inserted into [class
buffer
] when - vfunc
indenter
.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
- newtype Indenter = Indenter (ManagedPtr Indenter)
- class (GObject o, IsDescendantOf Indenter o) => IsIndenter o
- toIndenter :: (MonadIO m, IsIndenter o) => o -> m Indenter
- indenterIndent :: (HasCallStack, MonadIO m, IsIndenter a, IsView b) => a -> b -> TextIter -> m TextIter
- indenterIsTrigger :: (HasCallStack, MonadIO m, IsIndenter a, IsView b) => a -> b -> TextIter -> [ModifierType] -> Word32 -> m Bool
Exported types
Memory-managed wrapper type.
Instances
Eq Indenter Source # | |
GObject Indenter Source # | |
Defined in GI.GtkSource.Interfaces.Indenter | |
ManagedPtrNewtype Indenter Source # | |
Defined in GI.GtkSource.Interfaces.Indenter toManagedPtr :: Indenter -> ManagedPtr Indenter | |
TypedObject Indenter Source # | |
Defined in GI.GtkSource.Interfaces.Indenter | |
HasParentTypes Indenter Source # | |
Defined in GI.GtkSource.Interfaces.Indenter | |
IsGValue (Maybe Indenter) Source # | Convert |
Defined in GI.GtkSource.Interfaces.Indenter gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe Indenter -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe Indenter) | |
type ParentTypes Indenter Source # | |
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
(GObject o, IsDescendantOf Indenter o) => IsIndenter o Source # | |
Defined in GI.GtkSource.Interfaces.Indenter |
toIndenter :: (MonadIO m, IsIndenter o) => o -> m Indenter Source #
Methods
Click to display all available methods, including inherited ones
Methods
bindProperty, bindPropertyFull, forceFloating, freezeNotify, getv, indent, isFloating, isTrigger, notify, notifyByPspec, ref, refSink, runDispose, stealData, stealQdata, thawNotify, unref, watchClosure.
Getters
getData, getProperty, getQdata.
Setters
indent
:: (HasCallStack, MonadIO m, IsIndenter a, IsView b) | |
=> a |
|
-> b |
|
-> TextIter |
|
-> 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
:: (HasCallStack, MonadIO m, IsIndenter a, IsView b) | |
=> a |
|
-> b |
|
-> TextIter |
|
-> [ModifierType] |
|
-> Word32 |
|
-> m Bool | Returns: |
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.