00001
00002
00003
00004
00005 #include <stdio.h>
00006 #include <slang.h>
00007
00008 #include "demolib.c"
00009
00010 #define TIMEOUT 2
00011
00012 static int getch (void)
00013 {
00014 int ch;
00015
00016 while (0 == SLang_input_pending (1000))
00017 continue;
00018
00019 ch = SLang_getkey ();
00020
00021 if (ch == 033)
00022 {
00023 if (0 == SLang_input_pending (TIMEOUT))
00024 return 033;
00025 }
00026
00027 SLang_ungetkey (ch);
00028
00029 return SLkp_getkey ();
00030 }
00031
00032
00033 int main (int argc, char **argv)
00034 {
00035 int ch;
00036
00037 (void) argc; (void) argv;
00038
00039 if (-1 == demolib_init_terminal (1, 0))
00040 return 1;
00041
00042 fprintf (stderr, "This program illustrates the slkeypad facility.\n");
00043 fprintf (stderr, "Press any key ('q' quits).\n");
00044 while ('q' != (ch = getch ()))
00045 {
00046 fprintf (stderr, "Keysym: %d\r\n", ch);
00047 }
00048
00049 demolib_exit (0);
00050
00051 return 0;
00052 }