Browse Source

Some style cleanup, added for instance note (tooltip) foreground for dark themes.

merge-requests/365/head
eidheim 10 years ago
parent
commit
b75a7fc4d1
  1. 5
      src/files.h
  2. 3
      src/selectiondialog.cc
  3. 44
      src/source.cc
  4. 2
      src/tooltips.cc

5
src/files.h

@ -6,7 +6,7 @@ const std::string configjson =
" \"variant\": \"\" //Use \"\" for default variant, and \"dark\" for dark theme variant\n"
" },\n"
" \"source\": {\n"
" \"style\": \"juci\", //Choices on default install: classic, cobalt, kate, oblivion, solarized-dark, solarized-light, tango\n"
" \"style\": \"juci\", //Use \"\" for default style. 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"
" \"43\": \"def:type\",\n"
@ -127,6 +127,7 @@ const std::string juci_style =
"\n"
" <!-- Palette -->\n"
" <color name=\"white\" value=\"#FFFFFF\"/>\n"
" <color name=\"black\" value=\"#000000\"/>\n"
" <color name=\"red\" value=\"#FF0000\"/>\n"
" <color name=\"blue\" value=\"#0000FF\"/>\n"
" <color name=\"yellow\" value=\"#FFFF00\"/>\n"
@ -164,7 +165,7 @@ const std::string juci_style =
" <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"
" <style name=\"def:note\" foreground=\"black\" background=\"yellow\"/>\n"
"\n"
"</style-scheme>\n";

3
src/selectiondialog.cc

