]> git.saurik.com Git - wxWidgets.git/blobdiff - src/stc/scintilla/src/KeyMap.cxx
WinCE doesn't have GetThreadLocale
[wxWidgets.git] / src / stc / scintilla / src / KeyMap.cxx
index 9ab9694df15b9b99d9ec18a45d571c92950c925d..950916bd08dc14764a96de579e8983bdfcd03939 100644 (file)
@@ -1,6 +1,8 @@
 // Scintilla source code edit control
-// KeyMap.cxx  - defines a mapping between keystrokes and commands
-// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
+/** @file KeyMap.cxx
+ ** Defines a mapping between keystrokes and commands.
+ **/
+// Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
 // The License.txt file describes the conditions under which this software may be distributed.
 
 #include "Platform.h"
@@ -11,9 +13,9 @@
 
 KeyMap::KeyMap() : kmap(0), len(0), alloc(0) {
        for (int i = 0; MapDefault[i].key; i++) {
-               AssignCmdKey(MapDefault[i].key, 
+               AssignCmdKey(MapDefault[i].key,
                        MapDefault[i].modifiers,
-                       MapDefault[i].msg);
+                       MapDefault[i].msg);
        }
 }
 
@@ -28,12 +30,12 @@ void KeyMap::Clear() {
        alloc = 0;
 }
 
