summary refs log tree commit diff
path: root/Src/Modules/curses_keys.awk
blob: 25bd63c7e66be6b6b33804ff8327aad073006f94 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
BEGIN {nkeydefs = 0}

/^[\t ]*#[\t ]*define[\t _]*KEY_[A-Z0-9_]*[\t ]/ {
    keyindex = index($0, "KEY_")
    keytail = substr($0, keyindex, 80)
    split(keytail, tmp)
    keynam = substr(tmp[1], 5, 30)
    if (keynam != "MIN" && keynam != "MAX" && keynam != "CODE_YES") {
	name[nkeydefs++] = keynam
    }
}

END {
    printf("static const struct zcurses_namenumberpair keypad_names[] = {\n")
    for (i = 0; i < 0 + nkeydefs; i++) {
        if (name[i] == "EVENT")
            printf("#ifdef KEY_EVENT\n")
        printf("    {\"%s\", KEY_%s},\n", name[i], name[i])
        if (name[i] == "EVENT")
            printf("#endif\n")
    }
    printf("    {NULL, 0}\n")
    printf("};\n")
}