add create file and dir
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#include "content.hpp"
|
||||
|
||||
#include <oneapi/tbb/parallel_for.h>
|
||||
#include "logger/logger.hpp"
|
||||
|
||||
#include "buffer/buffer.hpp"
|
||||
|
||||
namespace rrr
|
||||
@@ -71,6 +73,10 @@ namespace rrr
|
||||
int content::get_preview_cursor_position()
|
||||
{
|
||||
int preview_cursor_position = 0;
|
||||
|
||||
if (std::filesystem::is_empty(PWD))
|
||||
return preview_cursor_position;
|
||||
|
||||
auto pwd = nav.store[PWD].at(cursor_position).path;
|
||||
|
||||
if (buffer::state.contains(pwd))
|
||||
@@ -103,6 +109,7 @@ namespace rrr
|
||||
{
|
||||
// ставим новый pwd и заполняем навигацию и историю
|
||||
PWD = PWD / nav.store[PWD].at(cursor_position).path.filename();
|
||||
|
||||
nav.fill(PWD);
|
||||
his.fill(PWD);
|
||||
|
||||
@@ -125,7 +132,11 @@ namespace rrr
|
||||
}
|
||||
|
||||
// и исходя из позиции курсора заполняем окно предварительного просмотра
|
||||
prev.fill(nav.store[PWD].at(cursor_position).path);
|
||||
// в зависимости от того пустаая ли она или неt
|
||||
if (std::filesystem::is_empty(PWD))
|
||||
prev.data.clear();
|
||||
else
|
||||
prev.fill(nav.store[PWD].at(cursor_position).path);
|
||||
}
|
||||
|
||||
void content::navigation_left()
|
||||
@@ -151,4 +162,23 @@ namespace rrr
|
||||
cursor_position = i;
|
||||
});
|
||||
}
|
||||
|
||||
void content::create_file(std::string filename)
|
||||
{
|
||||
std::string cmd;
|
||||
|
||||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd = "touch " + std::string(PWD / filename);
|
||||
}
|
||||
|
||||
hack::utils::unix_cmd(cmd);
|
||||
nav.fill(PWD);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user