diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..0e1fd60 Binary files /dev/null and b/icon.png differ diff --git a/img_logo.png b/img_logo.png new file mode 100644 index 0000000..304cd25 Binary files /dev/null and b/img_logo.png differ diff --git a/src/rrr/content/content.cpp b/src/rrr/content/content.cpp index f8a9fe3..cdf8dec 100644 --- a/src/rrr/content/content.cpp +++ b/src/rrr/content/content.cpp @@ -5,6 +5,7 @@ #include "logger/logger.hpp" #include "buffer/buffer.hpp" +#include "utils/func.hpp" namespace rrr { @@ -187,16 +188,17 @@ namespace rrr void content::create_file(std::string filename) { std::string cmd; + auto pwd = func::sheilding(PWD); if (filename.find("/") != std::string::npos) { - if (filename.at(filename.size() - 1) == '/') cmd = "mkdir -p " + std::string(PWD / filename); - else cmd = "mkdir -p " + std::string(PWD / std::filesystem::path(filename).parent_path()) - + " && touch " + std::string(PWD / filename); + if (filename.at(filename.size() - 1) == '/') cmd = "mkdir -p " + std::string(pwd / filename); + else cmd = "mkdir -p " + std::string(pwd / std::filesystem::path(filename).parent_path()) + + " && touch " + std::string(pwd / filename); } else { - cmd = "touch " + std::string(PWD / filename); + cmd = "touch " + std::string(pwd / filename); } hack::utils::unix_cmd(cmd); @@ -215,7 +217,7 @@ namespace rrr new_name = old_name.parent_path() / std::filesystem::path(new_name); } - hack::utils::unix_cmd("mv " + old_name.string() + " " + new_name.string()); + hack::utils::unix_cmd("mv " + func::sheilding(old_name).string() + " " + func::sheilding(new_name).string()); nav.fill(PWD); tbb::parallel_for(tbb::blocked_range(0, nav.data.size()), [&](tbb::blocked_range r) @@ -245,7 +247,7 @@ namespace rrr } std::string cmd = std::filesystem::is_directory(f) ? "cp -R " : "cp "; - hack::utils::unix_cmd(cmd + f.string() + " " + target.string()); + hack::utils::unix_cmd(cmd + func::sheilding(f).string() + " " + func::sheilding(target).string()); nav.fill(PWD); check_cursor_position(); @@ -253,7 +255,7 @@ namespace rrr void content::delete_file(file f) { - std::string cmd = "delete " + f.path.string(); + std::string cmd = "delete " + func::sheilding(f.path).string(); hack::utils::unix_cmd(cmd); nav.fill(PWD); increment_position(-1); @@ -276,7 +278,7 @@ namespace rrr } std::string cmd = "mv "; - hack::utils::unix_cmd(cmd + f.string() + " " + target.string()); + hack::utils::unix_cmd(cmd + func::sheilding(f).string() + " " + func::sheilding(target).string()); nav.fill(PWD); tbb::parallel_for(tbb::blocked_range(0, nav.data.size()), [&](tbb::blocked_range r) diff --git a/src/rrr/content/content.hpp b/src/rrr/content/content.hpp index a2c73cc..6276f3e 100644 --- a/src/rrr/content/content.hpp +++ b/src/rrr/content/content.hpp @@ -51,13 +51,12 @@ namespace rrr int navigation_cursor_position = 0; int preview_cursor_position = 0; int history_cursor_position = 0; + file navigation_selected_file; private: void set_history_cursor_position(); void set_preview_cursor_position(); void check_cursor_position(); - - file navigation_selected_file; }; } diff --git a/src/rrr/layers/gui/browser/history/history.cpp b/src/rrr/layers/gui/browser/history/history.cpp index 58b5bf6..51e0158 100644 --- a/src/rrr/layers/gui/browser/history/history.cpp +++ b/src/rrr/layers/gui/browser/history/history.cpp @@ -52,7 +52,7 @@ namespace rrr::layers::gui TR_PUSH_FONT(SEMI_BOLD, 18); ImGui::TextUnformatted(">"); ImGui::SameLine(22.f); - current_position = it - data->begin(); + current_position = std::distance(it, data->begin()); } else { diff --git a/src/rrr/layers/gui/browser/navigation/navigation.cpp b/src/rrr/layers/gui/browser/navigation/navigation.cpp index 81b05ae..bd45001 100644 --- a/src/rrr/layers/gui/browser/navigation/navigation.cpp +++ b/src/rrr/layers/gui/browser/navigation/navigation.cpp @@ -50,7 +50,7 @@ namespace rrr::layers::gui push_style(item); - if (selected_file.path == item.path) + if (!selected_file.path.empty() && selected_file.path == item.path) { if (selected_file.is_hidden) TR_PUSH_FONT(SEMI_BOLD_ITALIC, 18); @@ -283,9 +283,6 @@ namespace rrr::layers::gui set_scroll(); } - // HERE начинаем тут - // если дирректория пуста и туда заъодить, то происходит краш приложения - // сотрим тут: void content::navigation_right() if (key.get_keycode() == try_engine::key::L) { cnt->navigation_right(); @@ -351,6 +348,7 @@ namespace rrr::layers::gui // помощь if (key.get_keycode() == try_engine::key::F1) { + hack::log()("help"); em->execute(types::event_type::SHOW_HELP_DIALOG, nullptr); freeze = true; } @@ -418,6 +416,8 @@ namespace rrr::layers::gui void navigation::set_scroll() { + if (selected_file.path.empty()) return; + delta = 0; current_position = 0; cursor_position = 0; @@ -460,6 +460,7 @@ namespace rrr::layers::gui void navigation::detect_file() { + if (selected_file.path.empty()) return; if (std::filesystem::is_directory(selected_file.path)) return; if (selected_file.path.extension() == ".jpg" || diff --git a/src/rrr/layers/gui/browser/preview/preview.cpp b/src/rrr/layers/gui/browser/preview/preview.cpp index 4017fcf..c7e0b30 100644 --- a/src/rrr/layers/gui/browser/preview/preview.cpp +++ b/src/rrr/layers/gui/browser/preview/preview.cpp @@ -75,7 +75,7 @@ namespace rrr::layers::gui TR_PUSH_FONT(SEMI_BOLD, 18); ImGui::TextUnformatted(">"); ImGui::SameLine(22.f); - current_position = it - data->begin(); + current_position = std::distance(it, data->begin()); } else { diff --git a/src/rrr/layers/gui/dialogs/dialogs.cpp b/src/rrr/layers/gui/dialogs/dialogs.cpp index 95cc886..de0495e 100644 --- a/src/rrr/layers/gui/dialogs/dialogs.cpp +++ b/src/rrr/layers/gui/dialogs/dialogs.cpp @@ -40,6 +40,8 @@ namespace rrr::layers::gui if (help_dialog) draw_help_dialog(); + hack::log()("render dialog"); + END_IMGUI_WIN(); ImGui::PopStyleVar(); @@ -93,6 +95,7 @@ namespace rrr::layers::gui { show = true; help_dialog = true; + hack::log()("SHOW_HELP_DIALOG", show, help_dialog); } break; default: @@ -284,6 +287,7 @@ namespace rrr::layers::gui void dialogs::draw_help_dialog() { + hack::log()("draw_help_dialog"); height = try_engine::application::get()->get_window()->height() / 2.5f; TR_PUSH_FONT(MEDIUM, 16); diff --git a/src/rrr/utils/func.hpp b/src/rrr/utils/func.hpp index 76f2a92..9c9fe4e 100644 --- a/src/rrr/utils/func.hpp +++ b/src/rrr/utils/func.hpp @@ -1,5 +1,7 @@ #pragma once +#include + namespace rrr::func { template @@ -7,4 +9,24 @@ namespace rrr::func { return Color(r / 255.f, g / 255.f, b / 255.f, 1.f); } + + // для экоранирования путей чтоб unix команды нормально выполнялись + // правила тут вилимо будут добавлятся так что эт не конец:( + inline std::filesystem::path sheilding(std::filesystem::path PWD) + { + std::string pwd_local; + + for (char c : PWD.string()) { + if (c == ' ') + pwd_local += "\\ "; + else if (c == '(') + pwd_local += "\\("; + else if (c == ')') + pwd_local += "\\)"; + else + pwd_local += c; + } + + return pwd_local; + } }