Esempio n. 1
0
        internal protected override void MousePressed(MarginMouseEventArgs args)
        {
            base.MousePressed(args);

            if (args.Button != PointerButton.Left || args.LineNumber < DocumentLocation.MinLine)
            {
                return;
            }
            editor.LockedMargin = this;
            int  lineNumber      = args.LineNumber;
            bool extendSelection = (args.ModifierState & ModifierKeys.Shift) == ModifierKeys.Shift;

            if (lineNumber <= editor.Document.LineCount)
            {
                DocumentLocation loc  = new DocumentLocation(lineNumber, DocumentLocation.MinColumn);
                DocumentLine     line = args.LineSegment;
                if (args.RawEvent.MultiplePress == 2)
                {
                    if (line != null)
                    {
                        editor.MainSelection = new Selection(loc, GetLineEndLocation(editor.GetTextEditorData(), lineNumber));
                    }
                }
                else if (extendSelection)
                {
                    if (!editor.IsSomethingSelected)
                    {
                        editor.MainSelection = new Selection(loc, loc);
                    }
                    else
                    {
                        editor.MainSelection = editor.MainSelection.WithLead(loc);
                    }
                }
                else
                {
                    anchorLocation = loc;
                    editor.ClearSelection();
                }
                editor.Caret.PreserveSelection = true;
                editor.Caret.Location          = loc;
                editor.Caret.PreserveSelection = false;
            }
        }
Esempio n. 2
0
        internal protected override void MousePressed(MarginMouseEventArgs args)
        {
            base.MousePressed(args);

            if (args.Button != 1 || args.LineNumber < DocumentLocation.MinLine)
            {
                return;
            }
            editor.LockedMargin = this;
            int  lineNumber      = args.LineNumber;
            bool extendSelection = (args.ModifierState & Gdk.ModifierType.ShiftMask) == Gdk.ModifierType.ShiftMask;

            if (lineNumber <= editor.Document.LineCount)
            {
                DocumentLocation loc  = new DocumentLocation(lineNumber, DocumentLocation.MinColumn);
                LineSegment      line = args.LineSegment;
                if (args.Type == EventType.TwoButtonPress)
                {
                    if (line != null)
                    {
                        editor.MainSelection = new Selection(loc, GetLineEndLocation(editor.GetTextEditorData(), lineNumber));
                    }
                }
                else if (extendSelection)
                {
                    if (!editor.IsSomethingSelected)
                    {
                        editor.MainSelection = new Selection(loc, loc);
                    }
                    editor.MainSelection.Lead = loc;
                }
                else
                {
                    anchorLocation = loc;
                    editor.ClearSelection();
                }
                editor.Caret.PreserveSelection = true;
                editor.Caret.Location          = loc;
                editor.Caret.PreserveSelection = false;
            }
        }