add single_buffer and copy/paste one file or dir
This commit is contained in:
@@ -91,12 +91,12 @@ namespace rrr
|
||||
auto pwd = nav.data.at(navigation_cursor_position).path;
|
||||
preview_cursor_position = 0;
|
||||
|
||||
if (buffer::state.contains(pwd))
|
||||
if (buffers::get_instance().path_buffer.contains(pwd))
|
||||
{
|
||||
tbb::parallel_for(tbb::blocked_range<int>(0, prev.data.size()), [&](tbb::blocked_range<int> r)
|
||||
{
|
||||
for (int i = r.begin(); i < r.end(); ++i)
|
||||
if (prev.data.at(i).path == buffer::state[pwd].path)
|
||||
if (prev.data.at(i).path == buffers::get_instance().path_buffer[pwd].path)
|
||||
preview_cursor_position = i;
|
||||
});
|
||||
}
|
||||
@@ -134,9 +134,9 @@ namespace rrr
|
||||
// смотрим есть ли в этом pwd какой-то файл в буфере
|
||||
// проще говоря, были ли мы тут
|
||||
// и если были, то устанавливаем курсор
|
||||
if (buffer::state.contains(PWD))
|
||||
if (buffers::get_instance().path_buffer.contains(PWD))
|
||||
{
|
||||
auto f = buffer::state[PWD];
|
||||
auto f = buffers::get_instance().path_buffer[PWD];
|
||||
tbb::parallel_for(tbb::blocked_range<int>(0, nav.data.size()), [&](tbb::blocked_range<int> r)
|
||||
{
|
||||
for (int i = r.begin(); i < r.end(); ++i)
|
||||
@@ -162,7 +162,7 @@ namespace rrr
|
||||
// буфер заполняется только когда отсюда уходишь
|
||||
// типа я тут был и если тут что-то есть
|
||||
if (!std::filesystem::is_empty(PWD))
|
||||
buffer::state[PWD] = nav.data.at(navigation_cursor_position);
|
||||
buffers::get_instance().path_buffer[PWD] = nav.data.at(navigation_cursor_position);
|
||||
|
||||
auto from = PWD;
|
||||
|
||||
@@ -216,7 +216,6 @@ namespace rrr
|
||||
}
|
||||
|
||||
hack::utils::unix_cmd("mv " + old_name.string() + " " + new_name.string());
|
||||
hack::log()(old_name, new_name);
|
||||
nav.fill(PWD);
|
||||
|
||||
tbb::parallel_for(tbb::blocked_range<int>(0, nav.data.size()), [&](tbb::blocked_range<int> r)
|
||||
@@ -229,6 +228,29 @@ namespace rrr
|
||||
check_cursor_position();
|
||||
}
|
||||
|
||||
void content::paste(std::filesystem::path f)
|
||||
{
|
||||
std::filesystem::path target;
|
||||
if (std::filesystem::exists(PWD / f.filename()))
|
||||
{
|
||||
target = f.filename().string() + "_" +
|
||||
std::to_string(
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count()
|
||||
);
|
||||
target = f.parent_path() / std::filesystem::path(target);
|
||||
}
|
||||
else
|
||||
{
|
||||
target = PWD / f.filename();
|
||||
}
|
||||
|
||||
std::string cmd = std::filesystem::is_directory(f) ? "cp -R " : "cp ";
|
||||
hack::utils::unix_cmd(cmd + f.string() + " " + target.string());
|
||||
nav.fill(PWD);
|
||||
|
||||
check_cursor_position();
|
||||
}
|
||||
|
||||
void content::delete_file(file f)
|
||||
{
|
||||
std::string cmd = "delete " + f.path.string();
|
||||
|
||||
Reference in New Issue
Block a user