/******************************************************************************

  This file is part of the:

  TCEditor class by SET, copyright (c) 1996.

    This files can be used by Robert Hhne for your RHIDE, any other use
  needs the permission of the author.

  E-Mail: salvador@inti.edu.ar
  
  Telephone: (+541) 759-0013
  
  Postal Address:
  Salvador E. Tropea
  Curapalige 2124
  (1678) Caseros - 3 de Febrero
  Prov: Buenos Aires
  Argentina

******************************************************************************/

/****************************************************************************

   Keyboard Translation

****************************************************************************/

// That's the first include because is used to configure the editor.
#include "ceditint.h"

#include "ceditor.h"

// Now the tables are generated automaticaly by bind2cc using the keybind.txt file, I made
// that because is much more easy
#include "kbfun.h"


/****************** Old values
unsigned char kbFunNormal[128] =
{
//         0            1           2           3    4    5    6             7          8          9    A            B           C             D             E              F
           0,           0,          0,          0,   0,   0,   0,            0,         0,         0,   0,           0,          0,            0, cmbBackSpace,             0,       // 0
           0,           0,          0,          0,   0,   0,   0,            0,         0,         0,   0,           0, cmbNewLine,            0,            0,             0,       // 1
           0,           0,          0,          0,   0,   0,   0,            0,         0,         0,   0,           0,          0,            0,            0,             0,       // 2
           0,           0,          0,          0,   0,   0,   0,            0,         0,         0,   0,           0,          0,            0,            0,             0,       // 3
           0,           0,          0,          0,   0,   0,   0, cmbLineStart, cmbLineUp, cmbPageUp,   0, cmbCharLeft,          0, cmbCharRight,            0,    cmbLineEnd,       // 4
 cmbLineDown, cmbPageDown, cmbInsMode, cmbDelChar,   0,   0,   0,            0,         0,         0,   0,           0,          0,            0,            0,             0,       // 5
           0,           0,          0,          0,   0,   0,   0,            0,         0,         0,   0,           0,          0,            0,            0, cmbExpandCode,       // 6
           0,           0,          0,          0,   0,   0,   0,            0,         0,         0,   0,           0,          0,            0,            0,             0        // 7
};

unsigned char kbFunShift[128] =
{
//         0            1           2           3    4    5    6             7          8              9    A            B           C             D    E             F
           0,           0,          0,          0,   0,   0,   0,            0,         0,             0,   0,           0,          0,            0,   0, cmbBackSpace,       // 0
           0,           0,          0,          0,   0,   0,   0,            0,         0,             0,   0,           0, cmbNewLine,            0,   0,            0,       // 1
           0,           0,          0,          0,   0,   0,   0,            0,         0,             0,   0,           0,          0,            0,   0,            0,       // 2
           0,           0,          0,          0,   0,   0,   0,            0,         0, cmbExpandCode,   0,           0,          0,            0,   0,            0,       // 3
           0,           0,          0,          0,   0,   0,   0, cmbLineStart, cmbLineUp,     cmbPageUp,   0, cmbCharLeft,          0, cmbCharRight,   0,   cmbLineEnd,       // 4
 cmbLineDown, cmbPageDown,   cmbPaste,     cmbCut,   0,   0,   0,            0,         0,             0,   0,           0,          0,            0,   0,            0,       // 5
           0,           0,          0,          0,   0,   0,   0,            0,         0,             0,   0,           0,          0,            0,   0,            0,       // 6
           0,           0,          0,          0,   0,   0,   0,            0,         0,             0,   0,           0,          0,            0,   0,            0        // 7
};

unsigned char kbFunCtrl[128] =
{
//         0              1             2             3                  4            5               6                      7              8             9               A             B            C            D               E                    F
           0,             0, cmbGotoMark1, cmbGotoMark2,      cmbGotoMark3, cmbGotoMark4,   cmbGotoMark5,         cmbGotoMark6,  cmbGotoMark7, cmbGotoMark8,   cmbGotoMark9, cmbGotoMark0,           0,            0, cmbDelPrevWord,      cmbSmartIndent,       // 0
    cmbCtrlQ, cmbScrollDown,    cmbLineUp,    cmbPageUp,        cmbDelWord,   cmbDelLine,        cmbUndo,                    0, cmbIndentMode,            0, cmbSearchStart, cmbSearchEnd,           0,            0,    cmbWordLeft,         cmbCharLeft,       // 1
cmbCharRight,  cmbWordRight,   cmbDelChar, cmbBackSpace, cmbGotoEditorLine,     cmbCtrlK, cmbSearchAgain,                    0,             0,            0,              0,            0, cmbScrollUp,  cmbLineDown,    cmbPageDown,          cmbInsMode,       // 2
           0,             0,   cmbNewLine,            0,                 0,            0,              0,                    0,             0,            0,              0,            0,           0,            0,              0,                   0,       // 3
           0,             0,            0,            0,                 0,            0,              0, cmbFirstLineInScreen,             0, cmbTextStart,              0,  cmbWordLeft,           0, cmbWordRight,              0, cmbLastLineInScreen,       // 4
           0,    cmbTextEnd,      cmbCopy,     cmbClear,                 0,            0,              0,                    0,             0,            0,              0,            0,           0,            0,              0,                   0,       // 5
           0,             0,            0,            0,                 0,            0,              0,                    0,             0,            0,              0,            0,           0,            0,              0,                   0,       // 6
           0,             0,            0,            0,                 0,            0,              0,                    0,             0,            0,              0,            0,           0,            0,              0,                   0        // 7
};

unsigned char kbFunShiftCtrl[128] =
{
//         0              1                 2             3                  4            5               6                      7              8             9               A             B            C             D               E                    F
           0,             0,     cmbGotoMark1, cmbGotoMark2,      cmbGotoMark3, cmbGotoMark4,   cmbGotoMark5,         cmbGotoMark6,  cmbGotoMark7, cmbGotoMark8, cmbSearchOpPar, cmbSearchClPar,           0,            0, cmbDelPrevWord,    cmbSmartUnIndent,       // 0
    cmbCtrlQ, cmbScrollDown,        cmbLineUp,    cmbPageUp,        cmbDelWord,   cmbDelLine,        cmbUndo,                    0, cmbLastPosCur,            0, cmbSearchOpCor, cmbSearchClCor,           0,            0,    cmbWordLeft,         cmbCharLeft,       // 1
cmbCharRight,  cmbWordRight,       cmbDelChar, cmbBackSpace, cmbGotoEditorLine,     cmbCtrlK, cmbSearchAgain,                    0,             0,            0,              0,              0, cmbScrollUp,  cmbLineDown,    cmbPageDown,          cmbInsMode,       // 2
           0,             0,       cmbNewLine,            0,                 0,            0,              0,                    0,             0,            0,              0,              0,           0,            0,              0,                   0,       // 3
           0,             0,                0,            0,                 0,            0,              0, cmbFirstLineInScreen,             0, cmbTextStart,              0,    cmbWordLeft,           0, cmbWordRight,              0, cmbLastLineInScreen,       // 4
           0,    cmbTextEnd, cmbReplaceSelect,     cmbClear,                 0,            0,              0,                    0,             0,            0,              0,              0,           0,            0,              0,                   0,       // 5
           0,             0,                0,            0,                 0,            0,              0,                    0,             0,            0,              0,              0,           0,            0,              0,                   0,       // 6
           0,             0,                0,            0,                 0,            0,              0,                    0,             0,            0,              0,              0,           0,            0,              0,                   0        // 7
};

unsigned char kbFunCtrlQNorm[128] =
{
//            0        1             2             3             4              5             6             7             8             9             A             B    C    D           E             F
              0,       0, cmbGotoMark1, cmbGotoMark2, cmbGotoMark3,  cmbGotoMark4, cmbGotoMark5, cmbGotoMark6, cmbGotoMark7, cmbGotoMark8, cmbGotoMark9, cmbGotoMark0,   0,   0,          0,            0,       // 0
              0,       0,            0, cmbTextStart,            0,     cmbDelEnd,            0,            0,            0,            0,            0,            0,   0,   0, cmbReplace, cmbLineStart,       // 1
     cmbLineEnd, cmbFind,            0,  cmbDelStart,            0, cmbGoEndBlock, cmbSelLength,            0,            0,            0,            0,            0,   0,   0, cmbTextEnd,            0,       // 2
cmbGoBeginBlock,       0,            0,            0,            0,             0,            0,            0,            0,            0,            0,            0,   0,   0,          0,            0,       // 3
              0,       0,            0,            0,            0,             0,            0,            0,            0,            0,            0,            0,   0,   0,          0,            0,       // 4
              0,       0,            0,            0,            0,             0,            0,            0,            0,            0,            0,            0,   0,   0,          0,            0,       // 5
              0,       0,            0,            0,            0,             0,            0,            0,            0,            0,            0,            0,   0,   0,          0,            0,       // 6
              0,       0,            0,            0,            0,             0,            0,            0,            0,            0,            0,            0,   0,   0,          0,            0        // 7
};

unsigned char kbFunCtrlKNorm[128] =
{
//           0              1            2              3            4             5                  6                7            8            9            A            B    C    D             E              F
             0,             0, cmbPutMark1,   cmbPutMark2, cmbPutMark3,  cmbPutMark4,       cmbPutMark5,     cmbPutMark6, cmbPutMark7, cmbPutMark8, cmbPutMark9, cmbPutMark0,   0,   0,            0,  cmbIndentBlk,       // 0
             0, cmbWriteBlock,           0,  cmbReadBlock, cmbMarkWord,       cmbCut, cmbUnIndentBlkOne, cmbIndentBlkOne,  cmbToLower,           0,           0,           0,   0,   0,            0,             0,       // 1
             0,             0,           0, cmbHideSelect,           0, cmbEndSelect,       cmbMarkLine,               0,           0,           0,           0,   	   0,   0,   0, cmbCopyBlock, cmbMoveBlock,        // 2
cmbStartSelect,             0,  cmbToUpper,             0,           0,            0,                 0,               0,           0,           0,           0,           0,   0,   0,            0,             0,       // 3
             0,             0,           0,             0,           0,            0,                 0,               0,           0,           0,           0,           0,   0,   0,            0,             0,       // 4
             0,             0,           0,             0,           0,            0,                 0,               0,           0,           0,           0,           0,   0,   0,            0,             0,       // 5
             0,             0,           0,             0,           0,            0,                 0,               0,           0,           0,           0,           0,   0,   0,            0,             0,       // 6
             0,             0,           0,             0,           0,            0,                 0,               0,           0,           0,           0,           0,   0,   0,            0,             0        // 7
};

unsigned char kbFunCtrlKShift[128] =
{
//            0              1               2               3            4             5                  6                7            8                 9            A            B    C    D               E                F
              0,             0,    cmbPutMark1,    cmbPutMark2, cmbPutMark3,   cmbPutMark4,       cmbPutMark5,     cmbPutMark6, cmbPutMark7,     cmbPutMark8, cmbPutMark9, cmbPutMark0,   0,   0,              0,  cmbUnIndentBlk,       // 0
              0, cmbWriteBlock,              0,   cmbReadBlock, cmbMarkWord,        cmbCut, cmbUnIndentBlkOne, cmbIndentBlkOne,  cmbToLower, cmbSelRectPaste,           0,           0,   0,   0,              0,               0,       // 1
              0,             0,              0, cmbSelRectHide,           0, cmbSelRectEnd,     cmbSelRectDel,               0,           0,               0,           0,           0,   0,   0, cmbSelRectCopy,    cmbMoveBlock,       // 2
cmbSelRectStart,             0, cmbSelRectMove,              0,           0,             0,                 0,               0,           0,               0,           0,           0,   0,   0,              0,               0,       // 3
              0,             0,              0,              0,           0,             0,                 0,               0,           0,               0,           0,           0,   0,   0,              0,               0,       // 4
              0,             0,              0,              0,           0,             0,                 0,               0,           0,               0,           0,           0,   0,   0,              0,               0,       // 5
              0,             0,              0,              0,           0,             0,                 0,               0,           0,               0,           0,           0,   0,   0,              0,               0,       // 6
              0,             0,              0,              0,           0,             0,                 0,               0,           0,               0,           0,           0,   0,   0,              0,               0        // 7
};
*********************/
/* Old tables, now Obsolet
const ushort firstKeys[] =
{
    73,
    kbCtrlA, cmWordLeft,
    kbCtrlC, cmPageDown,
    kbCtrlD, cmCharRight,
    kbCtrlE, cmLineUp,
    kbCtrlF, cmWordRight,
    kbCtrlG, cmDelChar,
    kbCtrlH, cmBackSpace,
    kbCtrlJ, cmGotoEditorLine,
    kbCtrlK, 0xFF02,
    kbCtrlL, cmSearchAgain,
    kbCtrlM, cmNewLine,
    kbCtrlO, cmIndentMode,
    kbCtrlQ, 0xFF01,
    kbCtrlR, cmPageUp,
    kbCtrlS, cmCharLeft,
    kbCtrlT, cmDelWord,
    kbCtrlU, cmUndo,
    kbCtrlV, cmInsMode,
    kbCtrlW, cmScrollDown,
    kbCtrlX, cmLineDown,
    kbCtrlY, cmDelLine,
    kbCtrlZ, cmScrollUp,
    kbLeft, cmCharLeft,
    kbRight, cmCharRight,
    kbCtrlLeft, cmWordLeft,
    kbCtrlRight, cmWordRight,
    kbHome, cmLineStart,
    kbEnd, cmLineEnd,
    kbUp, cmLineUp,
    kbDown, cmLineDown,
    kbPgUp, cmPageUp,
    kbPgDn, cmPageDown,
    kbCtrlPgUp, cmTextStart,
    kbCtrlPgDn, cmTextEnd,
    kbIns, cmInsMode,
    kbDel, cmDelChar,
    kbShiftIns, cmPaste,
    kbShiftDel, cmCut,
    kbCtrlShiftIns,  cmReplaceSelect,
    kbCtrlIns, cmCopy,
    kbCtrlDel, cmClear,
    kbCtrlHome, cmFirstLineInScreen,
    kbCtrlEnd, cmLastLineInScreen,
    kbCtrlOpenBrace, cmSearchStart,
    kbCtrlCloseBrace, cmSearchEnd,
    kbShiftSpace, cmExpandCode,
    kbCtrlBackSpace, cmDelPrevWord,
    kbCtrlTab,       cmSmartIndent,
    kbCtrlShiftTab,  cmSmartUnIndent,
    kbAlt0, cmGotoMark0,
    kbAlt1, cmGotoMark1,
    kbAlt2, cmGotoMark2,
    kbAlt3, cmGotoMark3,
    kbAlt4, cmGotoMark4,
    kbAlt5, cmGotoMark5,
    kbAlt6, cmGotoMark6,
    kbAlt7, cmGotoMark7,
    kbAlt8, cmGotoMark8,
    kbAlt9, cmGotoMark9,
    kbShiftTab, cmBackSpace,
    kbShiftUp, cmLineUp,
    kbShiftDown, cmLineDown,
    kbShiftLeft, cmCharLeft,
    kbShiftRight, cmCharRight,
    kbShiftHome, cmLineStart,
    kbShiftEnd, cmLineEnd,
    kbShiftPgUp, cmPageUp,
    kbShiftPgDn, cmPageDown,
    kbShiftCtrlPgUp, cmTextStart,
    kbShiftCtrlPgDn, cmTextEnd,
    kbShiftCtrlHome, cmFirstLineInScreen,
    kbShiftCtrlEnd, cmLastLineInScreen,
    kbEnter, cmNewLine
};

// ^Qx
const ushort quickKeys[] =
{   21,
    'A', cmReplace,
    'B', cmGoBeginBlock,
    'C', cmTextEnd,
    'D', cmLineEnd,
    'F', cmFind,
    'H', cmDelStart,
    'K', cmGoEndBlock,
    'L', cmSelLength,
    'R', cmTextStart,
    'S', cmLineStart,
    'Y', cmDelEnd,
    '0', cmGotoMark0,
    '1', cmGotoMark1,
    '2', cmGotoMark2,
    '3', cmGotoMark3,
    '4', cmGotoMark4,
    '5', cmGotoMark5,
    '6', cmGotoMark6,
    '7', cmGotoMark7,
    '8', cmGotoMark8,
    '9', cmGotoMark9
};

// ^Kx
const ushort blockKeys[] =
{   26,
    'B', cmStartSelect,
    'C', cmPaste,
    'H', cmHideSelect,
    'I', cmIndentBlkOne,
    'K', cmEndSelect,
    'L', cmMarkLine,
    'M', cmToUpper,
    'O', cmToLower,
    'R', cmReadBlock,
    'T', cmMarkWord,
    'U', cmUnIndentBlkOne,
    'V', cmMoveBlock,
    'W', cmWriteBlock,
    'Y', cmCut,
    '0', cmPutMark0,
    '1', cmPutMark1,
    '2', cmPutMark2,
    '3', cmPutMark3,
    '4', cmPutMark4,
    '5', cmPutMark5,
    '6', cmPutMark6,
    '7', cmPutMark7,
    '8', cmPutMark8,
    '9', cmPutMark9,
    kbTab, cmIndentBlk,
    kbShiftTab, cmUnIndentBlk
};

const ushort *keyMap[] = { firstKeys, quickKeys, blockKeys };
*/
