From 6398f526d871838ae205cbd3d2ebf9be2a113f4a Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 17 Feb 2022 14:43:52 -0800 Subject: [PATCH] print the selected date to stdout on exit Doesn't quite work yet in the presence of redirects. For some reason the highlights disappear. --- ncal.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ncal.c b/ncal.c index d186d45..6bf619a 100644 --- a/ncal.c +++ b/ncal.c @@ -563,7 +563,9 @@ main(int argc, char *argv[]) printeaster(y, flag_julian_cal, flag_orthodox); else { int key; - initscr(); + FILE *f = fopen("/dev/tty", "r+"); + SCREEN *screen = newterm(NULL, f, f); + set_term(screen); noecho(); curs_set(0); keypad(stdscr, 1); @@ -579,9 +581,12 @@ main(int argc, char *argv[]) mvprintw(30, 60, "%d %d", key, highlightdate); processkeyr(key, y, m, flag_julian_day, before, after, &highlightdate); } - } while (key != 'q'); + } while (key != /*enter*/10); endwin(); } + struct date result; + sdateb(highlightdate, &result); + printf("%d/%02d/%02d\n", result.y, result.m, result.d); return (0); }