-void KeyMap::AssignCmdKey(int key, int modifiers, UINT msg) {
+void KeyMap::AssignCmdKey(int key, int modifiers, unsigned int msg) {
        if ((len+1) >= alloc) {
                KeyToCommand *ktcNew = new KeyToCommand[alloc + 5];
                if (!ktcNew)
                        return;
-               for (int k=0;k<len;k++)
+               for (int k = 0; k < len; k++)
                        ktcNew[k] = kmap[k];
                alloc += 5;
                delete []kmap;
@@ -51,8 +53,8 @@ void KeyMap::AssignCmdKey(int key, int modifiers, UINT msg) {
        len++;
 }
 
-UINT KeyMap::Find(int key, int modifiers) {
-       for (int i=0; i < len; i++) {
+unsigned int KeyMap::Find(int key, int modifiers) {
+       for (int i = 0; i < len; i++) {
                if ((key == kmap[i].key) && (modifiers == kmap[i].modifiers)) {
                        return kmap[i].msg;
                }
@@ -60,57 +62,87 @@ UINT KeyMap::Find(int key, int modifiers) {
        return 0;
 }
 
-KeyToCommand KeyMap::MapDefault[] = {
-    VK_DOWN,           SCI_NORM,       SCI_LINEDOWN,
-    VK_DOWN,           SCI_SHIFT,      SCI_LINEDOWNEXTEND,
-    VK_UP,                     SCI_NORM,       SCI_LINEUP,
-    VK_UP,                     SCI_SHIFT,      SCI_LINEUPEXTEND,
-    VK_LEFT,           SCI_NORM,       SCI_CHARLEFT,
-    VK_LEFT,           SCI_SHIFT,      SCI_CHARLEFTEXTEND,
-    VK_LEFT,           SCI_CTRL,       SCI_WORDLEFT,
-    VK_LEFT,           SCI_CSHIFT,     SCI_WORDLEFTEXTEND,
-    VK_RIGHT,          SCI_NORM,       SCI_CHARRIGHT,
-    VK_RIGHT,          SCI_SHIFT,      SCI_CHARRIGHTEXTEND,
-    VK_RIGHT,          SCI_CTRL,       SCI_WORDRIGHT,
-    VK_RIGHT,          SCI_CSHIFT,     SCI_WORDRIGHTEXTEND,
-    VK_HOME,           SCI_NORM,       SCI_VCHOME,
-    VK_HOME,           SCI_SHIFT,      SCI_VCHOMEEXTEND,
-    VK_HOME,           SCI_CTRL,       SCI_DOCUMENTSTART,
-    VK_HOME,           SCI_CSHIFT,     SCI_DOCUMENTSTARTEXTEND,
-    VK_END,            SCI_NORM,       SCI_LINEEND,
-    VK_END,            SCI_SHIFT,      SCI_LINEENDEXTEND,
-    VK_END,            SCI_CTRL,       SCI_DOCUMENTEND,
-    VK_END,            SCI_CSHIFT,     SCI_DOCUMENTENDEXTEND,
-    VK_PRIOR,          SCI_NORM,       SCI_PAGEUP,
-    VK_PRIOR,          SCI_SHIFT,      SCI_PAGEUPEXTEND,
-    VK_NEXT,           SCI_NORM,       SCI_PAGEDOWN,
-    VK_NEXT,           SCI_SHIFT,      SCI_PAGEDOWNEXTEND,
-    VK_DELETE,         SCI_NORM,       WM_CLEAR,
-    VK_DELETE,         SCI_SHIFT,      WM_CUT,
-    VK_DELETE,         SCI_CTRL,       SCI_DELWORDRIGHT,
-    VK_INSERT,                 SCI_NORM,       SCI_EDITTOGGLEOVERTYPE,
-    VK_INSERT,                 SCI_SHIFT,      WM_PASTE,
-    VK_INSERT,                 SCI_CTRL,       WM_COPY,
-    VK_ESCAPE,         SCI_NORM,       SCI_CANCEL,
-    VK_BACK,           SCI_NORM,       SCI_DELETEBACK,
-    VK_BACK,           SCI_CTRL,       SCI_DELWORDLEFT,
-    'Z',                       SCI_CTRL,       WM_UNDO,
-    'Y',                       SCI_CTRL,       SCI_REDO,
-    'X',                       SCI_CTRL,       WM_CUT,
-    'C',                       SCI_CTRL,       WM_COPY,
-    'V',                       SCI_CTRL,       WM_PASTE,
-    'A',                       SCI_CTRL,       SCI_SELECTALL,
-    VK_TAB,            SCI_NORM,       SCI_TAB,
-    VK_TAB,            SCI_SHIFT,      SCI_BACKTAB,
-    VK_RETURN,         SCI_NORM,       SCI_NEWLINE,
-    VK_ADD,            SCI_CTRL,       SCI_ZOOMIN,
-    VK_SUBTRACT,       SCI_CTRL,       SCI_ZOOMOUT,
+const KeyToCommand KeyMap::MapDefault[] = {
+    {SCK_DOWN,         SCI_NORM,       SCI_LINEDOWN},
+    {SCK_DOWN,         SCI_SHIFT,      SCI_LINEDOWNEXTEND},
+    {SCK_DOWN,         SCI_CTRL,       SCI_LINESCROLLDOWN},
+    {SCK_DOWN,         SCI_ASHIFT,     SCI_LINEDOWNRECTEXTEND},
+    {SCK_UP,           SCI_NORM,       SCI_LINEUP},
+    {SCK_UP,                   SCI_SHIFT,      SCI_LINEUPEXTEND},
+    {SCK_UP,                   SCI_CTRL,       SCI_LINESCROLLUP},
+    {SCK_UP,           SCI_ASHIFT,     SCI_LINEUPRECTEXTEND},
+    {'[',                      SCI_CTRL,               SCI_PARAUP},
+    {'[',                      SCI_CSHIFT,     SCI_PARAUPEXTEND},
+    {']',                      SCI_CTRL,               SCI_PARADOWN},
+    {']',                      SCI_CSHIFT,     SCI_PARADOWNEXTEND},
+    {SCK_LEFT,         SCI_NORM,       SCI_CHARLEFT},
+    {SCK_LEFT,         SCI_SHIFT,      SCI_CHARLEFTEXTEND},
+    {SCK_LEFT,         SCI_CTRL,       SCI_WORDLEFT},
+    {SCK_LEFT,         SCI_CSHIFT,     SCI_WORDLEFTEXTEND},
+    {SCK_LEFT,         SCI_ASHIFT,     SCI_CHARLEFTRECTEXTEND},
+    {SCK_RIGHT,                SCI_NORM,       SCI_CHARRIGHT},
+    {SCK_RIGHT,                SCI_SHIFT,      SCI_CHARRIGHTEXTEND},
+    {SCK_RIGHT,                SCI_CTRL,       SCI_WORDRIGHT},
+    {SCK_RIGHT,                SCI_CSHIFT,     SCI_WORDRIGHTEXTEND},
+    {SCK_RIGHT,                SCI_ASHIFT,     SCI_CHARRIGHTRECTEXTEND},
+    {'/',              SCI_CTRL,               SCI_WORDPARTLEFT},
+    {'/',              SCI_CSHIFT,     SCI_WORDPARTLEFTEXTEND},
+    {'\\',             SCI_CTRL,               SCI_WORDPARTRIGHT},
+    {'\\',             SCI_CSHIFT,     SCI_WORDPARTRIGHTEXTEND},
+    {SCK_HOME,         SCI_NORM,       SCI_VCHOME},
+    {SCK_HOME,                 SCI_SHIFT,      SCI_VCHOMEEXTEND},
+    {SCK_HOME,                 SCI_CTRL,       SCI_DOCUMENTSTART},
+    {SCK_HOME,                 SCI_CSHIFT,     SCI_DOCUMENTSTARTEXTEND},
+    {SCK_HOME,                 SCI_ALT,        SCI_HOMEDISPLAY},
+//    {SCK_HOME,               SCI_ASHIFT,     SCI_HOMEDISPLAYEXTEND},
+    {SCK_HOME,         SCI_ASHIFT,     SCI_VCHOMERECTEXTEND},
+    {SCK_END,          SCI_NORM,       SCI_LINEEND},
+    {SCK_END,          SCI_SHIFT,      SCI_LINEENDEXTEND},
+    {SCK_END,          SCI_CTRL,       SCI_DOCUMENTEND},
+    {SCK_END,          SCI_CSHIFT,     SCI_DOCUMENTENDEXTEND},
+    {SCK_END,          SCI_ALT,        SCI_LINEENDDISPLAY},
+//    {SCK_END,                SCI_ASHIFT,     SCI_LINEENDDISPLAYEXTEND},
+    {SCK_END,          SCI_ASHIFT,     SCI_LINEENDRECTEXTEND},
+    {SCK_PRIOR,                SCI_NORM,       SCI_PAGEUP},
+    {SCK_PRIOR,                SCI_SHIFT,      SCI_PAGEUPEXTEND},
+    {SCK_PRIOR,                SCI_ASHIFT,     SCI_PAGEUPRECTEXTEND},
+    {SCK_NEXT,                 SCI_NORM,       SCI_PAGEDOWN},
+    {SCK_NEXT,                 SCI_SHIFT,      SCI_PAGEDOWNEXTEND},
+    {SCK_NEXT,         SCI_ASHIFT,     SCI_PAGEDOWNRECTEXTEND},
+    {SCK_DELETE,       SCI_NORM,       SCI_CLEAR},
+    {SCK_DELETE,       SCI_SHIFT,      SCI_CUT},
+    {SCK_DELETE,       SCI_CTRL,       SCI_DELWORDRIGHT},
+    {SCK_DELETE,       SCI_CSHIFT,     SCI_DELLINERIGHT},
+    {SCK_INSERT,               SCI_NORM,       SCI_EDITTOGGLEOVERTYPE},
+    {SCK_INSERT,               SCI_SHIFT,      SCI_PASTE},
+    {SCK_INSERT,               SCI_CTRL,       SCI_COPY},
+    {SCK_ESCAPE,       SCI_NORM,       SCI_CANCEL},
+    {SCK_BACK,         SCI_NORM,       SCI_DELETEBACK},
+    {SCK_BACK,         SCI_SHIFT,      SCI_DELETEBACK},
+    {SCK_BACK,         SCI_CTRL,       SCI_DELWORDLEFT},
+    {SCK_BACK,                 SCI_ALT,        SCI_UNDO},
+    {SCK_BACK,         SCI_CSHIFT,     SCI_DELLINELEFT},
+    {'Z',                      SCI_CTRL,       SCI_UNDO},
+    {'Y',                      SCI_CTRL,       SCI_REDO},
+    {'X',                      SCI_CTRL,       SCI_CUT},
+    {'C',                      SCI_CTRL,       SCI_COPY},
+    {'V',                      SCI_CTRL,       SCI_PASTE},
+    {'A',                      SCI_CTRL,       SCI_SELECTALL},
+    {SCK_TAB,          SCI_NORM,       SCI_TAB},
+    {SCK_TAB,          SCI_SHIFT,      SCI_BACKTAB},
+    {SCK_RETURN,       SCI_NORM,       SCI_NEWLINE},
+    {SCK_RETURN,       SCI_SHIFT,      SCI_NEWLINE},
+    {SCK_ADD,          SCI_CTRL,       SCI_ZOOMIN},
+    {SCK_SUBTRACT,     SCI_CTRL,       SCI_ZOOMOUT},
+    {SCK_DIVIDE,       SCI_CTRL,       SCI_SETZOOM},
     //'L',                     SCI_CTRL,               SCI_FORMFEED,
-    'L',                       SCI_CTRL,       SCI_LINECUT,
-    'L',                       SCI_CSHIFT,     SCI_LINEDELETE,
-    'T',                       SCI_CTRL,       SCI_LINETRANSPOSE,
-    'U',                       SCI_CTRL,       SCI_LOWERCASE,
-    'U',                       SCI_CSHIFT,     SCI_UPPERCASE,
-    0,0,0,
+    {'L',                      SCI_CTRL,       SCI_LINECUT},
+    {'L',                      SCI_CSHIFT,     SCI_LINEDELETE},
+    {'T',                      SCI_CSHIFT,     SCI_LINECOPY},
+    {'T',                      SCI_CTRL,       SCI_LINETRANSPOSE},
+    {'D',                      SCI_CTRL,       SCI_LINEDUPLICATE},
+    {'U',                      SCI_CTRL,       SCI_LOWERCASE},
+    {'U',                      SCI_CSHIFT,     SCI_UPPERCASE},
+    {0,0,0},
 };