Skip to content

Commit

Permalink
Add the “S-” prefix to msymbols for non-ASCII characters only if the …
Browse files Browse the repository at this point in the history
…character “is not graph”

“is not graph” is the same as “is space or is not printable”.

Resolves: #90
  • Loading branch information
mike-fabian committed Nov 7, 2024
1 parent d1cbe91 commit c902a65
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -675,8 +675,23 @@ ibus_m17n_key_event_to_symbol (IBusM17NEngine *m17n,
g_string_free (keysym, TRUE);
return Mnil;
}
mask |= modifiers & (IBUS_CONTROL_MASK | IBUS_SHIFT_MASK);
g_string_append (keysym, name);
mask |= modifiers & IBUS_CONTROL_MASK;
if (modifiers & IBUS_SHIFT_MASK) {
const gunichar unicode = ibus_keyval_to_unicode (keyval);
if (!g_unichar_isgraph(unicode)) {
/*
https://github.com/ibus/ibus-m17n/issues/90
Add IBUS_SHIFT_MASK only if the unicode character is not “graph”,
that means it is either a space or not printable.
Do not add it for other characters, for example if Shift+ü has
been typed, the keysym is “Udiaeresis” and the Shift has been
absorbed in the uppercase, adding IBUS_SHIFT_MASK would result
in the msymbol “S-Udiaeresis”, which would be wrong.
*/
mask |= IBUS_SHIFT_MASK;
}
}
}

mask |= modifiers & (IBUS_MOD1_MASK |
Expand Down Expand Up @@ -707,7 +722,6 @@ ibus_m17n_key_event_to_symbol (IBusM17NEngine *m17n,
if (mask & IBUS_SHIFT_MASK) {
g_string_prepend (keysym, "S-");
}

mkeysym = msymbol (keysym->str);
g_string_free (keysym, TRUE);

Expand Down

0 comments on commit c902a65

Please sign in to comment.