Conversation
There are two issues related when dumping a keymap in text format: - These is a conflict between skipping the keymaps in `lk_dump_keymaps` and forcing all keymaps in `lk_dump_keys`. Fixed by always including all defined keymaps, independently of the `LK_KEYWORD_ALTISMETA` flag. - The function `lk_add_constants` is not called, so implicit mappings such as `Ctrl + q = Control_q` are not set. Fixed by properly calling `lk_add_constants` before each call of `lk_dump_keymap`. `lk_add_constants` is not added to `lk_dump_keymap`, since it modifies the keymap. Note that since it is easy to forget to call `lk_add_constants`, a better fix could be to call `lk_add_constants` just before returning from `lk_parse_keymap`. Signed-off-by: Pierre Le Marre <dev@wismill.eu> Signed-off-by: Alexey Gladkov <legion@kernel.org>
It is necessary to output keymaps only if there is a range. Otherwise, a syntactically incorrect keymap will be output. Before: $ src/loadkeys --tkeymap - < /dev/null keymaps $ After: $ src/loadkeys --tkeymap - < /dev/null $ Signed-off-by: Alexey Gladkov <legion@kernel.org>
The lk_dump_bkeymap() and lk_dump_ctable() add implicit mappings by calling lk_add_constants(). The lk_dump_keymap() does not do this. To improve consistency let's add an additional function that does the same way. Signed-off-by: Alexey Gladkov <legion@kernel.org>
|
@dmage could you take a look and tell me what you think? |
src/libkeymap/dump.c
Outdated
| @@ -496,7 +494,8 @@ void lk_dump_keys(struct lk_ctx *ctx, FILE *fd, lk_table_shape table, char numer | |||
| if (table == LK_SHAPE_SEPARATE_LINES) { | |||
| for (j = 0; j < keymapnr; j++) { | |||
| //if (buf[j] != K_HOLE) | |||
There was a problem hiding this comment.
The time to remove this comment has come
| kw = i = n = m = s = 0; | ||
|
|
||
| for (i = 0; i < ctx->keymap->total; i++) { | ||
| if (ctx->keywords & LK_KEYWORD_ALTISMETA && i == (i | M_ALT)) |
There was a problem hiding this comment.
This code skipped (did not output) those keymaps that were ALT variants (i | M_ALT) if the ALTISMETA flag was set. That is, if alt_is_meta was active, ALT tables were not explicitly output, implying that they were automatically restored if alt_is_meta is specified. But dump_keymaps does not restore alt_is_meta itself.
Now the keymap dump always fully reflects all real tables, without the "magic" of silencing ALT tables. This makes the dump more transparent and unambiguous.
dmage
left a comment
There was a problem hiding this comment.
lgtm, though I don't understand the part related to alt_is_meta
Signed-off-by: Alexey Gladkov <legion@kernel.org>
|
I've noticed that if the original keymap specifies |
Signed-off-by: Alexey Gladkov <legion@kernel.org>
Signed-off-by: Alexey Gladkov <legion@kernel.org>
ad9699f to
1eaff68
Compare
This is an adaptation of the #136 with additional changes.