Class SpaceDrawer

java.lang.Object
All Implemented Interfaces:
Proxy

@Generated("io.github.jwharm.JavaGI") public class SpaceDrawer extends GObject
Represent white space characters with symbols.

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.