File: showkey.c

package info (click to toggle)
newt 0.52.14-11.1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 1,548 kB
  • sloc: ansic: 9,098; python: 708; makefile: 235; sh: 14
file content (41 lines) | stat: -rw-r--r-- 670 bytes parent folder | download | duplicates (11)
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) {
    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: %s", 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();
    return 0;
}