Commit bc718596 authored by Ole Christian Eidheim's avatar Ole Christian Eidheim

Added Window->Split Source Buffer

parent 5f6c6745
Pipeline #94083039 passed with stages
in 16 minutes and 6 seconds
cmake_minimum_required (VERSION 2.8.8)
project(juci)
set(JUCI_VERSION "1.5.0.2")
set(JUCI_VERSION "1.5.0.3")
set(CPACK_PACKAGE_NAME "jucipp")
set(CPACK_PACKAGE_CONTACT "Ole Christian Eidheim <[email protected]>")
......
......@@ -153,7 +153,8 @@ const std::string default_config_file = R"RAW({
#endif
R"RAW(
"window_close_tab": "<primary>w",
"window_toggle_split": "",)RAW"
"window_toggle_split": "",
"window_split_source_buffer": "",)RAW"
#ifdef __APPLE__
R"RAW(
"window_toggle_full_screen": "<primary><control>f",)RAW"
......
......@@ -489,6 +489,10 @@ const Glib::ustring menu_xml = R"RAW(<interface>
<attribute name='label' translatable='yes'>_Toggle _Split</attribute>
<attribute name='action'>app.window_toggle_split</attribute>
</item>
<item>
<attribute name='label' translatable='yes'>_Split _Source _Buffer</attribute>
<attribute name='action'>app.window_split_source_buffer</attribute>
</item>
</section>
<section>
<item>
......
......@@ -103,7 +103,7 @@ std::vector<Source::View *> &Notebook::get_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_);
if(notebook_index == 1 && !split)
......@@ -114,17 +114,19 @@ void Notebook::open(const boost::filesystem::path &file_path_, size_t notebook_i
auto canonical_file_path = boost::filesystem::canonical(file_path, ec);
if(ec)
canonical_file_path = file_path;
for(size_t c = 0; c < size(); c++) {
bool equal;
{
LockGuard lock(source_views[c]->canonical_file_path_mutex);
equal = canonical_file_path == source_views[c]->canonical_file_path;
}
if(equal) {
auto notebook_page = get_notebook_page(c);
notebooks[notebook_page.first].set_current_page(notebook_page.second);
focus_view(source_views[c]);
return;
if(!copy) {
for(size_t c = 0; c < size(); c++) {
bool equal;
{
LockGuard lock(source_views[c]->canonical_file_path_mutex);
equal = canonical_file_path == source_views[c]->canonical_file_path;
}
if(equal) {
auto notebook_page = get_notebook_page(c);
notebooks[notebook_page.first].set_current_page(notebook_page.second);
focus_view(source_views[c]);
return;
}
}
}
......@@ -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));
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->scroll_to_cursor_delayed = [this](Source::BaseView *view, bool center, bool show_tooltips) {
......
......@@ -34,7 +34,7 @@ public:
Source::View *get_current_view();
std::vector<Source::View *> &get_views();
void open(const boost::filesystem::path &file_path, size_t notebook_index = -1);
void open(const boost::filesystem::path &file_path, size_t notebook_index = -1, bool copy = false);
void open_uri(const std::string &uri);
void configure(size_t index);
bool save(size_t index);
......
......@@ -1426,6 +1426,20 @@ void Window::set_menu_actions() {
menu.add_action("window_toggle_split", [] {
Notebook::get().toggle_split();
});
menu.add_action("window_split_source_buffer", [] {
auto view = Notebook::get().get_current_view();
if(!view) {
Info::get().print("No source buffers found");
return;
}
auto iter = view->get_buffer()->get_insert()->get_iter();
Notebook::get().open(view->file_path, -1, true);
auto new_view = Notebook::get().get_current_view();
new_view->place_cursor_at_line_offset(iter.get_line(), iter.get_line_offset());
new_view->scroll_to_cursor_delayed(new_view, true, false);
});
menu.add_action("window_toggle_full_screen", [this] {
if(this->get_window()->get_state() & Gdk::WindowState::WINDOW_STATE_FULLSCREEN)
unfullscreen();
......
......@@ -6,4 +6,4 @@ Source::View *Notebook::get_current_view() {
return nullptr;
}
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) {}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment