first commit
This commit is contained in:
176
ICSharpCode.TextEditor/Project/Src/Actions/SelectionActions.cs
Normal file
176
ICSharpCode.TextEditor/Project/Src/Actions/SelectionActions.cs
Normal file
@@ -0,0 +1,176 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using ICSharpCode.TextEditor.Document;
|
||||
|
||||
namespace ICSharpCode.TextEditor.Actions
|
||||
{
|
||||
public class ShiftCaretRight : CaretRight
|
||||
{
|
||||
public override void Execute(TextArea textArea)
|
||||
{
|
||||
TextLocation oldCaretPos = textArea.Caret.Position;
|
||||
base.Execute(textArea);
|
||||
textArea.AutoClearSelection = false;
|
||||
textArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);
|
||||
}
|
||||
}
|
||||
|
||||
public class ShiftCaretLeft : CaretLeft
|
||||
{
|
||||
public override void Execute(TextArea textArea)
|
||||
{
|
||||
TextLocation oldCaretPos = textArea.Caret.Position;
|
||||
base.Execute(textArea);
|
||||
textArea.AutoClearSelection = false;
|
||||
textArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);
|
||||
}
|
||||
}
|
||||
|
||||
public class ShiftCaretUp : CaretUp
|
||||
{
|
||||
public override void Execute(TextArea textArea)
|
||||
{
|
||||
TextLocation oldCaretPos = textArea.Caret.Position;
|
||||
base.Execute(textArea);
|
||||
textArea.AutoClearSelection = false;
|
||||
textArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);
|
||||
}
|
||||
}
|
||||
|
||||
public class ShiftCaretDown : CaretDown
|
||||
{
|
||||
public override void Execute(TextArea textArea)
|
||||
{
|
||||
TextLocation oldCaretPos = textArea.Caret.Position;
|
||||
base.Execute(textArea);
|
||||
textArea.AutoClearSelection = false;
|
||||
textArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);
|
||||
}
|
||||
}
|
||||
|
||||
public class ShiftWordRight : WordRight
|
||||
{
|
||||
public override void Execute(TextArea textArea)
|
||||
{
|
||||
TextLocation oldCaretPos = textArea.Caret.Position;
|
||||
base.Execute(textArea);
|
||||
textArea.AutoClearSelection = false;
|
||||
textArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);
|
||||
}
|
||||
}
|
||||
|
||||
public class ShiftWordLeft : WordLeft
|
||||
{
|
||||
public override void Execute(TextArea textArea)
|
||||
{
|
||||
TextLocation oldCaretPos = textArea.Caret.Position;
|
||||
base.Execute(textArea);
|
||||
textArea.AutoClearSelection = false;
|
||||
textArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);
|
||||
}
|
||||
}
|
||||
|
||||
public class ShiftHome : Home
|
||||
{
|
||||
public override void Execute(TextArea textArea)
|
||||
{
|
||||
TextLocation oldCaretPos = textArea.Caret.Position;
|
||||
base.Execute(textArea);
|
||||
textArea.AutoClearSelection = false;
|
||||
textArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);
|
||||
}
|
||||
}
|
||||
|
||||
public class ShiftEnd : End
|
||||
{
|
||||
public override void Execute(TextArea textArea)
|
||||
{
|
||||
TextLocation oldCaretPos = textArea.Caret.Position;
|
||||
base.Execute(textArea);
|
||||
textArea.AutoClearSelection = false;
|
||||
textArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);
|
||||
}
|
||||
}
|
||||
|
||||
public class ShiftMoveToStart : MoveToStart
|
||||
{
|
||||
public override void Execute(TextArea textArea)
|
||||
{
|
||||
TextLocation oldCaretPos = textArea.Caret.Position;
|
||||
base.Execute(textArea);
|
||||
textArea.AutoClearSelection = false;
|
||||
textArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);
|
||||
}
|
||||
}
|
||||
|
||||
public class ShiftMoveToEnd : MoveToEnd
|
||||
{
|
||||
public override void Execute(TextArea textArea)
|
||||
{
|
||||
TextLocation oldCaretPos = textArea.Caret.Position;
|
||||
base.Execute(textArea);
|
||||
textArea.AutoClearSelection = false;
|
||||
textArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);
|
||||
}
|
||||
}
|
||||
|
||||
public class ShiftMovePageUp : MovePageUp
|
||||
{
|
||||
public override void Execute(TextArea textArea)
|
||||
{
|
||||
TextLocation oldCaretPos = textArea.Caret.Position;
|
||||
base.Execute(textArea);
|
||||
textArea.AutoClearSelection = false;
|
||||
textArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);
|
||||
}
|
||||
}
|
||||
|
||||
public class ShiftMovePageDown : MovePageDown
|
||||
{
|
||||
public override void Execute(TextArea textArea)
|
||||
{
|
||||
TextLocation oldCaretPos = textArea.Caret.Position;
|
||||
base.Execute(textArea);
|
||||
textArea.AutoClearSelection = false;
|
||||
textArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);
|
||||
}
|
||||
}
|
||||
|
||||
public class SelectWholeDocument : AbstractEditAction
|
||||
{
|
||||
public override void Execute(TextArea textArea)
|
||||
{
|
||||
textArea.AutoClearSelection = false;
|
||||
TextLocation startPoint = new TextLocation(0, 0);
|
||||
TextLocation endPoint = textArea.Document.OffsetToPosition(textArea.Document.TextLength);
|
||||
if (textArea.SelectionManager.HasSomethingSelected) {
|
||||
if (textArea.SelectionManager.SelectionCollection[0].StartPosition == startPoint &&
|
||||
textArea.SelectionManager.SelectionCollection[0].EndPosition == endPoint) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
textArea.Caret.Position = textArea.SelectionManager.NextValidPosition(endPoint.Y);
|
||||
textArea.SelectionManager.ExtendSelection(startPoint, endPoint);
|
||||
// after a SelectWholeDocument selection, the caret is placed correctly,
|
||||
// but it is not positioned internally. The effect is when the cursor
|
||||
// is moved up or down a line, the caret will take on the column that
|
||||
// it was in before the SelectWholeDocument
|
||||
textArea.SetDesiredColumn();
|
||||
}
|
||||
}
|
||||
|
||||
public class ClearAllSelections : AbstractEditAction
|
||||
{
|
||||
public override void Execute(TextArea textArea)
|
||||
{
|
||||
textArea.SelectionManager.ClearSelection();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user