mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 05:41:31 +00:00
checkpatch fixes
This commit is contained in:
parent
3bf858a580
commit
166e31b512
220
nnn.c
220
nnn.c
|
@ -109,12 +109,12 @@ disabledbg()
|
||||||
#define MAX_BM 10
|
#define MAX_BM 10
|
||||||
|
|
||||||
/* Macros to define process spawn behaviour as flags */
|
/* Macros to define process spawn behaviour as flags */
|
||||||
#define SP_NONE 0x00 /* no flag set */
|
#define F_NONE 0x00 /* no flag set */
|
||||||
#define SP_MARKER 0x01 /* draw marker to indicate nnn spawned (e.g. shell) */
|
#define F_MARKER 0x01 /* draw marker to indicate nnn spawned (e.g. shell) */
|
||||||
#define SP_NOWAIT 0x02 /* don't wait for child process (e.g. file manager) */
|
#define F_NOWAIT 0x02 /* don't wait for child process (e.g. file manager) */
|
||||||
#define SP_NOTRACE 0x04 /* suppress stdout and strerr (no traces) */
|
#define F_NOTRACE 0x04 /* suppress stdout and strerr (no traces) */
|
||||||
#define SP_SIGINT 0x08 /* restore default SIGINT handler */
|
#define F_SIGINT 0x08 /* restore default SIGINT handler */
|
||||||
#define SP_NORMAL 0x80 /* spawn child process in non-curses regular mode */
|
#define F_NORMAL 0x80 /* spawn child process in non-curses regular mode */
|
||||||
|
|
||||||
typedef unsigned long ulong;
|
typedef unsigned long ulong;
|
||||||
typedef unsigned int uint;
|
typedef unsigned int uint;
|
||||||
|
@ -136,8 +136,7 @@ typedef struct {
|
||||||
} bm;
|
} bm;
|
||||||
|
|
||||||
/* Settings */
|
/* Settings */
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
uchar filtermode : 1; /* Set to enter filter mode */
|
uchar filtermode : 1; /* Set to enter filter mode */
|
||||||
uchar mtimeorder : 1; /* Set to sort by time modified */
|
uchar mtimeorder : 1; /* Set to sort by time modified */
|
||||||
uchar sizeorder : 1; /* Set to sort by file size */
|
uchar sizeorder : 1; /* Set to sort by file size */
|
||||||
|
@ -252,9 +251,8 @@ xstrlen(const char *s)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
len = 0;
|
len = 0;
|
||||||
while (*s) {
|
while (*s)
|
||||||
++len, ++s;
|
++len, ++s;
|
||||||
}
|
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
@ -485,7 +483,7 @@ spawn(char *file, char *arg1, char *arg2, char *dir, uchar flag)
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
if (flag & SP_NORMAL)
|
if (flag & F_NORMAL)
|
||||||
exitcurses();
|
exitcurses();
|
||||||
|
|
||||||
pid = fork();
|
pid = fork();
|
||||||
|
@ -494,13 +492,14 @@ spawn(char *file, char *arg1, char *arg2, char *dir, uchar flag)
|
||||||
status = chdir(dir);
|
status = chdir(dir);
|
||||||
|
|
||||||
/* Show a marker (to indicate nnn spawned shell) */
|
/* Show a marker (to indicate nnn spawned shell) */
|
||||||
if (flag & SP_MARKER) {
|
if (flag & F_MARKER) {
|
||||||
printf("\n +-++-++-+\n | n n n |\n +-++-++-+\n\n");
|
printf("\n +-++-++-+\n | n n n |\n +-++-++-+\n\n");
|
||||||
printf("Spawned shell level: %d\n", atoi(getenv("SHLVL")) + 1);
|
printf("Spawned shell level: %d\n",
|
||||||
|
atoi(getenv("SHLVL")) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Suppress stdout and stderr */
|
/* Suppress stdout and stderr */
|
||||||
if (flag & SP_NOTRACE) {
|
if (flag & F_NOTRACE) {
|
||||||
int fd = open("/dev/null", O_WRONLY, 0200);
|
int fd = open("/dev/null", O_WRONLY, 0200);
|
||||||
|
|
||||||
dup2(fd, 1);
|
dup2(fd, 1);
|
||||||
|
@ -508,18 +507,18 @@ spawn(char *file, char *arg1, char *arg2, char *dir, uchar flag)
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flag & SP_SIGINT)
|
if (flag & F_SIGINT)
|
||||||
signal(SIGINT, SIG_DFL);
|
signal(SIGINT, SIG_DFL);
|
||||||
execlp(file, file, arg1, arg2, NULL);
|
execlp(file, file, arg1, arg2, NULL);
|
||||||
_exit(1);
|
_exit(1);
|
||||||
} else {
|
} else {
|
||||||
if (!(flag & SP_NOWAIT))
|
if (!(flag & F_NOWAIT))
|
||||||
/* Ignore interruptions */
|
/* Ignore interruptions */
|
||||||
while (waitpid(pid, &status, 0) == -1)
|
while (waitpid(pid, &status, 0) == -1)
|
||||||
DPRINTF_D(status);
|
DPRINTF_D(status);
|
||||||
|
|
||||||
DPRINTF_D(pid);
|
DPRINTF_D(pid);
|
||||||
if (flag & SP_NORMAL)
|
if (flag & F_NORMAL)
|
||||||
initcurses();
|
initcurses();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -792,7 +791,8 @@ fill(struct entry **dents,
|
||||||
(*dents)[count].mode = (*dents)[ndents].mode;
|
(*dents)[count].mode = (*dents)[ndents].mode;
|
||||||
(*dents)[count].t = (*dents)[ndents].t;
|
(*dents)[count].t = (*dents)[ndents].t;
|
||||||
(*dents)[count].size = (*dents)[ndents].size;
|
(*dents)[count].size = (*dents)[ndents].size;
|
||||||
(*dents)[count].blocks = (*dents)[ndents].blocks;
|
(*dents)[count].blocks
|
||||||
|
= (*dents)[ndents].blocks;
|
||||||
|
|
||||||
/* Copy tmp to ndents - 1 */
|
/* Copy tmp to ndents - 1 */
|
||||||
xstrlcpy((*dents)[ndents].name, _dent.name,
|
xstrlcpy((*dents)[ndents].name, _dent.name,
|
||||||
|
@ -1010,8 +1010,11 @@ readinput(void)
|
||||||
return g_buf[0] ? g_buf : NULL;
|
return g_buf[0] ? g_buf : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Replace escape characters in a string with '?'
|
||||||
|
*/
|
||||||
static char *
|
static char *
|
||||||
replace_escape(const char *str)
|
unescape(const char *str)
|
||||||
{
|
{
|
||||||
static char buffer[PATH_MAX];
|
static char buffer[PATH_MAX];
|
||||||
static wchar_t wbuf[PATH_MAX];
|
static wchar_t wbuf[PATH_MAX];
|
||||||
|
@ -1047,22 +1050,22 @@ printent(struct entry *ent, int sel)
|
||||||
|
|
||||||
if (S_ISDIR(ent->mode))
|
if (S_ISDIR(ent->mode))
|
||||||
snprintf(g_buf, ncols, "%s%s/", CURSYM(sel),
|
snprintf(g_buf, ncols, "%s%s/", CURSYM(sel),
|
||||||
replace_escape(ent->name));
|
unescape(ent->name));
|
||||||
else if (S_ISLNK(ent->mode))
|
else if (S_ISLNK(ent->mode))
|
||||||
snprintf(g_buf, ncols, "%s%s@", CURSYM(sel),
|
snprintf(g_buf, ncols, "%s%s@", CURSYM(sel),
|
||||||
replace_escape(ent->name));
|
unescape(ent->name));
|
||||||
else if (S_ISSOCK(ent->mode))
|
else if (S_ISSOCK(ent->mode))
|
||||||
snprintf(g_buf, ncols, "%s%s=", CURSYM(sel),
|
snprintf(g_buf, ncols, "%s%s=", CURSYM(sel),
|
||||||
replace_escape(ent->name));
|
unescape(ent->name));
|
||||||
else if (S_ISFIFO(ent->mode))
|
else if (S_ISFIFO(ent->mode))
|
||||||
snprintf(g_buf, ncols, "%s%s|", CURSYM(sel),
|
snprintf(g_buf, ncols, "%s%s|", CURSYM(sel),
|
||||||
replace_escape(ent->name));
|
unescape(ent->name));
|
||||||
else if (ent->mode & 0100)
|
else if (ent->mode & 0100)
|
||||||
snprintf(g_buf, ncols, "%s%s*", CURSYM(sel),
|
snprintf(g_buf, ncols, "%s%s*", CURSYM(sel),
|
||||||
replace_escape(ent->name));
|
unescape(ent->name));
|
||||||
else
|
else
|
||||||
snprintf(g_buf, ncols, "%s%s", CURSYM(sel),
|
snprintf(g_buf, ncols, "%s%s", CURSYM(sel),
|
||||||
replace_escape(ent->name));
|
unescape(ent->name));
|
||||||
|
|
||||||
/* Dirs are always shown on top */
|
/* Dirs are always shown on top */
|
||||||
if (cfg.dircolor && !S_ISDIR(ent->mode)) {
|
if (cfg.dircolor && !S_ISDIR(ent->mode)) {
|
||||||
|
@ -1116,63 +1119,63 @@ printent_long(struct entry *ent, int sel)
|
||||||
if (!cfg.blkorder) {
|
if (!cfg.blkorder) {
|
||||||
if (S_ISDIR(ent->mode))
|
if (S_ISDIR(ent->mode))
|
||||||
snprintf(g_buf, ncols, "%s%-16.16s / %s/",
|
snprintf(g_buf, ncols, "%s%-16.16s / %s/",
|
||||||
CURSYM(sel), buf, replace_escape(ent->name));
|
CURSYM(sel), buf, unescape(ent->name));
|
||||||
else if (S_ISLNK(ent->mode))
|
else if (S_ISLNK(ent->mode))
|
||||||
snprintf(g_buf, ncols, "%s%-16.16s @ %s@",
|
snprintf(g_buf, ncols, "%s%-16.16s @ %s@",
|
||||||
CURSYM(sel), buf, replace_escape(ent->name));
|
CURSYM(sel), buf, unescape(ent->name));
|
||||||
else if (S_ISSOCK(ent->mode))
|
else if (S_ISSOCK(ent->mode))
|
||||||
snprintf(g_buf, ncols, "%s%-16.16s = %s=",
|
snprintf(g_buf, ncols, "%s%-16.16s = %s=",
|
||||||
CURSYM(sel), buf, replace_escape(ent->name));
|
CURSYM(sel), buf, unescape(ent->name));
|
||||||
else if (S_ISFIFO(ent->mode))
|
else if (S_ISFIFO(ent->mode))
|
||||||
snprintf(g_buf, ncols, "%s%-16.16s | %s|",
|
snprintf(g_buf, ncols, "%s%-16.16s | %s|",
|
||||||
CURSYM(sel), buf, replace_escape(ent->name));
|
CURSYM(sel), buf, unescape(ent->name));
|
||||||
else if (S_ISBLK(ent->mode))
|
else if (S_ISBLK(ent->mode))
|
||||||
snprintf(g_buf, ncols, "%s%-16.16s b %s",
|
snprintf(g_buf, ncols, "%s%-16.16s b %s",
|
||||||
CURSYM(sel), buf, replace_escape(ent->name));
|
CURSYM(sel), buf, unescape(ent->name));
|
||||||
else if (S_ISCHR(ent->mode))
|
else if (S_ISCHR(ent->mode))
|
||||||
snprintf(g_buf, ncols, "%s%-16.16s c %s",
|
snprintf(g_buf, ncols, "%s%-16.16s c %s",
|
||||||
CURSYM(sel), buf, replace_escape(ent->name));
|
CURSYM(sel), buf, unescape(ent->name));
|
||||||
else if (ent->mode & 0100)
|
else if (ent->mode & 0100)
|
||||||
snprintf(g_buf, ncols, "%s%-16.16s %8.8s* %s*",
|
snprintf(g_buf, ncols, "%s%-16.16s %8.8s* %s*",
|
||||||
CURSYM(sel), buf, coolsize(ent->size),
|
CURSYM(sel), buf, coolsize(ent->size),
|
||||||
replace_escape(ent->name));
|
unescape(ent->name));
|
||||||
else
|
else
|
||||||
snprintf(g_buf, ncols, "%s%-16.16s %8.8s %s",
|
snprintf(g_buf, ncols, "%s%-16.16s %8.8s %s",
|
||||||
CURSYM(sel), buf, coolsize(ent->size),
|
CURSYM(sel), buf, coolsize(ent->size),
|
||||||
replace_escape(ent->name));
|
unescape(ent->name));
|
||||||
} else {
|
} else {
|
||||||
if (S_ISDIR(ent->mode))
|
if (S_ISDIR(ent->mode))
|
||||||
snprintf(g_buf, ncols, "%s%-16.16s %8.8s/ %s/",
|
snprintf(g_buf, ncols, "%s%-16.16s %8.8s/ %s/",
|
||||||
CURSYM(sel), buf, coolsize(ent->blocks << 9),
|
CURSYM(sel), buf, coolsize(ent->blocks << 9),
|
||||||
replace_escape(ent->name));
|
unescape(ent->name));
|
||||||
else if (S_ISLNK(ent->mode))
|
else if (S_ISLNK(ent->mode))
|
||||||
snprintf(g_buf, ncols, "%s%-16.16s @ %s@",
|
snprintf(g_buf, ncols, "%s%-16.16s @ %s@",
|
||||||
CURSYM(sel), buf,
|
CURSYM(sel), buf,
|
||||||
replace_escape(ent->name));
|
unescape(ent->name));
|
||||||
else if (S_ISSOCK(ent->mode))
|
else if (S_ISSOCK(ent->mode))
|
||||||
snprintf(g_buf, ncols, "%s%-16.16s = %s=",
|
snprintf(g_buf, ncols, "%s%-16.16s = %s=",
|
||||||
CURSYM(sel), buf,
|
CURSYM(sel), buf,
|
||||||
replace_escape(ent->name));
|
unescape(ent->name));
|
||||||
else if (S_ISFIFO(ent->mode))
|
else if (S_ISFIFO(ent->mode))
|
||||||
snprintf(g_buf, ncols, "%s%-16.16s | %s|",
|
snprintf(g_buf, ncols, "%s%-16.16s | %s|",
|
||||||
CURSYM(sel), buf,
|
CURSYM(sel), buf,
|
||||||
replace_escape(ent->name));
|
unescape(ent->name));
|
||||||
else if (S_ISBLK(ent->mode))
|
else if (S_ISBLK(ent->mode))
|
||||||
snprintf(g_buf, ncols, "%s%-16.16s b %s",
|
snprintf(g_buf, ncols, "%s%-16.16s b %s",
|
||||||
CURSYM(sel), buf,
|
CURSYM(sel), buf,
|
||||||
replace_escape(ent->name));
|
unescape(ent->name));
|
||||||
else if (S_ISCHR(ent->mode))
|
else if (S_ISCHR(ent->mode))
|
||||||
snprintf(g_buf, ncols, "%s%-16.16s c %s",
|
snprintf(g_buf, ncols, "%s%-16.16s c %s",
|
||||||
CURSYM(sel), buf,
|
CURSYM(sel), buf,
|
||||||
replace_escape(ent->name));
|
unescape(ent->name));
|
||||||
else if (ent->mode & 0100)
|
else if (ent->mode & 0100)
|
||||||
snprintf(g_buf, ncols, "%s%-16.16s %8.8s* %s*",
|
snprintf(g_buf, ncols, "%s%-16.16s %8.8s* %s*",
|
||||||
CURSYM(sel), buf, coolsize(ent->blocks << 9),
|
CURSYM(sel), buf, coolsize(ent->blocks << 9),
|
||||||
replace_escape(ent->name));
|
unescape(ent->name));
|
||||||
else
|
else
|
||||||
snprintf(g_buf, ncols, "%s%-16.16s %8.8s %s",
|
snprintf(g_buf, ncols, "%s%-16.16s %8.8s %s",
|
||||||
CURSYM(sel), buf, coolsize(ent->blocks << 9),
|
CURSYM(sel), buf, coolsize(ent->blocks << 9),
|
||||||
replace_escape(ent->name));
|
unescape(ent->name));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Dirs are always shown on top */
|
/* Dirs are always shown on top */
|
||||||
|
@ -1341,13 +1344,11 @@ show_stats(char *fpath, char *fname, struct stat *sb)
|
||||||
|
|
||||||
if (len != -1) {
|
if (len != -1) {
|
||||||
g_buf[len] = '\0';
|
g_buf[len] = '\0';
|
||||||
dprintf(fd, " File: '%s' -> ",
|
dprintf(fd, " File: '%s' -> ", unescape(fname));
|
||||||
replace_escape(fname));
|
dprintf(fd, "'%s'", unescape(g_buf));
|
||||||
dprintf(fd, "'%s'",
|
|
||||||
replace_escape(g_buf));
|
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
dprintf(fd, " File: '%s'", replace_escape(fname));
|
dprintf(fd, " File: '%s'", unescape(fname));
|
||||||
|
|
||||||
/* Show size, blocks, file type */
|
/* Show size, blocks, file type */
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
@ -1590,7 +1591,8 @@ dentfill(char *path, struct entry **dents,
|
||||||
if (!cfg.blkorder)
|
if (!cfg.blkorder)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (fstatat(fd, dp->d_name, &sb, AT_SYMLINK_NOFOLLOW) == -1)
|
if (fstatat(fd, dp->d_name, &sb, AT_SYMLINK_NOFOLLOW)
|
||||||
|
== -1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (S_ISDIR(sb.st_mode)) {
|
if (S_ISDIR(sb.st_mode)) {
|
||||||
|
@ -1791,7 +1793,7 @@ redraw(char *path)
|
||||||
if (cfg.showdetail) {
|
if (cfg.showdetail) {
|
||||||
if (ndents) {
|
if (ndents) {
|
||||||
static char ind[2] = "\0\0";
|
static char ind[2] = "\0\0";
|
||||||
static char sort[17];
|
static char sort[9];
|
||||||
|
|
||||||
if (cfg.mtimeorder)
|
if (cfg.mtimeorder)
|
||||||
sprintf(sort, "by time ");
|
sprintf(sort, "by time ");
|
||||||
|
@ -1813,14 +1815,19 @@ redraw(char *path)
|
||||||
else
|
else
|
||||||
ind[0] = '\0';
|
ind[0] = '\0';
|
||||||
|
|
||||||
|
/* We need to show filename as it may
|
||||||
|
* be truncated in directory listing
|
||||||
|
*/
|
||||||
if (!cfg.blkorder)
|
if (!cfg.blkorder)
|
||||||
sprintf(g_buf, "total %d %s[%s%s]", ndents, sort,
|
sprintf(g_buf, "total %d %s[%s%s]", ndents,
|
||||||
replace_escape(dents[cur].name), ind);
|
sort, unescape(dents[cur].name), ind);
|
||||||
else {
|
else {
|
||||||
i = sprintf(g_buf, "du: %s (%lu files) ",
|
i = sprintf(g_buf, "du: %s (%lu files) ",
|
||||||
coolsize(dir_blocks << 9), num_files);
|
coolsize(dir_blocks << 9),
|
||||||
sprintf(g_buf + i, "vol: %s free [%s%s]", coolsize(fs_free),
|
num_files);
|
||||||
replace_escape(dents[cur].name), ind);
|
sprintf(g_buf + i, "vol: %s free [%s%s]",
|
||||||
|
coolsize(fs_free),
|
||||||
|
unescape(dents[cur].name), ind);
|
||||||
}
|
}
|
||||||
|
|
||||||
printmsg(g_buf);
|
printmsg(g_buf);
|
||||||
|
@ -1835,7 +1842,7 @@ browse(char *ipath, char *ifilter)
|
||||||
char path[PATH_MAX], oldpath[PATH_MAX], newpath[PATH_MAX];
|
char path[PATH_MAX], oldpath[PATH_MAX], newpath[PATH_MAX];
|
||||||
char lastdir[PATH_MAX];
|
char lastdir[PATH_MAX];
|
||||||
char fltr[LINE_MAX];
|
char fltr[LINE_MAX];
|
||||||
char *mime, *dir, *tmp, *run, *env;
|
char *dir, *tmp, *run, *env;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
int r, fd, presel;
|
int r, fd, presel;
|
||||||
enum action sel = SEL_RUNARG + 1;
|
enum action sel = SEL_RUNARG + 1;
|
||||||
|
@ -1957,10 +1964,9 @@ nochange:
|
||||||
* open text in EDITOR
|
* open text in EDITOR
|
||||||
*/
|
*/
|
||||||
if (editor) {
|
if (editor) {
|
||||||
mime = getmime(dents[cur].name);
|
if (getmime(dents[cur].name)) {
|
||||||
if (mime) {
|
|
||||||
spawn(editor, newpath, NULL,
|
spawn(editor, newpath, NULL,
|
||||||
NULL, SP_NORMAL);
|
NULL, F_NORMAL);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1974,13 +1980,13 @@ nochange:
|
||||||
|
|
||||||
if (strstr(g_buf, "text/") == g_buf) {
|
if (strstr(g_buf, "text/") == g_buf) {
|
||||||
spawn(editor, newpath, NULL,
|
spawn(editor, newpath, NULL,
|
||||||
NULL, SP_NORMAL);
|
NULL, F_NORMAL);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Invoke desktop opener as last resort */
|
/* Invoke desktop opener as last resort */
|
||||||
spawn(utils[0], newpath, NULL, NULL, SP_NOTRACE);
|
spawn(utils[0], newpath, NULL, NULL, F_NOTRACE);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -2004,7 +2010,7 @@ nochange:
|
||||||
printmsg("navigate-as-you-type off");
|
printmsg("navigate-as-you-type off");
|
||||||
goto nochange;
|
goto nochange;
|
||||||
case SEL_SEARCH:
|
case SEL_SEARCH:
|
||||||
spawn(player, path, "search", NULL, SP_NORMAL);
|
spawn(player, path, "search", NULL, F_NORMAL);
|
||||||
break;
|
break;
|
||||||
case SEL_NEXT:
|
case SEL_NEXT:
|
||||||
if (cur < ndents - 1)
|
if (cur < ndents - 1)
|
||||||
|
@ -2103,20 +2109,21 @@ nochange:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
--r;
|
/* Show a message if already at / */
|
||||||
|
if (path[0] == '/' && path[1] == '\0') {
|
||||||
|
printmsg("You are at /");
|
||||||
|
free(input);
|
||||||
|
goto nochange;
|
||||||
|
}
|
||||||
|
|
||||||
|
--r; /* One . for the current dir */
|
||||||
dir = path;
|
dir = path;
|
||||||
|
|
||||||
|
/* Note: fd is used as a tmp variable here */
|
||||||
for (fd = 0; fd < r; ++fd) {
|
for (fd = 0; fd < r; ++fd) {
|
||||||
/* Reached / ? */
|
/* Reached / ? */
|
||||||
if (path[0] == '/' && path[1] == '\0') {
|
if (path[0] == '/' && path[1] == '\0') {
|
||||||
/* If it's a cd .. at / */
|
/* Can't cd beyond / */
|
||||||
if (fd == 0) {
|
|
||||||
printmsg("You are at /");
|
|
||||||
free(input);
|
|
||||||
goto nochange;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Can't cd beyond / anyway */
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2241,45 +2248,43 @@ nochange:
|
||||||
case SEL_CDBM:
|
case SEL_CDBM:
|
||||||
printprompt("key: ");
|
printprompt("key: ");
|
||||||
tmp = readinput();
|
tmp = readinput();
|
||||||
if (tmp == NULL) {
|
|
||||||
clearprompt();
|
|
||||||
goto nochange;
|
|
||||||
}
|
|
||||||
|
|
||||||
clearprompt();
|
clearprompt();
|
||||||
|
if (tmp == NULL)
|
||||||
|
goto nochange;
|
||||||
|
|
||||||
for (r = 0; bookmark[r].key && r < MAX_BM; ++r) {
|
for (r = 0; bookmark[r].key && r < MAX_BM; ++r) {
|
||||||
if (xstrcmp(bookmark[r].key, tmp) == 0) {
|
if (xstrcmp(bookmark[r].key, tmp) == -1)
|
||||||
if (bookmark[r].loc[0] == '~') {
|
continue;
|
||||||
/* Expand ~ to HOME */
|
|
||||||
char *home = getenv("HOME");
|
|
||||||
|
|
||||||
if (home)
|
if (bookmark[r].loc[0] == '~') {
|
||||||
snprintf(newpath,
|
/* Expand ~ to HOME */
|
||||||
PATH_MAX,
|
char *home = getenv("HOME");
|
||||||
"%s%s",
|
|
||||||
home,
|
|
||||||
bookmark[r].loc
|
|
||||||
+ 1);
|
|
||||||
else {
|
|
||||||
printmsg("HOME not set");
|
|
||||||
goto nochange;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
mkpath(path, bookmark[r].loc,
|
|
||||||
newpath, PATH_MAX);
|
|
||||||
|
|
||||||
if (access(newpath, R_OK) == -1) {
|
if (home)
|
||||||
printwarn();
|
snprintf(newpath,
|
||||||
|
PATH_MAX,
|
||||||
|
"%s%s",
|
||||||
|
home,
|
||||||
|
bookmark[r].loc
|
||||||
|
+ 1);
|
||||||
|
else {
|
||||||
|
printmsg("HOME not set");
|
||||||
goto nochange;
|
goto nochange;
|
||||||
}
|
}
|
||||||
|
} else
|
||||||
|
mkpath(path, bookmark[r].loc,
|
||||||
|
newpath, PATH_MAX);
|
||||||
|
|
||||||
if (xstrcmp(path, newpath) == 0)
|
if (access(newpath, R_OK) == -1) {
|
||||||
break;
|
printwarn();
|
||||||
|
goto nochange;
|
||||||
oldpath[0] = '\0';
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (xstrcmp(path, newpath) == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
oldpath[0] = '\0';
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bookmark[r].key) {
|
if (!bookmark[r].key) {
|
||||||
|
@ -2367,7 +2372,8 @@ nochange:
|
||||||
goto nochange;
|
goto nochange;
|
||||||
}
|
}
|
||||||
|
|
||||||
spawn(desktop_manager, path, NULL, path, SP_NOTRACE | SP_NOWAIT);
|
spawn(desktop_manager, path, NULL, path,
|
||||||
|
F_NOTRACE | F_NOWAIT);
|
||||||
break;
|
break;
|
||||||
case SEL_FSIZE:
|
case SEL_FSIZE:
|
||||||
cfg.sizeorder ^= 1;
|
cfg.sizeorder ^= 1;
|
||||||
|
@ -2414,7 +2420,7 @@ nochange:
|
||||||
else
|
else
|
||||||
snprintf(newpath, PATH_MAX, "%s/%s",
|
snprintf(newpath, PATH_MAX, "%s/%s",
|
||||||
path, dents[cur].name);
|
path, dents[cur].name);
|
||||||
spawn(copier, newpath, NULL, NULL, SP_NONE);
|
spawn(copier, newpath, NULL, NULL, F_NONE);
|
||||||
printmsg(newpath);
|
printmsg(newpath);
|
||||||
} else if (!copier)
|
} else if (!copier)
|
||||||
printmsg("NNN_COPIER is not set");
|
printmsg("NNN_COPIER is not set");
|
||||||
|
@ -2424,18 +2430,19 @@ nochange:
|
||||||
break;
|
break;
|
||||||
case SEL_RUN:
|
case SEL_RUN:
|
||||||
run = xgetenv(env, run);
|
run = xgetenv(env, run);
|
||||||
spawn(run, NULL, NULL, path, SP_NORMAL | SP_MARKER);
|
spawn(run, NULL, NULL, path, F_NORMAL | F_MARKER);
|
||||||
/* Repopulate as directory content may have changed */
|
/* Repopulate as directory content may have changed */
|
||||||
goto begin;
|
goto begin;
|
||||||
case SEL_RUNARG:
|
case SEL_RUNARG:
|
||||||
run = xgetenv(env, run);
|
run = xgetenv(env, run);
|
||||||
spawn(run, dents[cur].name, NULL, path, SP_NORMAL);
|
spawn(run, dents[cur].name, NULL, path, F_NORMAL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Screensaver */
|
/* Screensaver */
|
||||||
if (idletimeout != 0 && idle == idletimeout) {
|
if (idletimeout != 0 && idle == idletimeout) {
|
||||||
idle = 0;
|
idle = 0;
|
||||||
spawn(player, "", "screensaver", NULL, SP_NORMAL | SP_SIGINT);
|
spawn(player, "", "screensaver", NULL,
|
||||||
|
F_NORMAL | F_SIGINT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2475,7 +2482,7 @@ main(int argc, char *argv[])
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "dlSinp:vh")) != -1) {
|
while ((opt = getopt(argc, argv, "lSinp:vh")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'S':
|
case 'S':
|
||||||
cfg.blkorder = 1;
|
cfg.blkorder = 1;
|
||||||
|
@ -2496,9 +2503,6 @@ main(int argc, char *argv[])
|
||||||
case 'v':
|
case 'v':
|
||||||
printf("%s\n", VERSION);
|
printf("%s\n", VERSION);
|
||||||
return 0;
|
return 0;
|
||||||
case 'd':
|
|
||||||
fprintf(stderr, "Option -d is deprecated and will be removed, detail view mode is default now.\n");
|
|
||||||
break;
|
|
||||||
case 'h': // fallthrough
|
case 'h': // fallthrough
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
|
|
Loading…
Reference in a new issue