]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/keynames.c
ncurses 5.5
[ncurses.git] / test / keynames.c
index 88cadd2f8a840dcfc6ad22423ad62b38ac5c932d..7dd944e621367046927164772b05b1ee28cd19cf 100644 (file)
@@ -1,14 +1,27 @@
 /*
 /*
- * $Id: keynames.c,v 1.2 1998/06/06 22:45:13 tom Exp $
+ * $Id: keynames.c,v 1.7 2005/04/30 20:13:59 tom Exp $
  */
 
 #include <test.priv.h>
 
  */
 
 #include <test.priv.h>
 
-int main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED)
+int
+main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
 {
 {
-       int n;
-       for (n = -1; n < 512; n++) {
-               printf("%d(%5o):%s\n", n, n, keyname(n));
-       }
-       return EXIT_SUCCESS;
+    int n;
+
+    /*
+     * 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);
+    endwin();
+
+    for (n = -1; n < KEY_MAX + 512; n++) {
+       const char *result = keyname(n);
+       if (result != 0)
+           printf("%d(%5o):%s\n", n, n, result);
+    }
+    ExitProgram(EXIT_SUCCESS);
 }
 }