diff --git a/juci/api.cc b/juci/api.cc index 83f8c54..425b1f5 100644 --- a/juci/api.cc +++ b/juci/api.cc @@ -51,17 +51,15 @@ void libjuci::ApiServiceProvider::AddKeybinding() { "Add snippet"), Gtk::AccelKey("space"), []() { - std::cout << "ctrl alt space" << std::endl; libjuci::LoadPlugin("snippet"); }); - std::cout << "addkeybinding" << std::endl; } /////////////////////// //// Api to python //// /////////////////////// -void libjuci::ReplaceWord(const std::string word_) { - libjuci::ApiServiceProvider::ReplaceWord(word_); +void libjuci::ReplaceWord(const std::string word) { + libjuci::ApiServiceProvider::ReplaceWord(word); } void libjuci::ReplaceLine(const std::string line) { @@ -122,7 +120,12 @@ void libjuci::IterToWordEnd(Gtk::TextIter &iter) { } Glib::RefPtr libjuci::BufferFromNotebook() { - return Glib::RefPtr(libjuci::ApiServiceProvider::notebook_->source_vec_.back()->view().get_buffer()); + //TODO forgie: make sure it does not get the buffer to the last created textview. + int i = 0; + while(!libjuci::ApiServiceProvider::notebook_->source_vec_.at(i)->view().has_focus()) { + i++; + } + return Glib::RefPtr(libjuci::ApiServiceProvider::notebook_->source_vec_.at(i)->view().get_buffer()); } Gtk::TextIter libjuci::IterFromNotebook() { diff --git a/juci/api.h b/juci/api.h index e3035e9..f087b22 100644 --- a/juci/api.h +++ b/juci/api.h @@ -35,13 +35,14 @@ namespace libjuci { void IterToWordStart(Gtk::TextIter &iter); void IterToWordEnd(Gtk::TextIter &iter); Gtk::TextIter IterFromNotebook(); + //TODO forgie: make sure it does not get the buffer to the last created textview. Glib::RefPtr BufferFromNotebook(); /////////////////////// //// Api to python //// /////////////////////// - void ReplaceWord(const std::string word_); - void ReplaceLine(const std::string line_); + void ReplaceWord(const std::string word); + void ReplaceLine(const std::string line); std::string GetWord(); //TODO forgie: Make more functions targeting the python module