Code Coverage Statistics for Source File
C:\Users\Marcus\Documents\MyCode\2007\SharpSelectWord\SharpSelectWord\Src\SelectWordCommand.cs
|
Sequence Point Coverage
0,0%
0 of 16
|
Branch Coverage
N/A
0 of 0
|
Lines
60
|
Highlight:
Uncovered Code
Covered Code
| L | V | Source |
|---|---|---|
1 |
// SharpSelectWord is a addin to SharpDevelop that can select text. |
|
2 |
// Copyright (C) 2007 Marcus Holmgren |
|
3 |
// |
|
4 |
// This library is free software; you can redistribute it and/or |
|
5 |
// modify it under the terms of the GNU Lesser General Public |
|
6 |
// License as published by the Free Software Foundation; either |
|
7 |
// version 2.1 of the License, or (at your option) any later version. |
|
8 |
// |
|
9 |
// This library is distributed in the hope that it will be useful, |
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
12 |
// Lesser General Public License for more details. |
|
13 |
// |
|
14 |
// You should have received a copy of the GNU Lesser General Public |
|
15 |
// License along with this library; if not, write to the Free Software |
|
16 |
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 |
||
18 |
||
19 |
using ICSharpCode.Core; |
|
20 |
using ICSharpCode.SharpDevelop.Gui; |
|
21 |
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; |
|
22 |
using ICSharpCode.TextEditor; |
|
23 |
using ICSharpCode.TextEditor.Document; |
|
24 |
||
25 |
namespace MarcusHolmgren.SharpDevelop.SelectWord |
|
26 |
{ |
|
27 |
public class SelectWordCommand : AbstractMenuCommand |
|
28 |
{ |
|
29 |
public override void Run() |
|
30 |
{ |
|
31 |
0 |
ITextEditorControlProvider tecp = WorkbenchSingleton.Workbench.ActiveContent as ITextEditorControlProvider; |
32 |
0 |
if (tecp == null) return; |
33 |
||
34 |
0 |
TextArea textArea = tecp.TextEditorControl.ActiveTextAreaControl.TextArea; |
35 |
||
36 |
0 |
ISelection selector = MakeWordSelector(textArea); |
37 |
0 |
textArea.SelectionManager.SetSelection(selector); |
38 |
||
39 |
0 |
textArea.Refresh(); |
40 |
0 |
} |
41 |
||
42 |
private static ISelection MakeWordSelector(TextArea textArea) |
|
43 |
{ |
|
44 |
0 |
IDocument document = textArea.Document; |
45 |
||
46 |
0 |
if (!textArea.SelectionManager.HasSomethingSelected) |
47 |
{ |
|
48 |
0 |
int currentOffset = textArea.Caret.Offset; |
49 |
0 |
return new SingleWordSelection(document, currentOffset); |
50 |
} |
|
51 |
else |
|
52 |
{ |
|
53 |
0 |
SelectionManager selectionManager = textArea.SelectionManager; |
54 |
0 |
ISelection firstSelection = selectionManager.SelectionCollection[0]; |
55 |
||
56 |
0 |
return new ExtendBlockSelection(document, firstSelection); |
57 |
} |
|
58 |
} |
|
59 |
} |
|
60 |
} |