print the selected date to stdout on exit

Doesn't quite work yet in the presence of redirects. For some reason the
highlights disappear.
This commit is contained in:
Kartik K. Agaram 2022-02-17 14:43:52 -08:00
parent 8458d95e8f
commit 6398f526d8
1 changed files with 7 additions and 2 deletions

9
ncal.c
View File

@ -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);
}