From d2beb15277e6f3ec1086d131472703892ac4bcb2 Mon Sep 17 00:00:00 2001 From: eidheim Date: Wed, 11 May 2016 10:09:16 +0200 Subject: [PATCH] Cleanup of #215 --- src/config.cc | 2 +- src/config.h | 2 +- src/files.h | 6 +++--- src/source.cc | 21 +++++++-------------- src/source.h | 2 ++ 5 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/config.cc b/src/config.cc index 07271d0..ebd6e98 100644 --- a/src/config.cc +++ b/src/config.cc @@ -186,7 +186,7 @@ void Config::get_source() { source.font=source_json.get("font"); source.cleanup_whitespace_characters=source_json.get("cleanup_whitespace_characters"); - source.draw_spaces=source_json.get("draw_spaces"); + source.show_whitespace_characters=source_json.get("show_whitespace_characters"); source.show_map = source_json.get("show_map"); source.map_font_size = source_json.get("map_font_size"); diff --git a/src/config.h b/src/config.h index 3ce7373..96c9256 100644 --- a/src/config.h +++ b/src/config.h @@ -56,7 +56,7 @@ public: std::string spellcheck_language; bool cleanup_whitespace_characters; - std::string draw_spaces; + std::string show_whitespace_characters; bool show_map; std::string map_font_size; diff --git a/src/files.h b/src/files.h index c589989..906c44c 100644 --- a/src/files.h +++ b/src/files.h @@ -2,7 +2,7 @@ #define JUCI_FILES_H_ #include -#define JUCI_VERSION "1.1.3-2" +#define JUCI_VERSION "1.1.3-3" const std::string configjson = "{\n" @@ -37,8 +37,8 @@ const std::string configjson = #endif " \"cleanup_whitespace_characters_comment\": \"Remove trailing whitespace characters on save, and add trailing newline if missing\",\n" " \"cleanup_whitespace_characters\": false,\n" -" \"draw_spaces_comment\": \"Determines what kind of whitespaces should be drawn. Use comma-separated list of: space, tab, newline, nbsp, leading, text, trailing or all\",\n" -" \"draw_spaces\": \"\",\n" +" \"show_whitespace_characters_comment\": \"Determines what kind of whitespaces should be drawn. Use comma-separated list of: space, tab, newline, nbsp, leading, text, trailing or all\",\n" +" \"show_whitespace_characters\": \"\",\n" " \"show_map\": true,\n" " \"map_font_size\": \"1\",\n" " \"spellcheck_language_comment\": \"Use \\\"\\\" to set language from your locale settings\",\n" diff --git a/src/source.cc b/src/source.cc index 599c01d..81362b8 100644 --- a/src/source.cc +++ b/src/source.cc @@ -1,17 +1,14 @@ +#include "source.h" #include "config.h" #include "filesystem.h" -#include "source.h" #include "terminal.h" - +#include #include #include #include #include - -#include - -#include #include +#include #include namespace sigc { @@ -381,8 +378,7 @@ void Source::View::set_tab_char_and_size(char tab_char, unsigned tab_size) { tab+=tab_char; } -Gsv::DrawSpacesFlags parse_draw_spaces(std::string text) -{ +Gsv::DrawSpacesFlags Source::View::parse_show_whitespace_characters(const std::string &text) { namespace qi = boost::spirit::qi; qi::symbols options; @@ -396,15 +392,12 @@ Gsv::DrawSpacesFlags parse_draw_spaces(std::string text) ("trailing", Gsv::DRAW_SPACES_TRAILING) ("all", Gsv::DRAW_SPACES_ALL); - auto begin = text.begin(); - auto end = text.end(); - std::set out; // parse comma-separated list of options - qi::phrase_parse(begin, end, options % ',', qi::space, out); + qi::phrase_parse(text.begin(), text.end(), options % ',', qi::space, out); - return out.count(Gsv::DRAW_SPACES_ALL) ? + return out.count(Gsv::DRAW_SPACES_ALL)>0 ? Gsv::DRAW_SPACES_ALL : static_cast(std::accumulate(out.begin(), out.end(), 0)); } @@ -423,7 +416,7 @@ void Source::View::configure() { Terminal::get().print("Error: Could not find gtksourceview style: "+Config::get().source.style+'\n', true); } - set_draw_spaces(parse_draw_spaces(Config::get().source.draw_spaces)); + set_draw_spaces(parse_show_whitespace_characters(Config::get().source.show_whitespace_characters)); if(Config::get().source.wrap_lines) set_wrap_mode(Gtk::WrapMode::WRAP_CHAR); diff --git a/src/source.h b/src/source.h index 9aa3b8f..9ee69b9 100644 --- a/src/source.h +++ b/src/source.h @@ -169,6 +169,8 @@ namespace Source { guint previous_non_modifier_keyval=0; guint last_keyval=0; private: + Gsv::DrawSpacesFlags parse_show_whitespace_characters(const std::string &text); + GtkSourceSearchContext *search_context; GtkSourceSearchSettings *search_settings; static void search_occurrences_updated(GtkWidget* widget, GParamSpec* property, gpointer data);