sfm

simple file manager
git clone git://git.afify.dev/sfm
Log | Files | Refs | README | LICENSE

commit 2f8749f9139f27f54332470d050c4060ae650ae6
parent 38587347cc602a07716b7cb9750fe0f684948039
Author: afify <hassan@afify.dev>
Date:   Mon,  7 Dec 2020 07:11:24 +0300

[ref] vmode paste

Diffstat:
Mconfig.def.h | 2+-
Msfm.c | 37+++++++++++--------------------------
2 files changed, 12 insertions(+), 27 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -75,7 +75,7 @@ static Key nkeys[] = { { {.ch = 'q'}, quit }, { {.ch = 'v'}, start_vmode }, { {.ch = 'y'}, yank }, - { {.ch = 'p'}, selpst }, + { {.ch = 'p'}, paste }, { {.ch = 'P'}, selmv }, { {.ch = 'c'}, rname }, { {.key = TB_KEY_SPACE}, switch_pane }, diff --git a/sfm.c b/sfm.c @@ -156,7 +156,7 @@ static void selall(void); static void selref(void); static void selynk(void); static void selcalc(void); -static void selpst(void); +static void paste(void); static void selmv(void); static void seldel(void); static void init_files(void); @@ -1542,8 +1542,9 @@ seldel(void) } static void -selpst(void) +paste(void) { + size_t i; if (strlen(yank_file) != 0) { print_status(cprompt, "coping"); if (spawn(cp_cmd, cpane->dirn) != 0) @@ -1555,32 +1556,16 @@ selpst(void) } print_error("nothing to paste"); -// -// if (selected_files == NULL) -// return; -// print_status(cprompt, "coping"); -// if (spawn(cp_cmd, cpane->dirn) != 0) -// print_error("coping failed"); -// else -// print_status(cprompt, "files are copied"); -// free_files(); -// return; - - -// if (files == NULL) { -// return; -// } - -// size_t i; -// for (i = 0; i < selection_size; i++) { -// char *cp_cmd[] = { "cp", "-rf", files[i], cpane->dirn, NULL }; -// spawn(cp_cmd, NULL); -// } - -// free_files(); -// print_status(cprompt, "%d files are copied", selection_size); + if (selected_files == NULL) + return; + for (i = 0; i < selection_size; i++) { + char *selcp_cmd[] = { "cp", "-r", selected_files[i], cpane->dirn, NULL }; + spawn(selcp_cmd,NULL); + } + print_status(cprompt, "%d files are copied", selection_size); + free_files(); } static void