@ -91,8 +91,7 @@ void SelectionDialogBase::update_tooltips() {
tooltips=std::unique_ptr<Tooltips>(new Tooltips());
auto get_tooltip_buffer=[this, tooltip_text]() {
auto tooltip_buffer=Gtk::TextBuffer::create(text_view.get_buffer()->get_tag_table());
//TODO: Insert newlines to tooltip_text (use 80 chars, then newline?)
tooltip_buffer->insert_at_cursor(tooltip_text);
tooltip_buffer->insert_with_tag(tooltip_buffer->get_insert()->get_iter(), tooltip_text, "def:note");
return tooltip_buffer;
};
tooltips->emplace_back(get_tooltip_buffer, text_view, text_view.get_buffer()->create_mark(start_mark->get_iter()), text_view.get_buffer()->create_mark(text_view.get_buffer()->get_insert()->get_iter()));

44
src/source.cc

@ -60,12 +60,14 @@ Source::View::View(const boost::filesystem::path &file_path): file_path(file_pat
auto style_scheme_manager=Gsv::StyleSchemeManager::get_default();
style_scheme_manager->prepend_search_path(Singleton::style_dir());
auto scheme = style_scheme_manager->get_scheme(Singleton::Config::source()->style);
if(Singleton::Config::source()->style.size()>0) {
auto scheme = style_scheme_manager->get_scheme(Singleton::Config::source()->style);
if(scheme)
get_source_buffer()->set_style_scheme(scheme);
else
Singleton::terminal()->print("Error: Could not find gtksourceview style: "+Singleton::Config::source()->style+'\n');
if(scheme)
get_source_buffer()->set_style_scheme(scheme);
else
Singleton::terminal()->print("Error: Could not find gtksourceview style: "+Singleton::Config::source()->style+'\n');
}
property_highlight_current_line() = Singleton::Config::source()->highlight_current_line;
property_show_line_numbers() = Singleton::Config::source()->show_line_numbers;
@ -414,8 +416,8 @@ Source::View(file_path), project_path(project_path) {
//Create tags for diagnostic warnings and errors:
auto style=scheme->get_style("def:warning");
auto diagnostic_tag=get_source_buffer()->create_tag("diagnostic_warning");
auto diagnostic_tag_underline=Gtk::TextTag::create("diagnostic_warning_underline");
auto diagnostic_tag=get_source_buffer()->create_tag("def:warning");
auto diagnostic_tag_underline=Gtk::TextTag::create("def:warning_underline");
if(style && (style->property_foreground_set() || style->property_background_set())) {
Glib::ustring warning_property;
if(style->property_foreground_set()) {
@ -434,8 +436,8 @@ Source::View(file_path), project_path(project_path) {
}
}
style=scheme->get_style("def:error");
diagnostic_tag=get_source_buffer()->create_tag("diagnostic_error");
diagnostic_tag_underline=Gtk::TextTag::create("diagnostic_error_underline");
diagnostic_tag=get_source_buffer()->create_tag("def:error");
diagnostic_tag_underline=Gtk::TextTag::create("def:error_underline");
if(style && (style->property_foreground_set() || style->property_background_set())) {
Glib::ustring error_property;
if(style->property_foreground_set()) {
@ -455,11 +457,15 @@ Source::View(file_path), project_path(project_path) {
}
//TODO: clear tag_class and param_spec?
//Add tooltip background
//Add tooltip foreground and background
style = scheme->get_style("def:note");
auto tag=get_source_buffer()->create_tag("tooltip_background");
auto note_tag=get_source_buffer()->create_tag("def:note_background");
if(style->property_background_set()) {
tag->property_background()=style->property_background();
note_tag->property_background()=style->property_background();
}
note_tag=get_source_buffer()->create_tag("def:note");
if(style->property_foreground_set()) {
note_tag->property_foreground()=style->property_foreground();
}
parsing_in_progress=Singleton::terminal()->print_in_progress("Parsing "+file_path.string());
@ -639,8 +645,8 @@ void Source::ClangViewParse::update_syntax() {
void Source::ClangViewParse::update_diagnostics() {
diagnostic_tooltips.clear();
get_buffer()->remove_tag_by_name("diagnostic_warning_underline", get_buffer()->begin(), get_buffer()->end());
get_buffer()->remove_tag_by_name("diagnostic_error_underline", get_buffer()->begin(), get_buffer()->end());
get_buffer()->remove_tag_by_name("def:warning_underline", get_buffer()->begin(), get_buffer()->end());
get_buffer()->remove_tag_by_name("def:error_underline", get_buffer()->begin(), get_buffer()->end());
auto diagnostics=clang_tu->get_diagnostics();
for(auto &diagnostic: diagnostics) {
if(diagnostic.path==file_path.string()) {
@ -648,16 +654,16 @@ void Source::ClangViewParse::update_diagnostics() {
auto end=get_buffer()->get_iter_at_line_index(diagnostic.offsets.second.line-1, diagnostic.offsets.second.index-1);
std::string diagnostic_tag_name;
if(diagnostic.severity<=CXDiagnostic_Warning)
diagnostic_tag_name="diagnostic_warning";
diagnostic_tag_name="def:warning";
else
diagnostic_tag_name="diagnostic_error";
diagnostic_tag_name="def:error";
auto spelling=diagnostic.spelling;
auto severity_spelling=diagnostic.severity_spelling;
auto create_tooltip_buffer=[this, spelling, severity_spelling, diagnostic_tag_name]() {
auto tooltip_buffer=Gtk::TextBuffer::create(get_buffer()->get_tag_table());
tooltip_buffer->insert_with_tag(tooltip_buffer->get_insert()->get_iter(), severity_spelling, diagnostic_tag_name);
tooltip_buffer->insert_at_cursor(":\n"+spelling);
tooltip_buffer->insert_with_tag(tooltip_buffer->get_insert()->get_iter(), ":\n"+spelling, "def:note");
//TODO: Insert newlines to clang_tu->diagnostics[c].spelling (use 80 chars, then newline?)
return tooltip_buffer;
};
@ -676,10 +682,10 @@ void Source::ClangViewParse::update_types() {
auto end=get_buffer()->get_iter_at_line_index(token.offsets.second.line-1, token.offsets.second.index-1);
auto create_tooltip_buffer=[this, &token]() {
auto tooltip_buffer=Gtk::TextBuffer::create(get_buffer()->get_tag_table());
tooltip_buffer->insert_at_cursor("Type: "+token.get_type());
tooltip_buffer->insert_with_tag(tooltip_buffer->get_insert()->get_iter(), "Type: "+token.get_type(), "def:note");
auto brief_comment=token.get_brief_comments();
if(brief_comment!="")
tooltip_buffer->insert_at_cursor("\n\n"+brief_comment);
tooltip_buffer->insert_with_tag(tooltip_buffer->get_insert()->get_iter(), "\n\n"+brief_comment, "def:note");
return tooltip_buffer;
};

2
src/tooltips.cc

@ -54,7 +54,7 @@ void Tooltip::adjust(bool disregard_drawn) {
tooltip_widget=std::unique_ptr<Gtk::TextView>(new Gtk::TextView(create_tooltip_buffer()));
wrap_lines(tooltip_widget->get_buffer());
tooltip_widget->set_editable(false);
auto tag=text_view.get_buffer()->get_tag_table()->lookup("tooltip_background");
auto tag=text_view.get_buffer()->get_tag_table()->lookup("def:note_background");
tooltip_widget->override_background_color(tag->property_background_rgba());
window->add(*tooltip_widget);

Loading…
Cancel
Save