Code Coverage Statistics for Source File

c:\Tools\SD3\src\Libraries\ICSharpCode.TextEditor\Project\Src\Actions\SelectionActions.cs

Sequence Point Coverage
N/A
0 of 0
Branch Coverage
N/A
0 of 0
Lines
176
Highlight: Uncovered Code Covered Code
L V Source
1
// <file>
2
//     <copyright see="prj:///doc/copyright.txt"/>
3
//     <license see="prj:///doc/license.txt"/>
4
//     <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
5
//     <version>$Revision: 2659 $</version>
6
// </file>
7
8
using System;
9
using System.Drawing;
10
using ICSharpCode.TextEditor.Document;
11
12
namespace ICSharpCode.TextEditor.Actions
13
{
14
	public class ShiftCaretRight : CaretRight
15
	{
16
		public override void Execute(TextArea textArea)
17
		{
18
			TextLocation oldCaretPos  = textArea.Caret.Position;
19
			base.Execute(textArea);
20
			textArea.AutoClearSelection = false;
21
			textArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);
22
		}
23
	}
24
	
25
	public class ShiftCaretLeft : CaretLeft
26
	{
27
		public override void Execute(TextArea textArea)
28
		{
29
			TextLocation oldCaretPos  = textArea.Caret.Position;
30
			base.Execute(textArea);
31
			textArea.AutoClearSelection = false;
32
			textArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);
33
		}
34
	}
35
	
36
	public class ShiftCaretUp : CaretUp
37
	{
38
		public override void Execute(TextArea textArea)
39
		{
40
			TextLocation oldCaretPos  = textArea.Caret.Position;
41
			base.Execute(textArea);
42
			textArea.AutoClearSelection = false;
43
			textArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);
44
		}
45
	}
46
	
47
	public class ShiftCaretDown : CaretDown
48
	{
49
		public override void Execute(TextArea textArea)
50
		{
51
			TextLocation oldCaretPos  = textArea.Caret.Position;
52
			base.Execute(textArea);
53
			textArea.AutoClearSelection = false;
54
			textArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);
55
		}
56
	}
57
	
58
	public class ShiftWordRight : WordRight
59
	{
60
		public override void Execute(TextArea textArea)
61
		{
62
			TextLocation oldCaretPos  = textArea.Caret.Position;
63
			base.Execute(textArea);
64
			textArea.AutoClearSelection = false;
65
			textArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);
66
		}
67
	}
68
	
69
	public class ShiftWordLeft : WordLeft
70
	{
71
		public override void Execute(TextArea textArea)
72
		{
73
			TextLocation oldCaretPos  = textArea.Caret.Position;
74
			base.Execute(textArea);
75
			textArea.AutoClearSelection = false;
76
			textArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);
77
		}
78
	}
79
	
80
	public class ShiftHome : Home
81
	{
82
		public override void Execute(TextArea textArea)
83
		{
84
			TextLocation oldCaretPos  = textArea.Caret.Position;
85
			base.Execute(textArea);
86
			textArea.AutoClearSelection = false;
87
			textArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);
88
		}
89
	}
90
	
91
	public class ShiftEnd : End
92
	{
93
		public override void Execute(TextArea textArea)
94
		{
95
			TextLocation oldCaretPos  = textArea.Caret.Position;
96
			base.Execute(textArea);
97
			textArea.AutoClearSelection = false;
98
			textArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);
99
		}
100
	}
101
	
102
	public class ShiftMoveToStart : MoveToStart
103
	{
104
		public override void Execute(TextArea textArea)
105
		{
106
			TextLocation oldCaretPos  = textArea.Caret.Position;
107
			base.Execute(textArea);
108
			textArea.AutoClearSelection = false;
109
			textArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);
110
		}
111
	}
112
	
113
	public class ShiftMoveToEnd : MoveToEnd
114
	{
115
		public override void Execute(TextArea textArea)
116
		{
117
			TextLocation oldCaretPos  = textArea.Caret.Position;
118
			base.Execute(textArea);
119
			textArea.AutoClearSelection = false;
120
			textArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);
121
		}
122
	}
123
	
124
	public class ShiftMovePageUp : MovePageUp
125
	{
126
		public override void Execute(TextArea textArea)
127
		{
128
			TextLocation oldCaretPos  = textArea.Caret.Position;
129
			base.Execute(textArea);
130
			textArea.AutoClearSelection = false;
131
			textArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);
132
		}
133
	}
134
	
135
	public class ShiftMovePageDown : MovePageDown
136
	{
137
		public override void Execute(TextArea textArea)
138
		{
139
			TextLocation oldCaretPos  = textArea.Caret.Position;
140
			base.Execute(textArea);
141
			textArea.AutoClearSelection = false;
142
			textArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);
143
		}
144
	}
145
	
146
	public class SelectWholeDocument : AbstractEditAction
147
	{
148
		public override void Execute(TextArea textArea)
149
		{
150
			textArea.AutoClearSelection = false;
151
			TextLocation startPoint = new TextLocation(0, 0);
152
			TextLocation endPoint   = textArea.Document.OffsetToPosition(textArea.Document.TextLength);
153
			if (textArea.SelectionManager.HasSomethingSelected) {
154
				if (textArea.SelectionManager.SelectionCollection[0].StartPosition == startPoint &&
155
				    textArea.SelectionManager.SelectionCollection[0].EndPosition   == endPoint) {
156
					return;
157
				}
158
			}
159
			textArea.Caret.Position = textArea.SelectionManager.NextValidPosition(endPoint.Y);
160
			textArea.SelectionManager.ExtendSelection(startPoint, endPoint);
161
			// after a SelectWholeDocument selection, the caret is placed correctly,
162
			// but it is not positioned internally.  The effect is when the cursor
163
			// is moved up or down a line, the caret will take on the column that
164
			// it was in before the SelectWholeDocument
165
			textArea.SetDesiredColumn();
166
		}
167
	}
168
	
169
	public class ClearAllSelections : AbstractEditAction
170
	{
171
		public override void Execute(TextArea textArea)
172
		{
173
			textArea.SelectionManager.ClearSelection();
174
		}
175
	}
176
}