File: showkey.c

package info (click to toggle)
newt 0.21-8
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 296 kB
  • ctags: 753
  • sloc: ansic: 4,813; python: 312; makefile: 179; sh: 2
file content (41 lines) | stat: -rw-r--r-- 670 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <stdio.h>
#include <slang.h>

int main(void) {
    char n = 0;
    int i;
    char * buf;

    SLtt_get_terminfo();
    SLang_init_tty(4, 0, 0);

    buf = SLtt_tgetstr("ku");
    if (!buf) {
	printf("termcap entry not found for kl\n\r");
    } else {
	printf("termcap entry found for kl: ", buf);
	while (*buf) {
	    printf("0x%02x ", *buf++);
	}
	printf("\n\r");
    }

    printf("\n\r");

    printf("Press a key: ");
    fflush(stdout);
   
    SLang_input_pending(50);

    printf("\n\r");
    printf("You pressed: ");

    while (SLang_input_pending(1)) {
	i = SLang_getkey();
	printf("0x%02x ", i);
    }

    printf("\n\r");

    SLang_reset_tty();
}