Code Coverage Statistics for Source File
c:\Tools\SD3\src\Libraries\ICSharpCode.TextEditor\Project\Src\Actions\HomeEndActions.cs
|
Sequence Point Coverage
N/A
0 of 0
|
Branch Coverage
N/A
0 of 0
|
Lines
114
|
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.Collections.Generic; |
|
10 |
using System.Drawing; |
|
11 |
||
12 |
using ICSharpCode.TextEditor.Document; |
|
13 |
||
14 |
namespace ICSharpCode.TextEditor.Actions |
|
15 |
{ |
|
16 |
public class Home : AbstractEditAction |
|
17 |
{ |
|
18 |
public override void Execute(TextArea textArea) |
|
19 |
{ |
|
20 |
LineSegment curLine; |
|
21 |
TextLocation newPos = textArea.Caret.Position; |
|
22 |
bool jumpedIntoFolding = false; |
|
23 |
do { |
|
24 |
curLine = textArea.Document.GetLineSegment(newPos.Y); |
|
25 |
||
26 |
if (TextUtilities.IsEmptyLine(textArea.Document, newPos.Y)) { |
|
27 |
if (newPos.X != 0) { |
|
28 |
newPos.X = 0; |
|
29 |
} else { |
|
30 |
newPos.X = curLine.Length; |
|
31 |
} |
|
32 |
} else { |
|
33 |
int firstCharOffset = TextUtilities.GetFirstNonWSChar(textArea.Document, curLine.Offset); |
|
34 |
int firstCharColumn = firstCharOffset - curLine.Offset; |
|
35 |
||
36 |
if (newPos.X == firstCharColumn) { |
|
37 |
newPos.X = 0; |
|
38 |
} else { |
|
39 |
newPos.X = firstCharColumn; |
|
40 |
} |
|
41 |
} |
|
42 |
List<FoldMarker> foldings = textArea.Document.FoldingManager.GetFoldingsFromPosition(newPos.Y, newPos.X); |
|
43 |
jumpedIntoFolding = false; |
|
44 |
foreach (FoldMarker foldMarker in foldings) { |
|
45 |
if (foldMarker.IsFolded) { |
|
46 |
newPos = new TextLocation(foldMarker.StartColumn, foldMarker.StartLine); |
|
47 |
jumpedIntoFolding = true; |
|
48 |
break; |
|
49 |
} |
|
50 |
} |
|
51 |
||
52 |
} while (jumpedIntoFolding); |
|
53 |
||
54 |
if (newPos != textArea.Caret.Position) { |
|
55 |
textArea.Caret.Position = newPos; |
|
56 |
textArea.SetDesiredColumn(); |
|
57 |
} |
|
58 |
} |
|
59 |
} |
|
60 |
||
61 |
public class End : AbstractEditAction |
|
62 |
{ |
|
63 |
public override void Execute(TextArea textArea) |
|
64 |
{ |
|
65 |
LineSegment curLine; |
|
66 |
TextLocation newPos = textArea.Caret.Position; |
|
67 |
bool jumpedIntoFolding = false; |
|
68 |
do { |
|
69 |
curLine = textArea.Document.GetLineSegment(newPos.Y); |
|
70 |
newPos.X = curLine.Length; |
|
71 |
||
72 |
List<FoldMarker> foldings = textArea.Document.FoldingManager.GetFoldingsFromPosition(newPos.Y, newPos.X); |
|
73 |
jumpedIntoFolding = false; |
|
74 |
foreach (FoldMarker foldMarker in foldings) { |
|
75 |
if (foldMarker.IsFolded) { |
|
76 |
newPos = new TextLocation(foldMarker.EndColumn, foldMarker.EndLine); |
|
77 |
jumpedIntoFolding = true; |
|
78 |
break; |
|
79 |
} |
|
80 |
} |
|
81 |
} while (jumpedIntoFolding); |
|
82 |
||
83 |
if (newPos != textArea.Caret.Position) { |
|
84 |
textArea.Caret.Position = newPos; |
|
85 |
textArea.SetDesiredColumn(); |
|
86 |
} |
|
87 |
} |
|
88 |
} |
|
89 |
||
90 |
||
91 |
public class MoveToStart : AbstractEditAction |
|
92 |
{ |
|
93 |
public override void Execute(TextArea textArea) |
|
94 |
{ |
|
95 |
if (textArea.Caret.Line != 0 || textArea.Caret.Column != 0) { |
|
96 |
textArea.Caret.Position = new TextLocation(0, 0); |
|
97 |
textArea.SetDesiredColumn(); |
|
98 |
} |
|
99 |
} |
|
100 |
} |
|
101 |
||
102 |
||
103 |
public class MoveToEnd : AbstractEditAction |
|
104 |
{ |
|
105 |
public override void Execute(TextArea textArea) |
|
106 |
{ |
|
107 |
TextLocation endPos = textArea.Document.OffsetToPosition(textArea.Document.TextLength); |
|
108 |
if (textArea.Caret.Position != endPos) { |
|
109 |
textArea.Caret.Position = endPos; |
|
110 |
textArea.SetDesiredColumn(); |
|
111 |
} |
|
112 |
} |
|
113 |
} |
|
114 |
} |