diff --git a/src/notebook.cc b/src/notebook.cc index 7bfd4f9..ad329ab 100644 --- a/src/notebook.cc +++ b/src/notebook.cc @@ -67,7 +67,7 @@ void Notebook::open(const boost::filesystem::path &file_path) { else Singleton::terminal()->print("Error: could not find project path for "+file_path.string()+"\n"); } - source_views.emplace_back(new Source::ClangView(file_path, project_path)); + source_views.emplace_back(new Source::ClangView(file_path, project_path, language)); } else source_views.emplace_back(new Source::GenericView(file_path, language)); diff --git a/src/source.cc b/src/source.cc index 6f652f5..adab60d 100644 --- a/src/source.cc +++ b/src/source.cc @@ -97,6 +97,19 @@ Source::View::View(const boost::filesystem::path &file_path): file_path(file_pat tab+=tab_char; tabs_regex=std::regex(std::string("^(")+tab_char+"*)(.*)$"); + + get_buffer()->signal_changed().connect([this](){ + auto iter=get_buffer()->get_insert()->get_iter(); + if(iter.backward_char()) { + auto context_iter=iter; + if(context_iter.backward_char()) { + if(get_source_buffer()->iter_has_context_class(context_iter, "comment")) { + //TODO: get word, and spellcheck + //cout << "comment: " << (char)*iter << endl; + } + } + } + }); } void Source::View::search_occurrences_updated(GtkWidget* widget, GParamSpec* property, gpointer data) { @@ -1394,7 +1407,12 @@ Source::ClangViewAutocomplete(file_path, project_path) { }; } -Source::ClangView::ClangView(const boost::filesystem::path &file_path, const boost::filesystem::path& project_path): ClangViewRefactor(file_path, project_path) { +Source::ClangView::ClangView(const boost::filesystem::path &file_path, const boost::filesystem::path& project_path, Glib::RefPtr language): ClangViewRefactor(file_path, project_path) { + if(language) { + get_source_buffer()->set_highlight_syntax(false); + get_source_buffer()->set_language(language); + } + do_delete_object.connect([this](){ if(delete_thread.joinable()) delete_thread.join(); diff --git a/src/source.h b/src/source.h index 5380f00..20185f9 100644 --- a/src/source.h +++ b/src/source.h @@ -184,7 +184,7 @@ namespace Source { class ClangView : public ClangViewRefactor { public: - ClangView(const boost::filesystem::path &file_path, const boost::filesystem::path& project_path); + ClangView(const boost::filesystem::path &file_path, const boost::filesystem::path& project_path, Glib::RefPtr language); void async_delete(); bool restart_parse(); private: