Exemplo n.º 1
0
 public virtual void ConvertEvent(ref Event Event)
 {
     if (Event.What == Event.KeyDown)
     {
         if (((Drivers.GetShiftState() & 0x03) != 0) &&
             (Event.ScanCode >= 0x47) && (Event.ScanCode <= 0x51))
         {
             Event.CharCode = 0;
         }
         KeyboardKeys Key = Event.KeyCode;
         if (KeyState != 0)
         {
             if ((((int)Key & 0xFF) >= 0x01) & (((int)Key & 0xFF) <= 0x1A))
             {
                 Key += 0x40;
             }
             if ((((int)Key & 0xFF) >= 0x61) & (((int)Key & 0x7A) <= 0x1A))
             {
                 Key -= 0x20;
             }
         }
         Key      = (KeyboardKeys)ScanKeyMap(KeyMap[KeyState], (uint)Key);
         KeyState = 0;
         if (Key != 0)
         {
             if ((((int)Key & 0xFF00) >> 8) == 0xFF)
             {
                 KeyState = ((int)Key & 0xFF);
                 ClearEvent(ref Event);
             }
             else
             {
                 Event.What    = Event.evCommand;
                 Event.Command = (int)Key;
             }
         }
     }
 }
Exemplo n.º 2
0
        public override void HandleEvent(ref Event Event)
        {
            Point Mouse;
            Point D;
            bool  CenterCursor = false;
            byte  selectMode   = 0;

            base.HandleEvent(ref Event);
            ConvertEvent(ref Event);
            CenterCursor = !CursorVisible();
            selectMode   = 0;
            if (Selecting || ((Drivers.GetShiftState() & 0x03) != 0))
            {
                selectMode = smExtend;
            }
            switch (Event.What)
            {
            case Event.MouseDown:
                if (Event.Double)
                {
                    selectMode |= smDouble;
                }
                do
                {
                    Lock();
                    if (Event.What == Event.MouseAuto)
                    {
                        Mouse = MakeLocal(Event.Where);
                        D     = Delta;
                        if (Mouse.X < 0)
                        {
                            D.X--;
                        }
                        if (Mouse.X >= Size.X)
                        {
                            D.X++;
                        }
                        if (Mouse.Y < 0)
                        {
                            D.Y--;
                        }
                        if (Mouse.Y >= Size.Y)
                        {
                            D.Y++;
                        }
                        ScrollTo(D.X, D.Y);
                    }
                    SetCurPtr(GetMousePtr(Event.Where), selectMode);
                    selectMode |= smExtend;
                    UnLock();
                } while (!MouseEvent(ref Event, Event.MouseMove | Event.MouseAuto));
                break;

            case Event.KeyDown:
                if ((Event.KeyEvent.UnicodeChar == '\x0009') || (Event.KeyEvent.UnicodeChar >= '\x0020' /* && Event.KeyEvent.UnicodeChar <= '\x00FF'*/))
                {
                    Lock();
                    if (Overwrite && (!HasSelection()))
                    {
                        if (CurPtr != LineEnd((int)CurPtr))
                        {
                            SelEnd = NextChar((int)CurPtr);
                        }
                    }
                    char c = (char)Event.KeyEvent.UnicodeChar;
                    InsertText(new char[] { Event.KeyEvent.UnicodeChar }, 1, false);
                    TrackCursor(CenterCursor);
                    UnLock();
                }
                else
                {
                    return;
                }
                break;

            case Event.evCommand:
                switch (Event.Command)
                {
                case cmFind:
//                            Find();
//                            break;
//                        case cmReplace :
//                            Replace();
//                            break;
//                        case cmSearchAgain :
//                            SearchAgain();
//                            break;
                default:
                    Lock();
                    switch (Event.Command)
                    {
                    case cmCut:
                        ClipCut();
                        break;

                    case cmCopy:
                        ClipCopy();
                        break;

                    case cmPaste:
                        ClipPaste();
                        break;

                    case cmUndo:
                        Undo();
                        break;

                    case cmClear:
                        DeleteSelect();
                        break;

                    case cmCharLeft:
                        SetCurPtr(PrevChar((int)CurPtr), selectMode);
                        break;

                    case cmCharRight:
                        SetCurPtr(NextChar((int)CurPtr), selectMode);
                        break;

                    case cmWordLeft:
                        SetCurPtr(PrevWord((int)CurPtr), selectMode);
                        break;

                    case cmWordRight:
                        SetCurPtr(NextWord((int)CurPtr), selectMode);
                        break;

                    case cmLineStart:
                        SetCurPtr(LineStart((int)CurPtr), selectMode);
                        break;

                    case cmLineEnd:
                        SetCurPtr(LineEnd((int)CurPtr), selectMode);
                        break;

                    case cmLineUp:
                        SetCurPtr(LineMove((int)CurPtr, -1), selectMode);
                        break;

                    case cmLineDown:
                        SetCurPtr(LineMove((int)CurPtr, 1), selectMode);
                        break;

                    case cmPageUp:
                        SetCurPtr(LineMove((int)CurPtr, -(Size.Y - 1)), selectMode);
                        break;

                    case cmPageDown:
                        SetCurPtr(LineMove((int)CurPtr, Size.Y - 1), selectMode);
                        break;

                    case cmTextStart:
                        SetCurPtr(0, selectMode);
                        break;

                    case cmTextEnd:
                        SetCurPtr((int)BufLen, selectMode);
                        break;

                    case cmNewLine:
                        NewLine();
                        break;

                    case cmBackSpace:
                        DeleteRange(PrevChar((int)CurPtr), (int)CurPtr, true);
                        break;

                    case cmDelChar:
                        DeleteRange((int)CurPtr, (int)NextChar((int)CurPtr), true);
                        break;

                    case cmDelWord:
                        DeleteRange((int)CurPtr, NextWord((int)CurPtr), false);
                        break;

                    case cmDelStart:
                        DeleteRange((int)LineStart((int)CurPtr), (int)CurPtr, false);
                        break;

                    case cmDelEnd:
                        DeleteRange((int)CurPtr, (int)LineEnd((int)CurPtr), false);
                        break;

                    case cmDelLine:
                        DeleteRange((int)LineStart((int)CurPtr), NextLine((int)CurPtr), false);
                        break;

                    case cmInsMode:
                        ToggleInsMode();
                        break;

                    case cmStartSelect:
                        StartSelect();
                        break;

                    case cmHideSelect:
                        HideSelect();
                        break;

                    case cmIndentMode:
                        AutoIndent = !AutoIndent;
                        break;

                    default:
                        UnLock();
                        return;
                    }
                    TrackCursor(CenterCursor);
                    UnLock();
                    break;
                }
                break;

            case Event.Broadcast:
                switch (Event.Command)
                {
                case cmScrollBarChanged:
                    if ((Event.InfoPtr == HScrollBar) || (Event.InfoPtr == VScrollBar))
                    {
                        CheckScrollBar(Event, HScrollBar, ref Delta.X);
                        CheckScrollBar(Event, VScrollBar, ref Delta.Y);
                    }
                    else
                    {
                        return;
                    }
                    break;

                default:
                    return;
                }
                break;

            default:
                return;
            }
            ClearEvent(ref Event);
        }