diff --git a/src/cmake.cpp b/src/cmake.cpp index c6bac87..8cf8cb8 100644 --- a/src/cmake.cpp +++ b/src/cmake.cpp @@ -51,7 +51,7 @@ bool CMake::update_default_build(const boost::filesystem::path &default_build_pa boost::system::error_code ec; boost::filesystem::create_directories(default_build_path, ec); if(ec) { - Terminal::get().print("\e[31mError\e[m: could not create " + default_build_path.string() + ": " + ec.message() + "\n", true); + Terminal::get().print("\e[31mError\e[m: could not create " + filesystem::get_short_path(default_build_path).string() + ": " + ec.message() + "\n", true); return false; } } @@ -112,7 +112,7 @@ bool CMake::update_debug_build(const boost::filesystem::path &debug_build_path, boost::system::error_code ec; boost::filesystem::create_directories(debug_build_path, ec); if(ec) { - Terminal::get().print("\e[31mError\e[m: could not create " + debug_build_path.string() + ": " + ec.message() + "\n", true); + Terminal::get().print("\e[31mError\e[m: could not create " + filesystem::get_short_path(debug_build_path).string() + ": " + ec.message() + "\n", true); return false; } } diff --git a/src/config.cpp b/src/config.cpp index d12e4bb..5d725b5 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -44,7 +44,7 @@ void Config::load() { } catch(const std::exception &e) { dispatcher.post([config_json = std::move(config_json), e_what = std::string(e.what())] { - ::Terminal::get().print("\e[31mError\e[m: could not parse " + config_json.string() + ": " + e_what + "\n", true); + ::Terminal::get().print("\e[31mError\e[m: could not parse " + filesystem::get_short_path(config_json).string() + ": " + e_what + "\n", true); }); std::stringstream ss; ss << default_config_file; diff --git a/src/directories.cpp b/src/directories.cpp index fc34c42..3f2fec8 100644 --- a/src/directories.cpp +++ b/src/directories.cpp @@ -56,7 +56,7 @@ bool Directories::TreeStore::drag_data_received_vfunc(const TreeModel::Path &pat boost::system::error_code ec; if(boost::filesystem::exists(target_path, ec)) { - Terminal::get().print("\e[31mError\e[m: could not move file: " + target_path.string() + " already exists\n", true); + Terminal::get().print("\e[31mError\e[m: could not move file: " + filesystem::get_short_path(target_path).string() + " already exists\n", true); return false; } @@ -287,12 +287,12 @@ Directories::Directories() : Gtk::ListViewText(1) { on_save_file(target_path); } else { - Terminal::get().print("\e[31mError\e[m: could not create " + target_path.string() + '\n', true); + Terminal::get().print("\e[31mError\e[m: could not create " + filesystem::get_short_path(target_path).string() + '\n', true); return; } } else { - Terminal::get().print("\e[31mError\e[m: could not create " + target_path.string() + ": already exists\n", true); + Terminal::get().print("\e[31mError\e[m: could not create " + filesystem::get_short_path(target_path).string() + ": already exists\n", true); return; } @@ -331,12 +331,12 @@ Directories::Directories() : Gtk::ListViewText(1) { select(target_path); } else { - Terminal::get().print("\e[31mError\e[m: could not create " + target_path.string() + ": " + ec.message(), true); + Terminal::get().print("\e[31mError\e[m: could not create " + filesystem::get_short_path(target_path).string() + ": " + ec.message(), true); return; } } else { - Terminal::get().print("\e[31mError\e[m: could not create " + target_path.string() + ": already exists\n", true); + Terminal::get().print("\e[31mError\e[m: could not create " + filesystem::get_short_path(target_path).string() + ": already exists\n", true); return; } @@ -372,7 +372,7 @@ Directories::Directories() : Gtk::ListViewText(1) { auto target_path = source_path.parent_path() / content; if(boost::filesystem::exists(target_path, ec)) { - Terminal::get().print("\e[31mError\e[m: could not rename to " + target_path.string() + ": already exists\n", true); + Terminal::get().print("\e[31mError\e[m: could not rename to " + filesystem::get_short_path(target_path).string() + ": already exists\n", true); return; } @@ -381,7 +381,7 @@ Directories::Directories() : Gtk::ListViewText(1) { boost::filesystem::rename(source_path, target_path, ec); if(ec) { - Terminal::get().print("\e[31mError\e[m: could not rename " + source_path.string() + ": " + ec.message() + '\n', true); + Terminal::get().print("\e[31mError\e[m: could not rename " + filesystem::get_short_path(source_path).string() + ": " + ec.message() + '\n', true); return; } update(); @@ -412,7 +412,7 @@ Directories::Directories() : Gtk::ListViewText(1) { if(view->language) new_language_id = view->language->get_id(); if(new_language_id != old_language_id) - Terminal::get().print("\e[33mWarning\e[m: language for " + target_path.string() + " has changed. Please reopen the file\n"); + Terminal::get().print("\e[33mWarning\e[m: language for " + filesystem::get_short_path(target_path).string() + " has changed.\nPlease reopen the file.\n"); } } @@ -448,7 +448,7 @@ Directories::Directories() : Gtk::ListViewText(1) { boost::filesystem::remove_all(menu_popup_row_path, ec); if(ec) { - Terminal::get().print("\e[31mError\e[m: could not delete " + menu_popup_row_path.string() + ": " + ec.message() + "\n", true); + Terminal::get().print("\e[31mError\e[m: could not delete " + filesystem::get_short_path(menu_popup_row_path).string() + ": " + ec.message() + "\n", true); return; } @@ -517,7 +517,7 @@ Directories::~Directories() { void Directories::open(const boost::filesystem::path &dir_path) { boost::system::error_code ec; if(dir_path.empty() || !boost::filesystem::is_directory(dir_path, ec)) { - Terminal::get().print("\e[31mError\e[m: could not open " + dir_path.string() + '\n', true); + Terminal::get().print("\e[31mError\e[m: could not open " + filesystem::get_short_path(dir_path).string() + '\n', true); return; } diff --git a/src/meson.cpp b/src/meson.cpp index a2a6bfa..67f2a71 100644 --- a/src/meson.cpp +++ b/src/meson.cpp @@ -50,7 +50,7 @@ bool Meson::update_default_build(const boost::filesystem::path &default_build_pa boost::system::error_code ec; boost::filesystem::create_directories(default_build_path, ec); if(ec) { - Terminal::get().print("\e[31mError\e[m: could not create " + default_build_path.string() + ": " + ec.message() + "\n", true); + Terminal::get().print("\e[31mError\e[m: could not create " + filesystem::get_short_path(default_build_path).string() + ": " + ec.message() + "\n", true); return false; } } @@ -93,7 +93,7 @@ bool Meson::update_debug_build(const boost::filesystem::path &debug_build_path, boost::system::error_code ec; boost::filesystem::create_directories(debug_build_path, ec); if(ec) { - Terminal::get().print("\e[31mError\e[m: could not create " + debug_build_path.string() + ": " + ec.message() + "\n", true); + Terminal::get().print("\e[31mError\e[m: could not create " + filesystem::get_short_path(debug_build_path).string() + ": " + ec.message() + "\n", true); return false; } } diff --git a/src/notebook.cpp b/src/notebook.cpp index cdfd575..0094eef 100644 --- a/src/notebook.cpp +++ b/src/notebook.cpp @@ -117,7 +117,7 @@ bool Notebook::open(Source::View *view) { 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))) { - Terminal::get().print("\e[31mError\e[m: could not open " + file_path_.string() + "\n", true); + Terminal::get().print("\e[31mError\e[m: could not open " + filesystem::get_short_path(file_path_).string() + "\n", true); return false; } @@ -147,7 +147,7 @@ bool Notebook::open(const boost::filesystem::path &file_path_, Position position if(boost::filesystem::exists(file_path, ec)) { std::ifstream can_read(file_path.string()); if(!can_read) { - Terminal::get().print("\e[31mError\e[m: could not open " + file_path.string() + "\n", true); + Terminal::get().print("\e[31mError\e[m: could not open " + filesystem::get_short_path(file_path).string() + "\n", true); return false; } can_read.close(); diff --git a/src/project.cpp b/src/project.cpp index e9753d3..7165a20 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -366,7 +366,7 @@ void Project::LLDB::debug_start() { Terminal::get().print("\e[31mError\e[m: build folder no longer valid, please rebuild project.\n", true); else { Terminal::get().print("\e[33mWarning\e[m: could not find executable.\n"); - Terminal::get().print("\e[32mSolution\e[m: either use Project Set Run Arguments, or open a source file within a directory where an executable is defined.\n"); + Terminal::get().print("Either use Project Set Run Arguments, or open a source file within a directory where an executable is defined.\n"); } return; } @@ -874,7 +874,7 @@ void Project::Clang::compile_and_run() { Terminal::get().print("\e[31mError\e[m: build folder no longer valid, please rebuild project.\n", true); else { Terminal::get().print("\e[33mWarning\e[m: could not find executable.\n"); - Terminal::get().print("\e[32mSolution\e[m: either use Project Set Run Arguments, or open a source file within a directory where an executable is defined.\n"); + Terminal::get().print("Either use Project Set Run Arguments, or open a source file within a directory where an executable is defined.\n"); } return; } diff --git a/src/source.cpp b/src/source.cpp index f4b4253..c413f82 100644 --- a/src/source.cpp +++ b/src/source.cpp @@ -421,7 +421,7 @@ bool Source::View::save() { } } catch(const Glib::Error &error) { - Terminal::get().print("\e[31mError\e[m: Could not save file " + filesystem::get_short_path(file_path).string() + ": " + error.what() + '\n', true); + Terminal::get().print("\e[31mError\e[m: could not save file " + filesystem::get_short_path(file_path).string() + ": " + error.what() + '\n', true); return false; } diff --git a/src/source_clang.cpp b/src/source_clang.cpp index 1332960..ee9739a 100644 --- a/src/source_clang.cpp +++ b/src/source_clang.cpp @@ -196,7 +196,7 @@ void Source::ClangViewParse::parse_initialize() { parse_state = ParseState::stop; parse_mutex.unlock(); dispatcher.post([this] { - Terminal::get().print("\e[31mError\e[m: failed to reparse " + filesystem::get_short_path(this->file_path).string() + ".\n", true); + Terminal::get().print("\e[31mError\e[m: failed to reparse " + filesystem::get_short_path(this->file_path).string() + "\n", true); status_state = ""; if(update_status_state) update_status_state(this); diff --git a/src/source_generic.cpp b/src/source_generic.cpp index a7d3f76..b56a22a 100644 --- a/src/source_generic.cpp +++ b/src/source_generic.cpp @@ -31,7 +31,7 @@ Source::GenericView::GenericView(const boost::filesystem::path &file_path, const boost::property_tree::xml_parser::read_xml(language_file.string(), pt); } catch(const std::exception &e) { - Terminal::get().print("\e[31mError\e[m: error parsing language file " + language_file.string() + ": " + e.what() + '\n', true); + Terminal::get().print("\e[31mError\e[m: error parsing language file " + filesystem::get_short_path(language_file).string() + ": " + e.what() + '\n', true); } bool has_context_class = false; parse_language_file(has_context_class, pt); diff --git a/src/source_language_protocol.cpp b/src/source_language_protocol.cpp index d54cc74..30e04cd 100644 --- a/src/source_language_protocol.cpp +++ b/src/source_language_protocol.cpp @@ -863,7 +863,7 @@ void Source::LanguageProtocolView::setup_navigation_and_refactoring() { changes_renamed.emplace_back(change); } else - Terminal::get().print("\e[31mError\e[m: could not write to file " + change->file + '\n', true); + Terminal::get().print("\e[31mError\e[m: could not write to file " + filesystem::get_short_path(change->file).string() + '\n', true); } for(auto &pair : changes_in_opened_files) { diff --git a/src/window.cpp b/src/window.cpp index 51f2526..39df5d2 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -293,7 +293,7 @@ void Window::set_menu_actions() { if(!path.empty()) { boost::system::error_code ec; if(boost::filesystem::exists(path, ec)) { - Terminal::get().print("\e[31mError\e[m: " + path.string() + " already exists.\n", true); + Terminal::get().print("\e[31mError\e[m: " + filesystem::get_short_path(path).string() + " already exists\n", true); } else { if(filesystem::write(path)) { @@ -302,10 +302,9 @@ void Window::set_menu_actions() { Notebook::get().open(path); if(!Directories::get().path.empty()) Directories::get().on_save_file(path); - Terminal::get().print("New file " + path.string() + " created.\n"); } else - Terminal::get().print("\e[31mError\e[m: could not create new file " + path.string() + ".\n", true); + Terminal::get().print("\e[31mError\e[m: could not create new file " + filesystem::get_short_path(path).string() + "\n", true); } } }); @@ -320,10 +319,9 @@ void Window::set_menu_actions() { Directories::get().update(); else Directories::get().open(path); - Terminal::get().print("New folder " + path.string() + " created.\n"); } else - Terminal::get().print("\e[31mError\e[m: " + path.string() + " already exists.\n", true); + Terminal::get().print("\e[31mError\e[m: " + filesystem::get_short_path(path).string() + " already exists\n", true); Directories::get().select(path); } }); @@ -347,22 +345,22 @@ void Window::set_menu_actions() { build_config = "project('" + project_name + "', 'c')\n\nadd_project_arguments('-std=c11', '-Wall', '-Wextra', language: 'c')\n\nexecutable('" + project_name + "', 'main.c')\n"; } else { - Terminal::get().print("\e[31mError\e[m: build management system " + Config::get().project.default_build_management_system + " not supported.\n", true); + Terminal::get().print("\e[31mError\e[m: build management system " + Config::get().project.default_build_management_system + " not supported\n", true); return; } auto c_main_path = project_path / "main.c"; auto clang_format_path = project_path / ".clang-format"; boost::system::error_code ec; if(boost::filesystem::exists(build_config_path, ec)) { - Terminal::get().print("\e[31mError\e[m: " + build_config_path.string() + " already exists.\n", true); + Terminal::get().print("\e[31mError\e[m: " + filesystem::get_short_path(build_config_path).string() + " already exists\n", true); return; } if(boost::filesystem::exists(c_main_path, ec)) { - Terminal::get().print("\e[31mError\e[m: " + c_main_path.string() + " already exists.\n", true); + Terminal::get().print("\e[31mError\e[m: " + filesystem::get_short_path(c_main_path).string() + " already exists\n", true); return; } if(boost::filesystem::exists(clang_format_path, ec)) { - Terminal::get().print("\e[31mError\e[m: " + clang_format_path.string() + " already exists.\n", true); + Terminal::get().print("\e[31mError\e[m: " + filesystem::get_short_path(clang_format_path).string() + " already exists\n", true); return; } std::string c_main = "#include \n\nint main() {\n printf(\"Hello World!\\n\");\n}\n"; @@ -371,10 +369,10 @@ void Window::set_menu_actions() { Directories::get().open(project_path); Notebook::get().open(c_main_path); Directories::get().update(); - Terminal::get().print("C project " + project_name + " \e[32mcreated\e[m.\n"); + Terminal::get().print("C project " + project_name + " \e[32mcreated\e[m\n"); } else - Terminal::get().print("\e[31mError\e[m: Could not create project " + project_path.string() + "\n", true); + Terminal::get().print("\e[31mError\e[m: Could not create project " + filesystem::get_short_path(project_path).string() + "\n", true); } }); menu.add_action("file_new_project_cpp", []() { @@ -397,22 +395,22 @@ void Window::set_menu_actions() { build_config = "project('" + project_name + "', 'cpp')\n\nadd_project_arguments('-std=c++1y', '-Wall', '-Wextra', language: 'cpp')\n\nexecutable('" + project_name + "', 'main.cpp')\n"; } else { - Terminal::get().print("\e[31mError\e[m: build management system " + Config::get().project.default_build_management_system + " not supported.\n", true); + Terminal::get().print("\e[31mError\e[m: build management system " + Config::get().project.default_build_management_system + " not supported\n", true); return; } auto cpp_main_path = project_path / "main.cpp"; auto clang_format_path = project_path / ".clang-format"; boost::system::error_code ec; if(boost::filesystem::exists(build_config_path, ec)) { - Terminal::get().print("\e[31mError\e[m: " + build_config_path.string() + " already exists.\n", true); + Terminal::get().print("\e[31mError\e[m: " + filesystem::get_short_path(build_config_path).string() + " already exists\n", true); return; } if(boost::filesystem::exists(cpp_main_path, ec)) { - Terminal::get().print("\e[31mError\e[m: " + cpp_main_path.string() + " already exists.\n", true); + Terminal::get().print("\e[31mError\e[m: " + filesystem::get_short_path(cpp_main_path).string() + " already exists\n", true); return; } if(boost::filesystem::exists(clang_format_path, ec)) { - Terminal::get().print("\e[31mError\e[m: " + clang_format_path.string() + " already exists.\n", true); + Terminal::get().print("\e[31mError\e[m: " + filesystem::get_short_path(clang_format_path).string() + " already exists\n", true); return; } std::string cpp_main = "#include \n\nint main() {\n std::cout << \"Hello World!\\n\";\n}\n"; @@ -421,10 +419,10 @@ void Window::set_menu_actions() { Directories::get().open(project_path); Notebook::get().open(cpp_main_path); Directories::get().update(); - Terminal::get().print("C++ project " + project_name + " \e[32mcreated\e[m.\n"); + Terminal::get().print("C++ project " + project_name + " \e[32mcreated\e[m\n"); } else - Terminal::get().print("\e[31mError\e[m: Could not create project " + project_path.string() + "\n", true); + Terminal::get().print("\e[31mError\e[m: Could not create project " + filesystem::get_short_path(project_path).string() + "\n", true); } }); @@ -448,13 +446,13 @@ void Window::set_menu_actions() { if(boost::filesystem::exists(view->file_path, ec)) { std::ifstream can_read(view->file_path.string()); if(!can_read) { - Terminal::get().print("\e[31mError\e[m: could not read " + view->file_path.string() + "\n", true); + Terminal::get().print("\e[31mError\e[m: could not read " + filesystem::get_short_path(view->file_path).string() + "\n", true); return; } can_read.close(); } else { - Terminal::get().print("\e[31mError\e[m: " + view->file_path.string() + " does not exist\n", true); + Terminal::get().print("\e[31mError\e[m: " + filesystem::get_short_path(view->file_path).string() + " does not exist\n", true); return; } @@ -487,10 +485,9 @@ void Window::set_menu_actions() { if(!Directories::get().path.empty()) Directories::get().update(); Notebook::get().open(path); - Terminal::get().print("File saved to: " + filesystem::get_short_path(filesystem::get_normal_path(path)).string() + "\n"); } else - Terminal::get().print("Error saving file\n", true); + Terminal::get().print("\e[31mError\e[m: could not save file " + filesystem::get_short_path(path).string() + '\n', true); } } });