|
|
|
|
@ -205,22 +205,16 @@ void Source::CommonView::cut() {
|
|
|
|
|
else { |
|
|
|
|
Gtk::TextIter start, end; |
|
|
|
|
get_buffer()->get_selection_bounds(start, end); |
|
|
|
|
if(start.get_line() == end.get_line() || start.starts_line()) |
|
|
|
|
if(start.starts_line() && end.starts_line()) { |
|
|
|
|
get_buffer()->cut_clipboard(Gtk::Clipboard::get()); |
|
|
|
|
else { // In order to improve paste indentation: copy entire starting line if only whitespaces before start iter
|
|
|
|
|
auto iter = start; |
|
|
|
|
while(!iter.starts_line() && iter.backward_char() && (*iter == ' ' || *iter == '\t')) { |
|
|
|
|
keep_clipboard = true; |
|
|
|
|
} |
|
|
|
|
if(iter.starts_line()) { |
|
|
|
|
Gtk::Clipboard::get()->set_text(get_buffer()->get_text(iter, end)); |
|
|
|
|
else if(copy_with_first_line_indentation()) |
|
|
|
|
get_buffer()->erase(start, end); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
get_buffer()->cut_clipboard(Gtk::Clipboard::get()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
keep_clipboard = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Source::CommonView::cut_lines() { |
|
|
|
|
if(!get_editable()) |
|
|
|
|
@ -283,22 +277,9 @@ void Source::CommonView::copy() {
|
|
|
|
|
} |
|
|
|
|
Gtk::Clipboard::get()->set_text(selection); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
Gtk::TextIter start, end; |
|
|
|
|
get_buffer()->get_selection_bounds(start, end); |
|
|
|
|
if(start.get_line() == end.get_line() || start.starts_line()) |
|
|
|
|
get_buffer()->copy_clipboard(Gtk::Clipboard::get()); |
|
|
|
|
else { // In order to improve paste indentation: copy entire starting line if only whitespaces before start iter
|
|
|
|
|
auto iter = start; |
|
|
|
|
while(!iter.starts_line() && iter.backward_char() && (*iter == ' ' || *iter == '\t')) { |
|
|
|
|
} |
|
|
|
|
if(iter.starts_line()) |
|
|
|
|
Gtk::Clipboard::get()->set_text(get_buffer()->get_text(iter, end)); |
|
|
|
|
else |
|
|
|
|
else if(!copy_with_first_line_indentation()) |
|
|
|
|
get_buffer()->copy_clipboard(Gtk::Clipboard::get()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Source::CommonView::copy_lines() { |
|
|
|
|
Gtk::TextIter start, end; |
|
|
|
|
@ -326,6 +307,20 @@ void Source::CommonView::copy_lines() {
|
|
|
|
|
Gtk::Clipboard::get()->set_text(get_buffer()->get_text(start, end)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool Source::CommonView::copy_with_first_line_indentation() { |
|
|
|
|
Gtk::TextIter start, end; |
|
|
|
|
get_buffer()->get_selection_bounds(start, end); |
|
|
|
|
|
|
|
|
|
auto line_start = start; |
|
|
|
|
while(!line_start.starts_line() && line_start.backward_char() && (*line_start == ' ' || *line_start == '\t')) { |
|
|
|
|
} |
|
|
|
|
if(!line_start.starts_line()) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
Gtk::Clipboard::get()->set_text(get_buffer()->get_text(line_start, end)); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Source::BaseView::BaseView(const boost::filesystem::path &file_path, const Glib::RefPtr<Gsv::Language> &language) : CommonView(language), file_path(file_path), status_diagnostics(0, 0, 0) { |
|
|
|
|
get_style_context()->add_class("juci_source_view"); |
|
|
|
|
|
|
|
|
|
|