|
|
|
@ -186,11 +186,21 @@ Source::SpellCheckView::SpellCheckView() : Gsv::View() { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
get_buffer()->get_tag_table()->signal_tag_added().connect([this](const Glib::RefPtr<Gtk::TextTag> &tag) { |
|
|
|
signal_tag_added_connection=get_buffer()->get_tag_table()->signal_tag_added().connect([this](const Glib::RefPtr<Gtk::TextTag> &tag) { |
|
|
|
if(tag->property_name()=="gtksourceview:context-classes:comment") |
|
|
|
if(tag->property_name()=="gtksourceview:context-classes:comment") |
|
|
|
comment_tag=tag; |
|
|
|
comment_tag=tag; |
|
|
|
else if(tag->property_name()=="gtksourceview:context-classes:string") |
|
|
|
else if(tag->property_name()=="gtksourceview:context-classes:string") |
|
|
|
string_tag=tag; |
|
|
|
string_tag=tag; |
|
|
|
|
|
|
|
else if(tag->property_name()=="gtksourceview:context-classes:no-spell-check") |
|
|
|
|
|
|
|
no_spell_check_tag=tag; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
signal_tag_removed_connection=get_buffer()->get_tag_table()->signal_tag_removed().connect([this](const Glib::RefPtr<Gtk::TextTag> &tag) { |
|
|
|
|
|
|
|
if(tag->property_name()=="gtksourceview:context-classes:comment") |
|
|
|
|
|
|
|
comment_tag.reset(); |
|
|
|
|
|
|
|
else if(tag->property_name()=="gtksourceview:context-classes:string") |
|
|
|
|
|
|
|
string_tag.reset(); |
|
|
|
|
|
|
|
else if(tag->property_name()=="gtksourceview:context-classes:no-spell-check") |
|
|
|
|
|
|
|
no_spell_check_tag.reset(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -200,6 +210,9 @@ Source::SpellCheckView::~SpellCheckView() { |
|
|
|
|
|
|
|
|
|
|
|
if(spellcheck_checker!=nullptr) |
|
|
|
if(spellcheck_checker!=nullptr) |
|
|
|
delete_aspell_speller(spellcheck_checker); |
|
|
|
delete_aspell_speller(spellcheck_checker); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
signal_tag_added_connection.disconnect(); |
|
|
|
|
|
|
|
signal_tag_removed_connection.disconnect(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Source::SpellCheckView::configure() { |
|
|
|
void Source::SpellCheckView::configure() { |
|
|
|
@ -308,13 +321,16 @@ void Source::SpellCheckView::goto_next_spellcheck_error() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool Source::SpellCheckView::is_code_iter(const Gtk::TextIter &iter) { |
|
|
|
bool Source::SpellCheckView::is_code_iter(const Gtk::TextIter &iter) { |
|
|
|
if(spellcheck_all) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
if(*iter=='\'') { |
|
|
|
if(*iter=='\'') { |
|
|
|
auto previous_iter=iter; |
|
|
|
auto previous_iter=iter; |
|
|
|
if(!iter.starts_line() && previous_iter.backward_char() && *previous_iter=='\'') |
|
|
|
if(!iter.starts_line() && previous_iter.backward_char() && *previous_iter=='\'') |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(spellcheck_all) { |
|
|
|
|
|
|
|
if(no_spell_check_tag && (iter.has_tag(no_spell_check_tag) || iter.begins_tag(no_spell_check_tag) || iter.ends_tag(no_spell_check_tag))) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
if(comment_tag && ((iter.has_tag(comment_tag) && !iter.begins_tag(comment_tag)) || iter.ends_tag(comment_tag))) |
|
|
|
if(comment_tag && ((iter.has_tag(comment_tag) && !iter.begins_tag(comment_tag)) || iter.ends_tag(comment_tag))) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
if(string_tag && iter.has_tag(string_tag) && !iter.begins_tag(string_tag)) |
|
|
|
if(string_tag && iter.has_tag(string_tag) && !iter.begins_tag(string_tag)) |
|
|
|
|