Merge pull request #2432 from keymanapp/feat/developer/138-hotkey-statement-bare-virtual-keys

fix(developer): Allow unquoted hotkeys in hotkey statement.
This commit is contained in:
Marc Durdin 2019-12-09 09:12:26 +00:00 • committed by GitHub
commit 7cd8bc54c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 3 deletions

View file

@ -3,6 +3,7 @@
## 13.0 alpha
* Start version 13.0
* Feature: Add unsupported kmdecomp decompiler utility (#2419)
* Feature: Hotkeys defined in .kmn no longer need to be quoted (#2432)
* Bug Fix: Keyboard ID was not clean by default with Import Windows Keyboard (#2431)
## 2019-11-18 12.0.55 stable

View file

@ -2792,6 +2792,8 @@ DWORD ProcessEthnologueStore(PWSTR p) // I2646
return res;
}
#define K_HOTKEYSHIFTFLAGS (K_SHIFTFLAG | K_CTRLFLAG | K_ALTFLAG | ISVIRTUALKEY)
DWORD ProcessHotKey(PWSTR p, DWORD *hk)
{
PWSTR q, r;
@ -2800,6 +2802,25 @@ DWORD ProcessHotKey(PWSTR p, DWORD *hk)
*hk = 0;
if(*p == UC_SENTINEL && *(p+1) == CODE_EXTENDED) {
WORD Key = *(p + 3);
WORD ShiftFlags = *(p + 2);
// Convert virtual key to hotkey (different bitflags)
if (ShiftFlags & ~K_HOTKEYSHIFTFLAGS) {
AddWarning(CWARN_HotkeyHasInvalidModifier);
}
if (ShiftFlags & K_SHIFTFLAG) *hk |= HK_SHIFT;
if (ShiftFlags & K_CTRLFLAG) *hk |= HK_CTRL;
if (ShiftFlags & K_ALTFLAG) *hk |= HK_ALT;
*hk |= Key;
return CERR_None;
}
q = wcschr(p, '[');
if(q)
{

View file

@ -222,5 +222,6 @@ END
STRINGTABLE
BEGIN
CWARN_LanguageHeadersDeprecatedInKeyman10 "This language header has been deprecated in Keyman 10. Instead, add language metadata in the package file"
CWARN_HotkeyHasInvalidModifier "Hotkey has modifiers that are not supported. Use only SHIFT, CTRL and ALT"
CINFO_NonUnicodeFile "Keyman Developer has detected that the file has ANSI encoding. Consider converting this file to UTF-8"
END

View file

@ -37,9 +37,8 @@ int main(int argc, char *argv[])
if(argc < 3)
{
puts("Usage: kcframe infile.kmn outfile.kmx");
return 0;
return 1;
}
CompileKeyboardFile(argv[1], argv[2], TRUE, FALSE, TRUE, msgproc); // I4865 // I4866
return 1;
return CompileKeyboardFile(argv[1], argv[2], TRUE, FALSE, TRUE, msgproc) ? 0 : 1; // I4865 // I4866
}

View file

@ -189,6 +189,8 @@
#define CWARN_TooManyErrorsOrWarnings 0x000020A7
#define CWARN_HotkeyHasInvalidModifier 0x000020A8
#define CERR_BufferOverflow 0x000080C0
#define CERR_Break 0x000080C1