Browse Source

Can now enable word wrap for specific languages

pipelines/235045657
eidheim 5 years ago
parent
commit
f469a41601
  1. 2
      CMakeLists.txt
  2. 2
      src/config.cpp
  3. 2
      src/config.hpp
  4. 3
      src/files.hpp
  5. 11
      src/source.cpp

2
CMakeLists.txt

@ -1,7 +1,7 @@
cmake_minimum_required (VERSION 2.8.8)
project(juci)
set(JUCI_VERSION "1.6.0.4")
set(JUCI_VERSION "1.6.0.5")
set(CPACK_PACKAGE_NAME "jucipp")
set(CPACK_PACKAGE_CONTACT "Ole Christian Eidheim <eidheim@gmail.com>")

2
src/config.cpp

@ -164,7 +164,7 @@ void Config::read(const boost::property_tree::ptree &cfg) {
source.default_tab_size = source_json.get<unsigned>("default_tab_size");
source.auto_tab_char_and_size = source_json.get<bool>("auto_tab_char_and_size");
source.tab_indents_line = source_json.get<bool>("tab_indents_line");
source.wrap_lines = source_json.get<bool>("wrap_lines");
source.word_wrap = source_json.get<std::string>("word_wrap");
source.highlight_current_line = source_json.get<bool>("highlight_current_line");
source.show_line_numbers = source_json.get<bool>("show_line_numbers");
source.enable_multiple_cursors = source_json.get<bool>("enable_multiple_cursors");

2
src/config.hpp

@ -85,7 +85,7 @@ public:
char default_tab_char;
unsigned default_tab_size;
bool tab_indents_line;
bool wrap_lines;
std::string word_wrap;
bool highlight_current_line;
bool show_line_numbers;
bool enable_multiple_cursors;

3
src/files.hpp

@ -57,7 +57,8 @@ const std::string default_config_file = R"RAW({
"default_tab_char": " ",
"default_tab_size": 2,
"tab_indents_line": true,
"wrap_lines": false,
"word_wrap_comment": "Specify language ids that should enable word wrap, for instance: chdr, c, cpphdr, cpp, js, python, or all to enable word wrap for all languages",
"word_wrap": "markdown, latex",
"highlight_current_line": true,
"show_line_numbers": true,
"enable_multiple_cursors": false,

11
src/source.cpp

@ -437,11 +437,18 @@ void Source::View::configure() {
}
set_draw_spaces(parse_show_whitespace_characters(Config::get().source.show_whitespace_characters));
if(Config::get().source.wrap_lines || (language && (language->get_id() == "markdown" || language->get_id() == "latex")))
{ // Set Word Wrap
auto language_id = language ? language->get_id() : "";
namespace qi = boost::spirit::qi;
std::set<std::string> word_wrap_language_ids;
qi::phrase_parse(Config::get().source.word_wrap.begin(), Config::get().source.word_wrap.end(), (+(~qi::char_(','))) % ',', qi::space, word_wrap_language_ids);
if(std::any_of(word_wrap_language_ids.begin(), word_wrap_language_ids.end(), [&language_id](const std::string &word_wrap_language_id) {
return word_wrap_language_id == language_id || word_wrap_language_id == "all";
}))
set_wrap_mode(Gtk::WrapMode::WRAP_WORD_CHAR);
else
set_wrap_mode(Gtk::WrapMode::WRAP_NONE);
}
property_highlight_current_line() = Config::get().source.highlight_current_line;
line_renderer->set_visible(Config::get().source.show_line_numbers);

Loading…
Cancel
Save