Browse Source

Added and made use of Notebook::open(Source::View *view)

pipelines/235045657
eidheim 6 years ago
parent
commit
803195dafd
  1. 12
      src/notebook.cpp
  2. 1
      src/notebook.hpp
  3. 10
      src/window.cpp

12
src/notebook.cpp

@ -102,6 +102,18 @@ std::vector<Source::View *> &Notebook::get_views() {
return source_views;
}
bool Notebook::open(Source::View *view) {
for(size_t c = 0; c < size(); c++) {
if(view == source_views[c]) {
auto notebook_page = get_notebook_page(c);
notebooks[notebook_page.first].set_current_page(notebook_page.second);
focus_view(source_views[c]);
return true;
}
}
return false;
}
bool Notebook::open(const boost::filesystem::path &file_path_, Position position) {
boost::system::error_code ec;
if(file_path_.empty() || (boost::filesystem::exists(file_path_, ec) && !boost::filesystem::is_regular_file(file_path_, ec))) {

1
src/notebook.hpp

@ -41,6 +41,7 @@ public:
std::vector<Source::View *> &get_views();
enum class Position { left, right, infer, split };
bool open(Source::View *view);
bool open(const boost::filesystem::path &file_path, Position position = Position::infer);
void open_uri(const std::string &uri);
void configure(size_t index);

10
src/window.cpp

@ -784,7 +784,7 @@ void Window::set_menu_actions() {
if(current_cursor_location->view != Notebook::get().get_current_view()) {
// Move to current position if current position's view is not current view
// (for instance, in case one is looking at a new file but has not yet placed the cursor within the file)
if(!Notebook::get().open(current_cursor_location->view->file_path))
if(!Notebook::get().open(current_cursor_location->view))
return;
}
else {
@ -793,7 +793,7 @@ void Window::set_menu_actions() {
--current_cursor_location;
if(current_cursor_location->view != Notebook::get().get_current_view()) {
if(!Notebook::get().open(current_cursor_location->view->file_path))
if(!Notebook::get().open(current_cursor_location->view))
return;
}
}
@ -809,7 +809,7 @@ void Window::set_menu_actions() {
if(current_cursor_location->view != Notebook::get().get_current_view()) {
// Move to current position if current position's view is not current view
// (for instance, in case one is looking at a new file but has not yet placed the cursor within the file)
if(!Notebook::get().open(current_cursor_location->view->file_path))
if(!Notebook::get().open(current_cursor_location->view))
return;
}
else {
@ -818,7 +818,7 @@ void Window::set_menu_actions() {
++current_cursor_location;
if(current_cursor_location->view != Notebook::get().get_current_view()) {
if(!Notebook::get().open(current_cursor_location->view->file_path))
if(!Notebook::get().open(current_cursor_location->view))
return;
}
}
@ -1307,7 +1307,7 @@ void Window::set_menu_actions() {
Info::get().print("Saved Fix-Its to header file: " + filesystem::get_short_path(view->file_path).string());
}
if(current_view != Notebook::get().get_current_view())
Notebook::get().open(current_view->file_path);
Notebook::get().open(current_view);
}
}
});

Loading…
Cancel
Save