~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/Misc/SearchAndReplace/Project/Engine/DocumentIterator/CurrentDocumentIterator.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
 
3
 
 
4
using ICSharpCode.SharpDevelop.Editor;
 
5
using System;
 
6
using ICSharpCode.SharpDevelop;
 
7
using ICSharpCode.SharpDevelop.Editor.Search;
 
8
using ICSharpCode.SharpDevelop.Gui;
 
9
 
 
10
namespace SearchAndReplace
 
11
{
 
12
        public class CurrentDocumentIterator : IDocumentIterator
 
13
        {
 
14
                bool      didRead = false;
 
15
                
 
16
                public CurrentDocumentIterator()
 
17
                {
 
18
                        Reset();
 
19
                }
 
20
                
 
21
                public string CurrentFileName {
 
22
                        get {
 
23
                                if (!SearchReplaceUtilities.IsTextAreaSelected) {
 
24
                                        return null;
 
25
                                }
 
26
                                return WorkbenchSingleton.Workbench.ActiveViewContent.PrimaryFileName;
 
27
                        }
 
28
                }
 
29
                
 
30
                public ProvidedDocumentInformation Current {
 
31
                        get {
 
32
                                ITextEditor textEditor = SearchReplaceUtilities.GetActiveTextEditor();
 
33
                                if (textEditor != null)
 
34
                                        return new ProvidedDocumentInformation(textEditor.Document, CurrentFileName, textEditor);
 
35
                                else
 
36
                                        return null;
 
37
                        }
 
38
                }
 
39
                
 
40
                public bool MoveForward()
 
41
                {
 
42
                        if (!SearchReplaceUtilities.IsTextAreaSelected) {
 
43
                                return false;
 
44
                        }
 
45
                        if (didRead) {
 
46
                                return false;
 
47
                        }
 
48
                        didRead = true;
 
49
                        
 
50
                        return true;
 
51
                }
 
52
                
 
53
                public bool MoveBackward()
 
54
                {
 
55
                        return MoveForward();
 
56
                }
 
57
                
 
58
                public void Reset()
 
59
                {
 
60
                        didRead = false;
 
61
                }
 
62
        }
 
63
}