Class SpaceDrawer
- All Implemented Interfaces:
Proxy
GtkSourceSpaceDrawer
provides a way to visualize white spaces, by drawing
symbols.
Call View.getSpaceDrawer()
to get the GtkSourceSpaceDrawer
instance of a certain View
.
By default, no white spaces are drawn because the
SpaceDrawer:enable-matrix
is false
.
To draw white spaces, setTypesForLocations(java.util.Set<org.gnome.gtksourceview.SpaceLocationFlags>, java.util.Set<org.gnome.gtksourceview.SpaceTypeFlags>)
can
be called to set the SpaceDrawer:matrix
property (by default all
space types are enabled at all locations). Then call
setEnableMatrix(boolean)
.
For a finer-grained method, there is also the Tag
's
Tag:draw-spaces
property.
Example
To draw non-breaking spaces everywhere and draw all types of trailing spaces
except newlines:
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
SpaceDrawer.Builder<B extends SpaceDrawer.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static class
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionCreates a newGtkSourceSpaceDrawer
object.SpaceDrawer
(MemorySegment address) Create a SpaceDrawer proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected SpaceDrawer
asParent()
Returns this instance as if it were its parent type.void
bindMatrixSetting
(Settings settings, String key, Set<SettingsBindFlags> flags) Binds theSpaceDrawer:matrix
property to aSettings
key.void
bindMatrixSetting
(Settings settings, String key, SettingsBindFlags... flags) Binds theSpaceDrawer:matrix
property to aSettings
key.static SpaceDrawer.Builder
<? extends SpaceDrawer.Builder> builder()
ASpaceDrawer.Builder
object constructs aSpaceDrawer
with the specified properties.boolean
Gets the value of theSpaceDrawer:matrix
property, as aGLib.Variant
.static Type
getType()
Get the GType of the SpaceDrawer classgetTypesForLocations
(Set<SpaceLocationFlags> locations) If only one location is specified, this function returns what kind of white spaces are drawn at that location.getTypesForLocations
(SpaceLocationFlags... locations) If only one location is specified, this function returns what kind of white spaces are drawn at that location.void
setEnableMatrix
(boolean enableMatrix) Sets whether theSpaceDrawer:matrix
property is enabled.void
Sets a new value to theSpaceDrawer:matrix
property, as aGLib.Variant
.void
setTypesForLocations
(Set<SpaceLocationFlags> locations, Set<SpaceTypeFlags> types) Modifies theSpaceDrawer:matrix
property at the specifiedlocations
.void
setTypesForLocations
(SpaceLocationFlags locations, SpaceTypeFlags... types) Modifies theSpaceDrawer:matrix
property at the specifiedlocations
.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, getMemoryLayout, 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
-
SpaceDrawer
Create a SpaceDrawer proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
SpaceDrawer
public SpaceDrawer()Creates a newGtkSourceSpaceDrawer
object.Useful for storing space drawing settings independently of a
View
.
-
-
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. -
bindMatrixSetting
Binds theSpaceDrawer:matrix
property to aSettings
key.The
Settings
key must be of the same type as theSpaceDrawer:matrix
property, that is,"au"
.The
Settings.bind(java.lang.String, org.gnome.gobject.GObject, java.lang.String, java.util.Set<org.gnome.gio.SettingsBindFlags>)
function cannot be used, because the default GIO mapping functions don't supportGLib.Variant
properties (maybe it will be supported by a future GIO version, in which case this function can be deprecated).- Parameters:
settings
- aGSettings
object.key
- thesettings
key to bind.flags
- flags for the binding.
-
bindMatrixSetting
Binds theSpaceDrawer:matrix
property to aSettings
key.The
Settings
key must be of the same type as theSpaceDrawer:matrix
property, that is,"au"
.The
Settings.bind(java.lang.String, org.gnome.gobject.GObject, java.lang.String, java.util.Set<org.gnome.gio.SettingsBindFlags>)
function cannot be used, because the default GIO mapping functions don't supportGLib.Variant
properties (maybe it will be supported by a future GIO version, in which case this function can be deprecated).- Parameters:
settings
- aGSettings
object.key
- thesettings
key to bind.flags
- flags for the binding.
-
getEnableMatrix
public boolean getEnableMatrix() -
getMatrix
Gets the value of theSpaceDrawer:matrix
property, as aGLib.Variant
.An empty array can be returned in case the matrix is a zero matrix.
The
getTypesForLocations(java.util.Set<org.gnome.gtksourceview.SpaceLocationFlags>)
function may be more convenient to use.- Returns:
- the
GtkSourceSpaceDrawer
:matrix value as a new floatingGVariant
instance.
-
getTypesForLocations
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
SpaceDrawer: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
.- Parameters:
locations
- one or severalGtkSourceSpaceLocationFlags
.- Returns:
- a combination of
GtkSourceSpaceTypeFlags
.
-
getTypesForLocations
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
SpaceDrawer: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
.- Parameters:
locations
- one or severalGtkSourceSpaceLocationFlags
.- Returns:
- a combination of
GtkSourceSpaceTypeFlags
.
-
setEnableMatrix
public void setEnableMatrix(boolean enableMatrix) Sets whether theSpaceDrawer:matrix
property is enabled.- Parameters:
enableMatrix
- the new value.
-
setMatrix
Sets a new value to theSpaceDrawer:matrix
property, as aGLib.Variant
.If
matrix
isnull
, then an empty array is set.If
matrix
is floating, it is consumed.The
setTypesForLocations(java.util.Set<org.gnome.gtksourceview.SpaceLocationFlags>, java.util.Set<org.gnome.gtksourceview.SpaceTypeFlags>)
function may be more convenient to use.- Parameters:
matrix
- the new matrix value, ornull
.
-
setTypesForLocations
Modifies theSpaceDrawer:matrix
property at the specifiedlocations
.- Parameters:
locations
- one or severalGtkSourceSpaceLocationFlags
.types
- a combination ofGtkSourceSpaceTypeFlags
.
-
setTypesForLocations
Modifies theSpaceDrawer:matrix
property at the specifiedlocations
.- Parameters:
locations
- one or severalGtkSourceSpaceLocationFlags
.types
- a combination ofGtkSourceSpaceTypeFlags
.
-
builder
ASpaceDrawer.Builder
object constructs aSpaceDrawer
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withSpaceDrawer.Builder.build()
.
-