~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SearchAndReplaceWidget.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2011-06-27 17:03:13 UTC
  • mto: (1.8.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 54.
  • Revision ID: james.westby@ubuntu.com-20110627170313-6cvz3s19x6e9hqe9
Import upstream version 2.5.92+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
using Mono.TextEditor;
35
35
using MonoDevelop.Core;
36
36
using MonoDevelop.Ide;
 
37
using MonoDevelop.Ide.Commands;
 
38
using MonoDevelop.Components.Commands;
37
39
 
38
40
namespace MonoDevelop.SourceEditor
39
41
{
53
55
                bool isReplaceMode = true;
54
56
                Widget [] replaceWidgets;
55
57
                
56
 
                public static bool IsCaseSensitive {
 
58
                public bool IsCaseSensitive {
57
59
                        get { return PropertyService.Get ("IsCaseSensitive", true); }
58
60
                        set { 
59
61
                                if (IsCaseSensitive != value)
60
62
                                        PropertyService.Set ("IsCaseSensitive", value); 
61
 
                        }
62
 
                }
63
 
                
64
 
                public static bool IsWholeWordOnly {
65
 
                        get { return PropertyService.Get ("IsWholeWordOnly", false); }
66
 
                }
67
 
                
 
63
                        }
 
64
                }
 
65
                
 
66
                public static bool IsWholeWordOnly {
 
67
                        get { return PropertyService.Get ("IsWholeWordOnly", false); }
 
68
                }
 
69
                
68
70
                public const string DefaultSearchEngine = "default";
69
71
                public const string RegexSearchEngine   = "regex";
70
 
                public static string SearchEngine {
71
 
                        get {
72
 
                                return PropertyService.Get ("BufferSearchEngine", DefaultSearchEngine);
73
 
                        }
 
72
                public static string SearchEngine {
 
73
                        get {
 
74
                                return PropertyService.Get ("BufferSearchEngine", DefaultSearchEngine);
 
75
                        }
74
76
                }
75
77
                
76
78
                public string ReplacePattern {
140
142
                        FilterHistory (seachHistoryProperty);
141
143
                        FilterHistory (replaceHistoryProperty);
142
144
                        //HACK: GTK rendering issue on Mac, images don't repaint unless we put them in visible eventboxes
143
 
                        if (Platform.IsMac) {
144
 
                                foreach (var eb in new [] { eventbox2, eventbox3, eventbox4, eventbox5, eventbox6 }) {
 
145
                        if (Platform.IsMac) {
 
146
                                foreach (var eb in new [] { eventbox2, eventbox3, eventbox4, eventbox5, eventbox6 }) {
145
147
                                        eb.VisibleWindow = true;
146
148
                                        eb.ModifyBg (StateType.Normal, new Gdk.Color (230, 230, 230));
147
149
                                }
168
170
                                widget.SetSearchPattern (SearchPattern);
169
171
                                string oldPattern = searchPattern;
170
172
                                searchPattern = SearchPattern;
171
 
                                UpdateSearchEntry ();
 
173
                                if (oldPattern != searchPattern)
 
174
                                        UpdateSearchEntry ();
172
175
                                var history = GetHistory (seachHistoryProperty);
173
176
                                if (history.Count > 0 && history[0] == oldPattern) {
174
177
                                        ChangeHistory (seachHistoryProperty, searchPattern);
347
350
                        return base.OnEnterNotifyEvent (evnt);
348
351
                }
349
352
                
 
353
                [CommandHandler (EditCommands.SelectAll)]
 
354
                public void SelectAllCommand ()
 
355
                {
 
356
                        if (searchEntry.HasFocus) {
 
357
                                searchEntry.Entry.SelectRegion (0, searchEntry.Entry.Text.Length);
 
358
                        } else if (IsReplaceMode && entryReplace.HasFocus) {
 
359
                                entryReplace.SelectRegion (0, entryReplace.Text.Length);
 
360
                        }
 
361
                }
 
362
                
350
363
                public void UpdateSearchPattern ()
351
364
                {
352
365
                        searchEntry.Entry.Text = widget.TextEditor.SearchPattern;
541
554
                                        widget.TextEditor.ClearSelection ();
542
555
                                        return;
543
556
                                }
 
557
                                widget.TextEditor.StopSearchResultAnimation ();
544
558
                                widget.TextEditor.Caret.Offset = result.EndOffset;
545
559
                                widget.TextEditor.SetSelection (result.Offset, result.EndOffset);
546
560
                                widget.TextEditor.CenterToCaret ();
547
561
                                widget.TextEditor.AnimateSearchResult (result);
548
 
                        } catch (System.Exception) { 
 
562
                        } catch (System.Exception) {
549
563
                        }
550
564
                }
551
565
                
610
624
                
611
625
                void SetIsWholeWordOnly (bool value)
612
626
                {
613
 
                        PropertyService.Set ("IsWholeWordOnly", value);
 
627
                        PropertyService.Set ("IsWholeWordOnly", value);
614
628
                        widget.SetSearchOptions ();
615
629
                }
616
630