fix
This commit is contained in:
@@ -61,7 +61,7 @@ enum {
|
|||||||
enum class EntryType { Directory, File, Symlink };
|
enum class EntryType { Directory, File, Symlink };
|
||||||
|
|
||||||
struct Entry {
|
struct Entry {
|
||||||
std::string name; // display name (dirs end with '/', symlinks with '@')
|
std::string name; // display name (dirs end with '/')
|
||||||
std::string full_path; // absolute canonical path
|
std::string full_path; // absolute canonical path
|
||||||
EntryType type = EntryType::File;
|
EntryType type = EntryType::File;
|
||||||
bool is_hidden = false;
|
bool is_hidden = false;
|
||||||
@@ -298,6 +298,8 @@ void FileManager::restore_term() {
|
|||||||
curs_set(1);
|
curs_set(1);
|
||||||
endwin();
|
endwin();
|
||||||
}
|
}
|
||||||
|
// Clear screen and move cursor home (visible in scrollback otherwise)
|
||||||
|
printf("\033[2J\033[H");
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileManager::update_size() {
|
void FileManager::update_size() {
|
||||||
@@ -363,7 +365,6 @@ void FileManager::load_entries() {
|
|||||||
e.name += '/';
|
e.name += '/';
|
||||||
} else if (S_ISLNK(st.st_mode)) {
|
} else if (S_ISLNK(st.st_mode)) {
|
||||||
e.type = EntryType::Symlink;
|
e.type = EntryType::Symlink;
|
||||||
e.name += '@';
|
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
ssize_t len = readlink(e.full_path.c_str(), buf, sizeof(buf) - 1);
|
ssize_t len = readlink(e.full_path.c_str(), buf, sizeof(buf) - 1);
|
||||||
if (len > 0) { buf[len] = '\0'; e.symlink_target = buf; }
|
if (len > 0) { buf[len] = '\0'; e.symlink_target = buf; }
|
||||||
@@ -1187,8 +1188,8 @@ void FileManager::do_open() {
|
|||||||
if (!e) return;
|
if (!e) return;
|
||||||
|
|
||||||
std::string target = join_path(cwd_, e->name);
|
std::string target = join_path(cwd_, e->name);
|
||||||
// Strip trailing / for directory and @ for symlink
|
// Strip trailing / for directory
|
||||||
if (!target.empty() && (target.back() == '/' || target.back() == '@'))
|
if (!target.empty() && target.back() == '/')
|
||||||
target.pop_back();
|
target.pop_back();
|
||||||
|
|
||||||
switch (e->type) {
|
switch (e->type) {
|
||||||
@@ -1616,9 +1617,9 @@ void FileManager::do_rename() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Strip trailing / or @
|
// Strip trailing /
|
||||||
std::string name = e->name;
|
std::string name = e->name;
|
||||||
if (!name.empty() && (name.back() == '/' || name.back() == '@'))
|
if (!name.empty() && name.back() == '/')
|
||||||
name.pop_back();
|
name.pop_back();
|
||||||
|
|
||||||
std::string new_name;
|
std::string new_name;
|
||||||
@@ -1682,13 +1683,13 @@ void FileManager::do_delete() {
|
|||||||
std::vector<std::string> targets;
|
std::vector<std::string> targets;
|
||||||
if (!selected_.empty()) {
|
if (!selected_.empty()) {
|
||||||
for (const auto &sel_name : selected_)
|
for (const auto &sel_name : selected_)
|
||||||
targets.push_back(join_path(cwd_, strip_suffix(strip_suffix(sel_name, "@"), "/")));
|
targets.push_back(join_path(cwd_, strip_suffix(sel_name, "/")));
|
||||||
} else {
|
} else {
|
||||||
const Entry *e = get_sel();
|
const Entry *e = get_sel();
|
||||||
if (!e) return;
|
if (!e) return;
|
||||||
std::string n = e->name;
|
std::string n = e->name;
|
||||||
if (!n.empty() && n.back() == '/') n.pop_back();
|
if (!n.empty() && n.back() == '/') n.pop_back();
|
||||||
if (!n.empty() && n.back() == '@') n.pop_back();
|
|
||||||
targets.push_back(join_path(cwd_, n));
|
targets.push_back(join_path(cwd_, n));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1750,7 +1751,6 @@ void FileManager::do_trash() {
|
|||||||
|
|
||||||
std::string name = e->name;
|
std::string name = e->name;
|
||||||
if (!name.empty() && name.back() == '/') name.pop_back();
|
if (!name.empty() && name.back() == '/') name.pop_back();
|
||||||
if (!name.empty() && name.back() == '@') name.pop_back();
|
|
||||||
|
|
||||||
std::string src = join_path(cwd_, name);
|
std::string src = join_path(cwd_, name);
|
||||||
|
|
||||||
@@ -1797,7 +1797,6 @@ void FileManager::do_open_with() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::string name = e->name;
|
std::string name = e->name;
|
||||||
if (!name.empty() && name.back() == '@') name.pop_back();
|
|
||||||
std::string target = join_path(cwd_, name);
|
std::string target = join_path(cwd_, name);
|
||||||
|
|
||||||
std::string prog;
|
std::string prog;
|
||||||
@@ -1827,7 +1826,6 @@ void FileManager::do_chmod_x(bool set) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::string name = e->name;
|
std::string name = e->name;
|
||||||
if (!name.empty() && name.back() == '@') name.pop_back();
|
|
||||||
std::string target = join_path(cwd_, name);
|
std::string target = join_path(cwd_, name);
|
||||||
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
@@ -1950,7 +1948,6 @@ void FileManager::do_copy_path() {
|
|||||||
if (!e) return;
|
if (!e) return;
|
||||||
std::string name = e->name;
|
std::string name = e->name;
|
||||||
if (!name.empty() && name.back() == '/') name.pop_back();
|
if (!name.empty() && name.back() == '/') name.pop_back();
|
||||||
if (!name.empty() && name.back() == '@') name.pop_back();
|
|
||||||
std::string path = join_path(cwd_, name);
|
std::string path = join_path(cwd_, name);
|
||||||
|
|
||||||
// Try clipboard tools
|
// Try clipboard tools
|
||||||
@@ -2010,7 +2007,7 @@ void FileManager::do_yank() {
|
|||||||
for (const auto &sel_name : selected_) {
|
for (const auto &sel_name : selected_) {
|
||||||
std::string n = sel_name;
|
std::string n = sel_name;
|
||||||
if (!n.empty() && n.back() == '/') n.pop_back();
|
if (!n.empty() && n.back() == '/') n.pop_back();
|
||||||
if (!n.empty() && n.back() == '@') n.pop_back();
|
|
||||||
clipboard_paths_.push_back(join_path(cwd_, n));
|
clipboard_paths_.push_back(join_path(cwd_, n));
|
||||||
}
|
}
|
||||||
clip_mode_ = ClipMode::Copy;
|
clip_mode_ = ClipMode::Copy;
|
||||||
@@ -2021,7 +2018,7 @@ void FileManager::do_yank() {
|
|||||||
if (!e) return;
|
if (!e) return;
|
||||||
std::string n = e->name;
|
std::string n = e->name;
|
||||||
if (!n.empty() && n.back() == '/') n.pop_back();
|
if (!n.empty() && n.back() == '/') n.pop_back();
|
||||||
if (!n.empty() && n.back() == '@') n.pop_back();
|
|
||||||
clipboard_paths_.push_back(join_path(cwd_, n));
|
clipboard_paths_.push_back(join_path(cwd_, n));
|
||||||
clip_mode_ = ClipMode::Copy;
|
clip_mode_ = ClipMode::Copy;
|
||||||
flash_msg("yanked: " + e->name);
|
flash_msg("yanked: " + e->name);
|
||||||
@@ -2035,7 +2032,7 @@ void FileManager::do_cut() {
|
|||||||
for (const auto &sel_name : selected_) {
|
for (const auto &sel_name : selected_) {
|
||||||
std::string n = sel_name;
|
std::string n = sel_name;
|
||||||
if (!n.empty() && n.back() == '/') n.pop_back();
|
if (!n.empty() && n.back() == '/') n.pop_back();
|
||||||
if (!n.empty() && n.back() == '@') n.pop_back();
|
|
||||||
clipboard_paths_.push_back(join_path(cwd_, n));
|
clipboard_paths_.push_back(join_path(cwd_, n));
|
||||||
}
|
}
|
||||||
clip_mode_ = ClipMode::Cut;
|
clip_mode_ = ClipMode::Cut;
|
||||||
@@ -2046,7 +2043,7 @@ void FileManager::do_cut() {
|
|||||||
if (!e) return;
|
if (!e) return;
|
||||||
std::string n = e->name;
|
std::string n = e->name;
|
||||||
if (!n.empty() && n.back() == '/') n.pop_back();
|
if (!n.empty() && n.back() == '/') n.pop_back();
|
||||||
if (!n.empty() && n.back() == '@') n.pop_back();
|
|
||||||
clipboard_paths_.push_back(join_path(cwd_, n));
|
clipboard_paths_.push_back(join_path(cwd_, n));
|
||||||
clip_mode_ = ClipMode::Cut;
|
clip_mode_ = ClipMode::Cut;
|
||||||
flash_msg("cut: " + e->name);
|
flash_msg("cut: " + e->name);
|
||||||
|
|||||||
Reference in New Issue
Block a user