From 165f9fe9e57540d2f8f83d446c7e0f80c769b65d Mon Sep 17 00:00:00 2001 From: Markus Palme Date: Sat, 30 Sep 2006 13:59:28 +0000 Subject: [PATCH] patch from Troy Simpson improving gutter selection git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1859 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Document/Selection/SelectionManager.cs | 96 +++++++- .../Project/Src/Gui/GutterMargin.cs | 38 +-- .../Project/Src/Gui/TextArea.cs | 16 +- .../Project/Src/Gui/TextAreaMouseHandler.cs | 217 ++++++------------ 4 files changed, 187 insertions(+), 180 deletions(-) diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/Selection/SelectionManager.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/Selection/SelectionManager.cs index 12fcab5412..395ebd2e20 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/Selection/SelectionManager.cs +++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/Selection/SelectionManager.cs @@ -18,7 +18,11 @@ namespace ICSharpCode.TextEditor.Document /// public class SelectionManager : IDisposable { + public Point selectionStart; IDocument document; + TextArea textArea; + public SelectFrom selectFrom = new SelectFrom(); + List selectionCollection = new List(); /// @@ -70,8 +74,18 @@ namespace ICSharpCode.TextEditor.Document this.document = document; document.DocumentChanged += new DocumentEventHandler(DocumentChanged); } - - public void Dispose() + + /// + /// Creates a new instance of + /// + public SelectionManager(IDocument document, TextArea textArea) + { + this.document = document; + this.textArea = textArea; + document.DocumentChanged += new DocumentEventHandler(DocumentChanged); + } + + public void Dispose() { if (this.document != null) { document.DocumentChanged -= new DocumentEventHandler(DocumentChanged); @@ -154,7 +168,14 @@ namespace ICSharpCode.TextEditor.Document } } else { if (selection.StartPosition != newPosition) { - selection.StartPosition = newPosition; + // we're back to the line we started from and it was a gutter selection + if (selectFrom.where == WhereFrom.Gutter && newPosition.Y >= selectionStart.Y) + { + selection.StartPosition = selectionStart; + selection.EndPosition = NextValidPosition(selection.StartPosition.Y); + } else { + selection.StartPosition = newPosition; + } changed = true; } } @@ -179,8 +200,30 @@ namespace ICSharpCode.TextEditor.Document selection.StartPosition != newPosition) { changed = true; } - selection.EndPosition = selection.StartPosition; - selection.StartPosition = newPosition; + if (selectFrom.where == WhereFrom.Gutter) + { + if (selectFrom.first == WhereFrom.Gutter) + { + if(newPosition.Y == selectionStart.Y) { + selection.EndPosition = NextValidPosition(selection.StartPosition.Y); + selection.StartPosition = new Point(0, newPosition.Y); + } else { + selection.EndPosition = NextValidPosition(selection.StartPosition.Y); + selection.StartPosition = newPosition; + } + } else { + if(newPosition.Y == selectionStart.Y) { + selection.EndPosition = NextValidPosition(selection.StartPosition.Y); + selection.StartPosition = new Point(selectionStart.X, newPosition.Y); + } else { + selection.EndPosition = new Point(selectionStart.X, selection.StartPosition.Y); + selection.StartPosition = newPosition; + } + } + } else { + selection.EndPosition = selection.StartPosition; + selection.StartPosition = newPosition; + } changed = true; } else { if (selection.EndPosition != newPosition) { @@ -210,7 +253,20 @@ namespace ICSharpCode.TextEditor.Document OnSelectionChanged(EventArgs.Empty); } } - void ClearWithoutUpdate() + + // retrieve the next available line + // - checks that there are more lines available after the current one + // - if there are then the next line is returned + // - if there are NOT then the last position on the given line is returned + public Point NextValidPosition(int line) + { + if (line < document.TotalNumberOfLines - 1) + return new Point(0, line + 1); + else + return new Point(document.GetLineSegment(document.TotalNumberOfLines - 1).Length + 1, line); + } + + void ClearWithoutUpdate() { while (selectionCollection.Count > 0) { ISelection selection = selectionCollection[selectionCollection.Count - 1]; @@ -224,7 +280,16 @@ namespace ICSharpCode.TextEditor.Document /// public void ClearSelection() { - ClearWithoutUpdate(); + Point mousepos; + mousepos = textArea.mousepos; + // this is the most logical place to reset selection starting + // positions because it is always called before a new selection + selectFrom.first = selectFrom.where; + selectionStart = textArea.TextView.GetLogicalPosition(mousepos.X - textArea.TextView.DrawingPosition.X, mousepos.Y - textArea.TextView.DrawingPosition.Y); + if(selectFrom.where == WhereFrom.Gutter) + selectionStart.X = 0; + + ClearWithoutUpdate(); document.CommitUpdate(); } @@ -384,4 +449,21 @@ namespace ICSharpCode.TextEditor.Document public event EventHandler SelectionChanged; } + + // selection initiated from... + public class SelectFrom { + public int where = WhereFrom.None; // last selection initiator + public int first = WhereFrom.None; // first selection initiator + + public SelectFrom() + { + } + } + + // selection initiated from type... + public class WhereFrom { + public const int None = 0; + public const int Gutter = 1; + public const int TArea = 2; + } } diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/GutterMargin.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/GutterMargin.cs index 564861bbbc..9bd688d29e 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/GutterMargin.cs +++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/GutterMargin.cs @@ -92,39 +92,40 @@ namespace ICSharpCode.TextEditor } } } - + public override void HandleMouseDown(Point mousepos, MouseButtons mouseButtons) { - SelectFrom.where = WhereFrom.Gutter; + Point selectionStartPos; + + textArea.SelectionManager.selectFrom.where = WhereFrom.Gutter; int realline = textArea.TextView.GetLogicalLine(mousepos); if (realline >= 0 && realline < textArea.Document.TotalNumberOfLines) { + // shift-select if((Control.ModifierKeys & Keys.Shift) != 0) { if(!textArea.SelectionManager.HasSomethingSelected && realline != textArea.Caret.Position.Y) { if (realline >= textArea.Caret.Position.Y) { // at or below starting selection, place the cursor on the next line // nothing is selected so make a new selection from cursor - TextAreaMouseHandler.selectionStartPos = textArea.Caret.Position; - textArea.SelectionManager.ClearSelection(); + selectionStartPos = textArea.Caret.Position; // whole line selection - start of line to start of next line if (realline < textArea.Document.TotalNumberOfLines - 1) { - textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, TextAreaMouseHandler.selectionStartPos, new Point(0, realline + 1))); + textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, selectionStartPos, new Point(0, realline + 1))); textArea.Caret.Position = new Point(0, realline + 1); } else { - textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, TextAreaMouseHandler.selectionStartPos, new Point(textArea.Document.GetLineSegment(realline).Length + 1, realline))); + textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, selectionStartPos, new Point(textArea.Document.GetLineSegment(realline).Length + 1, realline))); textArea.Caret.Position = new Point(textArea.Document.GetLineSegment(realline).Length + 1, realline); } } else { // prior lines to starting selection, place the cursor on the same line as the new selection // nothing is selected so make a new selection from cursor - TextAreaMouseHandler.selectionStartPos = textArea.Caret.Position; - textArea.SelectionManager.ClearSelection(); + selectionStartPos = textArea.Caret.Position; // whole line selection - start of line to start of next line - textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, TextAreaMouseHandler.selectionStartPos, new Point(TextAreaMouseHandler.selectionStartPos.X, TextAreaMouseHandler.selectionStartPos.Y))); - textArea.SelectionManager.ExtendSelection(new Point(TextAreaMouseHandler.selectionStartPos.X, TextAreaMouseHandler.selectionStartPos.Y), new Point(0, realline)); + textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, selectionStartPos, new Point(selectionStartPos.X, selectionStartPos.Y))); + textArea.SelectionManager.ExtendSelection(new Point(selectionStartPos.X, selectionStartPos.Y), new Point(0, realline)); textArea.Caret.Position = new Point(0, realline); } } @@ -134,19 +135,24 @@ namespace ICSharpCode.TextEditor MouseEventArgs e = new MouseEventArgs(mouseButtons, 1, mousepos.X, mousepos.Y, 0); textArea.doMouseMove(e); } - } else { - TextAreaMouseHandler.selectionStartPos = new Point(0, realline); + } else { // this is a new selection with no shift-key + // sync the textareamousehandler mouse location + // (fixes problem with clicking out into a menu then back to the gutter whilst + // there is a selection) + textArea.mousepos = mousepos; + + selectionStartPos = new Point(0, realline); textArea.SelectionManager.ClearSelection(); // whole line selection - start of line to start of next line if (realline < textArea.Document.TotalNumberOfLines - 1) { - textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, TextAreaMouseHandler.selectionStartPos, new Point(TextAreaMouseHandler.selectionStartPos.X, TextAreaMouseHandler.selectionStartPos.Y + 1))); - textArea.Caret.Position = new Point(TextAreaMouseHandler.selectionStartPos.X, TextAreaMouseHandler.selectionStartPos.Y + 1); + textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, selectionStartPos, new Point(selectionStartPos.X, selectionStartPos.Y + 1))); + textArea.Caret.Position = new Point(selectionStartPos.X, selectionStartPos.Y + 1); } else { - textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, new Point(0, realline), new Point(textArea.Document.GetLineSegment(realline).Length + 1, TextAreaMouseHandler.selectionStartPos.Y))); - textArea.Caret.Position = new Point(textArea.Document.GetLineSegment(realline).Length + 1, TextAreaMouseHandler.selectionStartPos.Y); + textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, new Point(0, realline), new Point(textArea.Document.GetLineSegment(realline).Length + 1, selectionStartPos.Y))); + textArea.Caret.Position = new Point(textArea.Document.GetLineSegment(realline).Length + 1, selectionStartPos.Y); } } } diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextArea.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextArea.cs index 1ef96916b2..4b293e71e3 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextArea.cs +++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextArea.cs @@ -55,7 +55,10 @@ namespace ICSharpCode.TextEditor SelectionManager selectionManager; Caret caret; - + + public Point mousepos = new Point(0, 0); + //public Point selectionStartPos = new Point(0,0); + bool disposed; [Browsable(false)] @@ -179,7 +182,7 @@ namespace ICSharpCode.TextEditor this.motherTextEditorControl = motherTextEditorControl; caret = new Caret(this); - selectionManager = new SelectionManager(Document); + selectionManager = new SelectionManager(Document, this); this.textAreaClipboardHandler = new TextAreaClipboardHandler(this); @@ -298,8 +301,13 @@ namespace ICSharpCode.TextEditor protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e) { + // this corrects weird problems when text is selected, + // then a menu item is selected, then the text is + // clicked again - it correctly synchronises the + // click position + mousepos = new Point(e.X, e.Y); + base.OnMouseDown(e); - CloseToolTip(); foreach (AbstractMargin margin in leftMargins) { @@ -307,7 +315,7 @@ namespace ICSharpCode.TextEditor margin.HandleMouseDown(new Point(e.X, e.Y), e.Button); } } - } + } // static because the mouse can only be in one text area and we don't want to have diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaMouseHandler.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaMouseHandler.cs index d81363f776..012f9a1f0f 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaMouseHandler.cs +++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaMouseHandler.cs @@ -21,9 +21,8 @@ namespace ICSharpCode.TextEditor /// public class TextAreaMouseHandler { - TextArea textArea; + TextArea textArea; bool doubleclick = false; - Point mousepos = new Point(0, 0); int selbegin; int selend; bool clickedOnSelectedText = false; @@ -33,14 +32,13 @@ namespace ICSharpCode.TextEditor static readonly Point nilPoint = new Point(-1, -1); Point mousedownpos = nilPoint; Point lastmousedownpos = nilPoint; - public static Point selectionStartPos = nilPoint; bool gotmousedown = false; bool dodragdrop = false; - public TextAreaMouseHandler(TextArea textArea) + public TextAreaMouseHandler(TextArea ttextArea) { - this.textArea = textArea; + textArea = ttextArea; } public void Attach() @@ -115,21 +113,27 @@ namespace ICSharpCode.TextEditor void OnMouseUp(object sender, MouseEventArgs e) { + textArea.SelectionManager.selectFrom.where = WhereFrom.None; gotmousedown = false; mousedownpos = nilPoint; } void TextAreaClick(object sender, EventArgs e) { - if (dodragdrop) { + Point mousepos; + mousepos = textArea.mousepos; + + if (dodragdrop) + { return; } - - if (clickedOnSelectedText && textArea.TextView.DrawingPosition.Contains(mousepos.X, mousepos.Y)) { + + if (clickedOnSelectedText && textArea.TextView.DrawingPosition.Contains(mousepos.X, mousepos.Y)) + { textArea.SelectionManager.ClearSelection(); - - Point clickPosition = textArea.TextView.GetLogicalPosition(mousepos.X - textArea.TextView.DrawingPosition.X, - mousepos.Y - textArea.TextView.DrawingPosition.Y); + + Point clickPosition = textArea.TextView.GetLogicalPosition(mousepos.X - textArea.TextView.DrawingPosition.X, + mousepos.Y - textArea.TextView.DrawingPosition.Y); textArea.Caret.Position = clickPosition; textArea.SetDesiredColumn(); } @@ -138,10 +142,15 @@ namespace ICSharpCode.TextEditor void TextAreaMouseMove(object sender, MouseEventArgs e) { + Point mousepos; + mousepos = textArea.mousepos; + // honour the starting selection strategy - switch(SelectFrom.where) { + switch (textArea.SelectionManager.selectFrom.where) + { case WhereFrom.Gutter: - moveGutter(sender, e); + //moveGutter(sender, e); + ExtendSelectionToMouse(); break; case WhereFrom.TArea: @@ -155,11 +164,12 @@ namespace ICSharpCode.TextEditor } doubleclick = false; - mousepos = new Point(e.X, e.Y); + textArea.mousepos = new Point(e.X, e.Y); if (clickedOnSelectedText) { - if (Math.Abs(mousedownpos.X - mousepos.X) >= SystemInformation.DragSize.Width / 2 || - Math.Abs(mousedownpos.Y - mousepos.Y) >= SystemInformation.DragSize.Height / 2) { + if (Math.Abs(mousedownpos.X - mousepos.X) >= SystemInformation.DragSize.Width / 2 || + Math.Abs(mousedownpos.Y - mousepos.Y) >= SystemInformation.DragSize.Height / 2) + { clickedOnSelectedText = false; ISelection selection = textArea.SelectionManager.GetSelectionAt(textArea.Caret.Offset); if (selection != null) { @@ -178,7 +188,8 @@ namespace ICSharpCode.TextEditor } if (e.Button == MouseButtons.Left) { - if (gotmousedown) { + if (gotmousedown && textArea.SelectionManager.selectFrom.where == WhereFrom.TArea) + { ExtendSelectionToMouse(); } } @@ -186,15 +197,32 @@ namespace ICSharpCode.TextEditor void ExtendSelectionToMouse() { - Point realmousepos = textArea.TextView.GetLogicalPosition(Math.Max(0, mousepos.X - textArea.TextView.DrawingPosition.X), - mousepos.Y - textArea.TextView.DrawingPosition.Y); + Point mousepos; + mousepos = textArea.mousepos; + Point realmousepos = textArea.TextView.GetLogicalPosition(Math.Max(0, mousepos.X - textArea.TextView.DrawingPosition.X), + mousepos.Y - textArea.TextView.DrawingPosition.Y); int y = realmousepos.Y; realmousepos = textArea.Caret.ValidatePosition(realmousepos); Point oldPos = textArea.Caret.Position; - if (oldPos == realmousepos) { + if (oldPos == realmousepos && textArea.SelectionManager.selectFrom.where != WhereFrom.Gutter) + { return; } - textArea.Caret.Position = realmousepos; + + if (textArea.SelectionManager.selectFrom.where == WhereFrom.Gutter) + if(realmousepos.Y < textArea.SelectionManager.selectionStart.Y) { + // the selection is from the gutter and it has moved above the startpoint + textArea.Caret.Position = new Point(0, realmousepos.Y); + } else { + if(realmousepos.Y == textArea.SelectionManager.selectionStart.Y) { + textArea.Caret.Position = textArea.SelectionManager.NextValidPosition(realmousepos.Y); + } else { + textArea.Caret.Position = textArea.SelectionManager.NextValidPosition(realmousepos.Y); + } + } + else + textArea.Caret.Position = realmousepos; + if (minSelection != nilPoint && textArea.SelectionManager.SelectionCollection.Count > 0) { // Extend selection when selection was started with double-click ISelection selection = textArea.SelectionManager.SelectionCollection[0]; @@ -221,10 +249,14 @@ namespace ICSharpCode.TextEditor void DoubleClickSelectionExtend() { - textArea.SelectionManager.ClearSelection(); - if (textArea.TextView.DrawingPosition.Contains(mousepos.X, mousepos.Y)) { - FoldMarker marker = textArea.TextView.GetFoldMarkerFromPosition(mousepos.X - textArea.TextView.DrawingPosition.X, - mousepos.Y - textArea.TextView.DrawingPosition.Y); + Point mousepos; + mousepos = textArea.mousepos; + + textArea.SelectionManager.ClearSelection(); + if (textArea.TextView.DrawingPosition.Contains(mousepos.X, mousepos.Y)) + { + FoldMarker marker = textArea.TextView.GetFoldMarkerFromPosition(mousepos.X - textArea.TextView.DrawingPosition.X, + mousepos.Y - textArea.TextView.DrawingPosition.Y); if (marker != null && marker.IsFolded) { marker.IsFolded = false; textArea.MotherTextAreaControl.AdjustScrollBars(); @@ -261,7 +293,11 @@ namespace ICSharpCode.TextEditor DateTime lastTime = DateTime.Now; void OnMouseDown(object sender, MouseEventArgs e) { - if (dodragdrop) { + Point mousepos; + mousepos = textArea.mousepos; + + if (dodragdrop) + { return; } @@ -272,7 +308,7 @@ namespace ICSharpCode.TextEditor if (textArea.TextView.DrawingPosition.Contains(mousepos.X, mousepos.Y)) { gotmousedown = true; - SelectFrom.where = WhereFrom.TArea; + textArea.SelectionManager.selectFrom.where = WhereFrom.TArea; button = e.Button; if (button == MouseButtons.Left && (DateTime.Now - lastTime).Milliseconds < SystemInformation.DoubleClickTime) { @@ -327,7 +363,7 @@ namespace ICSharpCode.TextEditor textArea.SetDesiredColumn(); } } - } + } } else if (button == MouseButtons.Right) { // Rightclick sets the cursor to the click position unless // the previous selection was clicked @@ -412,8 +448,6 @@ namespace ICSharpCode.TextEditor Point minSelection = nilPoint; Point maxSelection = nilPoint; - - void OnDoubleClick(object sender, System.EventArgs e) { if (dodragdrop) { @@ -423,128 +457,5 @@ namespace ICSharpCode.TextEditor doubleclick = true; } - - bool selectionGutterDirectionDown = true; // direction of gutter selection affects whether a selection starts at the start of a line or at the end of a line - int gutterlastmoveline = -1; // last gutter movement line - public int gutterxstart = 0; // if initial selection is made from the gutter then set to zero, otherwise take the original starting position (from a mouse or keyboard select) - void moveGutter(object sender, MouseEventArgs e) - { - MouseButtons mouseButtons = e.Button; - if (mouseButtons == MouseButtons.Left) - { - bool directionChanged = false; // gone from a downward moving selection to an upward, or vice-versa - int realline = textArea.TextView.GetLogicalLine(mousepos); - Point realmousepos = new Point(0, realline); - - // avoid reprocessing the same selected line (prevent flicker) - if (gutterlastmoveline == realmousepos.Y) - return; - else - { - if (realmousepos.Y < selectionStartPos.Y) - { - // we need to record when the behaviour changes - // used down further - if (selectionGutterDirectionDown) - directionChanged = true; - - // determine the selection strategy - selectionGutterDirectionDown = false; - } - else - { - // we need to record when the behaviour changes - // used down further - if (!selectionGutterDirectionDown) - directionChanged = true; - - // determine the selection strategy - selectionGutterDirectionDown = true; - } - - gutterlastmoveline = realmousepos.Y; - } - - // between 1st and last lines - last line is handled differently - if (realmousepos.Y < textArea.Document.TotalNumberOfLines - 1) - { - if (selectionStartPos.Y == realmousepos.Y) - { - // this setselection defaults for a upward moving selection - textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, realmousepos, new Point(selectionStartPos.X, realmousepos.Y + 1))); - } - else if (selectionStartPos.Y < realmousepos.Y && textArea.SelectionManager.HasSomethingSelected) - { - // this fixes the selection for moving the selection down - if (directionChanged) - { - textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, selectionStartPos, new Point(selectionStartPos.X, selectionStartPos.Y))); - // this enforces the screen area update - textArea.SelectionManager.ExtendSelection(textArea.SelectionManager.SelectionCollection[0].EndPosition, new Point(0, realmousepos.Y + 1)); - } - else - { - // selection is extended to the end of the current line - textArea.SelectionManager.ExtendSelection(textArea.SelectionManager.SelectionCollection[0].EndPosition, new Point(0, realmousepos.Y + 1)); - } - } - else - { - // when something is already selected we must repect the existing selection - if (textArea.SelectionManager.HasSomethingSelected) - { - // this fixes the selection for moving the selection up - if (realmousepos.Y < selectionStartPos.Y && directionChanged) // the first time an upward selection moves above the first selection line - { - textArea.SelectionManager.ClearSelection(); - selectionStartPos = new Point(selectionStartPos.X, TextAreaMouseHandler.selectionStartPos.Y); - - if ((Control.ModifierKeys & Keys.Shift) != 0 && selectionStartPos.X != 0) - { - // shift-click - textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, selectionStartPos, new Point(selectionStartPos.X, selectionStartPos.Y))); - } - else - { - textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, selectionStartPos, new Point(selectionStartPos.X, selectionStartPos.Y + 1))); - } - textArea.SelectionManager.ExtendSelection(new Point(selectionStartPos.X, selectionStartPos.Y), new Point(realmousepos.X, realmousepos.Y)); - } - else - { - textArea.SelectionManager.ExtendSelection(textArea.Caret.Position, realmousepos); - } - } - } - - if (realmousepos.Y >= selectionStartPos.Y) // at or below starting selection, place the cursor on the next line - textArea.Caret.Position = new Point(0, realmousepos.Y + 1); - else // prior lines to starting selection, place the cursor on the same line as the new selection - textArea.Caret.Position = new Point(0, realmousepos.Y); - } - else - { - if (realmousepos.Y == textArea.Document.TotalNumberOfLines - 1) - { - // selection is last line of text - textArea.SelectionManager.ClearSelection(); - textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, new Point(selectionStartPos.X, selectionStartPos.Y), new Point(textArea.Document.GetLineSegment(realline).Length + 1, realline))); - textArea.Caret.Position = new Point(textArea.Document.GetLineSegment(realline).Length + 1, realline); - } - } - } - else - gutterlastmoveline = -1; - } } - - public class SelectFrom { - public static int where = WhereFrom.None; - } - - public class WhereFrom { - public const int None = 0; - public const int Gutter = 1; - public const int TArea = 2; - } }