mirror of
https://github.com/jarun/nnn.git
synced 2025-01-25 02:06:50 +00:00
Reformat create link to selection
This commit is contained in:
parent
ce6fc35929
commit
8166e0169a
25
src/nnn.c
25
src/nnn.c
|
@ -370,12 +370,14 @@ static char mv[] = "mvg -gi";
|
||||||
#define STR_INVBM_KEY 1
|
#define STR_INVBM_KEY 1
|
||||||
#define STR_DATE_ID 2
|
#define STR_DATE_ID 2
|
||||||
#define STR_TMPFILE 3
|
#define STR_TMPFILE 3
|
||||||
|
#define NONE_SELECTED 4
|
||||||
|
|
||||||
static const char * const messages[] = {
|
static const char * const messages[] = {
|
||||||
"no traversal",
|
"no traversal",
|
||||||
"invalid key",
|
"invalid key",
|
||||||
"%F %T %z",
|
"%F %T %z",
|
||||||
"/.nnnXXXXXX",
|
"/.nnnXXXXXX",
|
||||||
|
"empty selection",
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Supported configuration environment variables */
|
/* Supported configuration environment variables */
|
||||||
|
@ -1842,7 +1844,7 @@ static size_t mkpath(char *dir, char *name, char *out)
|
||||||
* Create symbolic/hard link(s) to file(s) in selection list
|
* Create symbolic/hard link(s) to file(s) in selection list
|
||||||
* Returns the number of links created
|
* Returns the number of links created
|
||||||
*/
|
*/
|
||||||
static int xlink(char *suffix, char *path, char *buf, int type)
|
static int xlink(char *suffix, char *path, char *buf, int *presel, int type)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
char *pbuf = pcopybuf, *fname;
|
char *pbuf = pcopybuf, *fname;
|
||||||
|
@ -1850,15 +1852,15 @@ static int xlink(char *suffix, char *path, char *buf, int type)
|
||||||
int (*link_fn)(const char *, const char *) = NULL;
|
int (*link_fn)(const char *, const char *) = NULL;
|
||||||
|
|
||||||
/* Check if selection is empty */
|
/* Check if selection is empty */
|
||||||
if (!copybufpos)
|
if (!copybufpos) {
|
||||||
return 0;
|
printwait(messages[NONE_SELECTED], presel);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (type == 's') /* symbolic link */
|
if (type == 's') /* symbolic link */
|
||||||
link_fn = &symlink;
|
link_fn = &symlink;
|
||||||
else if (type == 'h') /* hard link */
|
else /* hard link */
|
||||||
link_fn = &link;
|
link_fn = &link;
|
||||||
else
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
while (pos < copybufpos) {
|
while (pos < copybufpos) {
|
||||||
len = strlen(pbuf);
|
len = strlen(pbuf);
|
||||||
|
@ -1873,6 +1875,9 @@ static int xlink(char *suffix, char *path, char *buf, int type)
|
||||||
pbuf += len + 1;
|
pbuf += len + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!count)
|
||||||
|
printwait("none created", presel);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3707,7 +3712,7 @@ nochange:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
printwait("none selected", &presel);
|
printwait(messages[NONE_SELECTED], &presel);
|
||||||
goto nochange;
|
goto nochange;
|
||||||
case SEL_CP:
|
case SEL_CP:
|
||||||
case SEL_MV:
|
case SEL_MV:
|
||||||
|
@ -3894,13 +3899,11 @@ nochange:
|
||||||
} else if (r == 's' || r == 'h') {
|
} else if (r == 's' || r == 'h') {
|
||||||
if (tmp[0] == '@' && tmp[1] == '\0')
|
if (tmp[0] == '@' && tmp[1] == '\0')
|
||||||
tmp[0] = '\0';
|
tmp[0] = '\0';
|
||||||
r = xlink(tmp, path, newpath, r);
|
r = xlink(tmp, path, newpath, &presel, r);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
if (r <= 0) {
|
if (r <= 0)
|
||||||
printwait("none created", &presel);
|
|
||||||
goto nochange;
|
goto nochange;
|
||||||
}
|
|
||||||
|
|
||||||
if (cfg.filtermode)
|
if (cfg.filtermode)
|
||||||
presel = FILTER;
|
presel = FILTER;
|
||||||
|
|
Loading…
Reference in a new issue