Browse Source

Merge branch 'master' of https://github.com/hia3/jucipp

merge-requests/365/head
eidheim 10 years ago
parent
commit
10102b12a1
  1. 1
      src/config.cc
  2. 1
      src/config.h
  3. 4
      src/files.h
  4. 45
      src/source.cc

1
src/config.cc

@ -186,6 +186,7 @@ void Config::get_source() {
source.font=source_json.get<std::string>("font"); source.font=source_json.get<std::string>("font");
source.cleanup_whitespace_characters=source_json.get<bool>("cleanup_whitespace_characters"); source.cleanup_whitespace_characters=source_json.get<bool>("cleanup_whitespace_characters");
source.draw_spaces=source_json.get<std::string>("draw_spaces");
source.show_map = source_json.get<bool>("show_map"); source.show_map = source_json.get<bool>("show_map");
source.map_font_size = source_json.get<std::string>("map_font_size"); source.map_font_size = source_json.get<std::string>("map_font_size");

1
src/config.h

@ -56,6 +56,7 @@ public:
std::string spellcheck_language; std::string spellcheck_language;
bool cleanup_whitespace_characters; bool cleanup_whitespace_characters;
std::string draw_spaces;
bool show_map; bool show_map;
std::string map_font_size; std::string map_font_size;

4
src/files.h

@ -2,7 +2,7 @@
#define JUCI_FILES_H_ #define JUCI_FILES_H_
#include <string> #include <string>
#define JUCI_VERSION "1.1.3-1" #define JUCI_VERSION "1.1.3-2"
const std::string configjson = const std::string configjson =
"{\n" "{\n"
@ -37,6 +37,8 @@ const std::string configjson =
#endif #endif
" \"cleanup_whitespace_characters_comment\": \"Remove trailing whitespace characters on save, and add trailing newline if missing\",\n" " \"cleanup_whitespace_characters_comment\": \"Remove trailing whitespace characters on save, and add trailing newline if missing\",\n"
" \"cleanup_whitespace_characters\": false,\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_map\": true,\n" " \"show_map\": true,\n"
" \"map_font_size\": \"1\",\n" " \"map_font_size\": \"1\",\n"
" \"spellcheck_language_comment\": \"Use \\\"\\\" to set language from your locale settings\",\n" " \"spellcheck_language_comment\": \"Use \\\"\\\" to set language from your locale settings\",\n"

45
src/source.cc

@ -1,11 +1,18 @@
#include "source.h"
#include "config.h" #include "config.h"
#include "filesystem.h"
#include "source.h"
#include "terminal.h"
#include <boost/property_tree/json_parser.hpp> #include <boost/property_tree/json_parser.hpp>
#include <algorithm> #include <boost/spirit/home/qi/char.hpp>
#include <boost/spirit/home/qi/operator.hpp>
#include <boost/spirit/home/qi/string.hpp>
#include <gtksourceview/gtksource.h> #include <gtksourceview/gtksource.h>
#include <algorithm>
#include <iostream> #include <iostream>
#include "filesystem.h" #include <set>
#include "terminal.h"
namespace sigc { namespace sigc {
#ifndef SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE #ifndef SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE
@ -374,6 +381,34 @@ void Source::View::set_tab_char_and_size(char tab_char, unsigned tab_size) {
tab+=tab_char; tab+=tab_char;
} }
Gsv::DrawSpacesFlags parse_draw_spaces(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);
auto begin = text.begin();
auto end = text.end();
std::set<Gsv::DrawSpacesFlags> out;
// parse comma-separated list of options
qi::phrase_parse(begin, end, options % ',', qi::space, out);
return out.count(Gsv::DRAW_SPACES_ALL) ?
Gsv::DRAW_SPACES_ALL :
static_cast<Gsv::DrawSpacesFlags>(std::accumulate(out.begin(), out.end(), 0));
}
void Source::View::configure() { void Source::View::configure() {
//TODO: Move this to notebook? Might take up too much memory doing this for every tab. //TODO: Move this to notebook? Might take up too much memory doing this for every tab.
auto style_scheme_manager=Gsv::StyleSchemeManager::get_default(); auto style_scheme_manager=Gsv::StyleSchemeManager::get_default();
@ -388,6 +423,8 @@ void Source::View::configure() {
Terminal::get().print("Error: Could not find gtksourceview style: "+Config::get().source.style+'\n', true); 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));
if(Config::get().source.wrap_lines) if(Config::get().source.wrap_lines)
set_wrap_mode(Gtk::WrapMode::WRAP_CHAR); set_wrap_mode(Gtk::WrapMode::WRAP_CHAR);
else else

Loading…
Cancel
Save