From c7b1dd376c4032069215a9a4ab92d4c688a0794f Mon Sep 17 00:00:00 2001 From: cxl Date: Mon, 17 Nov 2014 16:07:51 +0000 Subject: [PATCH] CtrlCore: Added keys constants for the rest of keyboard (thanks Koldo) #925 git-svn-id: svn://ultimatepp.org/upp/trunk@7905 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CtrlCore/CtrlCore.h | 1 - uppsrc/CtrlCore/CtrlKbd.cpp | 10 ++++------ uppsrc/CtrlCore/GtkCtrl.cpp | 19 ------------------- uppsrc/CtrlCore/GtkKeys.h | 13 +++++++++++++ uppsrc/CtrlCore/Win32Ctrl.cpp | 18 ------------------ uppsrc/CtrlCore/Win32Keys.h | 14 ++++++++++++++ uppsrc/CtrlCore/X11Ctrl.cpp | 18 ------------------ uppsrc/CtrlCore/X11Keys.h | 12 ++++++++++++ 8 files changed, 43 insertions(+), 62 deletions(-) diff --git a/uppsrc/CtrlCore/CtrlCore.h b/uppsrc/CtrlCore/CtrlCore.h index 562e2e462..19ca7bf46 100644 --- a/uppsrc/CtrlCore/CtrlCore.h +++ b/uppsrc/CtrlCore/CtrlCore.h @@ -1259,7 +1259,6 @@ public: inline Size GetScreenSize() { return Ctrl::GetVirtualScreenArea().GetSize(); } // Deprecated -String GuiPlatformGetKeyDesc(dword key); bool GuiPlatformHasSizeGrip(); void GuiPlatformGripResize(TopWindow *q); Color GuiPlatformGetScreenPixel(int x, int y); diff --git a/uppsrc/CtrlCore/CtrlKbd.cpp b/uppsrc/CtrlCore/CtrlKbd.cpp index 3945f7f81..82306c2c6 100644 --- a/uppsrc/CtrlCore/CtrlKbd.cpp +++ b/uppsrc/CtrlCore/CtrlKbd.cpp @@ -379,7 +379,7 @@ String GetKeyDesc(dword key) key &= ~(K_CTRL | K_ALT | K_SHIFT | K_KEYUP); if(key < K_DELTA && key > 32 && key != K_DELETE) - return desc + String(key, 1); + return desc + ToUtf8((wchar)key); if(key >= K_NUMPAD0 && key <= K_NUMPAD9) desc << "Num " << (char)(key - K_NUMPAD0 + '0'); else if(key >= K_0 && key <= K_9) @@ -403,6 +403,9 @@ String GetKeyDesc(dword key) { K_INSERT, tt_("key\vInsert") }, { K_DELETE, tt_("key\vDelete") },{ K_BREAK, tt_("key\vBreak") }, { K_MULTIPLY, tt_("key\vNum[*]") }, { K_ADD, tt_("key\vNum[+]") }, { K_SUBTRACT, tt_("key\vNum[-]") }, { K_DIVIDE, tt_("key\vNum[/]") }, { K_ALT_KEY, tt_("key\vAlt") }, { K_SHIFT_KEY, tt_("key\vShift") }, { K_CTRL_KEY, tt_("key\vCtrl") }, + { K_PLUS, tt_("key\v[+]") }, { K_MINUS, tt_("key\v[-]") }, { K_COMMA, tt_("key\v[,]") }, { K_PERIOD, tt_("key\v[.]") }, + { K_SEMICOLON, tt_("key\v[;]") }, { K_SLASH, tt_("key\v[/]") }, { K_GRAVE, tt_("key\v[`]") }, { K_LBRACKET, tt_("key\v[[]") }, + { K_BACKSLASH, tt_("key\v[\\]") }, { K_RBRACKET, tt_("key\v[]]") }, { K_QUOTEDBL, tt_("key\v[']") }, { 0, NULL } }; for(int i = 0; nkey[i].key; i++) @@ -410,11 +413,6 @@ String GetKeyDesc(dword key) desc << GetLngString(nkey[i].name); return desc; } - String g = GuiPlatformGetKeyDesc(key); - if(g.GetCount()) { - desc << g; - return desc; - } desc << Format("%04x", (int)key); } return desc; diff --git a/uppsrc/CtrlCore/GtkCtrl.cpp b/uppsrc/CtrlCore/GtkCtrl.cpp index d774672ca..ef515ea2a 100644 --- a/uppsrc/CtrlCore/GtkCtrl.cpp +++ b/uppsrc/CtrlCore/GtkCtrl.cpp @@ -28,25 +28,6 @@ bool Ctrl::GuiPlatformSetFullRefreshSpecial() return false; } -String GuiPlatformGetKeyDesc(dword key) -{ - static Tuple2 nkey[] = { - { K_DELTA|GDKEY(grave), "[`]" }, - { K_DELTA|GDKEY(minus), "[-]" }, - { K_DELTA|GDKEY(equal), "[=]" }, - { K_DELTA|GDKEY(backslash), "[\\]" }, - { K_DELTA|GDKEY(bracketleft), "[[]" }, - { K_DELTA|GDKEY(bracketright), "[]]" }, - { K_DELTA|GDKEY(semicolon), "[;]" }, - { K_DELTA|GDKEY(apostrophe), "[']" }, - { K_DELTA|GDKEY(comma), "[,]" }, - { K_DELTA|GDKEY(period), "[.]" }, - { K_DELTA|GDKEY(underscore), "[/]" }, - }; - const Tuple2 *x = FindTuple(nkey, __countof(nkey), key); - return x ? String(x->b) : String(); -} - void GuiPlatformAdjustDragImage(ImageBuffer&) { } diff --git a/uppsrc/CtrlCore/GtkKeys.h b/uppsrc/CtrlCore/GtkKeys.h index 0138cf3d1..873130019 100644 --- a/uppsrc/CtrlCore/GtkKeys.h +++ b/uppsrc/CtrlCore/GtkKeys.h @@ -1,3 +1,4 @@ + K_BACK = 8, K_BACKSPACE = 8, @@ -46,6 +47,18 @@ K_DIVIDE = GDKEY(KP_Divide)|K_DELTA, K_SCROLL = GDKEY(Scroll_Lock)|K_DELTA, +K_PLUS = GDKEY(plus)|K_DELTA, +K_MINUS = GDKEY(minus)|K_DELTA, +K_COMMA = GDKEY(comma)|K_DELTA, +K_PERIOD = GDKEY(period)|K_DELTA, +K_SEMICOLON = GDKEY(semicolon)|K_DELTA, +K_SLASH = GDKEY(slash)|K_DELTA, +K_GRAVE = GDKEY(grave)|K_DELTA, +K_LBRACKET = GDKEY(bracketleft)|K_DELTA, +K_BACKSLASH = GDKEY(backslash)|K_DELTA, +K_RBRACKET = GDKEY(bracketright)|K_DELTA, +K_QUOTEDBL = GDKEY(quotedbl)|K_DELTA, + K_F1 = GDKEY(F1)|K_DELTA, K_F2 = GDKEY(F2)|K_DELTA, K_F3 = GDKEY(F3)|K_DELTA, diff --git a/uppsrc/CtrlCore/Win32Ctrl.cpp b/uppsrc/CtrlCore/Win32Ctrl.cpp index d6742e7b4..be7e05e4d 100644 --- a/uppsrc/CtrlCore/Win32Ctrl.cpp +++ b/uppsrc/CtrlCore/Win32Ctrl.cpp @@ -40,24 +40,6 @@ bool Ctrl::GuiPlatformSetFullRefreshSpecial() return isdhctrl; } -String GuiPlatformGetKeyDesc(dword key) -{ - static struct { - dword key; - const char *name; - } nkey[] = { - { 0x100c0, "[`]" }, { 0x100bd, "[-]" }, { 0x100bb, "[=]" }, { 0x100dc, "[\\]" }, - { 0x100db, "[[]" }, { 0x100dd, "[]]" }, - { 0x100ba, "[;]" }, { 0x100de, "[']" }, - { 0x100bc, "[,]" }, { 0x100be, "[.]" }, { 0x100bf, "[/]" }, - { 0, NULL } - }; - for(int i = 0; nkey[i].key; i++) - if(nkey[i].key == key) - return nkey[i].name; - return Null; -} - void Ctrl::GuiPlatformSelection(PasteClip&) { } diff --git a/uppsrc/CtrlCore/Win32Keys.h b/uppsrc/CtrlCore/Win32Keys.h index 000cea433..870bfdb4b 100644 --- a/uppsrc/CtrlCore/Win32Keys.h +++ b/uppsrc/CtrlCore/Win32Keys.h @@ -1,3 +1,4 @@ + K_BACK = VK_BACK + K_DELTA, K_BACKSPACE = VK_BACK + K_DELTA, @@ -42,8 +43,21 @@ K_SEPARATOR = VK_SEPARATOR + K_DELTA, K_SUBTRACT = VK_SUBTRACT + K_DELTA, K_DECIMAL = VK_DECIMAL + K_DELTA, K_DIVIDE = VK_DIVIDE + K_DELTA, + K_SCROLL = VK_SCROLL + K_DELTA, +K_PLUS = VK_OEM_PLUS + K_DELTA, +K_MINUS = VK_OEM_MINUS + K_DELTA, +K_COMMA = VK_OEM_COMMA + K_DELTA, +K_PERIOD = VK_OEM_PERIOD + K_DELTA, +K_SEMICOLON = VK_OEM_1 + K_DELTA, +K_SLASH = VK_OEM_2 + K_DELTA, +K_GRAVE = VK_OEM_3 + K_DELTA, +K_LBRACKET = VK_OEM_4 + K_DELTA, +K_BACKSLASH = VK_OEM_5 + K_DELTA, +K_RBRACKET = VK_OEM_6 + K_DELTA, +K_QUOTEDBL = VK_OEM_7 + K_DELTA, + K_F1 = VK_F1 + K_DELTA, K_F2 = VK_F2 + K_DELTA, K_F3 = VK_F3 + K_DELTA, diff --git a/uppsrc/CtrlCore/X11Ctrl.cpp b/uppsrc/CtrlCore/X11Ctrl.cpp index d50320205..35e529f54 100644 --- a/uppsrc/CtrlCore/X11Ctrl.cpp +++ b/uppsrc/CtrlCore/X11Ctrl.cpp @@ -39,24 +39,6 @@ bool Ctrl::GuiPlatformSetFullRefreshSpecial() return false; } -String GuiPlatformGetKeyDesc(dword key) -{ - static struct { - dword key; - const char *name; - } nkey[] = { - { 0x10060, "[`]" }, { 0x1002d, "[-]" }, { 0x1003d, "[=]" }, { 0x1005c, "[\\]" }, - { 0x1005b, "[[]" }, { 0x1005d, "[]]" }, - { 0x1003b, "[;]" }, { 0x10027, "[']" }, - { 0x1002c, "[,]" }, { 0x1002e, "[.]" }, { 0x1005f, "[/]" }, - { 0, NULL } - }; - for(int i = 0; nkey[i].key; i++) - if(nkey[i].key == key) - return nkey[i].name; - return Null; -} - void Ctrl::GuiPlatformSelection(PasteClip& d) { d.fmt.Clear(); diff --git a/uppsrc/CtrlCore/X11Keys.h b/uppsrc/CtrlCore/X11Keys.h index 41fe9feec..9be5b585c 100644 --- a/uppsrc/CtrlCore/X11Keys.h +++ b/uppsrc/CtrlCore/X11Keys.h @@ -47,6 +47,18 @@ K_DIVIDE = XK_KP_Divide + K_DELTA, K_SCROLL = XK_Scroll_Lock + K_DELTA, +K_PLUS = XK_plus|K_DELTA, +K_MINUS = XK_minus|K_DELTA, +K_COMMA = 0x2c|K_DELTA, +K_PERIOD = XK_period|K_DELTA, +K_SEMICOLON = XK_semicolon|K_DELTA, +K_SLASH = 0x5f|K_DELTA, +K_GRAVE = XK_grave|K_DELTA, +K_LBRACKET = XK_bracketleft|K_DELTA, +K_BACKSLASH = 0x5c|K_DELTA, +K_RBRACKET = XK_bracketright|K_DELTA, +K_QUOTEDBL = XK_quotedbl|K_DELTA, + K_F1 = XK_F1 + K_DELTA, K_F2 = XK_F2 + K_DELTA, K_F3 = XK_F3 + K_DELTA,