From 3cbb7dc5dfcbd79b672859959f3e6c6f264df0ec Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Thu, 3 Jan 2019 23:43:04 +0530 Subject: nnn as a file picker --- src/nnn.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nnn.c b/src/nnn.c index c018c46..45f6c23 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -780,13 +780,18 @@ static bool showcplist() /* Initialize curses mode */ static bool initcurses(void) { - if (initscr() == NULL) { + if (cfg.picker) { + if (!newterm(NULL, stderr, stdin)) { + fprintf(stderr, "newterm!\n"); + return FALSE; + } + } else if (!initscr()) { char *term = getenv("TERM"); if (term != NULL) fprintf(stderr, "error opening TERM: %s\n", term); else - fprintf(stderr, "initscr() failed\n"); + fprintf(stderr, "initscr!\n"); return FALSE; } @@ -3592,8 +3597,8 @@ int main(int argc, char *argv[]) } /* Confirm we are in a terminal */ - if (!isatty(0) || !isatty(1)) { - fprintf(stderr, "stdin or stdout is not a tty\n"); + if (!cfg.picker && !(isatty(0) && isatty(1))) { + fprintf(stderr, "stdin/stdout !tty\n"); return 1; } -- cgit v1.2.3-70-g09d2