Browse Source

Added default juci style, and option to set font (only the source font like gedit does it).

merge-requests/365/head
eidheim 10 years ago
parent
commit
fd4b6aef8a
  1. 7
      src/config.cc
  2. 53
      src/files.h
  3. 2
      src/source.cc
  4. 1
      src/source.h

7
src/config.cc

@ -16,6 +16,10 @@ MainConfig::MainConfig() {
Singleton::Config::window()->theme_variant=cfg.get<std::string>("visual.gtk_theme_variant"); Singleton::Config::window()->theme_variant=cfg.get<std::string>("visual.gtk_theme_variant");
boost::filesystem::create_directories(boost::filesystem::path(Singleton::style_dir())); boost::filesystem::create_directories(boost::filesystem::path(Singleton::style_dir()));
boost::filesystem::path juci_style_path=Singleton::style_dir();
juci_style_path+="juci.xml";
if(!boost::filesystem::exists(juci_style_path))
juci::filesystem::write(juci_style_path, juci_style);
Singleton::Config::source()->style=cfg.get<std::string>("visual.gtk_sourceview_style"); Singleton::Config::source()->style=cfg.get<std::string>("visual.gtk_sourceview_style");
Singleton::Config::terminal()->make_command=cfg.get<std::string>("project.make_command"); Singleton::Config::terminal()->make_command=cfg.get<std::string>("project.make_command");
@ -46,9 +50,10 @@ void MainConfig::GenerateSource() {
source_cfg->highlight_current_line = source_json.get_value<bool>("highlight_current_line"); source_cfg->highlight_current_line = source_json.get_value<bool>("highlight_current_line");
source_cfg->show_line_numbers = source_json.get_value<bool>("show_line_numbers"); source_cfg->show_line_numbers = source_json.get_value<bool>("show_line_numbers");
for (auto &i : source_json.get_child("clang_types")) for (auto &i : source_json.get_child("clang_types"))
source_cfg->clang_types[i.first] = i.second.get_value<std::string>(); source_cfg->clang_types[i.first] = i.second.get_value<std::string>();
source_cfg->font=source_json.get<std::string>("font");
} }
void MainConfig::GenerateDirectoryFilter() { void MainConfig::GenerateDirectoryFilter() {

53
src/files.h

@ -4,9 +4,10 @@ const std::string configjson =
" \"visual\": {\n" " \"visual\": {\n"
" \"gtk_theme\": \"Adwaita\", //Use \"\" for default theme, At least these two exist on all systems: Adwaita, Raleigh\n" " \"gtk_theme\": \"Adwaita\", //Use \"\" for default theme, At least these two exist on all systems: Adwaita, Raleigh\n"
" \"gtk_theme_variant\": \"\", //Use \"\" for default variant, and \"dark\" for dark theme variant\n" " \"gtk_theme_variant\": \"\", //Use \"\" for default variant, and \"dark\" for dark theme variant\n"
" \"gtk_sourceview_style\": \"classic\" //Choices on default install: classic, cobalt, kate, oblivion, solarized-dark, solarized-light, tango\n" " \"gtk_sourceview_style\": \"juci\" //Choices on default install: classic, cobalt, kate, oblivion, solarized-dark, solarized-light, tango\n"
" },\n" " },\n"
" \"source\": {\n" " \"source\": {\n"
" \"font\": \"Monospace\", //Use \"\" for default font, and for instance \"Monospace 12\" to also set size.\n"
" \"clang_types\": {\n" " \"clang_types\": {\n"
" \"43\": \"def:type\",\n" " \"43\": \"def:type\",\n"
" \"46\": \"def:preprocessor\",\n" " \"46\": \"def:preprocessor\",\n"
@ -117,6 +118,56 @@ const std::string menuxml =
" </menubar>\n" " </menubar>\n"
"</ui>\n"; "</ui>\n";
const std::string juci_style =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"\n"
"<style-scheme id=\"juci\" _name=\"juci\" version=\"1.0\">\n"
" <author>juCi++ team</author>\n"
" <_description>Default juCi++ style</_description>\n"
"\n"
" <!-- Palette -->\n"
" <color name=\"white\" value=\"#FFFFFF\"/>\n"
" <color name=\"red\" value=\"#FF0000\"/>\n"
" <color name=\"blue\" value=\"#0000FF\"/>\n"
" <color name=\"yellow\" value=\"#FFFF00\"/>\n"
" <color name=\"orange\" value=\"#FFA500\"/>\n"
"\n"
" <!-- Global Settings -->\n"
" <style name=\"current-line\" background=\"#eeeeec\"/>\n"
" <style name=\"current-line-number\" background=\"#eeeeec\"/>\n"
" <style name=\"draw-spaces\" foreground=\"#babdb6\"/>\n"
" <style name=\"background-pattern\" background=\"#f3f3f3\"/>\n"
"\n"
" <!-- Bracket Matching -->\n"
" <style name=\"bracket-match\" foreground=\"white\" background=\"#BEBEBE\" bold=\"true\"/>\n"
" <style name=\"bracket-mismatch\" foreground=\"white\" background=\"#FF0000\" bold=\"true\"/>\n"
"\n"
" <!-- Right Margin -->\n"
" <style name=\"right-margin\" foreground=\"#000000\" background=\"#000000\"/>\n"
"\n"
" <!-- Search Matching -->\n"
" <style name=\"search-match\" background=\"yellow\"/>\n"
"\n"
" <!-- Comments -->\n"
" <style name=\"def:comment\" foreground=\"blue\"/>\n"
"\n"
" <!-- Constants -->\n"
" <style name=\"def:constant\" foreground=\"#CC0000\"/>\n"
"\n"
" <!-- Statements -->\n"
" <style name=\"def:statement\" foreground=\"blue\"/>\n"
"\n"
" <!-- Types -->\n"
" <style name=\"def:type\" foreground=\"#0066FF\"/>\n"
"\n"
" <!-- Others -->\n"
" <style name=\"def:preprocessor\" foreground=\"#990099\"/>\n"
" <style name=\"def:error\" foreground=\"red\"/>\n"
" <style name=\"def:warning\" foreground=\"orange\"/>\n"
" <style name=\"def:note\" background=\"yellow\"/>\n"
"\n"
"</style-scheme>\n";
const std::string pluginspy = const std::string pluginspy =
"#!/usr/bin/python \n" "#!/usr/bin/python \n"
"import juci_to_python_api as juci \n" "import juci_to_python_api as juci \n"

2
src/source.cc

@ -69,6 +69,8 @@ Source::View::View(const boost::filesystem::path &file_path): file_path(file_pat
property_highlight_current_line() = Singleton::Config::source()->highlight_current_line; property_highlight_current_line() = Singleton::Config::source()->highlight_current_line;
property_show_line_numbers() = Singleton::Config::source()->show_line_numbers; property_show_line_numbers() = Singleton::Config::source()->show_line_numbers;
if(Singleton::Config::source()->font.size()>0)
override_font(Pango::FontDescription(Singleton::Config::source()->font));
} }
void Source::View::search_occurrences_updated(GtkWidget* widget, GParamSpec* property, gpointer data) { void Source::View::search_occurrences_updated(GtkWidget* widget, GParamSpec* property, gpointer data) {

1
src/source.h

@ -27,6 +27,7 @@ namespace Source {
bool highlight_current_line; bool highlight_current_line;
bool show_line_numbers; bool show_line_numbers;
std::unordered_map<std::string, std::string> clang_types; std::unordered_map<std::string, std::string> clang_types;
std::string font;
}; };
class Range { class Range {

Loading…
Cancel
Save