diff --git a/src/config.cc b/src/config.cc index 7aac125..7a433fb 100644 --- a/src/config.cc +++ b/src/config.cc @@ -10,20 +10,14 @@ MainConfig::MainConfig() { boost::property_tree::json_parser::read_json(Singleton::config_dir() + "config.json", cfg); Singleton::Config::window()->keybindings = cfg.get_child("keybindings"); GenerateSource(); - GenerateTheme(); GenerateDirectoryFilter(); + + Singleton::Config::window()->theme_name=cfg.get("gtk_theme.name"); + Singleton::Config::window()->theme_variant=cfg.get("gtk_theme.variant"); + Singleton::Config::terminal()->make_command=cfg.get("project.make_command"); } -void MainConfig::GenerateTheme() { - auto config = Singleton::Config::theme(); - auto props = cfg.get_child("theme"); - for (auto &prop : props) { - if (prop.first == "theme") config->theme = prop.second.get_value(); - if (prop.first == "main") config->main = prop.second.get_value(); - } -} - void MainConfig::find_or_create_config_files() { std::vector files = {"config.json", "menu.xml", "plugins.py"}; boost::filesystem::create_directories(boost::filesystem::path(Singleton::config_dir())); @@ -35,21 +29,35 @@ void MainConfig::find_or_create_config_files() { if (file == "menu.xml") juci::filesystem::write(path, menuxml); } } + + boost::filesystem::create_directories(boost::filesystem::path(Singleton::style_dir())); + boost::filesystem::path juci_style_path=Singleton::style_dir(); + juci_style_path+="juci-light.xml"; + if(!boost::filesystem::exists(juci_style_path)) + juci::filesystem::write(juci_style_path, juci_light_style); + juci_style_path=Singleton::style_dir(); + juci_style_path+="juci-dark.xml"; + if(!boost::filesystem::exists(juci_style_path)) + juci::filesystem::write(juci_style_path, juci_dark_style); } void MainConfig::GenerateSource() { auto source_cfg = Singleton::Config::source(); auto source_json = cfg.get_child("source"); - auto clang_types_json = source_json.get_child("clang_types"); - auto style_json = source_json.get_child("style"); - auto gsv_json = source_json.get_child("sourceview"); - for (auto &i : gsv_json) - source_cfg->gsv[i.first] = i.second.get_value(); - for (auto &i : style_json) - source_cfg->tags[i.first] = i.second.get_value(); - for (auto &i : clang_types_json) - source_cfg->types[i.first] = i.second.get_value(); + source_cfg->tab_size = source_json.get("tab_size"); + source_cfg->tab_char = source_json.get("tab_char"); + for(unsigned c=0;ctab_size;c++) + source_cfg->tab+=source_cfg->tab_char; + + source_cfg->highlight_current_line = source_json.get_value("highlight_current_line"); + source_cfg->show_line_numbers = source_json.get_value("show_line_numbers"); + + for (auto &i : source_json.get_child("clang_types")) + source_cfg->clang_types[i.first] = i.second.get_value(); + + Singleton::Config::source()->style=source_json.get("style"); + source_cfg->font=source_json.get("font"); } void MainConfig::GenerateDirectoryFilter() { diff --git a/src/config.h b/src/config.h index 4362fb0..b0b5afd 100644 --- a/src/config.h +++ b/src/config.h @@ -11,7 +11,6 @@ public: void PrintMenu(); void GenerateSource(); void GenerateDirectoryFilter(); - void GenerateTheme(); private: boost::property_tree::ptree cfg; }; diff --git a/src/files.h b/src/files.h index 4ac51f0..4312334 100644 --- a/src/files.h +++ b/src/files.h @@ -1,36 +1,32 @@ #include const std::string configjson = "{\n" +" \"gtk_theme\": {\n" +" \"name\": \"Adwaita\", //Use \"\" for default theme, At least these two exist on all systems: Adwaita, Raleigh\n" +" \"variant\": \"\" //Use \"\" for default variant, and \"dark\" for dark theme variant\n" +" },\n" " \"source\": {\n" -" \"colors\": {\n" -" \"text_color\": \"black\",\n" -" \"string\": \"#CC0000\",\n" -" \"namespace_ref\": \"#990099\",\n" -" \"type\": \"#0066FF\",\n" -" \"keyword\": \"blue\",\n" -" \"comment\": \"grey\",\n" -" \"own\": \"pink\",\n" -" \"diagnostic_warning\": \"orange\",\n" -" \"diagnostic_error\": \"red\"\n" -" },\n" -" \"syntax\": {\n" -" \"43\": \"type\",\n" -" \"46\": \"namespace_ref\",\n" -" \"109\": \"string\",\n" -" \"702\": \"keyword\",\n" -" \"703\": \"own\",\n" -" \"705\": \"comment\"\n" -" },\n" -" \"visual\": {\n" -" \"background\": \"white\",\n" -" \"background_selected\": \"blue\",\n" -" \"background_tooltips\": \"yellow\",\n" -" \"font\": \"Monospace\",\n" -" \"show_line_numbers\": 1,\n" -" \"highlight_current_line\": 1\n" +" \"style\": \"juci-light\", //Use \"\" for default style, and for instance juci-dark together with dark gtk_theme variant. Styles from normal gtksourceview install: classic, cobalt, kate, oblivion, solarized-dark, solarized-light, tango\n" +" \"font\": \"Monospace\", //Use \"\" for default font, and for instance \"Monospace 12\" to also set size.\n" +" \"clang_types\": {\n" +" \"8\": \"def:function\",\n" +" \"21\": \"def:function\",\n" +" \"22\": \"def:identifier\",\n" +" \"24\": \"def:function\",\n" +" \"25\": \"def:function\",\n" +" \"43\": \"def:type\",\n" +" \"44\": \"def:type\",\n" +" \"45\": \"def:type\",\n" +" \"46\": \"def:identifier\",\n" +" \"109\": \"def:string\",\n" +" \"500\": \"def:preprocessor\",\n" +" \"702\": \"def:statement\",\n" +" \"705\": \"def:comment\"\n" " },\n" " \"tab_size\": 2,\n" -" \"tab_char\": \"\"\n" +" \"tab_char\": \" \", //Use \"\\t\" for regular tab\n" +" \"highlight_current_line\": true,\n" +" \"show_line_numbers\": true\n" " },\n" " \"keybindings\": {\n" " \"new_file\": \"n\",\n" @@ -67,12 +63,10 @@ const std::string configjson = " \"#\",\n" " \"~\",\n" " \".idea\",\n" -" \".so\",\n" -" \"in-lowercase.pls\"\n" +" \".so\"\n" " ],\n" " \"exceptions\": [\n" -" \"cmakelists.txt\",\n" -" \"in-lowercase.pls\"\n" +" \"cmakelists.txt\"\n" " ]\n" " }\n" "}\n"; @@ -85,21 +79,24 @@ const std::string menuxml = " \n" " \n" " \n" +" \n" " \n" " \n" +" \n" " \n" " \n" " \n" " \n" " \n" " \n" +" \n" +" \n" +" \n" " \n" " \n" " \n" " \n" " \n" -" \n" -" \n" " \n" " \n" " \n" @@ -112,6 +109,7 @@ const std::string menuxml = " \n" " \n" " \n" +" \n" " \n" " \n" " \n" @@ -128,6 +126,120 @@ const std::string menuxml = " \n" "\n"; +const std::string juci_light_style = +"\n" +"\n" +"\n" +" juCi++ team\n" +" <_description>Default juCi++ style\n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +"