mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 13:51:31 +00:00
Change single-line 0-arg APIs to macros
This commit is contained in:
parent
9a4c446760
commit
7b6e3c261d
33
nnn.c
33
nnn.c
|
@ -119,6 +119,10 @@ disabledbg()
|
||||||
#define F_SIGINT 0x08 /* restore default SIGINT handler */
|
#define F_SIGINT 0x08 /* restore default SIGINT handler */
|
||||||
#define F_NORMAL 0x80 /* spawn child process in non-curses regular mode */
|
#define F_NORMAL 0x80 /* spawn child process in non-curses regular mode */
|
||||||
|
|
||||||
|
#define exitcurses() endwin()
|
||||||
|
#define clearprompt() printmsg("")
|
||||||
|
#define printwarn() printmsg(strerror(errno))
|
||||||
|
|
||||||
typedef unsigned long ulong;
|
typedef unsigned long ulong;
|
||||||
typedef unsigned int uint;
|
typedef unsigned int uint;
|
||||||
typedef unsigned char uchar;
|
typedef unsigned char uchar;
|
||||||
|
@ -222,7 +226,6 @@ static char *STR_NOHOME = "HOME not set";
|
||||||
|
|
||||||
/* Forward declarations */
|
/* Forward declarations */
|
||||||
static void printmsg(char *);
|
static void printmsg(char *);
|
||||||
static void printwarn(void);
|
|
||||||
static void printerr(int, char *);
|
static void printerr(int, char *);
|
||||||
static void redraw(char *path);
|
static void redraw(char *path);
|
||||||
|
|
||||||
|
@ -489,7 +492,7 @@ spawn(char *file, char *arg1, char *arg2, char *dir, uchar flag)
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
if (flag & F_NORMAL)
|
if (flag & F_NORMAL)
|
||||||
endwin();
|
exitcurses();
|
||||||
|
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
|
@ -704,29 +707,15 @@ printmsg(char *msg)
|
||||||
mvprintw(LINES - 1, 0, "%s\n", msg);
|
mvprintw(LINES - 1, 0, "%s\n", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Display warning as a message */
|
|
||||||
static void
|
|
||||||
printwarn(void)
|
|
||||||
{
|
|
||||||
printmsg(strerror(errno));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Kill curses and display error before exiting */
|
/* Kill curses and display error before exiting */
|
||||||
static void
|
static void
|
||||||
printerr(int ret, char *prefix)
|
printerr(int ret, char *prefix)
|
||||||
{
|
{
|
||||||
endwin();
|
exitcurses();
|
||||||
fprintf(stderr, "%s: %s\n", prefix, strerror(errno));
|
fprintf(stderr, "%s: %s\n", prefix, strerror(errno));
|
||||||
exit(ret);
|
exit(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear the last line */
|
|
||||||
static void
|
|
||||||
clearprompt(void)
|
|
||||||
{
|
|
||||||
printmsg("");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Print prompt on the last line */
|
/* Print prompt on the last line */
|
||||||
static void
|
static void
|
||||||
printprompt(char *str)
|
printprompt(char *str)
|
||||||
|
@ -1428,7 +1417,7 @@ show_stats(char *fpath, char *fname, struct stat *sb)
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
endwin();
|
exitcurses();
|
||||||
get_output(NULL, 0, "cat", tmp, NULL, 1);
|
get_output(NULL, 0, "cat", tmp, NULL, 1);
|
||||||
unlink(tmp);
|
unlink(tmp);
|
||||||
initcurses();
|
initcurses();
|
||||||
|
@ -1441,7 +1430,7 @@ show_mediainfo(char *fpath, char *arg)
|
||||||
if (!get_output(g_buf, MAX_CMD_LEN, "which", metaviewer, NULL, 0))
|
if (!get_output(g_buf, MAX_CMD_LEN, "which", metaviewer, NULL, 0))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
endwin();
|
exitcurses();
|
||||||
get_output(NULL, 0, metaviewer, fpath, arg, 1);
|
get_output(NULL, 0, metaviewer, fpath, arg, 1);
|
||||||
initcurses();
|
initcurses();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1521,7 +1510,7 @@ Home, g, ^, ^A | Jump to first entry\n\
|
||||||
dprintf(fd, "\n");
|
dprintf(fd, "\n");
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
endwin();
|
exitcurses();
|
||||||
get_output(NULL, 0, "cat", tmp, NULL, 1);
|
get_output(NULL, 0, "cat", tmp, NULL, 1);
|
||||||
unlink(tmp);
|
unlink(tmp);
|
||||||
initcurses();
|
initcurses();
|
||||||
|
@ -2071,7 +2060,7 @@ nochange:
|
||||||
goto nochange;
|
goto nochange;
|
||||||
}
|
}
|
||||||
|
|
||||||
endwin();
|
exitcurses();
|
||||||
tmp = readline("chdir: ");
|
tmp = readline("chdir: ");
|
||||||
initcurses();
|
initcurses();
|
||||||
|
|
||||||
|
@ -2572,7 +2561,7 @@ main(int argc, char *argv[])
|
||||||
#endif
|
#endif
|
||||||
initcurses();
|
initcurses();
|
||||||
browse(ipath, ifilter);
|
browse(ipath, ifilter);
|
||||||
endwin();
|
exitcurses();
|
||||||
#ifdef DEBUGMODE
|
#ifdef DEBUGMODE
|
||||||
disabledbg();
|
disabledbg();
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue