~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
using MonoDevelop.Components.Commands;
34
34
using MonoDevelop.Core;
35
35
using MonoDevelop.Projects;
36
 
using MonoDevelop.Ide.Commands;
37
36
using Document = Mono.TextEditor.TextDocument;
38
37
using Services = MonoDevelop.Projects.Services;
39
38
using System.Threading;
46
45
using Mono.TextEditor.Highlighting;
47
46
using MonoDevelop.SourceEditor.QuickTasks;
48
47
using ICSharpCode.NRefactory.CSharp;
 
48
using ICSharpCode.NRefactory.Semantics;
49
49
 
50
50
namespace MonoDevelop.SourceEditor
51
51
{
66
66
//              bool canShowClassBrowser;
67
67
                ISourceEditorOptions options {
68
68
                        get {
69
 
                                return this.textEditor.Options;
 
69
                                return textEditor.Options;
70
70
                        }
71
71
                }
72
72
                
73
 
                bool isDisposed = false;
 
73
                bool isDisposed;
74
74
                
75
75
                ParsedDocument parsedDocument;
76
76
                
77
 
                readonly MonoDevelop.SourceEditor.ExtensibleTextEditor textEditor;
78
 
                MonoDevelop.SourceEditor.ExtensibleTextEditor splittedTextEditor;
79
 
                MonoDevelop.SourceEditor.ExtensibleTextEditor lastActiveEditor;
 
77
                readonly ExtensibleTextEditor textEditor;
 
78
                ExtensibleTextEditor splittedTextEditor;
 
79
                ExtensibleTextEditor lastActiveEditor;
80
80
                
81
81
                public MonoDevelop.SourceEditor.ExtensibleTextEditor TextEditor {
82
82
                        get {
84
84
                        }
85
85
                }
86
86
                
87
 
                public TextEditorContainer TextEditorContainer {
88
 
                        get {
89
 
                                return lastActiveEditor == textEditor ? textEditorContainer : splittedTextEditorContainer;
90
 
                        }
91
 
                }
92
 
                
93
87
                public Ambience Ambience {
94
88
                        get {
95
 
                                string fileName = this.view.IsUntitled ? this.view.UntitledName : this.view.ContentName;
 
89
                                string fileName = view.IsUntitled ? view.UntitledName : view.ContentName;
96
90
                                return AmbienceService.GetAmbienceForFile (fileName);
97
91
                        }
98
92
                }
113
107
                        if (secondsw != null)
114
108
                                secondsw.RemoveQuickTaskProvider (provider);
115
109
                }               
116
 
                
 
110
 
117
111
                
118
112
                List<IUsageProvider> usageProvider = new List<IUsageProvider> ();
119
113
                public void AddUsageTaskProvider (IUsageProvider provider)
162
156
                public Gtk.VBox Vbox {
163
157
                        get { return this.vbox; }
164
158
                }
 
159
 
 
160
                public bool SearchWidgetHasFocus {
 
161
                        get {
 
162
                                if (HasAnyFocusedChild (searchAndReplaceWidget) || HasAnyFocusedChild (gotoLineNumberWidget))
 
163
                                        return true;
 
164
                                return false;
 
165
                        }
 
166
                }
 
167
 
 
168
                static bool HasAnyFocusedChild (Widget widget)
 
169
                {
 
170
                        // Seems that this is the only reliable way doing it on os x and linux :/
 
171
                        if (widget == null)
 
172
                                return false;
 
173
                        var stack = new Stack<Widget> ();
 
174
                        stack.Push (widget);
 
175
                        while (stack.Count > 0) {
 
176
                                var cur = stack.Pop ();
 
177
                                if (cur.HasFocus) {
 
178
                                        return true;
 
179
                                }
 
180
                                var c = cur as Gtk.Container;
 
181
                                if (c!= null) {
 
182
                                        foreach (var child in c.Children) {
 
183
                                                stack.Push (child);
 
184
                                        }
 
185
                                }
 
186
                        }
 
187
                        return false;
 
188
                }
165
189
                
166
190
                public class Border : Gtk.DrawingArea
167
191
                {
176
200
                class DecoratedScrolledWindow : HBox
177
201
                {
178
202
                        SourceEditorWidget parent;
179
 
                        SmartScrolledWindow scrolledWindow;
 
203
                        ScrolledWindow scrolledWindow;
180
204
                        
181
205
                        QuickTaskStrip strip;
182
206
                        
191
215
                                        return scrolledWindow.Vadjustment;
192
216
                                }
193
217
                        }
194
 
                        
 
218
 
195
219
                        public DecoratedScrolledWindow (SourceEditorWidget parent)
196
220
                        {
197
221
                                this.parent = parent;
198
222
                                this.strip = new QuickTaskStrip ();
199
 
                                /*
200
 
                                Border border = new Border ();
201
 
                                border.HeightRequest = 1;
202
 
                                PackStart (border, false, true, 0);
203
 
                                                                 
204
 
                                HBox box = new HBox ();
205
 
                                
206
 
                                border = new Border ();
207
 
                                border.WidthRequest = 1;
208
 
                                box.PackStart (border, false, true, 0);
209
 
                                
210
 
                                scrolledWindow = new ScrolledWindow ();
211
 
                                scrolledWindow.BorderWidth = 0;
212
 
                                scrolledWindow.ShadowType = ShadowType.None;
213
 
                                scrolledWindow.ButtonPressEvent += PrepareEvent;
214
 
                                box.PackStart (scrolledWindow, true, true, 0);
215
 
                                
216
 
                                
217
 
                                border = new Border ();
218
 
                                border.WidthRequest = 1;
219
 
                                box.PackStart (border, false, true, 0);
220
 
                                
221
 
                                PackStart (box, true, true, 0);
222
 
                                
223
 
                                border = new Border ();
224
 
                                border.HeightRequest = 1;
225
 
                                PackStart (border, false, true, 0);*/
226
 
                                
227
 
                                scrolledWindow = new SmartScrolledWindow ();
228
 
//                              scrolledWindow.BorderWidth = 0;
229
 
//                              scrolledWindow.ShadowType = ShadowType.In;
 
223
 
 
224
                                scrolledWindow = new CompactScrolledWindow ();
230
225
                                scrolledWindow.ButtonPressEvent += PrepareEvent;
231
226
                                PackStart (scrolledWindow, true, true, 0);
232
 
                                if (parent.quickTaskProvider.Count > 0) {
233
 
                                        strip.VAdjustment = scrolledWindow.Vadjustment;
234
 
                                        scrolledWindow.ReplaceVScrollBar (strip);
 
227
                                strip.VAdjustment = scrolledWindow.Vadjustment;
 
228
                                PackEnd (strip, false, true, 0);
 
229
 
 
230
                                parent.quickTaskProvider.ForEach (AddQuickTaskProvider);
 
231
 
 
232
                                QuickTaskStrip.EnableFancyFeatures.Changed += FancyFeaturesChanged;
 
233
                                FancyFeaturesChanged (null, null);
 
234
                        }
 
235
 
 
236
                        void FancyFeaturesChanged (object sender, EventArgs e)
 
237
                        {
 
238
                                if (QuickTaskStrip.EnableFancyFeatures) {
 
239
                                        scrolledWindow.VScrollbar.SizeRequested += SuppressSize;
 
240
                                        scrolledWindow.VScrollbar.ExposeEvent += SuppressExpose;
235
241
                                } else {
236
 
                                        strip.Visible = false;
 
242
                                        scrolledWindow.VScrollbar.SizeRequested -= SuppressSize;
 
243
                                        scrolledWindow.VScrollbar.ExposeEvent -= SuppressExpose;
237
244
                                }
238
 
                                parent.quickTaskProvider.ForEach (p => AddQuickTaskProvider (p));
 
245
                                QueueResize ();
 
246
                        }
 
247
 
 
248
                        [GLib.ConnectBefore]
 
249
                        static void SuppressExpose (object o, ExposeEventArgs args)
 
250
                        {
 
251
                                args.RetVal = true;
 
252
                        }
 
253
 
 
254
                        [GLib.ConnectBefore]
 
255
                        static void SuppressSize (object o, SizeRequestedArgs args)
 
256
                        {
 
257
                                args.Requisition = Requisition.Zero;
 
258
                                args.RetVal = true;
239
259
                        }
240
260
                        
241
261
                        public void AddQuickTaskProvider (IQuickTaskProvider p)
242
262
                        {
243
 
                                if (!strip.Visible) {
244
 
                                        strip.VAdjustment = scrolledWindow.Vadjustment;
245
 
                                        scrolledWindow.ReplaceVScrollBar (strip);
246
 
                                }
247
263
                                p.TasksUpdated += HandleTasksUpdated; 
248
264
                        }
249
265
 
261
277
 
262
278
                        public void AddUsageProvider (IUsageProvider p)
263
279
                        {
264
 
                                if (!strip.Visible) {
265
 
                                        strip.VAdjustment = scrolledWindow.Vadjustment;
266
 
                                        scrolledWindow.ReplaceVScrollBar (strip);
267
 
                                }
268
280
                                p.UsagesUpdated += (sender, e) => strip.Update (p);
269
281
                        }
270
282
                        
272
284
                        {
273
285
                                if (scrolledWindow.Child != null)
274
286
                                        RemoveEvents ();
275
 
                                
 
287
 
 
288
                                QuickTaskStrip.EnableFancyFeatures.Changed -= FancyFeaturesChanged;
276
289
                                scrolledWindow.ButtonPressEvent -= PrepareEvent;
277
290
                                base.OnDestroyed ();
278
291
                        }
282
295
                                args.RetVal = true;
283
296
                        }
284
297
                
285
 
                        public void SetTextEditor (TextEditorContainer container)
 
298
                        public void SetTextEditor (TextEditor container)
286
299
                        {
287
300
                                scrolledWindow.Child = container;
288
 
                                this.strip.TextEditor = container.TextEditorWidget;
 
301
                                this.strip.TextEditor = container;
289
302
//                              container.TextEditorWidget.EditorOptionsChanged += OptionsChanged;
290
 
                                container.TextEditorWidget.Caret.ModeChanged += parent.UpdateLineColOnEventHandler;
291
 
                                container.TextEditorWidget.Caret.PositionChanged += parent.CaretPositionChanged;
292
 
                                container.TextEditorWidget.SelectionChanged += parent.UpdateLineColOnEventHandler;
 
303
                                container.Caret.ModeChanged += parent.UpdateLineColOnEventHandler;
 
304
                                container.Caret.PositionChanged += parent.CaretPositionChanged;
 
305
                                container.SelectionChanged += parent.UpdateLineColOnEventHandler;
293
306
                        }
294
307
                        
295
308
                        void OptionsChanged (object sender, EventArgs e)
296
309
                        {
297
310
                                TextEditor editor = (TextEditor)sender;
298
 
                                scrolledWindow.ModifyBg (StateType.Normal, editor.ColorStyle.Default.BackgroundColor);
 
311
                                scrolledWindow.ModifyBg (StateType.Normal, (Mono.TextEditor.HslColor)editor.ColorStyle.PlainText.Background);
299
312
                        }
300
313
                        
301
314
                        void RemoveEvents ()
302
315
                        {
303
 
                                TextEditorContainer container = scrolledWindow.Child as TextEditorContainer;
 
316
                                var container = scrolledWindow.Child as TextEditor;
304
317
                                if (container == null) {
305
318
                                        LoggingService.LogError ("can't remove events from text editor container.");
306
319
                                        return;
307
320
                                }
308
321
//                              container.TextEditorWidget.EditorOptionsChanged -= OptionsChanged;
309
 
                                container.TextEditorWidget.Caret.ModeChanged -= parent.UpdateLineColOnEventHandler;
310
 
                                container.TextEditorWidget.Caret.PositionChanged -= parent.CaretPositionChanged;
311
 
                                container.TextEditorWidget.SelectionChanged -= parent.UpdateLineColOnEventHandler;
 
322
                                container.Caret.ModeChanged -= parent.UpdateLineColOnEventHandler;
 
323
                                container.Caret.PositionChanged -= parent.CaretPositionChanged;
 
324
                                container.SelectionChanged -= parent.UpdateLineColOnEventHandler;
312
325
                        }
313
326
                        
314
 
                        public TextEditorContainer RemoveTextEditor ()
 
327
                        public TextEditor RemoveTextEditor ()
315
328
                        {
316
 
                                TextEditorContainer child = scrolledWindow.Child as TextEditorContainer;
 
329
                                var child = scrolledWindow.Child as TextEditor;
317
330
                                if (child == null)
318
331
                                        return null;
319
332
                                RemoveEvents ();
323
336
                        }
324
337
                }
325
338
                
326
 
                TextEditorContainer textEditorContainer;
327
339
                public SourceEditorWidget (SourceEditorView view)
328
340
                {
329
341
                        this.view = view;
330
342
                        vbox.SetSizeRequest (32, 32);
331
343
                        this.lastActiveEditor = this.textEditor = new MonoDevelop.SourceEditor.ExtensibleTextEditor (view);
332
 
                        this.textEditor.FocusInEvent += (o, s) => lastActiveEditor = (ExtensibleTextEditor)o;
333
 
                        this.textEditor.FocusOutEvent += delegate {
334
 
                                if (this.splittedTextEditor == null || !splittedTextEditor.HasFocus)
 
344
                        this.textEditor.TextArea.FocusInEvent += (o, s) => {
 
345
                                lastActiveEditor = (ExtensibleTextEditor)((TextArea)o).GetTextEditorData ().Parent;
 
346
                                view.FireCompletionContextChanged ();
 
347
                        };
 
348
                        this.textEditor.TextArea.FocusOutEvent += delegate {
 
349
                                if (this.splittedTextEditor == null || !splittedTextEditor.TextArea.HasFocus)
335
350
                                        OnLostFocus ();
336
351
                        };
337
352
                        mainsw = new DecoratedScrolledWindow (this);
338
 
                        this.textEditorContainer = new TextEditorContainer (textEditor);
339
 
                        mainsw.SetTextEditor (textEditorContainer);
 
353
                        mainsw.SetTextEditor (textEditor);
340
354
                        
341
355
                        vbox.PackStart (mainsw, true, true, 0);
342
356
                        
355
369
                                RemoveErrorUndelinesResetTimerId ();
356
370
                                StopParseInfoThread ();
357
371
                                KillWidgets ();
358
 
                                
 
372
 
 
373
                                foreach (var provider in quickTaskProvider.ToArray ()) {
 
374
                                        RemoveQuickTaskProvider (provider);
 
375
                                }
 
376
 
359
377
                                this.lastActiveEditor = null;
360
378
                                this.splittedTextEditor = null;
361
379
                                view = null;
362
380
                                
363
 
                                IdeApp.Workbench.StatusBar.ClearCaretState ();
 
381
//                              IdeApp.Workbench.StatusBar.ClearCaretState ();
364
382
                                if (parseInformationUpdaterWorkerThread != null) {
365
383
                                        parseInformationUpdaterWorkerThread.Dispose ();
366
384
                                        parseInformationUpdaterWorkerThread = null;
375
393
 
376
394
                void OnLostFocus ()
377
395
                {
378
 
                        //clears search status messages
379
 
                        IdeApp.Workbench.StatusBar.ShowReady ();
380
396
                }
381
397
 
382
398
                void UpdateLineColOnEventHandler (object sender, EventArgs e)
387
403
                void ResetFocusChain ()
388
404
                {
389
405
                        List<Widget> focusChain = new List<Widget> ();
390
 
                        
391
 
                        focusChain.Add (this.textEditor);
 
406
                        focusChain.Add (this.textEditor.TextArea);
392
407
                        if (this.searchAndReplaceWidget != null) {
393
408
                                focusChain.Add (this.searchAndReplaceWidget);
394
409
                        }
431
446
                        if (!options.ShowFoldMargin)
432
447
                                return;
433
448
                        // don't update parsed documents that contain errors - the foldings from there may be invalid.
434
 
                        if (doc.HasFoldSegments && parsedDocument.Errors.Any (err => err.ErrorType == ErrorType.Error))
 
449
                        if (parsedDocument.HasErrors)
435
450
                                return;
436
451
                        try {
437
452
                                List<FoldSegment > foldSegments = new List<FoldSegment> ();
645
660
                
646
661
                public bool EditorHasFocus {
647
662
                        get {
648
 
                                Gtk.Container c = vbox;
649
 
                                while (c != null) {
650
 
                                        if (c.FocusChild == textEditor)
651
 
                                                return true;
652
 
                                        c = c.FocusChild as Gtk.Container;
653
 
                                }
654
 
                                return false;
 
663
                                return TextEditor.TextArea.HasFocus;
655
664
                        }
656
665
                }
657
666
 
696
705
                        }
697
706
                }
698
707
                DecoratedScrolledWindow secondsw;
699
 
                TextEditorContainer splittedTextEditorContainer;
700
 
                
701
 
                
 
708
 
702
709
                public void Split (bool vSplit)
703
710
                {
704
711
                        double vadjustment = this.mainsw.Vadjustment.Value;
720
727
                                }
721
728
                        };
722
729
                        secondsw = new DecoratedScrolledWindow (this);
723
 
                        this.splittedTextEditor = new MonoDevelop.SourceEditor.ExtensibleTextEditor (view, this.textEditor.Options, textEditor.Document);
724
 
                        this.splittedTextEditor.FocusInEvent += (o, s) => lastActiveEditor = (ExtensibleTextEditor)o;
725
 
                        this.splittedTextEditor.FocusOutEvent += delegate {
726
 
                                 if (!textEditor.HasFocus)
 
730
                        splittedTextEditor = new MonoDevelop.SourceEditor.ExtensibleTextEditor (view, textEditor.Options, textEditor.Document);
 
731
                        splittedTextEditor.TextArea.FocusInEvent += (o, s) => {
 
732
                                lastActiveEditor = (ExtensibleTextEditor)((TextArea)o).GetTextEditorData ().Parent;
 
733
                                view.FireCompletionContextChanged ();
 
734
                        };
 
735
                        splittedTextEditor.TextArea.FocusOutEvent += delegate {
 
736
                                 if (!textEditor.TextArea.HasFocus)
727
737
                                        OnLostFocus ();
728
738
                        };
729
 
                        this.splittedTextEditor.Extension = textEditor.Extension;
730
 
                        
731
 
                        this.splittedTextEditorContainer = new TextEditorContainer (this.splittedTextEditor);
732
 
                        secondsw.SetTextEditor (this.splittedTextEditorContainer);
 
739
                        splittedTextEditor.Extension = textEditor.Extension;
 
740
                        if (textEditor.GetTextEditorData ().HasIndentationTracker)
 
741
                                splittedTextEditor.GetTextEditorData ().IndentationTracker = textEditor.GetTextEditorData ().IndentationTracker;
 
742
                        splittedTextEditor.Document.BracketMatcher = textEditor.Document.BracketMatcher;
 
743
 
 
744
                        secondsw.SetTextEditor (splittedTextEditor);
733
745
                        splitContainer.Add2 (secondsw);
734
746
                        
735
747
                        vbox.PackStart (splitContainer, true, true, 0);
736
 
                        this.splitContainer.Position = (vSplit ? vbox.Allocation.Height : vbox.Allocation.Width) / 2 - 1;
 
748
                        splitContainer.Position = (vSplit ? vbox.Allocation.Height : vbox.Allocation.Width) / 2 - 1;
737
749
                        
738
750
                        vbox.ShowAll ();
739
751
                        secondsw.Vadjustment.Value = mainsw.Vadjustment.Value = vadjustment; 
744
756
                {
745
757
                        // destroy old scrolled window to work around Bug 526721 - When splitting window vertically, 
746
758
                        // the slider under left split is not shown unitl window is resized
747
 
                        double vadjustment = this.mainsw.Vadjustment.Value;
748
 
                        double hadjustment = this.mainsw.Hadjustment.Value;
749
 
                        
750
 
                        var removedTextEditor = this.mainsw.RemoveTextEditor ();
751
 
                        this.mainsw.Destroy ();
752
 
                        
753
 
                        this.mainsw = new DecoratedScrolledWindow (this);
754
 
                        this.mainsw.SetTextEditor (removedTextEditor);
755
 
                        this.mainsw.Vadjustment.Value = vadjustment; 
756
 
                        this.mainsw.Hadjustment.Value = hadjustment;
 
759
                        double vadjustment = mainsw.Vadjustment.Value;
 
760
                        double hadjustment = mainsw.Hadjustment.Value;
 
761
                        
 
762
                        var removedTextEditor = mainsw.RemoveTextEditor ();
 
763
                        mainsw.Destroy ();
 
764
                        
 
765
                        mainsw = new DecoratedScrolledWindow (this);
 
766
                        mainsw.SetTextEditor (removedTextEditor);
 
767
                        mainsw.Vadjustment.Value = vadjustment; 
 
768
                        mainsw.Hadjustment.Value = hadjustment;
757
769
                        lastActiveEditor = textEditor;
758
770
                }
759
771
 
787
799
                        if (messageBar == null) {
788
800
                                messageBar = new MonoDevelop.Components.InfoBar (MessageType.Warning);
789
801
                                messageBar.SetMessageLabel (GettextCatalog.GetString (
790
 
                                        "<b>The file \"{0}\" has been changed outside of MonoDevelop.</b>\n" +
 
802
                                        "<b>The file \"{0}\" has been changed outside of {1}.</b>\n" +
791
803
                                        "Do you want to keep your changes, or reload the file from disk?",
792
 
                                        EllipsizeMiddle (Document.FileName, 50)));
 
804
                                        EllipsizeMiddle (Document.FileName, 50), BrandingService.ApplicationName));
793
805
                                
794
806
                                var b1 = new Button (GettextCatalog.GetString ("_Reload from disk"));
795
807
                                b1.Image = ImageService.GetImage (Gtk.Stock.Refresh, IconSize.Button);
840
852
                internal bool UseIncorrectMarkers { get; set; }
841
853
                internal bool HasIncorrectEolMarker {
842
854
                        get {
 
855
                                string eol = DetectedEolMarker;
 
856
                                if (eol == null)
 
857
                                        return false;
 
858
                                return eol != textEditor.Options.DefaultEolMarker;
 
859
                        }
 
860
                }
 
861
                string DetectedEolMarker {
 
862
                        get {
843
863
                                if (textEditor.IsDisposed) {
844
864
                                        LoggingService.LogWarning ("SourceEditorWidget.cs: HasIncorrectEolMarker was called on disposed source editor widget." + Environment.NewLine + Environment.StackTrace);
845
 
                                        return false;
 
865
                                        return null;
846
866
                                }
847
867
                                var firstLine = Document.GetLine (1);
848
868
                                if (firstLine != null && firstLine.DelimiterLength > 0) {
849
869
                                        string firstDelimiter = Document.GetTextAt (firstLine.Length, firstLine.DelimiterLength);
850
 
                                        return firstDelimiter != textEditor.Options.DefaultEolMarker;
 
870
                                        return firstDelimiter;
851
871
                                }
852
 
                                return false;
 
872
                                return null;
853
873
                        }
854
874
                }
855
875
 
891
911
                        
892
912
                        if (messageBar == null) {
893
913
                                messageBar = new MonoDevelop.Components.InfoBar (MessageType.Warning);
 
914
                                string detectedEol = DetectedEolMarker.Replace ("\n", "NL").Replace ("\r", "CR");
 
915
                                string defaultEol = textEditor.Options.DefaultEolMarker.Replace ("\n", "NL").Replace ("\r", "CR");
894
916
                                messageBar.SetMessageLabel (GettextCatalog.GetString (
895
 
                                        "<b>The file \"{0}\" has line endings which differ from the policy settings.</b>\n" +
 
917
                                        "<b>The file \"{0}\" has line endings (" + detectedEol + ") which differ from the policy settings(" + defaultEol + ").</b>\n" +
896
918
                                        "Do you want to convert the line endings?",
897
919
                                        EllipsizeMiddle (Document.FileName, 50)));
898
920
                                
942
964
                        view.WorkbenchWindow.ShowNotification = true;
943
965
                        
944
966
                        // Ensure that one file with incorret EOL markers is shown.
945
 
                        var currentView = IdeApp.Workbench.ActiveDocument.PrimaryView as SourceEditorView;
 
967
                        var currentView = IdeApp.Workbench.ActiveDocument.PrimaryView.GetContent<SourceEditorView> ();
946
968
                        if (currentView == null || !currentView.IsDirty || !currentView.SourceEditorWidget.HasIncorrectEolMarker || currentView.SourceEditorWidget.UseIncorrectMarkers)
947
969
                                view.WorkbenchWindow.SelectWindow ();
948
970
                }
953
975
                        TextEditor.Visible = false;
954
976
                        if (messageBar == null) {
955
977
                                messageBar = new MonoDevelop.Components.InfoBar (MessageType.Warning);
956
 
                                messageBar.SetMessageLabel (GettextCatalog.GetString (
 
978
                                messageBar.SetMessageLabel (BrandingService.BrandApplicationName (GettextCatalog.GetString (
957
979
                                                "<b>An autosave file has been found for this file.</b>\n" +
958
980
                                                "This could mean that another instance of MonoDevelop is editing this " +
959
981
                                                "file, or that MonoDevelop crashed with unsaved changes.\n\n" +
960
 
                                            "Do you want to use the original file, or load from the autosave file?"));
 
982
                                            "Do you want to use the original file, or load from the autosave file?")));
961
983
                                
962
984
                                Button b1 = new Button (GettextCatalog.GetString("_Use original file"));
963
985
                                b1.Image = ImageService.GetImage (Gtk.Stock.Refresh, IconSize.Button);
1060
1082
                
1061
1083
                internal void UpdateLineCol ()
1062
1084
                {
1063
 
                        int offset = TextEditor.Caret.Offset;
1064
 
                        if (offset < 0 || offset > TextEditor.Document.TextLength)
1065
 
                                return;
1066
 
                        DocumentLocation location = TextEditor.LogicalToVisualLocation (TextEditor.Caret.Location);
1067
 
                        IdeApp.Workbench.StatusBar.ShowCaretState (TextEditor.Caret.Line,
1068
 
                                                                   location.Column,
1069
 
                                                                   TextEditor.IsSomethingSelected ? TextEditor.SelectionRange.Length : 0,
1070
 
                                                                   TextEditor.Caret.IsInInsertMode);
 
1085
//                      int offset = TextEditor.Caret.Offset;
 
1086
//                      if (offset < 0 || offset > TextEditor.Document.TextLength)
 
1087
//                              return;
 
1088
//                      DocumentLocation location = TextEditor.LogicalToVisualLocation (TextEditor.Caret.Location);
 
1089
//                      IdeApp.Workbench.StatusBar.ShowCaretState (TextEditor.Caret.Line,
 
1090
//                                                                 location.Column,
 
1091
//                                                                 TextEditor.IsSomethingSelected ? TextEditor.SelectionRange.Length : 0,
 
1092
//                                                                 TextEditor.Caret.IsInInsertMode);
1071
1093
                }
1072
1094
                
1073
1095
                #endregion
1174
1196
                                searchAndReplaceWidgetFrame.Child = searchAndReplaceWidget = new SearchAndReplaceWidget (TextEditor, searchAndReplaceWidgetFrame);
1175
1197
                                searchAndReplaceWidget.Destroyed += (sender, e) => RemoveSearchWidget ();
1176
1198
                                searchAndReplaceWidgetFrame.ShowAll ();
1177
 
                                this.TextEditorContainer.AddAnimatedWidget (searchAndReplaceWidgetFrame, 300, Easing.ExponentialInOut, Blocking.Downstage, TextEditor.Allocation.Width - 400, -searchAndReplaceWidget.Allocation.Height);
 
1199
                                this.TextEditor.AddAnimatedWidget (searchAndReplaceWidgetFrame, 300, Mono.TextEditor.Theatrics.Easing.ExponentialInOut, Blocking.Downstage, TextEditor.Allocation.Width - 400, -searchAndReplaceWidget.Allocation.Height);
1178
1200
//                              this.PackEnd (searchAndReplaceWidget);
1179
1201
//                              this.SetChildPacking (searchAndReplaceWidget, false, false, CHILD_PADDING, PackType.End);
1180
1202
                                //              searchAndReplaceWidget.ShowAll ();
1214
1236
                                gotoLineNumberWidgetFrame.Child = gotoLineNumberWidget = new GotoLineNumberWidget (textEditor, gotoLineNumberWidgetFrame);
1215
1237
                                gotoLineNumberWidget.Destroyed += (sender, e) => RemoveSearchWidget ();
1216
1238
                                gotoLineNumberWidgetFrame.ShowAll ();
1217
 
                                TextEditorContainer.AddAnimatedWidget (gotoLineNumberWidgetFrame, 300, Easing.ExponentialInOut, Mono.TextEditor.Theatrics.Blocking.Downstage, this.TextEditor.Allocation.Width - 400, -gotoLineNumberWidget.Allocation.Height);
 
1239
                                TextEditor.AddAnimatedWidget (gotoLineNumberWidgetFrame, 300, Mono.TextEditor.Theatrics.Easing.ExponentialInOut, Mono.TextEditor.Theatrics.Blocking.Downstage, this.TextEditor.Allocation.Width - 400, -gotoLineNumberWidget.Allocation.Height);
1218
1240
                                
1219
1241
                                ResetFocusChain ();
1220
1242
                        }
1250
1272
                
1251
1273
                void SetSearchPatternToSelection ()
1252
1274
                {
 
1275
                        if (!TextEditor.IsSomethingSelected) {
 
1276
                                int start = textEditor.Caret.Offset;
 
1277
                                int end = start;
 
1278
                                while (start - 1 >= 0 && DynamicAbbrevHandler.IsIdentifierPart (textEditor.GetCharAt (start - 1)))
 
1279
                                        start--;
 
1280
 
 
1281
                                while (end < textEditor.Length && DynamicAbbrevHandler.IsIdentifierPart (textEditor.GetCharAt (end)))
 
1282
                                        end++;
 
1283
                                textEditor.Caret.Offset = end;
 
1284
                                TextEditor.SetSelection (start, end);
 
1285
                        }
 
1286
 
1253
1287
                        if (TextEditor.IsSomethingSelected) {
1254
1288
                                var pattern = FormatPatternToSelectionOption (TextEditor.SelectedText);
1255
 
                                        
1256
 
                                TextEditor.SearchPattern = pattern;
 
1289
                                SearchAndReplaceOptions.SearchPattern = pattern;
1257
1290
                                SearchAndReplaceWidget.UpdateSearchHistory (TextEditor.SearchPattern);
1258
1291
                        }
1259
1292
                        if (searchAndReplaceWidget != null)
1296
1329
                {
1297
1330
                        DomRegion region;
1298
1331
                        var res = TextEditor.GetLanguageItem (TextEditor.Caret.Offset, out region);
 
1332
                        if (res is UnknownIdentifierResolveResult) {
 
1333
                                var uir = (UnknownIdentifierResolveResult)res;
 
1334
                                IdeApp.HelpOperations.SearchHelpFor (uir.Identifier);
 
1335
                                return;
 
1336
                        }
 
1337
 
 
1338
                        if (res is UnknownMemberResolveResult) {
 
1339
                                var uir = (UnknownMemberResolveResult)res;
 
1340
                                IdeApp.HelpOperations.SearchHelpFor (uir.MemberName);
 
1341
                                return;
 
1342
                        }
 
1343
 
1299
1344
                        string url = HelpService.GetMonoDocHelpUrl (res);
1300
1345
                        if (url != null)
1301
1346
                                IdeApp.HelpOperations.ShowHelp (url);
1305
1350
                {
1306
1351
                        DomRegion region;
1307
1352
                        var res = TextEditor.GetLanguageItem (TextEditor.Caret.Offset, out region);
1308
 
                        if (res == null || !IdeApp.HelpOperations.CanShowHelp (res))
 
1353
                        if (res == null || !IdeApp.HelpOperations.CanShowHelp (res) && !(res is UnknownIdentifierResolveResult || res is UnknownMemberResolveResult))
1309
1354
                                cinfo.Bypass = true;
1310
1355
                }
1311
1356
                
1360
1405
                                }
1361
1406
                                string startLineText = Document.GetTextAt (startLine.Offset, startLine.Length);
1362
1407
                                string endLineText = Document.GetTextAt (endLine.Offset, endLine.Length);
1363
 
                                if (startLineText.StartsWith (blockStart) && endLineText.EndsWith (blockEnd)) {
 
1408
                                if (startLineText.StartsWith (blockStart) && endLineText.EndsWith (blockEnd, StringComparison.Ordinal)) {
1364
1409
                                        textEditor.Remove (endLine.Offset + endLine.Length - blockEnd.Length, blockEnd.Length);
1365
1410
                                        textEditor.Remove (startLine.Offset, blockStart.Length);
1366
1411
                                        if (TextEditor.IsSomethingSelected) {
1395
1440
                                        continue;
1396
1441
                                string text = Document.GetTextAt (line);
1397
1442
                                string trimmedText = text.TrimStart ();
1398
 
                                if (!trimmedText.StartsWith (commentTag)) {
 
1443
                                if (!trimmedText.StartsWith (commentTag, StringComparison.Ordinal)) {
1399
1444
                                        comment = true;
1400
1445
                                        break;
1401
1446
                                }
1569
1614
                        // may be null if no line is assigned to the error.
1570
1615
                        Wave = true;
1571
1616
                        
1572
 
                        ColorName = info.ErrorType == ErrorType.Warning ? Mono.TextEditor.Highlighting.ColorScheme.WarningUnderlineString : Mono.TextEditor.Highlighting.ColorScheme.ErrorUnderlineString;
1573
1617
                        StartCol = Info.Region.BeginColumn + 1;
1574
1618
                        if (Info.Region.EndColumn > StartCol) {
1575
1619
                                EndCol = Info.Region.EndColumn;
1589
1633
                                EndCol = Info.Region.BeginColumn + o - start + 1;
1590
1634
                        }
1591
1635
                }
 
1636
 
 
1637
                public override void Draw (TextEditor editor, Cairo.Context cr, Pango.Layout layout, bool selected, int startOffset, int endOffset, double y, double startXPos, double endXPos)
 
1638
                {
 
1639
                        Color = Info.ErrorType == ErrorType.Warning ? editor.ColorStyle.UnderlineWarning.Color : editor.ColorStyle.UnderlineError.Color;
 
1640
 
 
1641
                        base.Draw (editor, cr, layout, selected, startOffset, endOffset, y, startXPos, endXPos);
 
1642
                }
1592
1643
        }
1593
 
}
 
 
b'\\ No newline at end of file'
 
1644
}