X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Fkey_names.c;h=ba45656d50a8ddac0e43f0341b099e2b96a0035d;hp=dea60eb807a224b50f01b671c49204060062c63a;hb=c04d54322f7835ed42e597967d8fa5471025fcac;hpb=4ae6d1c18d0dec956b814865893812655ec3a22c diff --git a/test/key_names.c b/test/key_names.c index dea60eb8..ba45656d 100644 --- a/test/key_names.c +++ b/test/key_names.c @@ -26,20 +26,57 @@ * authorization. * ****************************************************************************/ /* - * $Id: key_names.c,v 1.3 2008/02/09 18:09:18 tom Exp $ + * $Id: key_names.c,v 1.4 2008/10/11 20:22:37 tom Exp $ */ #include #if USE_WIDEC_SUPPORT +static void +usage(void) +{ + fprintf(stderr, "Usage: key_names [-m] [-s]\n"); + ExitProgram(EXIT_FAILURE); +} + int -main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) +main(int argc, char *argv[]) { int n; + bool do_setup = FALSE; + bool do_meta = FALSE; + setlocale(LC_ALL, ""); - for (n = KEY_MIN; n < KEY_MAX + 512; n++) { + + while ((n = getopt(argc, argv, "ms")) != -1) { + switch (n) { + case 'm': + do_meta = TRUE; + break; + case 's': + do_setup = TRUE; + break; + default: + usage(); + /* NOTREACHED */ + } + } + + if (do_setup) { + /* + * Get the terminfo entry into memory, and tell ncurses that we want to + * use function keys. That will make it add any user-defined keys that + * appear in the terminfo. + */ + newterm(getenv("TERM"), stderr, stdin); + keypad(stdscr, TRUE); + if (do_meta) + meta(stdscr, TRUE); + endwin(); + } + for (n = -1; n < KEY_MAX + 512; n++) { const char *result = key_name(n); if (result != 0) printf("%d(%5o):%s\n", n, n, result);