|
|
|
@ -95,67 +95,67 @@ namespace ICSharpCode.TextEditor |
|
|
|
|
|
|
|
|
|
|
|
public override void HandleMouseDown(Point mousepos, MouseButtons mouseButtons) |
|
|
|
public override void HandleMouseDown(Point mousepos, MouseButtons mouseButtons) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Point selectionStartPos; |
|
|
|
Point selectionStartPos; |
|
|
|
|
|
|
|
|
|
|
|
textArea.SelectionManager.selectFrom.where = WhereFrom.Gutter; |
|
|
|
textArea.SelectionManager.selectFrom.where = WhereFrom.Gutter; |
|
|
|
int realline = textArea.TextView.GetLogicalLine(mousepos); |
|
|
|
int realline = textArea.TextView.GetLogicalLine(mousepos); |
|
|
|
if (realline >= 0 && realline < textArea.Document.TotalNumberOfLines) { |
|
|
|
if (realline >= 0 && realline < textArea.Document.TotalNumberOfLines) { |
|
|
|
// shift-select
|
|
|
|
// shift-select
|
|
|
|
if((Control.ModifierKeys & Keys.Shift) != 0) { |
|
|
|
if((Control.ModifierKeys & Keys.Shift) != 0) { |
|
|
|
if(!textArea.SelectionManager.HasSomethingSelected && realline != textArea.Caret.Position.Y) { |
|
|
|
if(!textArea.SelectionManager.HasSomethingSelected && realline != textArea.Caret.Position.Y) { |
|
|
|
if (realline >= textArea.Caret.Position.Y) |
|
|
|
if (realline >= textArea.Caret.Position.Y) |
|
|
|
{ // at or below starting selection, place the cursor on the next line
|
|
|
|
{ // at or below starting selection, place the cursor on the next line
|
|
|
|
// nothing is selected so make a new selection from cursor
|
|
|
|
// nothing is selected so make a new selection from cursor
|
|
|
|
selectionStartPos = textArea.Caret.Position; |
|
|
|
selectionStartPos = textArea.Caret.Position; |
|
|
|
// whole line selection - start of line to start of next line
|
|
|
|
// whole line selection - start of line to start of next line
|
|
|
|
if (realline < textArea.Document.TotalNumberOfLines - 1) |
|
|
|
if (realline < textArea.Document.TotalNumberOfLines - 1) |
|
|
|
{ |
|
|
|
{ |
|
|
|
textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, 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); |
|
|
|
textArea.Caret.Position = new Point(0, realline + 1); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, 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); |
|
|
|
textArea.Caret.Position = new Point(textArea.Document.GetLineSegment(realline).Length + 1, realline); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ // prior lines to starting selection, place the cursor on the same line as the new selection
|
|
|
|
{ // 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
|
|
|
|
// nothing is selected so make a new selection from cursor
|
|
|
|
selectionStartPos = textArea.Caret.Position; |
|
|
|
selectionStartPos = textArea.Caret.Position; |
|
|
|
// whole line selection - start of line to start of next line
|
|
|
|
// whole line selection - start of line to start of next line
|
|
|
|
textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, selectionStartPos, new Point(selectionStartPos.X, selectionStartPos.Y))); |
|
|
|
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.SelectionManager.ExtendSelection(new Point(selectionStartPos.X, selectionStartPos.Y), new Point(0, realline)); |
|
|
|
textArea.Caret.Position = new Point(0, realline); |
|
|
|
textArea.Caret.Position = new Point(0, realline); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
// let MouseMove handle a shift-click in a gutter
|
|
|
|
// let MouseMove handle a shift-click in a gutter
|
|
|
|
MouseEventArgs e = new MouseEventArgs(mouseButtons, 1, mousepos.X, mousepos.Y, 0); |
|
|
|
MouseEventArgs e = new MouseEventArgs(mouseButtons, 1, mousepos.X, mousepos.Y, 0); |
|
|
|
textArea.doMouseMove(e); |
|
|
|
textArea.RaiseMouseMove(e); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { // this is a new selection with no shift-key
|
|
|
|
} else { // this is a new selection with no shift-key
|
|
|
|
// sync the textareamousehandler mouse location
|
|
|
|
// sync the textareamousehandler mouse location
|
|
|
|
// (fixes problem with clicking out into a menu then back to the gutter whilst
|
|
|
|
// (fixes problem with clicking out into a menu then back to the gutter whilst
|
|
|
|
// there is a selection)
|
|
|
|
// there is a selection)
|
|
|
|
textArea.mousepos = mousepos; |
|
|
|
textArea.mousepos = mousepos; |
|
|
|
|
|
|
|
|
|
|
|
selectionStartPos = new Point(0, realline); |
|
|
|
selectionStartPos = new Point(0, realline); |
|
|
|
textArea.SelectionManager.ClearSelection(); |
|
|
|
textArea.SelectionManager.ClearSelection(); |
|
|
|
// whole line selection - start of line to start of next line
|
|
|
|
// whole line selection - start of line to start of next line
|
|
|
|
if (realline < textArea.Document.TotalNumberOfLines - 1) |
|
|
|
if (realline < textArea.Document.TotalNumberOfLines - 1) |
|
|
|
{ |
|
|
|
{ |
|
|
|
textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, selectionStartPos, new Point(selectionStartPos.X, 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); |
|
|
|
textArea.Caret.Position = new Point(selectionStartPos.X, selectionStartPos.Y + 1); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.Document, new Point(0, realline), new Point(textArea.Document.GetLineSegment(realline).Length + 1, 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); |
|
|
|
textArea.Caret.Position = new Point(textArea.Document.GetLineSegment(realline).Length + 1, selectionStartPos.Y); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|