diff --git a/WIN-packages/README.md b/WIN-packages/README.md new file mode 100644 index 0000000..11b5099 --- /dev/null +++ b/WIN-packages/README.md @@ -0,0 +1 @@ +Source code for the dll's can be found at https://github.com/cppit/dialogs \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a3d2b33..907b215 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -89,19 +89,17 @@ set(source_files juci.h if(MSYS) list(APPEND source_files terminal_win.cc) - list(APPEND source_files dialogs_win.cc) - set(DIALOGS_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/WIN-packages/") + list(APPEND source_files dialogs_win.cc) + set(DIALOGS_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/WIN-packages/") # if (64 bit) set(DIALOGS_LIBRARIES "${CMAKE_SOURCE_DIR}/WIN-packages/x64/libdialogs.dll") message(${DIALOGS_LIBRARIES}) # else # set(DIALOGS_LIBRARIES "${CMAKE_SOURCE_DIR}/WIN-packages/x32/libdialogs.dll") #TODO figure out how to do this.... - message("MSYS detected") else() list(APPEND source_files terminal.cc) list(APPEND source_files dialogs.cc) - message("UNIX detected") endif() if(${validation}) diff --git a/src/dialogs.cc b/src/dialogs.cc index 8009e02..e8588e5 100644 --- a/src/dialogs.cc +++ b/src/dialogs.cc @@ -46,6 +46,6 @@ std::string Dialog::select_file() { std::string Dialog::save_file() { return open_dialog("Please choose a file", {std::make_pair("Cancel", Gtk::RESPONSE_CANCEL),std::make_pair("Save", Gtk::RESPONSE_OK)}, - Gtk::FILE_CHOOSER_ACTION_OPEN); + Gtk::FILE_CHOOSER_ACTION_SAVE); } diff --git a/src/notebook.cc b/src/notebook.cc index 9299009..ec4d2c5 100644 --- a/src/notebook.cc +++ b/src/notebook.cc @@ -71,9 +71,9 @@ void Notebook::open(const boost::filesystem::path &file_path) { auto language=Source::guess_language(file_path); if(language && (language->get_id()=="chdr" || language->get_id()=="cpphdr" || language->get_id()=="c" || language->get_id()=="cpp" || language->get_id()=="objc")) { boost::filesystem::path project_path; - auto directories = *Singleton::directories(); - if(directories.cmake && directories.cmake->project_path!="" && file_path.generic_string().substr(0, directories.cmake->project_path.generic_string().size()+1)==directories.cmake->project_path.generic_string()+'/') { - project_path=directories.cmake->project_path; + auto directories = Singleton::directories(); + if(directories->cmake && directories->cmake->project_path!="" && file_path.generic_string().substr(0, directories->cmake->project_path.generic_string().size()+1)==directories->cmake->project_path.generic_string()+'/') { + project_path=directories->cmake->project_path; if(boost::filesystem::exists(project_path.string()+"/CMakeLists.txt") && !boost::filesystem::exists(project_path.string()+"/compile_commands.json")) CMake::create_compile_commands(project_path); } @@ -181,11 +181,11 @@ bool Notebook::save(int page, bool reparse_needed) { //If CMakeLists.txt have been modified: //TODO: recreate cmake even without directories open? if(view->file_path.filename()=="CMakeLists.txt") { - auto directories = *Singleton::directories(); - if(directories.cmake && directories.cmake->project_path!="" && view->file_path.generic_string().substr(0, directories.cmake->project_path.generic_string().size()+1)==directories.cmake->project_path.generic_string()+'/' && CMake::create_compile_commands(directories.cmake->project_path)) { + auto directories = Singleton::directories(); + if(directories->cmake && directories->cmake->project_path!="" && view->file_path.generic_string().substr(0, directories->cmake->project_path.generic_string().size()+1)==directories->cmake->project_path.generic_string()+'/' && CMake::create_compile_commands(directories->cmake->project_path)) { for(auto source_view: source_views) { if(auto source_clang_view=dynamic_cast(source_view)) { - if(directories.cmake->project_path.string()==source_clang_view->project_path) { + if(directories->cmake->project_path.string()==source_clang_view->project_path) { if(source_clang_view->restart_parse()) Singleton::terminal()->async_print("Reparsing "+source_clang_view->file_path.string()+"\n"); else diff --git a/src/window.cc b/src/window.cc index 851fac5..93add35 100644 --- a/src/window.cc +++ b/src/window.cc @@ -186,7 +186,7 @@ void Window::create_menu() { menu.action_group->add(Gtk::Action::create("FileNewFolder", "New Folder"), Gtk::AccelKey(menu.key_map["new_folder"]), [this]() { auto time_now=std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); boost::filesystem::path path = Dialog::new_folder(); - if(boost::filesystem::exists(path)) { + if(path!="" && boost::filesystem::exists(path)) { if(boost::filesystem::last_write_time(path)>=time_now) { if(Singleton::directories()->current_path!="") Singleton::directories()->update(); @@ -194,14 +194,14 @@ void Window::create_menu() { } else Singleton::terminal()->print("Error: "+path.string()+" already exists.\n"); - } else { - Singleton::terminal()->print("Dialog was closed \n"); } Singleton::directories()->select(path); }); menu.action_group->add(Gtk::Action::create("FileNewProject", "New Project")); menu.action_group->add(Gtk::Action::create("FileNewProjectCpp", "C++"), [this]() { boost::filesystem::path project_path = Dialog::new_folder(); + if(project_path=="") + return; auto project_name=project_path.filename().string(); for(size_t c=0;cadd(Gtk::Action::create("FileOpenFolder", "Open Folder"), Gtk::AccelKey(menu.key_map["open_folder"]), [this]() { auto path = Dialog::select_folder(); - if (boost::filesystem::exists(path)) + if (path!="" && boost::filesystem::exists(path)) Singleton::directories()->open(path); - else - Singleton::terminal()->print("Dialog was closed \n"); }); menu.action_group->add(Gtk::Action::create("FileSaveAs", "Save As"), Gtk::AccelKey(menu.key_map["save_as"]), [this]() { auto path = Dialog::save_file(); - if(path.size()>0) { + if(path!="") { std::ofstream file(path); if(file) { file << notebook.get_current_view()->get_buffer()->get_text();