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 42 43 44 45 46 47 48
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <keymap.h>
#include "libcommon.h"
int
main(int argc KBD_ATTR_UNUSED, char **argv KBD_ATTR_UNUSED)
{
const char *stringvalues[30] = {
/* F1 .. F20 */
"\033[[A", "\033[[B", "\033[[C", "\033[[D", "\033[[E",
"\033[17~", "\033[18~", "\033[19~", "\033[20~", "\033[21~",
"\033[23~", "\033[24~", "\033[25~", "\033[26~",
"\033[28~", "\033[29~",
"\033[31~", "\033[32~", "\033[33~", "\033[34~",
/* Find, Insert, Remove, Select, Prior */
"\033[1~", "\033[2~", "\033[3~", "\033[4~", "\033[5~",
/* Next, Macro, Help, Do, Pause */
"\033[6~", NULL, NULL, NULL, NULL
};
unsigned int i;
struct lk_ctx *ctx;
ctx = lk_init();
lk_set_log_fn(ctx, NULL, NULL);
for (i = 0; i < 30; i++) {
struct kbsentry ke;
if (!(stringvalues[i]))
continue;
strncpy((char *)ke.kb_string, stringvalues[i],
sizeof(ke.kb_string));
ke.kb_string[sizeof(ke.kb_string) - 1] = 0;
ke.kb_func = (unsigned char) i;
if (lk_add_func(ctx, &ke) == -1)
kbd_error(EXIT_FAILURE, 0, "Unable to add function");
}
lk_free(ctx);
return EXIT_SUCCESS;
}
|