diff --git a/src/config.cc b/src/config.cc index 6209822..aad5424 100644 --- a/src/config.cc +++ b/src/config.cc @@ -32,8 +32,8 @@ void MainConfig::GenerateSource() { DEBUG("Fetching source cfg"); // boost::property_tree::ptree auto source_json = cfg.get_child("source"); - auto syntax_json = source_json.get_child("syntax"); - auto colors_json = source_json.get_child("colors"); + auto clang_types_json = source_json.get_child("clang_types"); + auto style_json = source_json.get_child("style"); auto visual_json = source_json.get_child("visual"); for (auto &i : visual_json) { if (i.first == "background") @@ -54,9 +54,9 @@ void MainConfig::GenerateSource() { source_cfg->tab_size = source_json.get("tab_size"); for (unsigned c = 0; c < source_cfg->tab_size; c++) source_cfg->tab+=" "; - for (auto &i : colors_json) + for (auto &i : style_json) source_cfg->tags[i.first]=i.second.get_value(); - for (auto &i : syntax_json) + for (auto &i : clang_types_json) source_cfg->types[i.first]=i.second.get_value(); DEBUG("Source cfg fetched"); } diff --git a/src/juci.cc b/src/juci.cc index 629c22b..99dcf6f 100644 --- a/src/juci.cc +++ b/src/juci.cc @@ -8,7 +8,7 @@ void init_logging() { INFO("Logging initalized"); } -int Juci::on_command_line(const Glib::RefPtr &cmd) { +int juci::app::on_command_line(const Glib::RefPtr &cmd) { Glib::set_prgname("juci"); Glib::OptionContext ctx("[PATH ...]"); Glib::OptionGroup gtk_group(gtk_get_option_group(true)); @@ -31,7 +31,7 @@ int Juci::on_command_line(const Glib::RefPtr &cmd) return 0; } -void Juci::on_activate() { +void juci::app::on_activate() { window = std::unique_ptr(new Window()); add_window(*window); window->show(); @@ -43,7 +43,11 @@ void Juci::on_activate() { window->notebook.open(f); } +juci::app::app() : Gtk::Application("no.sout.juci", Gio::APPLICATION_HANDLES_COMMAND_LINE) { + +} + int main(int argc, char *argv[]) { init_logging(); - return Juci().run(argc, argv); + return juci::app().run(argc, argv); } diff --git a/src/juci.h b/src/juci.h index 4ce2cb2..41c0fd2 100644 --- a/src/juci.h +++ b/src/juci.h @@ -3,18 +3,19 @@ #include "window.h" #include "logging.h" - -class Juci : public Gtk::Application { -public: - Juci(): Gtk::Application("no.sout.juci", Gio::APPLICATION_HANDLES_COMMAND_LINE) {} +namespace juci { + class app : public Gtk::Application { + public: + app(); - int on_command_line(const Glib::RefPtr &cmd); - void on_activate(); + int on_command_line(const Glib::RefPtr &cmd); + void on_activate(); -private: - std::unique_ptr window; - std::string directory; - std::vector files; -}; + private: + std::unique_ptr window; + std::string directory; + std::vector files; + }; +} -#endif // JUCI_JUCI_H_ \ No newline at end of file +#endif // JUCI_JUCI_H_ diff --git a/src/source.cc b/src/source.cc index 6faea78..1239521 100644 --- a/src/source.cc +++ b/src/source.cc @@ -38,14 +38,10 @@ Glib::RefPtr Source::guess_language(const std::string &file_path) ////////////// Source::View::View(const std::string& file_path, const std::string& project_path): file_path(file_path), project_path(project_path) { - set_smart_home_end(Gsv::SMART_HOME_END_BEFORE); - set_show_line_numbers(Singleton::Config::source()->show_line_numbers); - set_highlight_current_line(Singleton::Config::source()->highlight_current_line); - + set_smart_home_end(Gsv::SMART_HOME_END_BEFORE); get_source_buffer()->begin_not_undoable_action(); juci::filesystem::read(file_path, get_buffer()); get_source_buffer()->end_not_undoable_action(); - get_buffer()->place_cursor(get_buffer()->get_iter_at_offset(0)); search_settings = gtk_source_search_settings_new(); gtk_source_search_settings_set_wrap_around(search_settings, true); @@ -66,8 +62,8 @@ file_path(file_path), project_path(project_path) { style_scheme_manager->prepend_search_path(Singleton::style_dir()); auto scheme = style_scheme_manager->get_scheme(Singleton::Config::source()->theme); + if(scheme) { -scheme->_cpp_destruction_is_in_progress() get_source_buffer()->set_style_scheme(scheme); } } @@ -279,12 +275,29 @@ clang::Index Source::ClangViewParse::clang_index(0, 0); Source::ClangViewParse::ClangViewParse(const std::string& file_path, const std::string& project_path): Source::View(file_path, project_path) { - override_font(Pango::FontDescription(Singleton::Config::source()->font)); - override_background_color(Gdk::RGBA(Singleton::Config::source()->background)); - override_background_color(Gdk::RGBA(Singleton::Config::source()->background_selected), Gtk::StateFlags::STATE_FLAG_SELECTED); + INFO("Tagtable beeing filled"); for (auto &item : Singleton::Config::source()->tags) { - get_source_buffer()->create_tag(item.first)->property_foreground() = item.second; + auto scheme = get_source_buffer()->get_style_scheme(); + auto style = scheme->get_style(item.second); + if (style) { + DEBUG("Style " + item.second + " found in style " + scheme->get_name()); + auto tag = get_source_buffer()->create_tag(item.first); + if (style->property_foreground_set()) + tag->property_foreground() = style->property_foreground(); + if (style->property_background_set()) + tag->property_background() = style->property_background(); + if (style->property_strikethrough_set()) + tag->property_strikethrough() = style->property_strikethrough(); + // // if (style->property_bold_set()) tag->property_weight() = style->property_bold(); + // // if (style->property_italic_set()) tag->property_italic() = style->property_italic(); + // // if (style->property_line_background_set()) tag->property_line_background() = style->property_line_background(); + // // if (style->property_underline_set()) tag->property_underline() = style->property_underline(); + } else { + DEBUG("Style " + item.second + " not found in " + scheme->get_name()); + get_source_buffer()->create_tag(item.first)->property_foreground() = item.second; + } } + INFO("Tagtable filled"); //Create underline color tags for diagnostic warnings and errors: auto diagnostic_tag=get_buffer()->get_tag_table()->lookup("diagnostic_warning"); @@ -479,7 +492,7 @@ void Source::ClangViewParse::update_syntax() { buffer->remove_tag_by_name(tag, buffer->begin(), buffer->end()); last_syntax_tags.clear(); for (auto &range : ranges) { - std::string type = std::to_string(range.kind); + auto type = std::to_string(range.kind); try { last_syntax_tags.emplace(Singleton::Config::source()->types.at(type)); } catch (std::exception) { @@ -490,6 +503,7 @@ void Source::ClangViewParse::update_syntax() { Gtk::TextIter end_iter = buffer->get_iter_at_offset(range.end_offset); buffer->apply_tag_by_name(Singleton::Config::source()->types.at(type), begin_iter, end_iter); + } } @@ -1099,4 +1113,4 @@ bool Source::ClangView::restart_parse() { return true; } return false; -} \ No newline at end of file +}