Browse Source

Fixes: spellcheck when using backspace, diagnostics underlines, and tooltips area of activation.

merge-requests/365/head
eidheim 10 years ago
parent
commit
a633f1611e
  1. 11
      src/source.cc
  2. 1
      src/source.h
  3. 2
      src/tooltips.cc

11
src/source.cc

@ -186,10 +186,11 @@ Source::View::View(const boost::filesystem::path &file_path): file_path(file_pat
delayed_spellcheck_suggestions_connection.disconnect(); delayed_spellcheck_suggestions_connection.disconnect();
auto iter=get_buffer()->get_insert()->get_iter(); auto iter=get_buffer()->get_insert()->get_iter();
if(iter.backward_char()) { if(last_keyval_is_backspace || iter.backward_char()) {
auto context_iter=iter; auto context_iter=iter;
if(context_iter.backward_char()) { if(context_iter.backward_char()) {
if((spellcheck_all && !get_source_buffer()->iter_has_context_class(context_iter, "no-spell-check")) || get_source_buffer()->iter_has_context_class(context_iter, "comment") || get_source_buffer()->iter_has_context_class(context_iter, "string")) { if((spellcheck_all && !get_source_buffer()->iter_has_context_class(context_iter, "no-spell-check")) || get_source_buffer()->iter_has_context_class(context_iter, "comment") || get_source_buffer()->iter_has_context_class(context_iter, "string")) {
cout << (char)*iter << endl;
if(*iter==32 || *iter==45) { //Might have used space or - to split two words if(*iter==32 || *iter==45) { //Might have used space or - to split two words
auto first=iter; auto first=iter;
auto second=iter; auto second=iter;
@ -510,6 +511,10 @@ bool Source::View::on_key_press_event(GdkEventKey* key) {
if(spellcheck_suggestions_dialog->on_key_press(key)) if(spellcheck_suggestions_dialog->on_key_press(key))
return true; return true;
} }
if(key->keyval==GDK_KEY_BackSpace)
last_keyval_is_backspace=true;
else
last_keyval_is_backspace=false;
get_source_buffer()->begin_user_action(); get_source_buffer()->begin_user_action();
//Indent as in next or previous line //Indent as in next or previous line
@ -1013,11 +1018,11 @@ void Source::ClangViewParse::update_diagnostics() {
if(diagnostic.path==file_path.string()) { if(diagnostic.path==file_path.string()) {
auto start_line=get_line(diagnostic.offsets.first.line-1); //index is sometimes off the line auto start_line=get_line(diagnostic.offsets.first.line-1); //index is sometimes off the line
auto start_line_index=diagnostic.offsets.first.index-1; auto start_line_index=diagnostic.offsets.first.index-1;
if(start_line_index>=start_line.size()) { if(start_line_index>start_line.size()) {
if(start_line.size()==0) if(start_line.size()==0)
start_line_index=0; start_line_index=0;
else else
start_line_index=start_line.size()-1; start_line_index=start_line.size();
} }
auto end_line=get_line(diagnostic.offsets.second.line-1); //index is sometimes off the line auto end_line=get_line(diagnostic.offsets.second.line-1); //index is sometimes off the line
auto end_line_index=diagnostic.offsets.second.index-1; auto end_line_index=diagnostic.offsets.second.index-1;

1
src/source.h

@ -114,6 +114,7 @@ namespace Source {
std::unique_ptr<SelectionDialog> spellcheck_suggestions_dialog; std::unique_ptr<SelectionDialog> spellcheck_suggestions_dialog;
bool spellcheck_suggestions_dialog_shown=false; bool spellcheck_suggestions_dialog_shown=false;
sigc::connection delayed_spellcheck_suggestions_connection; sigc::connection delayed_spellcheck_suggestions_connection;
bool last_keyval_is_backspace=false;
}; };
class GenericView : public View { class GenericView : public View {

2
src/tooltips.cc

@ -35,7 +35,7 @@ void Tooltip::update() {
auto end_iter=end_mark->get_iter(); auto end_iter=end_mark->get_iter();
text_view.get_iter_location(iter, activation_rectangle); text_view.get_iter_location(iter, activation_rectangle);
if(iter.get_offset()<end_iter.get_offset()) { if(iter.get_offset()<end_iter.get_offset()) {
while(iter!=end_iter && iter.forward_char()) { while(iter.forward_char() && iter!=end_iter) {
Gdk::Rectangle rectangle; Gdk::Rectangle rectangle;
text_view.get_iter_location(iter, rectangle); text_view.get_iter_location(iter, rectangle);
activation_rectangle.join(rectangle); activation_rectangle.join(rectangle);

Loading…
Cancel
Save