1 #pragma once 2 #include "dispatcher.hpp" 3 #include "json.hpp" 4 #include <boost/filesystem.hpp> 5 #include <string> 6 #include <unordered_map> 7 #include <utility> 8 #include <vector> 9 10 class Config { 11 public: 12 class Menu { 13 public: 14 std::unordered_map<std::string, std::string> keys; 15 }; 16 17 class Theme { 18 public: 19 std::string name; 20 std::string variant; 21 std::string font; 22 }; 23 24 class Terminal { 25 public: 26 int history_size; 27 std::string font; 28 bool clear_on_compile; 29 bool clear_on_run_command; 30 bool hide_entry_on_run_command; 31 }; 32 33 class Project { 34 public: 35 class CMake { 36 public: 37 std::string command; 38 std::string compile_command; 39 }; 40 class Meson { 41 public: 42 std::string command; 43 std::string compile_command; 44 }; 45 46 std::string default_build_path; 47 std::string debug_build_path; 48 CMake cmake; 49 Meson meson; 50 std::string default_build_management_system; 51 bool save_on_compile_or_run; 52 std::string ctags_command; 53 std::string grep_command; 54 std::string cargo_command; 55 std::string python_command; 56 std::string markdown_command; 57 }; 58 59 class Source { 60 public: 61 class DocumentationSearch { 62 public: 63 std::string separator; 64 std::unordered_map<std::string, std::string> queries; 65 }; 66 67 std::string style; 68 std::string font; 69 std::string spellcheck_language; 70 71 bool cleanup_whitespace_characters; 72 std::string show_whitespace_characters; 73 74 bool format_style_on_save; 75 bool format_style_on_save_if_style_file_found; 76 77 bool smart_brackets; 78 bool smart_inserts; 79 80 bool show_map; 81 unsigned map_font_size; 82 bool show_git_diff; 83 bool show_background_pattern; 84 bool show_right_margin; 85 unsigned right_margin_position; 86 87 bool auto_tab_char_and_size; 88 char default_tab_char; 89 unsigned default_tab_size; 90 bool tab_indents_line; 91 std::string word_wrap; 92 bool highlight_current_line; 93 bool show_line_numbers; 94 bool enable_multiple_cursors; 95 bool auto_reload_changed_files; 96 bool search_for_selection; 97 98 std::string clang_format_style; 99 unsigned clang_usages_threads; 100 101 bool clang_tidy_enable; 102 std::string clang_tidy_checks; 103 104 bool clang_detailed_preprocessing_record = false; 105 106 bool debug_place_cursor_at_stop; 107 108 std::unordered_map<std::string, DocumentationSearch> documentation_searches; 109 }; 110 111 class Log { 112 public: 113 bool libclang; 114 bool language_server; 115 }; 116 117 private: 118 Config(); 119 120 public: get()121 static Config &get() { 122 static Config instance; 123 return instance; 124 } 125 126 void load(); 127 128 Menu menu; 129 Theme theme; 130 Terminal terminal; 131 Project project; 132 Source source; 133 Log log; 134 135 boost::filesystem::path home_path; 136 boost::filesystem::path home_juci_path; 137 138 private: 139 /// Used to dispatch Terminal outputs after juCi++ GUI setup and configuration 140 Dispatcher dispatcher; 141 142 void update(JSON &cfg); 143 void make_version_dependent_corrections(JSON &cfg, const JSON &default_cfg, const std::string &version); 144 void add_missing_nodes(JSON &cfg, const JSON &default_cfg); 145 void remove_deprecated_nodes(JSON &cfg, const JSON &default_cfg); 146 void read(const JSON &cfg); 147 148 /// If you add or remove nodes from the default_config, increase the juci 149 /// version number (JUCI_VERSION) in ../CMakeLists.txt to automatically apply 150 /// the changes to user's ~/.juci/config/config.json files 151 std::string default_config(); 152 const char *juci_light_style(); 153 const char *juci_dark_style(); 154 const char *juci_dark_blue_style(); 155 }; 156