From: Alexey Gladkov Date: Tue, 18 Jun 2013 19:11:33 +0000 (+0400) Subject: Create lk_table_shape flag X-Git-Tag: 2.0.2~41^2~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5fecc437ae1a1a0959487b21bfd4c1cdb8ab60ee;p=platform%2Fupstream%2Fkbd.git Create lk_table_shape flag Signed-off-by: Alexey Gladkov --- diff --git a/src/dumpkeys.c b/src/dumpkeys.c index 3c8c748..98b35b5 100644 --- a/src/dumpkeys.c +++ b/src/dumpkeys.c @@ -75,7 +75,7 @@ main (int argc, char *argv[]) { char long_info = 0; char short_info = 0; char numeric = 0; - char table_shape = 0; + lk_table_shape table = LK_SHAPE_DEFAULT; char funcs_only = 0; char keys_only = 0; char diac_only = 0; @@ -104,13 +104,13 @@ main (int argc, char *argv[]) { numeric = 1; break; case 'f': - table_shape = FULL_TABLE; + table = LK_SHAPE_FULL_TABLE; break; case '1': - table_shape = SEPARATE_LINES; + table = LK_SHAPE_SEPARATE_LINES; break; case 'S': - table_shape = atoi(optarg); + table = atoi(optarg); break; case 't': funcs_only = 1; @@ -174,7 +174,7 @@ main (int argc, char *argv[]) { if (!diac_only) { #endif if (!funcs_only) { - lk_dump_keymap(&ctx, stdout, table_shape, numeric); + lk_dump_keymap(&ctx, stdout, table, numeric); } #ifdef KDGKBDIACR } diff --git a/src/libkeymap/dump.c b/src/libkeymap/dump.c index dd803bd..2674211 100644 --- a/src/libkeymap/dump.c +++ b/src/libkeymap/dump.c @@ -394,7 +394,7 @@ print_bind(struct lk_ctx *ctx, FILE *fd, int bufj, int i, int j, char numeric) } void -lk_dump_keys(struct lk_ctx *ctx, FILE *fd, char table_shape, char numeric) +lk_dump_keys(struct lk_ctx *ctx, FILE *fd, lk_table_shape table, char numeric) { unsigned int i, j; int buf[MAX_NR_KEYMAPS]; @@ -408,7 +408,7 @@ lk_dump_keys(struct lk_ctx *ctx, FILE *fd, char table_shape, char numeric) if (!keymapnr) return; - if (table_shape == FULL_TABLE || table_shape == SEPARATE_LINES) + if (table == LK_SHAPE_FULL_TABLE || table == LK_SHAPE_SEPARATE_LINES) goto no_shorthands; /* first pass: determine whether to set alt_is_meta */ @@ -457,10 +457,10 @@ no_shorthands: all_holes = 0; } - if (all_holes && table_shape != FULL_TABLE) + if (all_holes && table != LK_SHAPE_FULL_TABLE) continue; - if (table_shape == FULL_TABLE) { + if (table == LK_SHAPE_FULL_TABLE) { fprintf(fd, "keycode %3d =", i); for (j = 0; j < keymapnr; j++) @@ -470,7 +470,7 @@ no_shorthands: continue; } - if (table_shape == SEPARATE_LINES) { + if (table == LK_SHAPE_SEPARATE_LINES) { for (j = 0; j < keymapnr; j++) { //if (buf[j] != K_HOLE) print_bind(ctx, fd, buf[j], i, j, numeric); @@ -568,7 +568,7 @@ unexpected: } else { for (j = 0; j < keymapnr && buf[j] != K_HOLE && - (table_shape != UNTIL_HOLE || lk_map_exist(ctx, j)); + (table != LK_SHAPE_UNTIL_HOLE || lk_map_exist(ctx, j)); j++) { //print_bind(ctx, fd, buf[j], i, j, numeric); print_keysym(ctx, fd, buf[j], numeric); @@ -586,9 +586,9 @@ unexpected: } void -lk_dump_keymap(struct lk_ctx *ctx, FILE *fd, char table_shape, char numeric) +lk_dump_keymap(struct lk_ctx *ctx, FILE *fd, lk_table_shape table, char numeric) { lk_dump_keymaps(ctx, fd); - lk_dump_keys(ctx, fd, table_shape, numeric); + lk_dump_keys(ctx, fd, table, numeric); lk_dump_funcs(ctx, fd); } diff --git a/src/libkeymap/keymap/dump.h b/src/libkeymap/keymap/dump.h index 7348a23..b1c4951 100644 --- a/src/libkeymap/keymap/dump.h +++ b/src/libkeymap/keymap/dump.h @@ -5,21 +5,22 @@ #include +typedef enum { + LK_SHAPE_DEFAULT = (1 << 1), + LK_SHAPE_FULL_TABLE = (1 << 2), /* one line for each keycode */ + LK_SHAPE_SEPARATE_LINES = (1 << 3), /* one line for each (modifier,keycode) pair */ + LK_SHAPE_UNTIL_HOLE = (1 << 4) /* one line for each keycode, until 1st hole */ +} lk_table_shape; + int lk_dump_bkeymap(struct lk_ctx *ctx, FILE *fd); int lk_dump_ctable(struct lk_ctx *ctx, FILE *fd); -void lk_dump_keymap(struct lk_ctx *ctx, FILE *fd, char table_shape, char numeric); +void lk_dump_keymap(struct lk_ctx *ctx, FILE *fd, lk_table_shape table, char numeric); +void lk_dump_keys(struct lk_ctx *ctx, FILE *fd, lk_table_shape table, char numeric); void lk_dump_keymaps(struct lk_ctx *ctx, FILE *fd); void lk_dump_funcs(struct lk_ctx *ctx, FILE *fd); void lk_dump_diacs(struct lk_ctx *ctx, FILE *fd); -#define DEFAULT 0 -#define FULL_TABLE 1 /* one line for each keycode */ -#define SEPARATE_LINES 2 /* one line for each (modifier,keycode) pair */ -#define UNTIL_HOLE 3 /* one line for each keycode, until 1st hole */ - -void lk_dump_keys(struct lk_ctx *ctx, FILE *fd, char table_shape, char numeric); - void lk_dump_summary(struct lk_ctx *ctx, FILE *fd, int console); void lk_dump_symbols(FILE *fd); diff --git a/tests/libkeymap-dumpkeys.c b/tests/libkeymap-dumpkeys.c index 6e080e9..330c1f6 100644 --- a/tests/libkeymap-dumpkeys.c +++ b/tests/libkeymap-dumpkeys.c @@ -5,7 +5,8 @@ int main(int argc, char **argv) { - char table_shape, numeric; + lk_table_shape table; + char numeric; struct lk_ctx ctx; lkfile_t f; @@ -14,10 +15,10 @@ int main(int argc, char **argv) return 1; } - if (!strcasecmp(argv[2], "FULL_TABLE")) table_shape = FULL_TABLE; - else if (!strcasecmp(argv[2], "SEPARATE_LINES")) table_shape = SEPARATE_LINES; - else if (!strcasecmp(argv[2], "UNTIL_HOLE")) table_shape = UNTIL_HOLE; - else table_shape = DEFAULT; + if (!strcasecmp(argv[2], "FULL_TABLE")) table = LK_SHAPE_FULL_TABLE; + else if (!strcasecmp(argv[2], "SEPARATE_LINES")) table = LK_SHAPE_SEPARATE_LINES; + else if (!strcasecmp(argv[2], "UNTIL_HOLE")) table = LK_SHAPE_UNTIL_HOLE; + else table = LK_SHAPE_DEFAULT; numeric = (!strcasecmp(argv[3], "TRUE")) ? 1 : 0; @@ -29,7 +30,7 @@ int main(int argc, char **argv) f.fd = fopen( argv[1], "r"); lk_parse_keymap(&ctx, &f); - lk_dump_keymap(&ctx, stdout, table_shape, numeric); + lk_dump_keymap(&ctx, stdout, table, numeric); lk_dump_diacs(&ctx, stdout); lk_free(&ctx);