From 0be32747b4d4e3ae55fc571cd12ea6c3b842b8cd Mon Sep 17 00:00:00 2001 From: d3rrial Date: Wed, 31 Aug 2016 14:40:41 +0200 Subject: [PATCH] Revert "Introduced a method to clean build directory" This reverts commit 329c7e53a1b0e1e578d1a28ab5d0aee4903591f1. --- src/menu.cc | 10 +-- src/project.cc | 111 +++++++++++++----------------- src/project.h | 37 +++++----- src/window.cc | 183 +++++++++++++++++++++++-------------------------- 4 files changed, 154 insertions(+), 187 deletions(-) diff --git a/src/menu.cc b/src/menu.cc index 64bf67d..f42a8dc 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -244,10 +244,6 @@ Menu::Menu() { _Compile app.compile - - _Clean _Project - app.clean_project -
@@ -367,7 +363,7 @@ void Menu::add_action(const std::string &name, std::function action) { auto g_application=g_application_get_default(); auto gio_application=Glib::wrap(g_application, true); auto application=Glib::RefPtr::cast_static(gio_application); - + actions[name]=application->add_action(name, action); } @@ -375,7 +371,7 @@ void Menu::set_keys() { auto g_application=g_application_get_default(); auto gio_application=Glib::wrap(g_application, true); auto application=Glib::RefPtr::cast_static(gio_application); - + for(auto &key: Config::get().menu.keys) { if(key.second.size()>0 && actions.find(key.first)!=actions.end()) application->set_accel_for_action("app."+key.first, key.second); @@ -384,7 +380,7 @@ void Menu::set_keys() { void Menu::build() { builder = Gtk::Builder::create(); - + try { builder->add_from_string(ui_xml); auto object = Menu::get().builder->get_object("juci-menu"); diff --git a/src/project.cc b/src/project.cc index 40a1d39..4decbd7 100644 --- a/src/project.cc +++ b/src/project.cc @@ -47,14 +47,14 @@ void Project::on_save(size_t index) { cmake_path=view->file_path; else cmake_path=filesystem::find_file_in_path_parents("CMakeLists.txt", view->file_path.parent_path()); - + if(!cmake_path.empty()) { auto build=Build::create(cmake_path); if(dynamic_cast(build.get())) { build->update_default(true); if(boost::filesystem::exists(build->get_debug_path())) build->update_debug(true); - + for(size_t c=0;c(source_view)) { @@ -110,7 +110,7 @@ void Project::debug_update_stop() { std::unique_ptr Project::create() { std::unique_ptr build; - + if(auto view=Notebook::get().get_current_view()) { build=Build::create(view->file_path); if(view->language) { @@ -127,7 +127,7 @@ std::unique_ptr Project::create() { } else build=Build::create(Directories::get().path); - + if(dynamic_cast(build.get())) return std::unique_ptr(new Project::Clang(std::move(build))); else @@ -147,21 +147,6 @@ void Project::Base::compile_and_run() { Info::get().print("Could not find a supported project"); } -void Project::Base::clean_project() { - auto default_build_path=build->get_default_path(); - if(default_build_path.empty() || !build->update_default()) - return; - - if(Config::get().project.clear_terminal_on_compile) - Terminal::get().clear(); - Terminal::get().print("Cleaning build directory: "); - Terminal::get().print(default_build_path.c_str()); - Terminal::get().print("\n"); - boost::filesystem::remove_all(default_build_path); - boost::filesystem::create_directory(default_build_path); - Terminal::get().print("Build directory cleaned!\n"); -} - std::pair Project::Base::debug_get_run_arguments() { Info::get().print("Could not find a supported project"); return {"", ""}; @@ -183,17 +168,17 @@ Project::Clang::DebugOptions::DebugOptions() : Base::DebugOptions() { remote_host.signal_activate().connect([this] { set_visible(false); }); - + auto remote_vbox=Gtk::manage(new Gtk::VBox()); remote_vbox->pack_start(remote_enabled, true, true); remote_vbox->pack_end(remote_host, true, true); - + auto remote_frame=Gtk::manage(new Gtk::Frame()); remote_frame->set_label("Remote Debugging"); remote_frame->add(*remote_vbox); - + vbox.pack_end(*remote_frame, true, true); - + show_all(); set_visible(false); } @@ -203,17 +188,17 @@ std::pair Project::Clang::get_run_arguments() { auto build_path=build->get_default_path(); if(build_path.empty()) return {"", ""}; - + auto project_path=build->project_path.string(); auto run_arguments_it=run_arguments.find(project_path); std::string arguments; if(run_arguments_it!=run_arguments.end()) arguments=run_arguments_it->second; - + if(arguments.empty()) { auto view=Notebook::get().get_current_view(); auto executable=build->get_executable(view?view->file_path:"").string(); - + if(executable!="") { size_t pos=executable.find(project_path); if(pos!=std::string::npos) @@ -223,7 +208,7 @@ std::pair Project::Clang::get_run_arguments() { else arguments=filesystem::escape_argument(build->get_default_path()); } - + return {project_path, arguments}; } @@ -231,10 +216,10 @@ void Project::Clang::compile() { auto default_build_path=build->get_default_path(); if(default_build_path.empty() || !build->update_default()) return; - + if(Config::get().project.clear_terminal_on_compile) Terminal::get().clear(); - + compiling=true; Terminal::get().print("Compiling project "+build->project_path.string()+"\n"); Terminal::get().async_process(Config::get().project.make_command, default_build_path, [this](int exit_status) { @@ -246,14 +231,14 @@ void Project::Clang::compile_and_run() { auto default_build_path=build->get_default_path(); if(default_build_path.empty() || !build->update_default()) return; - + auto project_path=build->project_path; - + auto run_arguments_it=run_arguments.find(project_path.string()); std::string arguments; if(run_arguments_it!=run_arguments.end()) arguments=run_arguments_it->second; - + if(arguments.empty()) { auto view=Notebook::get().get_current_view(); arguments=build->get_executable(view?view->file_path:"").string(); @@ -267,10 +252,10 @@ void Project::Clang::compile_and_run() { arguments.replace(pos, project_path.string().size(), default_build_path.string()); arguments=filesystem::escape_argument(arguments); } - + if(Config::get().project.clear_terminal_on_compile) Terminal::get().clear(); - + compiling=true; Terminal::get().print("Compiling and running "+arguments+"\n"); Terminal::get().async_process(Config::get().project.make_command, default_build_path, [this, arguments, project_path](int exit_status){ @@ -288,17 +273,17 @@ std::pair Project::Clang::debug_get_run_arguments() { auto build_path=build->get_debug_path(); if(build_path.empty()) return {"", ""}; - + auto project_path=build->project_path.string(); auto run_arguments_it=debug_run_arguments.find(project_path); std::string arguments; if(run_arguments_it!=debug_run_arguments.end()) arguments=run_arguments_it->second; - + if(arguments.empty()) { auto view=Notebook::get().get_current_view(); auto executable=build->get_executable(view?view->file_path:"").string(); - + if(executable!="") { size_t pos=executable.find(project_path); if(pos!=std::string::npos) @@ -308,7 +293,7 @@ std::pair Project::Clang::debug_get_run_arguments() { else arguments=filesystem::escape_argument(build->get_debug_path()); } - + return {project_path, arguments}; } @@ -323,12 +308,12 @@ void Project::Clang::debug_start() { if(debug_build_path.empty() || !build->update_debug()) return; auto project_path=std::make_shared(build->project_path); - + auto run_arguments_it=debug_run_arguments.find(project_path->string()); auto run_arguments=std::make_shared(); if(run_arguments_it!=debug_run_arguments.end()) *run_arguments=run_arguments_it->second; - + if(run_arguments->empty()) { auto view=Notebook::get().get_current_view(); *run_arguments=build->get_executable(view?view->file_path:"").string(); @@ -342,10 +327,10 @@ void Project::Clang::debug_start() { run_arguments->replace(pos, project_path->string().size(), debug_build_path.string()); *run_arguments=filesystem::escape_argument(*run_arguments); } - + if(Config::get().project.clear_terminal_on_compile) Terminal::get().clear(); - + debugging=true; Terminal::get().print("Compiling and debugging "+*run_arguments+"\n"); Terminal::get().async_process(Config::get().project.make_command, debug_build_path, [this, run_arguments, project_path](int exit_status){ @@ -364,7 +349,7 @@ void Project::Clang::debug_start() { breakpoints.emplace_back(view->file_path, iter.get_line()+1); } } - + std::string remote_host; auto options_it=debug_options.find(project_path->string()); if(options_it!=debug_options.end() && options_it->second.remote_enabled.get_active()) @@ -381,7 +366,7 @@ void Project::Clang::debug_start() { Project::debug_stop.first=file_path; Project::debug_stop.second.first=line_nr-1; Project::debug_stop.second.second=line_index-1; - + debug_update_stop(); if(auto view=Notebook::get().get_current_view()) view->get_buffer()->place_cursor(view->get_buffer()->get_insert()->get_iter()); @@ -425,17 +410,17 @@ void Project::Clang::debug_backtrace() { auto view=Notebook::get().get_current_view(); if(view && debugging) { auto backtrace=Debug::LLDB::get().get_backtrace(); - + auto iter=view->get_iter_for_dialog(); view->selection_dialog=std::make_unique(*view, view->get_buffer()->create_mark(iter), true, true); auto rows=std::make_shared >(); if(backtrace.size()==0) return; - + bool cursor_set=false; for(auto &frame: backtrace) { std::string row=""+frame.module_filename+""; - + //Shorten frame.function_name if it is too long if(frame.function_name.size()>120) { frame.function_name=frame.function_name.substr(0, 58)+"...."+frame.function_name.substr(frame.function_name.size()-58); @@ -453,14 +438,14 @@ void Project::Clang::debug_backtrace() { cursor_set=true; } } - + view->selection_dialog->on_select=[this, rows](const std::string& selected, bool hide_window) { auto frame=rows->at(selected); if(!frame.file_path.empty()) { Notebook::get().open(frame.file_path); if(auto view=Notebook::get().get_current_view()) { Debug::LLDB::get().select_frame(frame.index); - + view->place_cursor_at_line_index(frame.line_nr-1, frame.line_index-1); view->scroll_to_cursor_delayed(view, true, true); } @@ -475,20 +460,20 @@ void Project::Clang::debug_show_variables() { auto view=Notebook::get().get_current_view(); if(debugging && view) { auto variables=Debug::LLDB::get().get_variables(); - + auto iter=view->get_iter_for_dialog(); view->selection_dialog=std::make_unique(*view, view->get_buffer()->create_mark(iter), true, true); auto rows=std::make_shared >(); if(variables.size()==0) return; - + for(auto &variable: variables) { std::string row="#"+std::to_string(variable.thread_index_id)+":#"+std::to_string(variable.frame_index)+":"+variable.file_path.filename().string()+":"+std::to_string(variable.line_nr)+" - "+Glib::Markup::escape_text(variable.name)+""; - + (*rows)[row]=variable; view->selection_dialog->add_row(row); } - + view->selection_dialog->on_select=[this, rows](const std::string& selected, bool hide_window) { auto variable=rows->at(selected); Debug::LLDB::get().select_frame(variable.frame_index, variable.thread_index_id); @@ -502,12 +487,12 @@ void Project::Clang::debug_show_variables() { if(!variable.declaration_found) Info::get().print("Debugger did not find declaration for the variable: "+variable.name); }; - + view->selection_dialog->on_hide=[this]() { debug_variable_tooltips.hide(); debug_variable_tooltips.clear(); }; - + view->selection_dialog->on_changed=[this, rows, iter](const std::string &selected) { if(selected.empty()) { debug_variable_tooltips.hide(); @@ -518,7 +503,7 @@ void Project::Clang::debug_show_variables() { auto create_tooltip_buffer=[this, rows, view, selected]() { auto variable=rows->at(selected); auto tooltip_buffer=Gtk::TextBuffer::create(view->get_buffer()->get_tag_table()); - + Glib::ustring value=variable.value; if(!value.empty()) { Glib::ustring::iterator iter; @@ -526,19 +511,19 @@ void Project::Clang::debug_show_variables() { auto next_char_iter=iter; next_char_iter++; value.replace(iter, next_char_iter, "?"); - } + } tooltip_buffer->insert_with_tag(tooltip_buffer->get_insert()->get_iter(), value.substr(0, value.size()-1), "def:note"); } - + return tooltip_buffer; }; - + debug_variable_tooltips.emplace_back(create_tooltip_buffer, *view, view->get_buffer()->create_mark(iter), view->get_buffer()->create_mark(iter)); - + debug_variable_tooltips.show(true); } }; - + view->hide_tooltips(); view->selection_dialog->show(); } @@ -585,7 +570,7 @@ void Project::Markdown::compile_and_run() { boost::filesystem::remove(last_temp_path); last_temp_path=boost::filesystem::path(); } - + std::stringstream stdin_stream, stdout_stream; auto exit_status=Terminal::get().process(stdin_stream, stdout_stream, "markdown "+filesystem::escape_argument(Notebook::get().get_current_view()->file_path.string())); if(exit_status==0) { @@ -599,7 +584,7 @@ void Project::Markdown::compile_and_run() { std::ofstream file_stream(temp_path.string(), std::fstream::binary); file_stream << stdout_stream.rdbuf(); file_stream.close(); - + auto uri=temp_path.string(); #ifdef __APPLE__ Terminal::get().process("open "+filesystem::escape_argument(uri)); diff --git a/src/project.h b/src/project.h index 7dad7b6..6d92112 100644 --- a/src/project.h +++ b/src/project.h @@ -14,7 +14,7 @@ namespace Project { Gtk::Label &debug_status_label(); void save_files(const boost::filesystem::path &path); void on_save(size_t index); - + extern boost::filesystem::path debug_last_stop_file_path; extern std::unordered_map run_arguments; extern std::unordered_map debug_run_arguments; @@ -23,7 +23,7 @@ namespace Project { extern std::pair > debug_stop; void debug_update_stop(); void debug_update_status(const std::string &debug_status); - + class Base { protected: #ifdef JUCI_ENABLE_DEBUG @@ -37,14 +37,13 @@ namespace Project { public: Base(std::unique_ptr &&build): build(std::move(build)) {} virtual ~Base() {} - + std::unique_ptr build; - + virtual std::pair get_run_arguments(); virtual void compile(); virtual void compile_and_run(); - virtual void clean_project(); - + virtual std::pair debug_get_run_arguments(); virtual Gtk::Popover *debug_get_options() { return nullptr; } Tooltips debug_variable_tooltips; @@ -64,7 +63,7 @@ namespace Project { virtual void debug_write(const std::string &buffer) {} virtual void debug_cancel() {} }; - + class Clang : public Base { #ifdef JUCI_ENABLE_DEBUG class DebugOptions : public Base::DebugOptions { @@ -75,16 +74,16 @@ namespace Project { }; static std::unordered_map debug_options; #endif - + Dispatcher dispatcher; public: Clang(std::unique_ptr &&build) : Base(std::move(build)) {} ~Clang() { dispatcher.disconnect(); } - + std::pair get_run_arguments() override; void compile() override; void compile_and_run() override; - + #ifdef JUCI_ENABLE_DEBUG std::pair debug_get_run_arguments() override; Gtk::Popover *debug_get_options() override; @@ -105,37 +104,37 @@ namespace Project { void debug_cancel() override; #endif }; - + class Markdown : public Base { public: Markdown(std::unique_ptr &&build) : Base(std::move(build)) {} ~Markdown(); - + boost::filesystem::path last_temp_path; void compile_and_run() override; }; - + class Python : public Base { public: Python(std::unique_ptr &&build) : Base(std::move(build)) {} - + void compile_and_run() override; }; - + class JavaScript : public Base { public: JavaScript(std::unique_ptr &&build) : Base(std::move(build)) {} - + void compile_and_run() override; }; - + class HTML : public Base { public: HTML(std::unique_ptr &&build) : Base(std::move(build)) {} - + void compile_and_run() override; }; - + std::unique_ptr create(); extern std::unique_ptr current; }; diff --git a/src/window.cc b/src/window.cc index 2a45269..364225d 100644 --- a/src/window.cc +++ b/src/window.cc @@ -27,42 +27,42 @@ namespace sigc { Window::Window() { set_title("juCi++"); set_events(Gdk::POINTER_MOTION_MASK|Gdk::FOCUS_CHANGE_MASK|Gdk::SCROLL_MASK|Gdk::LEAVE_NOTIFY_MASK); - + set_menu_actions(); configure(); activate_menu_items(false); - + set_default_size(Config::get().window.default_size.first, Config::get().window.default_size.second); - + auto directories_scrolled_window=Gtk::manage(new Gtk::ScrolledWindow()); directories_scrolled_window->add(Directories::get()); - + auto notebook_vbox=Gtk::manage(new Gtk::VBox()); notebook_vbox->pack_start(Notebook::get()); notebook_vbox->pack_end(EntryBox::get(), Gtk::PACK_SHRINK); - + auto terminal_scrolled_window=Gtk::manage(new Gtk::ScrolledWindow()); terminal_scrolled_window->add(Terminal::get()); - + auto notebook_and_terminal_vpaned=Gtk::manage(new Gtk::VPaned()); notebook_and_terminal_vpaned->set_position(static_cast(0.75*Config::get().window.default_size.second)); notebook_and_terminal_vpaned->pack1(*notebook_vbox, Gtk::SHRINK); notebook_and_terminal_vpaned->pack2(*terminal_scrolled_window, Gtk::SHRINK); - + auto hpaned=Gtk::manage(new Gtk::HPaned()); hpaned->set_position(static_cast(0.2*Config::get().window.default_size.first)); hpaned->pack1(*directories_scrolled_window, Gtk::SHRINK); hpaned->pack2(*notebook_and_terminal_vpaned, Gtk::SHRINK); - + auto info_and_status_hbox=Gtk::manage(new Gtk::HBox()); info_and_status_hbox->pack_start(Notebook::get().info, Gtk::PACK_SHRINK); info_and_status_hbox->set_center_widget(Project::debug_status_label()); info_and_status_hbox->pack_end(Notebook::get().status, Gtk::PACK_SHRINK); - + auto vbox=Gtk::manage(new Gtk::VBox()); vbox->pack_start(*hpaned); vbox->pack_start(*info_and_status_hbox, Gtk::PACK_SHRINK); - + auto overlay_vbox=Gtk::manage(new Gtk::VBox()); auto overlay_hbox=Gtk::manage(new Gtk::HBox()); overlay_vbox->set_hexpand(false); @@ -71,7 +71,7 @@ Window::Window() { overlay_hbox->set_hexpand(false); overlay_hbox->set_halign(Gtk::Align::ALIGN_END); overlay_hbox->pack_end(*overlay_vbox, Gtk::PACK_SHRINK, 20); - + auto overlay=Gtk::manage(new Gtk::Overlay()); overlay->add(*vbox); overlay->add_overlay(*overlay_hbox); @@ -79,7 +79,7 @@ Window::Window() { overlay->set_overlay_pass_through(*overlay_hbox, true); #endif add(*overlay); - + show_all_children(); Info::get().hide(); @@ -114,19 +114,19 @@ Window::Window() { } activate_menu_items(); - + Directories::get().select(view->file_path); - + if(view->full_reparse_needed) { if(!view->full_reparse()) Terminal::get().async_print("Error: failed to reparse "+view->file_path.string()+". Please reopen the file manually.\n", true); } else if(view->soft_reparse_needed) view->soft_reparse(); - + view->set_status(view->status); view->set_info(view->info); - + #ifdef JUCI_ENABLE_DEBUG if(Project::debugging) Project::debug_update_stop(); @@ -146,7 +146,7 @@ Window::Window() { #endif EntryBox::get().hide(); }; - + signal_focus_out_event().connect([](GdkEventFocus *event) { if(auto view=Notebook::get().get_current_view()) { view->hide_tooltips(); @@ -154,14 +154,14 @@ Window::Window() { } return false; }); - + about.signal_response().connect([this](int d){ about.hide(); }); - + about.set_version(Config::get().window.version); about.set_authors({"(in order of appearance)", - "Ted Johan Kristoffersen", + "Ted Johan Kristoffersen", "Jørgen Lien Sellæg", "Geir Morten Larsen", "Ole Christian Eidheim"}); @@ -192,7 +192,7 @@ void Window::configure() { void Window::set_menu_actions() { auto &menu = Menu::get(); - + menu.add_action("about", [this]() { about.show(); about.present(); @@ -203,7 +203,7 @@ void Window::set_menu_actions() { menu.add_action("quit", [this]() { close(); }); - + menu.add_action("new_file", [this]() { boost::filesystem::path path = Dialog::new_file(Notebook::get().get_current_folder()); if(path!="") { @@ -304,7 +304,7 @@ void Window::set_menu_actions() { Terminal::get().print("Error: Could not create project "+project_path.string()+"\n", true); } }); - + menu.add_action("open_file", [this]() { auto folder_path=Notebook::get().get_current_folder(); if(auto view=Notebook::get().get_current_view()) { @@ -320,7 +320,7 @@ void Window::set_menu_actions() { if (path!="" && boost::filesystem::exists(path)) Directories::get().open(path); }); - + menu.add_action("save", [this]() { if(auto view=Notebook::get().get_current_view()) { if(Notebook::get().save_current()) { @@ -352,15 +352,15 @@ void Window::set_menu_actions() { } } }); - + menu.add_action("print", [this]() { if(auto view=Notebook::get().get_current_view()) { auto print_operation=Gtk::PrintOperation::create(); auto print_compositor=Gsv::PrintCompositor::create(*view); - + print_operation->set_job_name(view->file_path.filename().string()); print_compositor->set_wrap_mode(Gtk::WrapMode::WRAP_WORD_CHAR); - + print_operation->signal_begin_print().connect([print_operation, print_compositor](const Glib::RefPtr& print_context) { while(!print_compositor->paginate(print_context)); print_operation->set_n_pages(print_compositor->get_n_pages()); @@ -368,11 +368,11 @@ void Window::set_menu_actions() { print_operation->signal_draw_page().connect([print_compositor](const Glib::RefPtr& print_context, int page_nr) { print_compositor->draw_page(print_context, page_nr); }); - + print_operation->run(Gtk::PRINT_OPERATION_ACTION_PRINT_DIALOG, *this); } }); - + menu.add_action("edit_undo", [this]() { if(auto view=Notebook::get().get_current_view()) { auto undo_manager = view->get_source_buffer()->get_undo_manager(); @@ -391,7 +391,7 @@ void Window::set_menu_actions() { } } }); - + menu.add_action("edit_cut", [this]() { auto widget=get_focus(); if(auto entry=dynamic_cast(widget)) @@ -413,11 +413,11 @@ void Window::set_menu_actions() { else if(auto view=Notebook::get().get_current_view()) view->paste(); }); - + menu.add_action("edit_find", [this]() { search_and_replace_entry(); }); - + menu.add_action("source_spellcheck", [this]() { if(auto view=Notebook::get().get_current_view()) { view->remove_spellcheck_errors(); @@ -432,7 +432,7 @@ void Window::set_menu_actions() { if(auto view=Notebook::get().get_current_view()) view->goto_next_spellcheck_error(); }); - + menu.add_action("source_git_next_diff", [this]() { if(auto view=Notebook::get().get_current_view()) view->git_goto_next_diff(); @@ -461,7 +461,7 @@ void Window::set_menu_actions() { } } }); - + menu.add_action("source_indentation_set_buffer_tab", [this]() { set_tab_entry(); }); @@ -470,7 +470,7 @@ void Window::set_menu_actions() { if(view && view->auto_indent) view->auto_indent(); }); - + menu.add_action("source_goto_line", [this]() { goto_line_entry(); }); @@ -478,7 +478,7 @@ void Window::set_menu_actions() { if(auto view=Notebook::get().get_current_view()) view->scroll_to_cursor_delayed(view, true, false); }); - + menu.add_action("source_find_symbol_ctags", [this]() { if(auto view=Notebook::get().get_current_view()) { auto pair=Ctags::get_result(view->file_path.parent_path()); @@ -488,20 +488,20 @@ void Window::set_menu_actions() { if(stream->tellg()==0) return; stream->seekg(0, std::ios::beg); - + auto dialog_iter=view->get_iter_for_dialog(); view->selection_dialog=std::make_unique(*view, view->get_buffer()->create_mark(dialog_iter), true, true); auto rows=std::make_shared >(); - + std::string line; while(std::getline(*stream, line)) { auto location=Ctags::get_location(line, true); - + std::string row=location.file_path.string()+":"+std::to_string(location.line+1)+": "+location.source; (*rows)[row]=Source::Offset(location.line, location.index, location.file_path); view->selection_dialog->add_row(row); } - + if(rows->size()==0) return; view->selection_dialog->on_select=[this, rows, path](const std::string &selected, bool hide_window) { @@ -521,7 +521,7 @@ void Window::set_menu_actions() { view->selection_dialog->show(); } }); - + menu.add_action("source_comments_toggle", [this]() { if(auto view=Notebook::get().get_current_view()) { if(view->toggle_comments) { @@ -539,7 +539,7 @@ void Window::set_menu_actions() { menu.add_action("source_find_documentation", [this]() { if(auto view=Notebook::get().get_current_view()) { if(view->get_token_data) { - auto data=view->get_token_data(); + auto data=view->get_token_data(); if(data.size()>0) { auto documentation_search=Config::get().source.documentation_searches.find(data[0]); if(documentation_search!=Config::get().source.documentation_searches.end()) { @@ -559,7 +559,7 @@ void Window::set_menu_actions() { query=documentation_search->second.queries.find("@empty"); if(query==documentation_search->second.queries.end()) query=documentation_search->second.queries.find("@any"); - + if(query!=documentation_search->second.queries.end()) { std::string uri=query->second+token_query; #ifdef __APPLE__ @@ -576,7 +576,7 @@ void Window::set_menu_actions() { } } }); - + menu.add_action("source_goto_declaration", [this]() { if(auto view=Notebook::get().get_current_view()) { if(view->get_declaration_location) { @@ -626,7 +626,7 @@ void Window::set_menu_actions() { view->selection_dialog->add_row(row); } } - + if(rows->size()==0) return; else if(rows->size()==1) { @@ -662,7 +662,7 @@ void Window::set_menu_actions() { auto dialog_iter=view->get_iter_for_dialog(); view->selection_dialog=std::make_unique(*view, view->get_buffer()->create_mark(dialog_iter), true, true); auto rows=std::make_shared >(); - + auto iter=view->get_buffer()->get_insert()->get_iter(); for(auto &usage: usages) { std::string row; @@ -675,14 +675,14 @@ void Window::set_menu_actions() { row+=std::to_string(usage.first.line+1)+": "+usage.second; (*rows)[row]=usage.first; view->selection_dialog->add_row(row); - + //Set dialog cursor to the last row if the textview cursor is at the same line if(current_page && iter.get_line()==static_cast(usage.first.line) && iter.get_line_index()>=static_cast(usage.first.index)) { view->selection_dialog->set_cursor_at_last_row(); } } - + if(rows->size()==0) return; view->selection_dialog->on_select=[this, rows](const std::string &selected, bool hide_window) { @@ -736,7 +736,7 @@ void Window::set_menu_actions() { }); menu.add_action("source_implement_method", [this]() { const static std::string button_text="Insert Method Implementation"; - + if(auto view=Notebook::get().get_current_view()) { if(view->get_method) { auto iter=view->get_buffer()->get_insert()->get_iter(); @@ -748,7 +748,7 @@ void Window::set_menu_actions() { auto method=std::make_shared(view->get_method()); if(method->empty()) return; - + EntryBox::get().clear(); EntryBox::get().labels.emplace_back(); EntryBox::get().labels.back().set_text(*method); @@ -762,7 +762,7 @@ void Window::set_menu_actions() { } } }); - + menu.add_action("source_goto_next_diagnostic", [this]() { if(auto view=Notebook::get().get_current_view()) { if(view->goto_next_diagnostic) { @@ -804,13 +804,13 @@ void Window::set_menu_actions() { } } }); - + menu.add_action("project_set_run_arguments", [this]() { auto project=Project::create(); auto run_arguments=std::make_shared >(project->get_run_arguments()); if(run_arguments->second.empty()) return; - + EntryBox::get().clear(); EntryBox::get().labels.emplace_back(); auto label_it=EntryBox::get().labels.begin(); @@ -834,12 +834,12 @@ void Window::set_menu_actions() { Info::get().print("Compile or debug in progress"); return; } - + Project::current=Project::create(); - + if(Config::get().project.save_on_compile_or_run) Project::save_files(Project::current->build->project_path); - + Project::current->compile_and_run(); }); menu.add_action("compile", [this]() { @@ -847,28 +847,15 @@ void Window::set_menu_actions() { Info::get().print("Compile or debug in progress"); return; } - + Project::current=Project::create(); - + if(Config::get().project.save_on_compile_or_run) Project::save_files(Project::current->build->project_path); - + Project::current->compile(); }); - menu.add_action("clean_project", [this]() { - if(Project::compiling || Project::debugging) { - Info::get().print("Compile or debug in progress"); - return; - } - - Project::current=Project::create(); - - if(Config::get().project.save_on_compile_or_run) - Project::save_files(Project::current->build->project_path); - - Project::current->clean_project(); - }); - + menu.add_action("run_command", [this]() { EntryBox::get().clear(); EntryBox::get().labels.emplace_back(); @@ -882,7 +869,7 @@ void Window::set_menu_actions() { last_run_command=content; auto run_path=Notebook::get().get_current_folder(); Terminal::get().async_print("Running: "+content+'\n'); - + Terminal::get().async_process(content, run_path, [this, content](int exit_status){ Terminal::get().async_print(content+" returned: "+std::to_string(exit_status)+'\n'); }); @@ -896,21 +883,21 @@ void Window::set_menu_actions() { }); EntryBox::get().show(); }); - + menu.add_action("kill_last_running", [this]() { Terminal::get().kill_last_async_process(); }); menu.add_action("force_kill_last_running", [this]() { Terminal::get().kill_last_async_process(true); }); - + #ifdef JUCI_ENABLE_DEBUG menu.add_action("debug_set_run_arguments", [this]() { auto project=Project::create(); auto run_arguments=std::make_shared >(project->debug_get_run_arguments()); if(run_arguments->second.empty()) return; - + EntryBox::get().clear(); EntryBox::get().labels.emplace_back(); auto label_it=EntryBox::get().labels.begin(); @@ -924,7 +911,7 @@ void Window::set_menu_actions() { }, 50); auto entry_it=EntryBox::get().entries.begin(); entry_it->set_placeholder_text("Debug: Set Run Arguments"); - + if(auto options=project->debug_get_options()) { EntryBox::get().buttons.emplace_back("", [this, options]() { options->set_visible(true); @@ -934,7 +921,7 @@ void Window::set_menu_actions() { EntryBox::get().buttons.back().set_tooltip_text("Additional Options"); options->set_relative_to(EntryBox::get().buttons.back()); } - + EntryBox::get().buttons.emplace_back("Debug: set run arguments", [this, entry_it](){ entry_it->activate(); }); @@ -949,12 +936,12 @@ void Window::set_menu_actions() { Project::current->debug_continue(); return; } - + Project::current=Project::create(); - + if(Config::get().project.save_on_compile_or_run) Project::save_files(Project::current->build->project_path); - + Project::current->debug_start(); }); menu.add_action("debug_stop", [this]() { @@ -1005,7 +992,7 @@ void Window::set_menu_actions() { menu.add_action("debug_toggle_breakpoint", [this](){ if(auto view=Notebook::get().get_current_view()) { auto line_nr=view->get_buffer()->get_insert()->get_iter().get_line(); - + if(view->get_source_buffer()->get_source_marks_at_line(line_nr, "debug_breakpoint").size()>0) { auto start_iter=view->get_buffer()->get_iter_at_line(line_nr); auto end_iter=view->get_iter_at_line_end(line_nr); @@ -1033,10 +1020,10 @@ void Window::set_menu_actions() { } } }); - + Project::debug_update_status(""); #endif - + menu.add_action("next_tab", [this]() { Notebook::get().next(); }); @@ -1052,7 +1039,7 @@ void Window::set_menu_actions() { else { Notebook::get().status.set_text(""); Notebook::get().info.set_text(""); - + activate_menu_items(false); } } @@ -1129,7 +1116,7 @@ bool Window::on_key_press_event(GdkEventKey *event) { bool Window::on_delete_event(GdkEventAny *event) { Notebook::get().save_session(); - + for(size_t c=Notebook::get().size()-1;c!=static_cast(-1);--c) { if(!Notebook::get().close(c)) return true; @@ -1203,7 +1190,7 @@ void Window::search_and_replace_entry() { replace_entry_it->signal_changed().connect([this, replace_entry_it](){ last_replace=replace_entry_it->get_text(); }); - + EntryBox::get().buttons.emplace_back("↑", [this](){ if(auto view=Notebook::get().get_current_view()) view->search_backward(); @@ -1225,7 +1212,7 @@ void Window::search_and_replace_entry() { view->replace_all(replace_entry_it->get_text()); }); EntryBox::get().buttons.back().set_tooltip_text("Replace All"); - + EntryBox::get().toggle_buttons.emplace_back("Aa"); EntryBox::get().toggle_buttons.back().set_tooltip_text("Match Case"); EntryBox::get().toggle_buttons.back().set_active(case_sensitive_search); @@ -1257,25 +1244,25 @@ void Window::set_tab_entry() { EntryBox::get().clear(); if(auto view=Notebook::get().get_current_view()) { auto tab_char_and_size=view->get_tab_char_and_size(); - + EntryBox::get().labels.emplace_back(); auto label_it=EntryBox::get().labels.begin(); - + EntryBox::get().entries.emplace_back(std::to_string(tab_char_and_size.second)); auto entry_tab_size_it=EntryBox::get().entries.begin(); entry_tab_size_it->set_placeholder_text("Tab size"); - + char tab_char=tab_char_and_size.first; std::string tab_char_string; if(tab_char==' ') tab_char_string="space"; else if(tab_char=='\t') tab_char_string="tab"; - + EntryBox::get().entries.emplace_back(tab_char_string); auto entry_tab_char_it=EntryBox::get().entries.rbegin(); entry_tab_char_it->set_placeholder_text("Tab char"); - + const auto activate_function=[this, entry_tab_char_it, entry_tab_size_it, label_it](const std::string& content){ if(auto view=Notebook::get().get_current_view()) { char tab_char=0; @@ -1300,14 +1287,14 @@ void Window::set_tab_entry() { } } }; - + entry_tab_char_it->on_activate=activate_function; entry_tab_size_it->on_activate=activate_function; - + EntryBox::get().buttons.emplace_back("Set tab in current buffer", [this, entry_tab_char_it](){ entry_tab_char_it->activate(); }); - + EntryBox::get().show(); } } @@ -1321,7 +1308,7 @@ void Window::goto_line_entry() { view->place_cursor_at_line_index(stoi(content)-1, 0); view->scroll_to_cursor_delayed(view, true, false); } - catch(const std::exception &e) {} + catch(const std::exception &e) {} EntryBox::get().hide(); } });