Пример #1
0
 public new void mouseDown(NSEvent e)
 {
     if ((e.modifierFlags() & Enums.NSAlternateKeyMask) != 0)
     {
         DoBuildUsingNamesOrder();
         SuperCall(NSPopUpButton.Class, "mouseDown:", e);
         DoBuildUsingOffsetsOrder();
     }
     else
         SuperCall(NSPopUpButton.Class, "mouseDown:", e);
 }
Пример #2
0
        private bool DoArrowKeys(NSEvent evt)
        {
            bool command = (evt.modifierFlags() & Enums.NSCommandKeyMask) == Enums.NSCommandKeyMask;
            bool option = (evt.modifierFlags() & Enums.NSAlternateKeyMask) == Enums.NSAlternateKeyMask;
            bool shift = (evt.modifierFlags() & Enums.NSShiftKeyMask) == Enums.NSShiftKeyMask;

            if (evt.keyCode() == Constants.LeftArrowKey)
            {
                if (command && option)
                {
                    // Cycle down through document windows.
                    DoActivateLowerWindow();
                    return true;
                }
                else if (option && shift)
                {
                    // Extend the selection to the left using the previous word (for some reason Cocoa
                    // does not call selectionRangeForProposedRange_granularity for this).
                    if (DoExtendSelectionLeft())
                        return true;
                }
                else if (option)
                {
                    // Move the insertion point to the start of the previous word.
                    if (DoMoveSelectionLeft())
                        return true;
                }
            }
            else if (evt.keyCode() == Constants.RightArrowKey)
            {
                if (command && option)
                {
                    // Cycle up through document windows.
                    DoActivateHigherWindow();
                    return true;
                }
                else if (option && shift)
                {
                    // Extend the selection to the right of the next word.
                    if (DoExtendSelectionRight())
                        return true;
                }
                else if (option)
                {
                    // Move the insertion point after the end of the next word.
                    if (DoMoveSelectionRight())
                        return true;
                }
            }
            else if (evt.keyCode() == Constants.UpArrowKey)
            {
                if (command && option)
                {
                    // Toggle between *.cpp/*.c/*.m and *.hpp/*.h files.
                    DoToggleHeader();
                    return true;
                }
            }

            return false;
        }
Пример #3
0
        private bool DoDeleteKey(NSEvent evt)
        {
            if (evt.keyCode() == Constants.DeleteKey)
            {
                var range = selectedRange();
                if ((evt.modifierFlags() & Enums.NSShiftKeyMask) == Enums.NSShiftKeyMask)
                {
                    if (range.length == 0)
                    {
                        // Shift-delete deletes the current line
                        DoDeleteLine(range.location);
                        return true;
                    }
                }
                else if (range.length == 0)
                {
                    TextController controller = (TextController) window().windowController();
                    if (controller.Language != null && !controller.UsesTabs && !NSObject.IsNullOrNil(controller.SpacesText))
                    {
                        // If we're inserting N spaces for tabs then delete should delete N spaces at a time.
                        int count = DoGetSpaceCount(string_(), range.location - 1);
                        int length = (int) controller.SpacesText.length();
                        if (count >= length)
                        {
                            setSelectedRange(new NSRange(range.location - length, length));
                            delete(this);
                            return true;
                        }
                    }
                }
            }

            return false;
        }
Пример #4
0
        private bool DoTabKey(NSEvent evt)
        {
            if (evt.keyCode() == Constants.TabKey)
            {
                TextController controller = (TextController) window().windowController();
                if ((evt.modifierFlags() & Enums.NSAlternateKeyMask) != 0)
                {
                    if ((evt.modifierFlags() & Enums.NSShiftKeyMask) == 0)
                    {
                        // Option-tab selects the prev identifier.
                        if (DoSelectNextIdentifier(controller))
                            return true;
                    }
                    else
                    {
                        // Option-shift-tab selects the prev identifier.
                        if (DoSelectPreviousIdentifier(controller))
                            return true;
                    }
                }
                else if ((evt.modifierFlags() & Enums.NSCommandKeyMask) != 0)
                {
                }
                else if ((evt.modifierFlags() & Enums.NSControlKeyMask) != 0)
                {
                }
                else if ((evt.modifierFlags() & Enums.NSShiftKeyMask) != 0)
                {
                    // Shift-tab with at least one line selected unindents lines
                    var selRange = selectedRange();
                    if (DoSelectionCrossesLines(selRange))
                    {
                        controller.shiftLeft(this);
                        return true;
                    }
                }
                else
                {
                    var selRange = selectedRange();
                    if (selRange.location > 0 && selRange.length > 1)
                    {
                        // Tab with at least one line selected indents lines
                        if (DoSelectionCrossesLines(selRange))
                        {
                            controller.shiftRight(this);
                            return true;
                        }
                    }
                    else if (selRange.location > 0 && selRange.length == 0)
                    {
                        // Tab with no selection at the end of a blank line indents like the previous line.
                        if (DoMatchPriorLineTabs(selRange.location))
                            return true;
                    }

                    if (controller.Language != null && !controller.UsesTabs)
                    {
                        if (!NSObject.IsNullOrNil(controller.SpacesText))
                        {
                            this.insertText(controller.SpacesText);
                            return true;
                        }
                    }
                }
            }

            return false;
        }