Browse Source

Minor improvement to space drawing code

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

40
src/source.cpp

@ -463,28 +463,30 @@ void Source::View::configure() {
std::set<std::string> out; 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); 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; int locations = GTK_SOURCE_SPACE_LOCATION_NONE;
if(out.count("leading") > 0)
locations |= GTK_SOURCE_SPACE_LOCATION_LEADING;
if(out.count("text") > 0)
locations |= GTK_SOURCE_SPACE_LOCATION_INSIDE_TEXT;
if(out.count("trailing") > 0)
locations |= GTK_SOURCE_SPACE_LOCATION_TRAILING;
if(out.count("all") > 0)
locations |= GTK_SOURCE_SPACE_LOCATION_ALL;
int types = GTK_SOURCE_SPACE_TYPE_NONE; int types = GTK_SOURCE_SPACE_TYPE_NONE;
if(out.count("space") > 0) for(auto &e : out) {
types |= GTK_SOURCE_SPACE_TYPE_SPACE; if(e == "leading")
if(out.count("tab") > 0) locations |= GTK_SOURCE_SPACE_LOCATION_LEADING;
types |= GTK_SOURCE_SPACE_TYPE_TAB; else if(e == "text")
if(out.count("newline") > 0) locations |= GTK_SOURCE_SPACE_LOCATION_INSIDE_TEXT;
types |= GTK_SOURCE_SPACE_TYPE_NEWLINE; else if(e == "trailing")
if(out.count("nbsp") > 0) locations |= GTK_SOURCE_SPACE_LOCATION_TRAILING;
types |= GTK_SOURCE_SPACE_TYPE_NBSP; else if(e == "all")
if(out.count("all") > 0) locations |= GTK_SOURCE_SPACE_LOCATION_ALL;
types |= GTK_SOURCE_SPACE_TYPE_ALL; else if(e == "space")
types |= GTK_SOURCE_SPACE_TYPE_SPACE;
else if(e == "tab")
types |= GTK_SOURCE_SPACE_TYPE_TAB;
else if(e == "newline")
types |= GTK_SOURCE_SPACE_TYPE_NEWLINE;
else if(e == "nbsp")
types |= GTK_SOURCE_SPACE_TYPE_NBSP;
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 || types != GTK_SOURCE_SPACE_TYPE_NONE) {
if(locations == GTK_SOURCE_SPACE_LOCATION_NONE) if(locations == GTK_SOURCE_SPACE_LOCATION_NONE)
locations = GTK_SOURCE_SPACE_LOCATION_ALL; locations = GTK_SOURCE_SPACE_LOCATION_ALL;

Loading…
Cancel
Save