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 |
Represent white space characters with symbols.
SpaceDrawer
provides a way to visualize white spaces, by drawing
symbols.
Call [methodview
.get_space_drawer] to get the GtkSourceSpaceDrawer
instance of a certain [classview
].
By default, no white spaces are drawn because the
[propertyspaceDrawer
:enable-matrix] is False
.
To draw white spaces, [methodspaceDrawer
.set_types_for_locations] can
be called to set the [propertyspaceDrawer
:matrix] property (by default all
space types are enabled at all locations). Then call
[methodspaceDrawer
.set_enable_matrix].
For a finer-grained method, there is also the [classtag
]'s
[propertytag
:draw-spaces] property.
Example
To draw non-breaking spaces everywhere and draw all types of trailing spaces except newlines:
c code
gtk_source_space_drawer_set_types_for_locations (space_drawer, GTK_SOURCE_SPACE_LOCATION_ALL, GTK_SOURCE_SPACE_TYPE_NBSP); gtk_source_space_drawer_set_types_for_locations (space_drawer, GTK_SOURCE_SPACE_LOCATION_TRAILING, GTK_SOURCE_SPACE_TYPE_ALL & ~GTK_SOURCE_SPACE_TYPE_NEWLINE); gtk_source_space_drawer_set_enable_matrix (space_drawer, TRUE);
Use-case: draw unwanted white spaces
A possible use-case is to draw only unwanted white spaces. Examples:
- Draw all trailing spaces.
- If the indentation and alignment must be done with spaces, draw tabs.
And non-breaking spaces can always be drawn, everywhere, to distinguish them from normal spaces.
Synopsis
- newtype SpaceDrawer = SpaceDrawer (ManagedPtr SpaceDrawer)
- class (GObject o, IsDescendantOf SpaceDrawer o) => IsSpaceDrawer o
- toSpaceDrawer :: (MonadIO m, IsSpaceDrawer o) => o -> m SpaceDrawer
- spaceDrawerBindMatrixSetting :: (HasCallStack, MonadIO m, IsSpaceDrawer a, IsSettings b) => a -> b -> Text -> [SettingsBindFlags] -> m ()
- spaceDrawerGetEnableMatrix :: (HasCallStack, MonadIO m, IsSpaceDrawer a) => a -> m Bool
- spaceDrawerGetMatrix :: (HasCallStack, MonadIO m, IsSpaceDrawer a) => a -> m GVariant
- spaceDrawerGetTypesForLocations :: (HasCallStack, MonadIO m, IsSpaceDrawer a) => a -> [SpaceLocationFlags] -> m [SpaceTypeFlags]
- spaceDrawerNew :: (HasCallStack, MonadIO m) => m SpaceDrawer
- spaceDrawerSetEnableMatrix :: (HasCallStack, MonadIO m, IsSpaceDrawer a) => a -> Bool -> m ()
- spaceDrawerSetMatrix :: (HasCallStack, MonadIO m, IsSpaceDrawer a) => a -> Maybe GVariant -> m ()
- spaceDrawerSetTypesForLocations :: (HasCallStack, MonadIO m, IsSpaceDrawer a) => a -> [SpaceLocationFlags] -> [SpaceTypeFlags] -> m ()
- constructSpaceDrawerEnableMatrix :: (IsSpaceDrawer o, MonadIO m) => Bool -> m (GValueConstruct o)
- getSpaceDrawerEnableMatrix :: (MonadIO m, IsSpaceDrawer o) => o -> m Bool
- setSpaceDrawerEnableMatrix :: (MonadIO m, IsSpaceDrawer o) => o -> Bool -> m ()
- clearSpaceDrawerMatrix :: (MonadIO m, IsSpaceDrawer o) => o -> m ()
- constructSpaceDrawerMatrix :: (IsSpaceDrawer o, MonadIO m) => GVariant -> m (GValueConstruct o)
- getSpaceDrawerMatrix :: (MonadIO m, IsSpaceDrawer o) => o -> m (Maybe GVariant)
- setSpaceDrawerMatrix :: (MonadIO m, IsSpaceDrawer o) => o -> GVariant -> m ()
Exported types
newtype SpaceDrawer Source #
Memory-managed wrapper type.
SpaceDrawer (ManagedPtr SpaceDrawer) |
Instances
Eq SpaceDrawer Source # | |
Defined in GI.GtkSource.Objects.SpaceDrawer (==) :: SpaceDrawer -> SpaceDrawer -> Bool # (/=) :: SpaceDrawer -> SpaceDrawer -> Bool # | |
GObject SpaceDrawer Source # | |
Defined in GI.GtkSource.Objects.SpaceDrawer | |
ManagedPtrNewtype SpaceDrawer Source # | |
Defined in GI.GtkSource.Objects.SpaceDrawer toManagedPtr :: SpaceDrawer -> ManagedPtr SpaceDrawer | |
TypedObject SpaceDrawer Source # | |
Defined in GI.GtkSource.Objects.SpaceDrawer | |
HasParentTypes SpaceDrawer Source # | |
Defined in GI.GtkSource.Objects.SpaceDrawer | |
IsGValue (Maybe SpaceDrawer) Source # | Convert |
Defined in GI.GtkSource.Objects.SpaceDrawer gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe SpaceDrawer -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe SpaceDrawer) | |
type ParentTypes SpaceDrawer Source # | |
Defined in GI.GtkSource.Objects.SpaceDrawer type ParentTypes SpaceDrawer = '[Object] |
class (GObject o, IsDescendantOf SpaceDrawer o) => IsSpaceDrawer o Source #
Type class for types which can be safely cast to SpaceDrawer
, for instance with toSpaceDrawer
.
Instances
(GObject o, IsDescendantOf SpaceDrawer o) => IsSpaceDrawer o Source # | |
Defined in GI.GtkSource.Objects.SpaceDrawer |
toSpaceDrawer :: (MonadIO m, IsSpaceDrawer o) => o -> m SpaceDrawer Source #
Cast to SpaceDrawer
, for types for which this is known to be safe. For general casts, use castTo
.
Methods
Click to display all available methods, including inherited ones
Methods
bindMatrixSetting, bindProperty, bindPropertyFull, forceFloating, freezeNotify, getv, isFloating, notify, notifyByPspec, ref, refSink, runDispose, stealData, stealQdata, thawNotify, unref, watchClosure.
Getters
getData, getEnableMatrix, getMatrix, getProperty, getQdata, getTypesForLocations.
Setters
setData, setDataFull, setEnableMatrix, setMatrix, setProperty, setTypesForLocations.
bindMatrixSetting
spaceDrawerBindMatrixSetting Source #
:: (HasCallStack, MonadIO m, IsSpaceDrawer a, IsSettings b) | |
=> a |
|
-> b |
|
-> Text |
|
-> [SettingsBindFlags] |
|
-> m () |
Binds the [propertyspaceDrawer
:matrix] property to a Settings
key.
The Settings
key must be of the same type as the
[propertyspaceDrawer
:matrix] property, that is, "au"
.
The settingsBind
function cannot be used, because the default GIO
mapping functions don't support [structgLib
.Variant] properties (maybe it will be
supported by a future GIO version, in which case this function can be
deprecated).
getEnableMatrix
spaceDrawerGetEnableMatrix Source #
:: (HasCallStack, MonadIO m, IsSpaceDrawer a) | |
=> a |
|
-> m Bool | Returns: whether the SpaceDrawer:matrix property is enabled. |
No description available in the introspection data.
getMatrix
:: (HasCallStack, MonadIO m, IsSpaceDrawer a) | |
=> a |
|
-> m GVariant | Returns: the SpaceDrawer:matrix value as a new floating |
Gets the value of the [propertyspaceDrawer
:matrix] property, as a [structgLib
.Variant].
An empty array can be returned in case the matrix is a zero matrix.
The [methodspaceDrawer
.get_types_for_locations] function may be more
convenient to use.
getTypesForLocations
spaceDrawerGetTypesForLocations Source #
:: (HasCallStack, MonadIO m, IsSpaceDrawer a) | |
=> a |
|
-> [SpaceLocationFlags] |
|
-> m [SpaceTypeFlags] | Returns: a combination of |
If only one location is specified, this function returns what kind of white spaces are drawn at that location.
The value is retrieved from the [propertyspaceDrawer
:matrix] property.
If several locations are specified, this function returns the logical AND for
those locations. Which means that if a certain kind of white space is present
in the return value, then that kind of white space is drawn at all the
specified locations
.
new
:: (HasCallStack, MonadIO m) | |
=> m SpaceDrawer | Returns: a new |
Creates a new SpaceDrawer
object.
Useful for storing space drawing settings independently of a [classview
].
setEnableMatrix
spaceDrawerSetEnableMatrix Source #
:: (HasCallStack, MonadIO m, IsSpaceDrawer a) | |
=> a |
|
-> Bool |
|
-> m () |
Sets whether the [propertyspaceDrawer
:matrix] property is enabled.
setMatrix
:: (HasCallStack, MonadIO m, IsSpaceDrawer a) | |
=> a |
|
-> Maybe GVariant |
|
-> m () |
Sets a new value to the [propertyspaceDrawer
:matrix] property, as a [structgLib
.Variant].
If matrix
is Nothing
, then an empty array is set.
If matrix
is floating, it is consumed.
The [methodspaceDrawer
.set_types_for_locations] function may be more
convenient to use.
setTypesForLocations
spaceDrawerSetTypesForLocations Source #
:: (HasCallStack, MonadIO m, IsSpaceDrawer a) | |
=> a |
|
-> [SpaceLocationFlags] |
|
-> [SpaceTypeFlags] |
|
-> m () |
Modifies the [propertyspaceDrawer
:matrix] property at the specified
locations
.
Properties
enableMatrix
Whether the [propertyspaceDrawer
:matrix] property is enabled.
constructSpaceDrawerEnableMatrix :: (IsSpaceDrawer o, MonadIO m) => Bool -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “enable-matrix
” property. This is rarely needed directly, but it is used by new
.
getSpaceDrawerEnableMatrix :: (MonadIO m, IsSpaceDrawer o) => o -> m Bool Source #
Get the value of the “enable-matrix
” property.
When overloading is enabled, this is equivalent to
get
spaceDrawer #enableMatrix
setSpaceDrawerEnableMatrix :: (MonadIO m, IsSpaceDrawer o) => o -> Bool -> m () Source #
Set the value of the “enable-matrix
” property.
When overloading is enabled, this is equivalent to
set
spaceDrawer [ #enableMatrix:=
value ]
matrix
The property is a [structgLib
.Variant] property to specify where and
what kind of white spaces to draw.
The [structgLib
.Variant] is of type "au"
, an array of unsigned integers. Each
integer is a combination of [flagsspaceTypeFlags
]. There is one
integer for each [flagsspaceLocationFlags
], in the same order as
they are defined in the enum (SpaceLocationFlagsNone
and
SpaceLocationFlagsAll
are not taken into account).
If the array is shorter than the number of locations, then the value
for the missing locations will be SpaceTypeFlagsNone
.
By default, SpaceTypeFlagsAll
is set for all locations.4
clearSpaceDrawerMatrix :: (MonadIO m, IsSpaceDrawer o) => o -> m () Source #
Set the value of the “matrix
” property to Nothing
.
When overloading is enabled, this is equivalent to
clear
#matrix
constructSpaceDrawerMatrix :: (IsSpaceDrawer o, MonadIO m) => GVariant -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “matrix
” property. This is rarely needed directly, but it is used by new
.
getSpaceDrawerMatrix :: (MonadIO m, IsSpaceDrawer o) => o -> m (Maybe GVariant) Source #
Get the value of the “matrix
” property.
When overloading is enabled, this is equivalent to
get
spaceDrawer #matrix
setSpaceDrawerMatrix :: (MonadIO m, IsSpaceDrawer o) => o -> GVariant -> m () Source #
Set the value of the “matrix
” property.
When overloading is enabled, this is equivalent to
set
spaceDrawer [ #matrix:=
value ]