|
|
|
@ -404,7 +404,27 @@ void Source::View::replace_all(const std::string &replacement) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Source::View::paste() { |
|
|
|
void Source::View::paste() { |
|
|
|
Gtk::Clipboard::get()->request_text([this](const Glib::ustring& text){ |
|
|
|
auto text=Gtk::Clipboard::get()->wait_for_text(); |
|
|
|
|
|
|
|
//remove carriage returns (which makes clang return wrong line index)
|
|
|
|
|
|
|
|
for(auto it=text.begin();it!=text.end();) { |
|
|
|
|
|
|
|
if(*it=='\r') { |
|
|
|
|
|
|
|
auto it2=it; |
|
|
|
|
|
|
|
it2++; |
|
|
|
|
|
|
|
if(it2!=text.end()) { |
|
|
|
|
|
|
|
if(*it2=='\n') |
|
|
|
|
|
|
|
it=text.erase(it); |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
text.replace(it, it2, "\n"); |
|
|
|
|
|
|
|
it++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
it=text.erase(it); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
it++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
auto line=get_line_before(); |
|
|
|
auto line=get_line_before(); |
|
|
|
std::smatch sm; |
|
|
|
std::smatch sm; |
|
|
|
std::string prefix_tabs; |
|
|
|
std::string prefix_tabs; |
|
|
|
@ -499,9 +519,10 @@ void Source::View::paste() { |
|
|
|
scroll_to(get_buffer()->get_insert()); |
|
|
|
scroll_to(get_buffer()->get_insert()); |
|
|
|
get_source_buffer()->end_user_action(); |
|
|
|
get_source_buffer()->end_user_action(); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else { |
|
|
|
|
|
|
|
Gtk::Clipboard::get()->set_text(text); |
|
|
|
get_buffer()->paste_clipboard(Gtk::Clipboard::get()); |
|
|
|
get_buffer()->paste_clipboard(Gtk::Clipboard::get()); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Source::View::set_status(const std::string &status) { |
|
|
|
void Source::View::set_status(const std::string &status) { |
|
|
|
|