Browse Source

Minor improvement to space drawing code

merge-requests/181/head
eidheim 1 year ago
parent
commit
617e5d96cb
  1. 24
      src/source.cpp

24
src/source.cpp

@ -463,28 +463,30 @@ void Source::View::configure() {
std::set<std::string> out;
qi::phrase_parse(Config::get().source.show_whitespace_characters.begin(), Config::get().source.show_whitespace_characters.end(), (+(~qi::char_(','))) % ',', qi::space, out);
auto space_drawer = gtk_source_view_get_space_drawer(gobj());
int locations = GTK_SOURCE_SPACE_LOCATION_NONE;
if(out.count("leading") > 0)
int types = GTK_SOURCE_SPACE_TYPE_NONE;
for(auto &e : out) {
if(e == "leading")
locations |= GTK_SOURCE_SPACE_LOCATION_LEADING;
if(out.count("text") > 0)
else if(e == "text")
locations |= GTK_SOURCE_SPACE_LOCATION_INSIDE_TEXT;
if(out.count("trailing") > 0)
else if(e == "trailing")
locations |= GTK_SOURCE_SPACE_LOCATION_TRAILING;
if(out.count("all") > 0)
else if(e == "all")
locations |= GTK_SOURCE_SPACE_LOCATION_ALL;
int types = GTK_SOURCE_SPACE_TYPE_NONE;
if(out.count("space") > 0)
else if(e == "space")
types |= GTK_SOURCE_SPACE_TYPE_SPACE;
if(out.count("tab") > 0)
else if(e == "tab")
types |= GTK_SOURCE_SPACE_TYPE_TAB;
if(out.count("newline") > 0)
else if(e == "newline")
types |= GTK_SOURCE_SPACE_TYPE_NEWLINE;
if(out.count("nbsp") > 0)
else if(e == "nbsp")
types |= GTK_SOURCE_SPACE_TYPE_NBSP;
if(out.count("all") > 0)
else if(e == "all")
types |= GTK_SOURCE_SPACE_TYPE_ALL;
}
auto space_drawer = gtk_source_view_get_space_drawer(gobj());
if(locations != GTK_SOURCE_SPACE_LOCATION_NONE || types != GTK_SOURCE_SPACE_TYPE_NONE) {
if(locations == GTK_SOURCE_SPACE_LOCATION_NONE)
locations = GTK_SOURCE_SPACE_LOCATION_ALL;

Loading…
Cancel
Save