GNOME Bugzilla – Bug 737796
Drawing whitespaces only in selected text
Last modified: 2021-07-05 11:00:32 UTC
Some text editors provide support for showing the whitespaces on a part of the file, e.g. on the selected text. Currently GtkSourceView can only be set the draw-spaces property globally.
Yes, it can be useful. See also bug #683678 and bug #721015.
Thanks for the comment Sébastien. Bug #683678 looks relevant indeed, with your proposed solution there to have separate GtkSourceSpaceType and GtkSourceSpaceLocation enums, we could simply add a SELECTION value to the GtkSourceSpaceLocation enum, as it clearly fits in that context. Would that be OK for you? If yes, I might take over and extend lamefun's patches from #683678.
Note that ideally the space drawing should be done by Pango and GtkTextView to have better performances. But it's not going to happen soon since nobody is working on that, having a better API in GtkSourceView in the meantime would be nice I think, and if there are problems with the new API, we can make another iteration when moving the API in GtkTextView. Adding a SELECTION flag seems a good solution. Providing two GtkTextIters would be more flexible, but can be done independently.
Bug 683678 reguested a use-case: sublime text has three possible settings for drawing whitespaces (all, none, selected) and gtksourceview already supports two. Showing whitespaces in selection only is the last option missing.
Ok, but why is it useful to draw spaces only for the selected text? Why sublime text do it? The reason that I see is to be able to know exactly what is copied or deleted.
(In reply to Sébastien Wilmet from comment #3) > Adding a SELECTION flag seems a good solution. Bug 683678 is fixed, there is now a GtkSourceSpaceLocationFlags enum. > Providing two GtkTextIters > would be more flexible, but can be done independently. And there is now GtkSourceTag, which is the most flexible.
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org. As part of that, we are mass-closing older open tickets in bugzilla.gnome.org which have not seen updates for a longer time (resources are unfortunately quite limited so not every ticket can get handled). If you can still reproduce the situation described in this ticket in a recent and supported software version, then please follow https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines and create a new ticket at https://gitlab.gnome.org/GNOME/gtksourceview/-/issues/ Thank you for your understanding and your help.