fix path error
This commit is contained in:
parent
ea80038121
commit
e5dca6cf34
BIN
img_logo.png
Normal file
BIN
img_logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 406 KiB |
@ -5,6 +5,7 @@
|
|||||||
#include "logger/logger.hpp"
|
#include "logger/logger.hpp"
|
||||||
|
|
||||||
#include "buffer/buffer.hpp"
|
#include "buffer/buffer.hpp"
|
||||||
|
#include "utils/func.hpp"
|
||||||
|
|
||||||
namespace rrr
|
namespace rrr
|
||||||
{
|
{
|
||||||
@ -187,16 +188,17 @@ namespace rrr
|
|||||||
void content::create_file(std::string filename)
|
void content::create_file(std::string filename)
|
||||||
{
|
{
|
||||||
std::string cmd;
|
std::string cmd;
|
||||||
|
auto pwd = func::sheilding(PWD);
|
||||||
|
|
||||||
if (filename.find("/") != std::string::npos)
|
if (filename.find("/") != std::string::npos)
|
||||||
{
|
{
|
||||||
if (filename.at(filename.size() - 1) == '/') cmd = "mkdir -p " + 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())
|
else cmd = "mkdir -p " + std::string(pwd / std::filesystem::path(filename).parent_path())
|
||||||
+ " && touch " + std::string(PWD / filename);
|
+ " && touch " + std::string(pwd / filename);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cmd = "touch " + std::string(PWD / filename);
|
cmd = "touch " + std::string(pwd / filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
hack::utils::unix_cmd(cmd);
|
hack::utils::unix_cmd(cmd);
|
||||||
@ -215,7 +217,7 @@ namespace rrr
|
|||||||
new_name = old_name.parent_path() / std::filesystem::path(new_name);
|
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);
|
nav.fill(PWD);
|
||||||
|
|
||||||
tbb::parallel_for(tbb::blocked_range<int>(0, nav.data.size()), [&](tbb::blocked_range<int> r)
|
tbb::parallel_for(tbb::blocked_range<int>(0, nav.data.size()), [&](tbb::blocked_range<int> r)
|
||||||
@ -245,7 +247,7 @@ namespace rrr
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string cmd = std::filesystem::is_directory(f) ? "cp -R " : "cp ";
|
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);
|
nav.fill(PWD);
|
||||||
|
|
||||||
check_cursor_position();
|
check_cursor_position();
|
||||||
@ -253,7 +255,7 @@ namespace rrr
|
|||||||
|
|
||||||
void content::delete_file(file f)
|
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);
|
hack::utils::unix_cmd(cmd);
|
||||||
nav.fill(PWD);
|
nav.fill(PWD);
|
||||||
increment_position(-1);
|
increment_position(-1);
|
||||||
@ -276,7 +278,7 @@ namespace rrr
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string cmd = "mv ";
|
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);
|
nav.fill(PWD);
|
||||||
|
|
||||||
tbb::parallel_for(tbb::blocked_range<int>(0, nav.data.size()), [&](tbb::blocked_range<int> r)
|
tbb::parallel_for(tbb::blocked_range<int>(0, nav.data.size()), [&](tbb::blocked_range<int> r)
|
||||||
|
@ -51,13 +51,12 @@ namespace rrr
|
|||||||
int navigation_cursor_position = 0;
|
int navigation_cursor_position = 0;
|
||||||
int preview_cursor_position = 0;
|
int preview_cursor_position = 0;
|
||||||
int history_cursor_position = 0;
|
int history_cursor_position = 0;
|
||||||
|
file navigation_selected_file;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void set_history_cursor_position();
|
void set_history_cursor_position();
|
||||||
void set_preview_cursor_position();
|
void set_preview_cursor_position();
|
||||||
void check_cursor_position();
|
void check_cursor_position();
|
||||||
|
|
||||||
file navigation_selected_file;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ namespace rrr::layers::gui
|
|||||||
TR_PUSH_FONT(SEMI_BOLD, 18);
|
TR_PUSH_FONT(SEMI_BOLD, 18);
|
||||||
ImGui::TextUnformatted(">");
|
ImGui::TextUnformatted(">");
|
||||||
ImGui::SameLine(22.f);
|
ImGui::SameLine(22.f);
|
||||||
current_position = it - data->begin();
|
current_position = std::distance(it, data->begin());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -50,7 +50,7 @@ namespace rrr::layers::gui
|
|||||||
|
|
||||||
push_style(item);
|
push_style(item);
|
||||||
|
|
||||||
if (selected_file.path == item.path)
|
if (!selected_file.path.empty() && selected_file.path == item.path)
|
||||||
{
|
{
|
||||||
if (selected_file.is_hidden)
|
if (selected_file.is_hidden)
|
||||||
TR_PUSH_FONT(SEMI_BOLD_ITALIC, 18);
|
TR_PUSH_FONT(SEMI_BOLD_ITALIC, 18);
|
||||||
@ -283,9 +283,6 @@ namespace rrr::layers::gui
|
|||||||
set_scroll();
|
set_scroll();
|
||||||
}
|
}
|
||||||
|
|
||||||
// HERE начинаем тут
|
|
||||||
// если дирректория пуста и туда заъодить, то происходит краш приложения
|
|
||||||
// сотрим тут: void content::navigation_right()
|
|
||||||
if (key.get_keycode() == try_engine::key::L)
|
if (key.get_keycode() == try_engine::key::L)
|
||||||
{
|
{
|
||||||
cnt->navigation_right();
|
cnt->navigation_right();
|
||||||
@ -351,6 +348,7 @@ namespace rrr::layers::gui
|
|||||||
// помощь
|
// помощь
|
||||||
if (key.get_keycode() == try_engine::key::F1)
|
if (key.get_keycode() == try_engine::key::F1)
|
||||||
{
|
{
|
||||||
|
hack::log()("help");
|
||||||
em->execute(types::event_type::SHOW_HELP_DIALOG, nullptr);
|
em->execute(types::event_type::SHOW_HELP_DIALOG, nullptr);
|
||||||
freeze = true;
|
freeze = true;
|
||||||
}
|
}
|
||||||
@ -418,6 +416,8 @@ namespace rrr::layers::gui
|
|||||||
|
|
||||||
void navigation::set_scroll()
|
void navigation::set_scroll()
|
||||||
{
|
{
|
||||||
|
if (selected_file.path.empty()) return;
|
||||||
|
|
||||||
delta = 0;
|
delta = 0;
|
||||||
current_position = 0;
|
current_position = 0;
|
||||||
cursor_position = 0;
|
cursor_position = 0;
|
||||||
@ -460,6 +460,7 @@ namespace rrr::layers::gui
|
|||||||
|
|
||||||
void navigation::detect_file()
|
void navigation::detect_file()
|
||||||
{
|
{
|
||||||
|
if (selected_file.path.empty()) return;
|
||||||
if (std::filesystem::is_directory(selected_file.path)) return;
|
if (std::filesystem::is_directory(selected_file.path)) return;
|
||||||
|
|
||||||
if (selected_file.path.extension() == ".jpg" ||
|
if (selected_file.path.extension() == ".jpg" ||
|
||||||
|
@ -75,7 +75,7 @@ namespace rrr::layers::gui
|
|||||||
TR_PUSH_FONT(SEMI_BOLD, 18);
|
TR_PUSH_FONT(SEMI_BOLD, 18);
|
||||||
ImGui::TextUnformatted(">");
|
ImGui::TextUnformatted(">");
|
||||||
ImGui::SameLine(22.f);
|
ImGui::SameLine(22.f);
|
||||||
current_position = it - data->begin();
|
current_position = std::distance(it, data->begin());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -40,6 +40,8 @@ namespace rrr::layers::gui
|
|||||||
if (help_dialog)
|
if (help_dialog)
|
||||||
draw_help_dialog();
|
draw_help_dialog();
|
||||||
|
|
||||||
|
hack::log()("render dialog");
|
||||||
|
|
||||||
END_IMGUI_WIN();
|
END_IMGUI_WIN();
|
||||||
|
|
||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
@ -93,6 +95,7 @@ namespace rrr::layers::gui
|
|||||||
{
|
{
|
||||||
show = true;
|
show = true;
|
||||||
help_dialog = true;
|
help_dialog = true;
|
||||||
|
hack::log()("SHOW_HELP_DIALOG", show, help_dialog);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -284,6 +287,7 @@ namespace rrr::layers::gui
|
|||||||
|
|
||||||
void dialogs::draw_help_dialog()
|
void dialogs::draw_help_dialog()
|
||||||
{
|
{
|
||||||
|
hack::log()("draw_help_dialog");
|
||||||
height = try_engine::application::get()->get_window()->height() / 2.5f;
|
height = try_engine::application::get()->get_window()->height() / 2.5f;
|
||||||
|
|
||||||
TR_PUSH_FONT(MEDIUM, 16);
|
TR_PUSH_FONT(MEDIUM, 16);
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
namespace rrr::func
|
namespace rrr::func
|
||||||
{
|
{
|
||||||
template<typename Color>
|
template<typename Color>
|
||||||
@ -7,4 +9,24 @@ namespace rrr::func
|
|||||||
{
|
{
|
||||||
return Color(r / 255.f, g / 255.f, b / 255.f, 1.f);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user