|
|
|
@ -103,7 +103,7 @@ std::vector<Source::View *> &Notebook::get_views() { |
|
|
|
return source_views; |
|
|
|
return source_views; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Notebook::open(const boost::filesystem::path &file_path_, size_t notebook_index) { |
|
|
|
void Notebook::open(const boost::filesystem::path &file_path_, size_t notebook_index, bool copy) { |
|
|
|
auto file_path = filesystem::get_normal_path(file_path_); |
|
|
|
auto file_path = filesystem::get_normal_path(file_path_); |
|
|
|
|
|
|
|
|
|
|
|
if(notebook_index == 1 && !split) |
|
|
|
if(notebook_index == 1 && !split) |
|
|
|
@ -114,6 +114,7 @@ void Notebook::open(const boost::filesystem::path &file_path_, size_t notebook_i |
|
|
|
auto canonical_file_path = boost::filesystem::canonical(file_path, ec); |
|
|
|
auto canonical_file_path = boost::filesystem::canonical(file_path, ec); |
|
|
|
if(ec) |
|
|
|
if(ec) |
|
|
|
canonical_file_path = file_path; |
|
|
|
canonical_file_path = file_path; |
|
|
|
|
|
|
|
if(!copy) { |
|
|
|
for(size_t c = 0; c < size(); c++) { |
|
|
|
for(size_t c = 0; c < size(); c++) { |
|
|
|
bool equal; |
|
|
|
bool equal; |
|
|
|
{ |
|
|
|
{ |
|
|
|
@ -127,6 +128,7 @@ void Notebook::open(const boost::filesystem::path &file_path_, size_t notebook_i |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(boost::filesystem::exists(file_path)) { |
|
|
|
if(boost::filesystem::exists(file_path)) { |
|
|
|
std::ifstream can_read(file_path.string()); |
|
|
|
std::ifstream can_read(file_path.string()); |
|
|
|
@ -162,6 +164,21 @@ void Notebook::open(const boost::filesystem::path &file_path_, size_t notebook_i |
|
|
|
source_views.emplace_back(new Source::GenericView(file_path, language)); |
|
|
|
source_views.emplace_back(new Source::GenericView(file_path, language)); |
|
|
|
|
|
|
|
|
|
|
|
auto view = source_views.back(); |
|
|
|
auto view = source_views.back(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(copy) { |
|
|
|
|
|
|
|
auto previous_view = get_current_view(); |
|
|
|
|
|
|
|
if(previous_view) { |
|
|
|
|
|
|
|
view->replace_text(previous_view->get_buffer()->get_text()); |
|
|
|
|
|
|
|
if(!split) |
|
|
|
|
|
|
|
toggle_split(); |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
auto pair = get_notebook_page(get_index(previous_view)); |
|
|
|
|
|
|
|
if(pair.second != -1) |
|
|
|
|
|
|
|
notebook_index = pair.first == 0 ? 1 : 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
view->configure(); |
|
|
|
view->configure(); |
|
|
|
|
|
|
|
|
|
|
|
view->scroll_to_cursor_delayed = [this](Source::BaseView *view, bool center, bool show_tooltips) { |
|
|
|
view->scroll_to_cursor_delayed = [this](Source::BaseView *view, bool center, bool show_tooltips) { |
|
|
|
|