[ CCode ( type_id = "gtk_source_space_drawer_get_type ()" ) ]
[ GIR ( name = "SpaceDrawer" ) ]
public class SourceSpaceDrawer : Object
Represent white space characters with symbols.
SourceSpaceDrawer provides a way to visualize white spaces, by drawing symbols.
Call [method@View.get_space_drawer] to get the `GtkSourceSpaceDrawer` instance of a certain [class@View].
By default, no white spaces are drawn because the [property@SpaceDrawer:enable-matrix] is false.
To draw white spaces, [method@SpaceDrawer.set_types_for_locations] can be called to set the [property@SpaceDrawer:matrix] property (by default all space types are enabled at all locations). Then call [method@SpaceDrawer.set_enable_matrix].
For a finer-grained method, there is also the [class@Tag]'s [property@Tag:draw-spaces] property.
To draw non-breaking spaces everywhere and draw all types of trailing spaces except newlines: ```c 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); ``` ```python space_drawer.set_types_for_locations( locations=GtkSource.SpaceLocationFlags.ALL, types=GtkSource.SpaceTypeFlags.NBSP, )
all_types_except_newline = GtkSource.SpaceTypeFlags( int(GtkSource.SpaceTypeFlags.ALL) & ~int(GtkSource.SpaceTypeFlags.NEWLINE) ) space_drawer.set_types_for_locations( locations=GtkSource.SpaceLocationFlags.TRAILING, types=all_types_except_newline, )
space_drawer.set_enable_matrix(True) ```
A possible use-case is to draw only unwanted white spaces. Examples:
And non-breaking spaces can always be drawn, everywhere, to distinguish them from normal spaces.