From cc257e0fd0c9320fce068b6402c263a3e6ead4f2 Mon Sep 17 00:00:00 2001 From: eidheim Date: Mon, 14 Sep 2015 07:33:02 +0200 Subject: [PATCH 1/2] Moved info and status right to below notebook. --- src/notebook.cc | 4 ++-- src/window.cc | 14 ++++++++------ src/window.h | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/notebook.cc b/src/notebook.cc index 40b9874..8c9b4e3 100644 --- a/src/notebook.cc +++ b/src/notebook.cc @@ -86,11 +86,11 @@ void Notebook::open(const boost::filesystem::path &file_path) { source_views.back()->on_update_status=[this](Source::View* view, const std::string &status) { if(get_current_page()!=-1 && get_current_view()==view) - Singleton::status()->set_text(status+" "); + Singleton::status()->set_text(status); }; source_views.back()->on_update_info=[this](Source::View* view, const std::string &info) { if(get_current_page()!=-1 && get_current_view()==view) - Singleton::info()->set_text(" "+info); + Singleton::info()->set_text(info); }; scrolled_windows.emplace_back(new Gtk::ScrolledWindow()); diff --git a/src/window.cc b/src/window.cc index 13bfa5a..b4c30d2 100644 --- a/src/window.cc +++ b/src/window.cc @@ -44,18 +44,20 @@ Window::Window() : box(Gtk::ORIENTATION_VERTICAL), notebook(directories), compil directory_and_notebook_panes.pack1(directories, Gtk::SHRINK); notebook_vbox.pack_start(notebook); - notebook_vbox.pack_end(entry_box, Gtk::PACK_SHRINK); + + entry_and_info_status_vbox.pack_start(entry_box, Gtk::PACK_SHRINK); + info_and_status_hbox.pack_start(*Singleton::info(), Gtk::PACK_SHRINK); + info_and_status_hbox.pack_end(*Singleton::status(), Gtk::PACK_SHRINK); + entry_and_info_status_vbox.pack_end(info_and_status_hbox, Gtk::PACK_SHRINK); + notebook_vbox.pack_end(entry_and_info_status_vbox, Gtk::PACK_SHRINK); directory_and_notebook_panes.pack2(notebook_vbox, Gtk::SHRINK); + directory_and_notebook_panes.set_position(120); vpaned.set_position(300); vpaned.pack1(directory_and_notebook_panes, true, false); terminal_scrolled_window.add(*Singleton::terminal()); - terminal_vbox.pack_start(terminal_scrolled_window); - info_and_status_hbox.pack_start(*Singleton::info(), Gtk::PACK_SHRINK); - info_and_status_hbox.pack_end(*Singleton::status(), Gtk::PACK_SHRINK); - terminal_vbox.pack_end(info_and_status_hbox, Gtk::PACK_SHRINK); - vpaned.pack2(terminal_vbox, true, true); + vpaned.pack2(terminal_scrolled_window, true, true); box.pack_end(vpaned); show_all_children(); diff --git a/src/window.h b/src/window.h index 5c8b349..2c66e62 100644 --- a/src/window.h +++ b/src/window.h @@ -31,7 +31,7 @@ private: Gtk::VPaned vpaned; Gtk::Paned directory_and_notebook_panes; Gtk::VBox notebook_vbox; - Gtk::VBox terminal_vbox; + Gtk::VBox entry_and_info_status_vbox; Gtk::ScrolledWindow terminal_scrolled_window; Gtk::HBox info_and_status_hbox; Gtk::AboutDialog about; From 3cf7429ccddadb8fd84c731a567f83315b6022e7 Mon Sep 17 00:00:00 2001 From: eidheim Date: Mon, 14 Sep 2015 08:44:14 +0200 Subject: [PATCH 2/2] Now properly removes spellcheck errors when the word is no longer in a string or comment. Also reverted the info/status field position. --- src/notebook.cc | 4 ++-- src/source.cc | 44 ++++++++++++++++++++++++-------------------- src/source.h | 1 + src/window.cc | 14 ++++++-------- src/window.h | 2 +- 5 files changed, 34 insertions(+), 31 deletions(-) diff --git a/src/notebook.cc b/src/notebook.cc index 8c9b4e3..40b9874 100644 --- a/src/notebook.cc +++ b/src/notebook.cc @@ -86,11 +86,11 @@ void Notebook::open(const boost::filesystem::path &file_path) { source_views.back()->on_update_status=[this](Source::View* view, const std::string &status) { if(get_current_page()!=-1 && get_current_view()==view) - Singleton::status()->set_text(status); + Singleton::status()->set_text(status+" "); }; source_views.back()->on_update_info=[this](Source::View* view, const std::string &info) { if(get_current_page()!=-1 && get_current_view()==view) - Singleton::info()->set_text(info); + Singleton::info()->set_text(" "+info); }; scrolled_windows.emplace_back(new Gtk::ScrolledWindow()); diff --git a/src/source.cc b/src/source.cc index 98cb8ff..f985777 100644 --- a/src/source.cc +++ b/src/source.cc @@ -220,22 +220,32 @@ Source::View::View(const boost::filesystem::path &file_path, Glib::RefPtrproperty_name()=="spellcheck_error") { - has_spellcheck_error=true; - break; - } - } - if(has_spellcheck_error) { - auto word=spellcheck_get_word(iter); - get_buffer()->remove_tag_by_name("spellcheck_error", word.first, word.second); - } - } } } + delayed_spellcheck_error_clear.disconnect(); + delayed_spellcheck_error_clear=Glib::signal_timeout().connect([this]() { + auto iter=get_buffer()->begin(); + bool spell_check=get_source_buffer()->iter_has_context_class(iter, "string") || get_source_buffer()->iter_has_context_class(iter, "comment"); + Gtk::TextIter begin_no_spellcheck_iter; + if(!spell_check) + begin_no_spellcheck_iter=iter; + while(iter!=get_buffer()->end()) { + auto iter1=iter; + auto iter2=iter; + get_source_buffer()->iter_forward_to_context_class_toggle(iter1, "string"); + get_source_buffer()->iter_forward_to_context_class_toggle(iter2, "comment"); + if(iter2remove_tag_by_name("spellcheck_error", begin_no_spellcheck_iter, iter); + } + return false; + }, 1000); }); get_buffer()->signal_mark_set().connect([this](const Gtk::TextBuffer::iterator& iter, const Glib::RefPtr& mark) { @@ -253,12 +263,6 @@ Source::View::View(const boost::filesystem::path &file_path, Glib::RefPtrget_insert()->get_iter(); - if(!((spellcheck_all && !get_source_buffer()->iter_has_context_class(iter, "no-spell-check")) || get_source_buffer()->iter_has_context_class(iter, "comment") || get_source_buffer()->iter_has_context_class(iter, "string"))) { - auto word=spellcheck_get_word(iter); - get_buffer()->remove_tag_by_name("spellcheck_error", word.first, word.second); - return false; - } spellcheck_suggestions_dialog=std::unique_ptr(new SelectionDialog(*this, get_buffer()->create_mark(get_buffer()->get_insert()->get_iter()), false)); spellcheck_suggestions_dialog->on_hide=[this](){ spellcheck_suggestions_dialog_shown=false; diff --git a/src/source.h b/src/source.h index 8fd6409..d607dbd 100644 --- a/src/source.h +++ b/src/source.h @@ -126,6 +126,7 @@ namespace Source { void spellcheck_word(const Gtk::TextIter& start, const Gtk::TextIter& end); std::vector spellcheck_get_suggestions(const Gtk::TextIter& start, const Gtk::TextIter& end); sigc::connection delayed_spellcheck_suggestions_connection; + sigc::connection delayed_spellcheck_error_clear; bool last_keyval_is_backspace=false; }; diff --git a/src/window.cc b/src/window.cc index b4c30d2..13bfa5a 100644 --- a/src/window.cc +++ b/src/window.cc @@ -44,20 +44,18 @@ Window::Window() : box(Gtk::ORIENTATION_VERTICAL), notebook(directories), compil directory_and_notebook_panes.pack1(directories, Gtk::SHRINK); notebook_vbox.pack_start(notebook); - - entry_and_info_status_vbox.pack_start(entry_box, Gtk::PACK_SHRINK); - info_and_status_hbox.pack_start(*Singleton::info(), Gtk::PACK_SHRINK); - info_and_status_hbox.pack_end(*Singleton::status(), Gtk::PACK_SHRINK); - entry_and_info_status_vbox.pack_end(info_and_status_hbox, Gtk::PACK_SHRINK); - notebook_vbox.pack_end(entry_and_info_status_vbox, Gtk::PACK_SHRINK); + notebook_vbox.pack_end(entry_box, Gtk::PACK_SHRINK); directory_and_notebook_panes.pack2(notebook_vbox, Gtk::SHRINK); - directory_and_notebook_panes.set_position(120); vpaned.set_position(300); vpaned.pack1(directory_and_notebook_panes, true, false); terminal_scrolled_window.add(*Singleton::terminal()); - vpaned.pack2(terminal_scrolled_window, true, true); + terminal_vbox.pack_start(terminal_scrolled_window); + info_and_status_hbox.pack_start(*Singleton::info(), Gtk::PACK_SHRINK); + info_and_status_hbox.pack_end(*Singleton::status(), Gtk::PACK_SHRINK); + terminal_vbox.pack_end(info_and_status_hbox, Gtk::PACK_SHRINK); + vpaned.pack2(terminal_vbox, true, true); box.pack_end(vpaned); show_all_children(); diff --git a/src/window.h b/src/window.h index 2c66e62..5c8b349 100644 --- a/src/window.h +++ b/src/window.h @@ -31,7 +31,7 @@ private: Gtk::VPaned vpaned; Gtk::Paned directory_and_notebook_panes; Gtk::VBox notebook_vbox; - Gtk::VBox entry_and_info_status_vbox; + Gtk::VBox terminal_vbox; Gtk::ScrolledWindow terminal_scrolled_window; Gtk::HBox info_and_status_hbox; Gtk::AboutDialog about;