|
|
|
@ -327,17 +327,12 @@ bool Notebook::open(const boost::filesystem::path &file_path_, Position position |
|
|
|
auto add_cursor_location = [this, view](const Gtk::TextIter &iter) { |
|
|
|
auto add_cursor_location = [this, view](const Gtk::TextIter &iter) { |
|
|
|
if(current_cursor_location != cursor_locations.end()) { |
|
|
|
if(current_cursor_location != cursor_locations.end()) { |
|
|
|
// Remove history newer than current (create new history branch)
|
|
|
|
// Remove history newer than current (create new history branch)
|
|
|
|
for(auto it = std::next(current_cursor_location); it != cursor_locations.end();) { |
|
|
|
for(auto it = std::next(current_cursor_location); it != cursor_locations.end();) |
|
|
|
it->view->get_buffer()->delete_mark(it->mark); |
|
|
|
|
|
|
|
it = cursor_locations.erase(it); |
|
|
|
it = cursor_locations.erase(it); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
current_cursor_location = cursor_locations.emplace(cursor_locations.end(), view, iter); |
|
|
|
current_cursor_location = cursor_locations.emplace(cursor_locations.end(), view, view->get_buffer()->create_mark(iter, false)); |
|
|
|
if(cursor_locations.size() > 10) |
|
|
|
if(cursor_locations.size() > 10) { |
|
|
|
cursor_locations.erase(cursor_locations.begin()); |
|
|
|
auto it = cursor_locations.begin(); |
|
|
|
|
|
|
|
it->view->get_buffer()->delete_mark(it->mark); |
|
|
|
|
|
|
|
cursor_locations.erase(it); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
view->get_buffer()->signal_mark_set().connect([this, view, add_cursor_location](const Gtk::TextIter & /*iter*/, const Glib::RefPtr<Gtk::TextBuffer::Mark> &mark) { |
|
|
|
view->get_buffer()->signal_mark_set().connect([this, view, add_cursor_location](const Gtk::TextIter & /*iter*/, const Glib::RefPtr<Gtk::TextBuffer::Mark> &mark) { |
|
|
|
if(mark->get_name() == "insert") { |
|
|
|
if(mark->get_name() == "insert") { |
|
|
|
@ -354,18 +349,14 @@ bool Notebook::open(const boost::filesystem::path &file_path_, Position position |
|
|
|
// Combine cursor histories adjacent and similar to current cursor
|
|
|
|
// Combine cursor histories adjacent and similar to current cursor
|
|
|
|
auto it = std::next(current_cursor_location); |
|
|
|
auto it = std::next(current_cursor_location); |
|
|
|
if(it != cursor_locations.end()) { |
|
|
|
if(it != cursor_locations.end()) { |
|
|
|
if(it->view == current_cursor_location->view && abs(it->mark->get_iter().get_line() - current_cursor_location->mark->get_iter().get_line()) <= 2) { |
|
|
|
if(it->view == current_cursor_location->view && abs(it->mark->get_iter().get_line() - current_cursor_location->mark->get_iter().get_line()) <= 2) |
|
|
|
it->view->get_buffer()->delete_mark(it->mark); |
|
|
|
|
|
|
|
cursor_locations.erase(it); |
|
|
|
cursor_locations.erase(it); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(current_cursor_location != cursor_locations.begin()) { |
|
|
|
if(current_cursor_location != cursor_locations.begin()) { |
|
|
|
it = std::prev(current_cursor_location); |
|
|
|
it = std::prev(current_cursor_location); |
|
|
|
if(it->view == current_cursor_location->view && abs(it->mark->get_iter().get_line() - current_cursor_location->mark->get_iter().get_line()) <= 2) { |
|
|
|
if(it->view == current_cursor_location->view && abs(it->mark->get_iter().get_line() - current_cursor_location->mark->get_iter().get_line()) <= 2) |
|
|
|
it->view->get_buffer()->delete_mark(it->mark); |
|
|
|
|
|
|
|
cursor_locations.erase(it); |
|
|
|
cursor_locations.erase(it); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -388,7 +379,6 @@ bool Notebook::open(const boost::filesystem::path &file_path_, Position position |
|
|
|
if(prev_it->view == it->view && abs(prev_it->mark->get_iter().get_line() - it->mark->get_iter().get_line()) <= 2) { |
|
|
|
if(prev_it->view == it->view && abs(prev_it->mark->get_iter().get_line() - it->mark->get_iter().get_line()) <= 2) { |
|
|
|
if(current_cursor_location == it) |
|
|
|
if(current_cursor_location == it) |
|
|
|
current_cursor_location = prev_it; |
|
|
|
current_cursor_location = prev_it; |
|
|
|
it->view->get_buffer()->delete_mark(it->mark); |
|
|
|
|
|
|
|
it = cursor_locations.erase(it); |
|
|
|
it = cursor_locations.erase(it); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
@ -563,7 +553,6 @@ void Notebook::delete_cursor_locations(Source::View *view) { |
|
|
|
if(it->view == view) { |
|
|
|
if(it->view == view) { |
|
|
|
if(current_cursor_location != cursor_locations.end() && current_cursor_location->view == view) |
|
|
|
if(current_cursor_location != cursor_locations.end() && current_cursor_location->view == view) |
|
|
|
current_cursor_location = cursor_locations.end(); |
|
|
|
current_cursor_location = cursor_locations.end(); |
|
|
|
it->view->get_buffer()->delete_mark(it->mark); |
|
|
|
|
|
|
|
it = cursor_locations.erase(it); |
|
|
|
it = cursor_locations.erase(it); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
|