|
|
|
@ -399,20 +399,6 @@ Source::View::View(const boost::filesystem::path &file_path, const Glib::RefPtr< |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Gsv::DrawSpacesFlags Source::View::parse_show_whitespace_characters(const std::string &text) { |
|
|
|
|
|
|
|
namespace qi = boost::spirit::qi; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
qi::symbols<char, Gsv::DrawSpacesFlags> options; |
|
|
|
|
|
|
|
options.add("space", Gsv::DRAW_SPACES_SPACE)("tab", Gsv::DRAW_SPACES_TAB)("newline", Gsv::DRAW_SPACES_NEWLINE)("nbsp", Gsv::DRAW_SPACES_NBSP)("leading", Gsv::DRAW_SPACES_LEADING)("text", Gsv::DRAW_SPACES_TEXT)("trailing", Gsv::DRAW_SPACES_TRAILING)("all", Gsv::DRAW_SPACES_ALL); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::set<Gsv::DrawSpacesFlags> out; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// parse comma-separated list of options
|
|
|
|
|
|
|
|
qi::phrase_parse(text.begin(), text.end(), options % ',', qi::space, out); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return out.count(Gsv::DRAW_SPACES_ALL) > 0 ? Gsv::DRAW_SPACES_ALL : static_cast<Gsv::DrawSpacesFlags>(std::accumulate(out.begin(), out.end(), 0)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool Source::View::save() { |
|
|
|
bool Source::View::save() { |
|
|
|
if(file_path.empty() || !get_buffer()->get_modified()) |
|
|
|
if(file_path.empty() || !get_buffer()->get_modified()) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
@ -470,7 +456,37 @@ void Source::View::configure() { |
|
|
|
get_source_buffer()->set_style_scheme(scheme); |
|
|
|
get_source_buffer()->set_style_scheme(scheme); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
set_draw_spaces(parse_show_whitespace_characters(Config::get().source.show_whitespace_characters)); |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
#if defined(GTK_SOURCE_MAJOR_VERSION) && (GTK_SOURCE_MAJOR_VERSION > 3 || (GTK_SOURCE_MAJOR_VERSION == 3 && GTK_SOURCE_MINOR_VERSION >= 24)) |
|
|
|
|
|
|
|
namespace qi = boost::spirit::qi; |
|
|
|
|
|
|
|
qi::symbols<char, GtkSourceSpaceLocationFlags> location_options; |
|
|
|
|
|
|
|
qi::symbols<char, GtkSourceSpaceTypeFlags> type_options; |
|
|
|
|
|
|
|
location_options.add("leading", GTK_SOURCE_SPACE_LOCATION_LEADING)("text", GTK_SOURCE_SPACE_LOCATION_INSIDE_TEXT)("trailing", GTK_SOURCE_SPACE_LOCATION_TRAILING)("all", GTK_SOURCE_SPACE_LOCATION_ALL); |
|
|
|
|
|
|
|
type_options.add("space", GTK_SOURCE_SPACE_TYPE_SPACE)("tab", GTK_SOURCE_SPACE_TYPE_TAB)("newline", GTK_SOURCE_SPACE_TYPE_NEWLINE)("nbsp", GTK_SOURCE_SPACE_TYPE_NBSP)("all", GTK_SOURCE_SPACE_TYPE_ALL); |
|
|
|
|
|
|
|
std::set<GtkSourceSpaceLocationFlags> location_out; |
|
|
|
|
|
|
|
std::set<GtkSourceSpaceTypeFlags> type_out; |
|
|
|
|
|
|
|
qi::phrase_parse(Config::get().source.show_whitespace_characters.begin(), Config::get().source.show_whitespace_characters.end(), location_options % ',', qi::space, location_out); |
|
|
|
|
|
|
|
qi::phrase_parse(Config::get().source.show_whitespace_characters.begin(), Config::get().source.show_whitespace_characters.end(), type_options % ',', qi::space, type_out); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto space_drawer = gtk_source_view_get_space_drawer(gobj()); |
|
|
|
|
|
|
|
auto locations = location_out.count(GTK_SOURCE_SPACE_LOCATION_ALL) > 0 ? GTK_SOURCE_SPACE_LOCATION_ALL : static_cast<GtkSourceSpaceLocationFlags>(std::accumulate(location_out.begin(), location_out.end(), 0)); |
|
|
|
|
|
|
|
auto types = type_out.count(GTK_SOURCE_SPACE_TYPE_ALL) > 0 ? GTK_SOURCE_SPACE_TYPE_ALL : static_cast<GtkSourceSpaceTypeFlags>(std::accumulate(type_out.begin(), type_out.end(), 0)); |
|
|
|
|
|
|
|
if(locations != GTK_SOURCE_SPACE_LOCATION_NONE || types != GTK_SOURCE_SPACE_TYPE_NONE) { |
|
|
|
|
|
|
|
gtk_source_space_drawer_set_types_for_locations(space_drawer, locations, types); |
|
|
|
|
|
|
|
gtk_source_space_drawer_set_enable_matrix(space_drawer, true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
gtk_source_space_drawer_set_enable_matrix(space_drawer, false); |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
namespace qi = boost::spirit::qi; |
|
|
|
|
|
|
|
qi::symbols<char, Gsv::DrawSpacesFlags> options; |
|
|
|
|
|
|
|
options.add("space", Gsv::DRAW_SPACES_SPACE)("tab", Gsv::DRAW_SPACES_TAB)("newline", Gsv::DRAW_SPACES_NEWLINE)("nbsp", Gsv::DRAW_SPACES_NBSP)("leading", Gsv::DRAW_SPACES_LEADING)("text", Gsv::DRAW_SPACES_TEXT)("trailing", Gsv::DRAW_SPACES_TRAILING)("all", Gsv::DRAW_SPACES_ALL); |
|
|
|
|
|
|
|
std::set<Gsv::DrawSpacesFlags> out; |
|
|
|
|
|
|
|
qi::phrase_parse(Config::get().source.show_whitespace_characters.begin(), Config::get().source.show_whitespace_characters.end(), options % ',', qi::space, out); |
|
|
|
|
|
|
|
set_draw_spaces(out.count(Gsv::DRAW_SPACES_ALL) > 0 ? Gsv::DRAW_SPACES_ALL : static_cast<Gsv::DrawSpacesFlags>(std::accumulate(out.begin(), out.end(), 0))); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
{ // Set Word Wrap
|
|
|
|
{ // Set Word Wrap
|
|
|
|
namespace qi = boost::spirit::qi; |
|
|
|
namespace qi = boost::spirit::qi; |
|
|
|
std::set<std::string> word_wrap_language_ids; |
|
|
|
std::set<std::string> word_wrap_language_ids; |
|
|
|
|