|
|
|
@ -10,22 +10,36 @@ libjuci::ApiServiceProvider::ApiServiceProvider( ){ |
|
|
|
std::cout << "Apiservice std.ctor" << std::endl; |
|
|
|
std::cout << "Apiservice std.ctor" << std::endl; |
|
|
|
} |
|
|
|
} |
|
|
|
void libjuci::ApiServiceProvider::ReplaceWord(std::string word){ |
|
|
|
void libjuci::ApiServiceProvider::ReplaceWord(std::string word){ |
|
|
|
|
|
|
|
Glib::RefPtr<Gtk::TextBuffer> buffer = libjuci::BufferFromNotebook(); |
|
|
|
|
|
|
|
Gtk::TextIter word_start = libjuci::IterFromNotebook(); |
|
|
|
|
|
|
|
Gtk::TextIter word_end = libjuci::IterFromNotebook(); |
|
|
|
|
|
|
|
|
|
|
|
Glib::RefPtr<Gtk::TextBuffer> buffer = libjuci::ApiServiceProvider::notebook_->source_vec_.back()->view().get_buffer(); |
|
|
|
libjuci::IterToWordStart(word_start); |
|
|
|
|
|
|
|
libjuci::IterToWordEnd(word_end); |
|
|
|
|
|
|
|
if(word_start != word_end) { |
|
|
|
|
|
|
|
buffer->erase(word_start, word_end); |
|
|
|
|
|
|
|
Gtk::TextIter current = libjuci::IterFromNotebook(); |
|
|
|
|
|
|
|
buffer->insert(current, word); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void libjuci::ApiServiceProvider::ReplaceLine(std::string line){} |
|
|
|
|
|
|
|
|
|
|
|
Gtk::TextIter text_iterator = buffer->get_insert()->get_iter(); |
|
|
|
std::string libjuci::ApiServiceProvider::GetWord(){ |
|
|
|
Gtk::TextIter end = buffer->get_insert()->get_iter(); |
|
|
|
Glib::RefPtr<Gtk::TextBuffer> buffer = libjuci::BufferFromNotebook(); |
|
|
|
|
|
|
|
Gtk::TextIter word_start = libjuci::IterFromNotebook(); |
|
|
|
|
|
|
|
Gtk::TextIter word_end = libjuci::IterFromNotebook(); |
|
|
|
|
|
|
|
|
|
|
|
while( !text_iterator.starts_word()){ |
|
|
|
libjuci::IterToWordStart(word_start); |
|
|
|
// text_iterator--;
|
|
|
|
libjuci::IterToWordEnd(word_end); |
|
|
|
text_iterator.backward_char(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
buffer->erase(text_iterator, end); |
|
|
|
|
|
|
|
text_iterator = buffer->get_insert()->get_iter(); |
|
|
|
|
|
|
|
buffer->insert(text_iterator, word); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::cout <<"start: " << word_start << std::endl << "end: " << word_end << std::endl; |
|
|
|
|
|
|
|
if(word_start < word_end) { |
|
|
|
|
|
|
|
std::string test = buffer->get_text(word_start, word_end); |
|
|
|
|
|
|
|
std::cout << "test: " << test << std::endl; |
|
|
|
|
|
|
|
return test; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return "no word, sry"; |
|
|
|
} |
|
|
|
} |
|
|
|
void libjuci::ApiServiceProvider::ReplaceLine(std::string line){} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void libjuci::ApiServiceProvider::AddKeybinding() { |
|
|
|
void libjuci::ApiServiceProvider::AddKeybinding() { |
|
|
|
|
|
|
|
|
|
|
|
@ -35,7 +49,7 @@ void libjuci::ApiServiceProvider::AddKeybinding() { |
|
|
|
Gtk::AccelKey("<control><alt>space"), |
|
|
|
Gtk::AccelKey("<control><alt>space"), |
|
|
|
[]() { |
|
|
|
[]() { |
|
|
|
std::cout << "ctrl alt space" << std::endl; |
|
|
|
std::cout << "ctrl alt space" << std::endl; |
|
|
|
libjuci::LoadPlugin("juci_api_test"); |
|
|
|
libjuci::LoadPlugin("snippet"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
std::cout << "addkeybinding" << std::endl; |
|
|
|
std::cout << "addkeybinding" << std::endl; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -44,22 +58,20 @@ void libjuci::ApiServiceProvider::AddKeybinding() { |
|
|
|
//// Api to python ////
|
|
|
|
//// Api to python ////
|
|
|
|
///////////////////////
|
|
|
|
///////////////////////
|
|
|
|
void libjuci::ReplaceWord(const std::string word_) { |
|
|
|
void libjuci::ReplaceWord(const std::string word_) { |
|
|
|
//TODO implement libjuci::ReplaceWord / change string to iter?
|
|
|
|
|
|
|
|
//some_namespace::controller::replaceWord(word_*);
|
|
|
|
|
|
|
|
//std::cout << "unimplemented function: 'libjuci::ReplaceWord()' called"
|
|
|
|
|
|
|
|
// << std::endl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//libjuci::ApiServiceProvider::ReplaceWord(word);
|
|
|
|
|
|
|
|
libjuci::ApiServiceProvider::ReplaceWord(word_); |
|
|
|
libjuci::ApiServiceProvider::ReplaceWord(word_); |
|
|
|
//std::cout << "The string: " << word_ << std::endl;
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void libjuci::ReplaceLine(const std::string line) { |
|
|
|
void libjuci::ReplaceLine(const std::string line) { |
|
|
|
//TODO implement libjuci::ReplaceLine / change string to iter?
|
|
|
|
//TODO forgie: implement libjuci::ReplaceLine / change string to iter?
|
|
|
|
//some_namespace::controller::replaceLine(line_);
|
|
|
|
//some_namespace::controller::replaceLine(line_);
|
|
|
|
std::cout << "unimplemented function: 'libjuci::ReplaceLine()' called" |
|
|
|
std::cout << "unimplemented function: 'libjuci::ReplaceLine()' called" |
|
|
|
<< std::endl; |
|
|
|
<< std::endl; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
std::string libjuci::GetWord() { |
|
|
|
|
|
|
|
// boost::python::str converted(libjuci::ApiServiceProvider::GetWord() );
|
|
|
|
|
|
|
|
return libjuci::ApiServiceProvider::GetWord(); |
|
|
|
|
|
|
|
// return converted;
|
|
|
|
|
|
|
|
} |
|
|
|
//////////////////////////////
|
|
|
|
//////////////////////////////
|
|
|
|
//// Boost.Python methods ////
|
|
|
|
//// Boost.Python methods ////
|
|
|
|
//////////////////////////////
|
|
|
|
//////////////////////////////
|
|
|
|
@ -91,3 +103,33 @@ boost::python::api::object libjuci::openPythonScript(const std::string path, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////
|
|
|
|
|
|
|
|
//// Glib wrappers ////
|
|
|
|
|
|
|
|
///////////////////////
|
|
|
|
|
|
|
|
void libjuci::IterToWordStart(Gtk::TextIter &iter) { |
|
|
|
|
|
|
|
if(!iter.starts_line()) { |
|
|
|
|
|
|
|
while(!iter.starts_word()) { |
|
|
|
|
|
|
|
iter.backward_char(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void libjuci::IterToWordEnd(Gtk::TextIter &iter) { |
|
|
|
|
|
|
|
if(!iter.ends_line()) { |
|
|
|
|
|
|
|
while(!iter.ends_word()) { |
|
|
|
|
|
|
|
iter.forward_char(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Glib::RefPtr<Gtk::TextBuffer> libjuci::BufferFromNotebook() { |
|
|
|
|
|
|
|
return Glib::RefPtr<Gtk::TextBuffer>(libjuci::ApiServiceProvider::notebook_->source_vec_.back()->view().get_buffer()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Gtk::TextIter libjuci::IterFromNotebook() { |
|
|
|
|
|
|
|
// Glib::RefPtr<Gtk::TextBuffer> buffer = libjuci::ApiServiceProvider::notebook_
|
|
|
|
|
|
|
|
//->source_vec_.back()->view().get_buffer();
|
|
|
|
|
|
|
|
return libjuci::BufferFromNotebook()->get_insert()->get_iter(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|