static string GetWordBeforeCaret (MonoDevelop.SourceEditor.ExtensibleTextEditor editor) { int startOffset = editor.Caret.Offset; int offset = startOffset - 1; while (offset > 0) { char ch = editor.Document.GetCharAt (offset); if (!ch.IsIdentifierPart ()) { offset++; break; } offset--; } if (offset >= startOffset) return ""; return editor.Document.GetTextBetween (offset, startOffset); }
void SetLastActiveEditor () { if (this.splittedTextEditor != null && this.splittedTextEditor.Parent != null && this.splittedTextEditor.HasFocus) { lastActiveEditor = this.splittedTextEditor; } if (this.textEditor != null && this.textEditor.Parent != null && this.textEditor.HasFocus) { lastActiveEditor = this.textEditor; } }
public void Split (bool vSplit) { double vadjustment = this.mainsw.Vadjustment.Value; double hadjustment = this.mainsw.Hadjustment.Value; if (splitContainer != null) Unsplit (); vbox.Remove (this.mainsw); RecreateMainSw (); this.splitContainer = vSplit ? (Gtk.Paned)new VPaned () : (Gtk.Paned)new HPaned (); splitContainer.Add1 (mainsw); this.splitContainer.ButtonPressEvent += delegate(object sender, ButtonPressEventArgs args) { if (args.Event.Type == Gdk.EventType.TwoButtonPress && args.RetVal == null) { Unsplit (); } }; secondsw = new DecoratedScrolledWindow (this); this.splittedTextEditor = new MonoDevelop.SourceEditor.ExtensibleTextEditor (view, this.textEditor.Options, textEditor.Document); this.splittedTextEditor.Extension = textEditor.Extension; this.splittedTextEditorContainer = new TextEditorContainer (this.splittedTextEditor); secondsw.SetTextEditor (this.splittedTextEditorContainer); splitContainer.Add2 (secondsw); vbox.PackStart (splitContainer, true, true, 0); this.splitContainer.Position = (vSplit ? vbox.Allocation.Height : vbox.Allocation.Width) / 2 - 1; vbox.ShowAll (); secondsw.Vadjustment.Value = mainsw.Vadjustment.Value = vadjustment; secondsw.Hadjustment.Value = mainsw.Hadjustment.Value = hadjustment; }
public void Unsplit () { if (splitContainer == null) return; double vadjustment = mainsw.Vadjustment.Value; double hadjustment = mainsw.Hadjustment.Value; splitContainer.Remove (mainsw); if (this.textEditor == lastActiveEditor) { secondsw.Destroy (); secondsw = null; splittedTextEditor = null; } else { this.mainsw.Destroy (); this.mainsw = secondsw; vadjustment = secondsw.Vadjustment.Value; hadjustment = secondsw.Hadjustment.Value; splitContainer.Remove (secondsw); lastActiveEditor = this.textEditor = splittedTextEditor; splittedTextEditor = null; } vbox.Remove (splitContainer); splitContainer.Destroy (); splitContainer = null; RecreateMainSw (); vbox.PackStart (mainsw, true, true, 0); vbox.ShowAll (); mainsw.Vadjustment.Value = vadjustment; mainsw.Hadjustment.Value = hadjustment; }
public SourceEditorWidget (SourceEditorView view) { this.view = view; vbox.SetSizeRequest (32, 32); this.lastActiveEditor = this.textEditor = new MonoDevelop.SourceEditor.ExtensibleTextEditor (view); mainsw = new DecoratedScrolledWindow (this); this.textEditorContainer = new TextEditorContainer (textEditor); mainsw.SetTextEditor (textEditorContainer); vbox.PackStart (mainsw, true, true, 0); this.textEditor.Errors = errors; options = this.textEditor.Options; textEditorData = textEditor.GetTextEditorData (); ResetFocusChain (); UpdateLineCol (); // this.IsClassBrowserVisible = this.widget.TextEditor.Options.EnableQuickFinder; vbox.BorderWidth = 0; vbox.Spacing = 0; vbox.Focused += delegate { UpdateLineCol (); }; vbox.Destroyed += delegate { isDisposed = true; StopParseInfoThread (); KillWidgets (); this.textEditor = null; this.lastActiveEditor = null; this.splittedTextEditor = null; view = null; IdeApp.Workbench.StatusBar.ClearCaretState (); if (parseInformationUpdaterWorkerThread != null) { parseInformationUpdaterWorkerThread.Dispose (); parseInformationUpdaterWorkerThread = null; } }; vbox.ShowAll (); parseInformationUpdaterWorkerThread = new BackgroundWorker (); parseInformationUpdaterWorkerThread.WorkerSupportsCancellation = true; parseInformationUpdaterWorkerThread.DoWork += HandleParseInformationUpdaterWorkerThreadDoWork; }
void RecreateMainSw () { // destroy old scrolled window to work around Bug 526721 - When splitting window vertically, // the slider under left split is not shown unitl window is resized double vadjustment = this.mainsw.Vadjustment.Value; double hadjustment = this.mainsw.Hadjustment.Value; var removedTextEditor = this.mainsw.RemoveTextEditor (); this.mainsw.Destroy (); this.mainsw = new DecoratedScrolledWindow (this); this.mainsw.SetTextEditor (removedTextEditor); this.mainsw.Vadjustment.Value = vadjustment; this.mainsw.Hadjustment.Value = hadjustment; lastActiveEditor = textEditor; }
public void Unsplit () { if (splitContainer == null) return; double vadjustment = mainsw.Vadjustment.Value; double hadjustment = mainsw.Hadjustment.Value; splitContainer.Remove (mainsw); secondsw.Destroy (); secondsw = null; splittedTextEditor = null; vbox.Remove (splitContainer); splitContainer.Destroy (); splitContainer = null; RecreateMainSw (); vbox.PackStart (mainsw, true, true, 0); vbox.ShowAll (); mainsw.Vadjustment.Value = vadjustment; mainsw.Hadjustment.Value = hadjustment; }
internal void SetLastActiveEditor (ExtensibleTextEditor editor) { this.lastActiveEditor = editor; }
public SearchAndReplaceWidget (SourceEditorWidget widget, Widget container) { this.container = container; this.textEditor = widget.TextEditor; this.textEditorContainer = widget.TextEditorContainer; textEditorContainer.SizeAllocated += HandleViewTextEditorhandleSizeAllocated; textEditor.TextViewMargin.SearchRegionsUpdated += HandleWidgetTextEditorTextViewMarginSearchRegionsUpdated; textEditor.Caret.PositionChanged += HandleWidgetTextEditorCaretPositionChanged; this.SizeAllocated += HandleViewTextEditorhandleSizeAllocated; this.Name = "SearchAndReplaceWidget"; this.Events = Gdk.EventMask.AllEventsMask; widget.DisableAutomaticSearchPatternCaseMatch = false; Build(); this.buttonReplace.TooltipText = GettextCatalog.GetString ("Replace"); this.buttonSearchForward.TooltipText = GettextCatalog.GetString ("Find next"); this.buttonSearchBackward.TooltipText = GettextCatalog.GetString ("Find previous"); this.buttonSearchMode.TooltipText = GettextCatalog.GetString ("Toggle between search and replace mode"); this.searchEntry.Ready = true; this.searchEntry.Visible = true; this.searchEntry.WidthRequest = widget.Vbox.Allocation.Width / 3; this.searchEntry.ForceFilterButtonVisible = true; replaceWidgets = new Widget [] { // labelReplace, entryReplace, buttonReplace, buttonReplaceAll }; this.FocusChain = new Widget [] { this.searchEntry, this.buttonSearchForward, this.buttonSearchBackward, entryReplace, buttonReplace, buttonReplaceAll }; this.widget = widget; FilterHistory (seachHistoryProperty); FilterHistory (replaceHistoryProperty); //HACK: GTK rendering issue on Mac, images don't repaint unless we put them in visible eventboxes if (Platform.IsMac) { foreach (var eb in new [] { eventbox2, eventbox3, eventbox4, eventbox5, eventbox6 }) { eb.VisibleWindow = true; eb.ModifyBg (StateType.Normal, new Gdk.Color (230, 230, 230)); } } if (String.IsNullOrEmpty (textEditor.SearchPattern)) { textEditor.SearchPattern = searchPattern; } else if (textEditor.SearchPattern != searchPattern) { searchPattern = textEditor.SearchPattern; //FireSearchPatternChanged (); } UpdateSearchPattern (); //searchEntry.Model = searchHistory; searchEntry.Entry.KeyReleaseEvent += delegate { widget.CheckSearchPatternCasing (SearchPattern); /* widget.SetSearchPattern (SearchPattern); searchPattern = SearchPattern; UpdateSearchEntry ();*/ }; searchEntry.Entry.Changed += delegate { widget.SetSearchPattern (SearchPattern); string oldPattern = searchPattern; searchPattern = SearchPattern; if (oldPattern != searchPattern) UpdateSearchEntry (); var history = GetHistory (seachHistoryProperty); if (history.Count > 0 && history[0] == oldPattern) { ChangeHistory (seachHistoryProperty, searchPattern); } else { UpdateSearchHistory (searchPattern); } }; entryReplace.Text = replacePattern; // entryReplace.Model = replaceHistory; // RestoreReplaceHistory (); foreach (Gtk.Widget child in Children) { child.KeyPressEvent += delegate (object sender, Gtk.KeyPressEventArgs args) { if (args.Event.Key == Gdk.Key.Escape) widget.RemoveSearchWidget (); }; } closeButton.Clicked += delegate { widget.RemoveSearchWidget (); }; buttonSearchMode.Clicked += delegate { IsReplaceMode = !IsReplaceMode; }; // comboboxSearchAs.AppendText (GettextCatalog.GetString ("Text")); // comboboxSearchAs.AppendText (GettextCatalog.GetString ("Regular Expressions")); // comboboxSearchAs.Active = 0; // ReplacePatternChanged += UpdateReplacePattern; //SearchPatternChanged += UpdateSearchPattern; FocusChildSet += delegate { StoreWidgetState (); }; searchEntry.Entry.Activated += delegate { UpdateSearchHistory (SearchPattern); widget.SetLastActiveEditor (textEditor); widget.FindNext (false); }; buttonSearchForward.Clicked += delegate { UpdateSearchHistory (SearchPattern); widget.SetLastActiveEditor (textEditor); widget.FindNext (false); }; buttonSearchBackward.Clicked += delegate { UpdateSearchHistory (SearchPattern); widget.SetLastActiveEditor (textEditor); widget.FindPrevious (false); }; // optionsButton.Label = MonoDevelop.Core.GettextCatalog.GetString ("Options"); this.searchEntry.RequestMenu += HandleSearchEntryhandleRequestMenu; entryReplace.Changed += delegate { replacePattern = ReplacePattern; if (!inReplaceUpdate) FireReplacePatternChanged (); }; entryReplace.Activated += delegate { UpdateSearchHistory (SearchPattern); UpdateReplaceHistory (ReplacePattern); widget.SetLastActiveEditor (textEditor); widget.Replace (); entryReplace.GrabFocus (); }; buttonReplace.Clicked += delegate { UpdateSearchHistory (SearchPattern); UpdateReplaceHistory (ReplacePattern); widget.SetLastActiveEditor (textEditor); widget.Replace (); }; buttonReplaceAll.Clicked += delegate { UpdateSearchHistory (SearchPattern); UpdateReplaceHistory (ReplacePattern); widget.SetLastActiveEditor (textEditor); widget.ReplaceAll (); }; buttonSearchForward.KeyPressEvent += OnNavigateKeyPressEvent; buttonSearchBackward.KeyPressEvent += OnNavigateKeyPressEvent; searchEntry.Entry.KeyPressEvent += OnNavigateKeyPressEvent; entryReplace.KeyPressEvent += OnNavigateKeyPressEvent; buttonReplace.KeyPressEvent += OnNavigateKeyPressEvent; buttonReplaceAll.KeyPressEvent += OnNavigateKeyPressEvent; resultInformLabelEventBox = this.searchEntry.AddLabelWidget (resultInformLabel); resultInformLabelEventBox.BorderWidth = 2; resultInformLabel.Xpad = 2; resultInformLabel.Show (); searchEntry.FilterButtonPixbuf = new Gdk.Pixbuf (typeof(SearchAndReplaceWidget).Assembly, "searchoptions.png"); }
public SearchAndReplaceWidget(SourceEditorWidget widget, Widget container) { this.container = container; this.textEditor = widget.TextEditor; this.textEditorContainer = widget.TextEditorContainer; textEditorContainer.SizeAllocated += HandleViewTextEditorhandleSizeAllocated; textEditor.TextViewMargin.SearchRegionsUpdated += HandleWidgetTextEditorTextViewMarginSearchRegionsUpdated; textEditor.Caret.PositionChanged += HandleWidgetTextEditorCaretPositionChanged; this.SizeAllocated += HandleViewTextEditorhandleSizeAllocated; this.Name = "SearchAndReplaceWidget"; this.Events = Gdk.EventMask.AllEventsMask; widget.DisableAutomaticSearchPatternCaseMatch = false; Build(); this.buttonReplace.TooltipText = GettextCatalog.GetString("Replace"); this.buttonSearchForward.TooltipText = GettextCatalog.GetString("Find next"); this.buttonSearchBackward.TooltipText = GettextCatalog.GetString("Find previous"); this.buttonSearchMode.TooltipText = GettextCatalog.GetString("Toggle between search and replace mode"); this.searchEntry.Ready = true; this.searchEntry.Visible = true; this.searchEntry.WidthRequest = widget.Vbox.Allocation.Width / 3; this.searchEntry.ForceFilterButtonVisible = true; replaceWidgets = new Widget [] { // labelReplace, entryReplace, buttonReplace, buttonReplaceAll }; this.FocusChain = new Widget [] { this.searchEntry, this.buttonSearchForward, this.buttonSearchBackward, entryReplace, buttonReplace, buttonReplaceAll }; this.widget = widget; FilterHistory(seachHistoryProperty); FilterHistory(replaceHistoryProperty); //HACK: GTK rendering issue on Mac, images don't repaint unless we put them in visible eventboxes if (Platform.IsMac) { foreach (var eb in new [] { eventbox2, eventbox3, eventbox4, eventbox5, eventbox6 }) { eb.VisibleWindow = true; eb.ModifyBg(StateType.Normal, new Gdk.Color(230, 230, 230)); } } if (String.IsNullOrEmpty(textEditor.SearchPattern)) { textEditor.SearchPattern = searchPattern; } else if (textEditor.SearchPattern != searchPattern) { searchPattern = textEditor.SearchPattern; //FireSearchPatternChanged (); } UpdateSearchPattern(); //searchEntry.Model = searchHistory; searchEntry.Entry.KeyReleaseEvent += delegate { widget.CheckSearchPatternCasing(SearchPattern); /* widget.SetSearchPattern (SearchPattern); * searchPattern = SearchPattern; * UpdateSearchEntry ();*/ }; searchEntry.Entry.Changed += delegate { widget.SetSearchPattern(SearchPattern); string oldPattern = searchPattern; searchPattern = SearchPattern; if (oldPattern != searchPattern) { UpdateSearchEntry(); } var history = GetHistory(seachHistoryProperty); if (history.Count > 0 && history[0] == oldPattern) { ChangeHistory(seachHistoryProperty, searchPattern); } else { UpdateSearchHistory(searchPattern); } }; entryReplace.Text = replacePattern; // entryReplace.Model = replaceHistory; // RestoreReplaceHistory (); foreach (Gtk.Widget child in Children) { child.KeyPressEvent += delegate(object sender, Gtk.KeyPressEventArgs args) { if (args.Event.Key == Gdk.Key.Escape) { widget.RemoveSearchWidget(); } }; } closeButton.Clicked += delegate { widget.RemoveSearchWidget(); }; buttonSearchMode.Clicked += delegate { IsReplaceMode = !IsReplaceMode; }; // comboboxSearchAs.AppendText (GettextCatalog.GetString ("Text")); // comboboxSearchAs.AppendText (GettextCatalog.GetString ("Regular Expressions")); // comboboxSearchAs.Active = 0; // ReplacePatternChanged += UpdateReplacePattern; //SearchPatternChanged += UpdateSearchPattern; FocusChildSet += delegate { StoreWidgetState(); }; searchEntry.Entry.Activated += delegate { UpdateSearchHistory(SearchPattern); widget.SetLastActiveEditor(textEditor); widget.FindNext(false); }; buttonSearchForward.Clicked += delegate { UpdateSearchHistory(SearchPattern); widget.SetLastActiveEditor(textEditor); widget.FindNext(false); }; buttonSearchBackward.Clicked += delegate { UpdateSearchHistory(SearchPattern); widget.SetLastActiveEditor(textEditor); widget.FindPrevious(false); }; // optionsButton.Label = MonoDevelop.Core.GettextCatalog.GetString ("Options"); this.searchEntry.RequestMenu += HandleSearchEntryhandleRequestMenu; entryReplace.Changed += delegate { replacePattern = ReplacePattern; if (!inReplaceUpdate) { FireReplacePatternChanged(); } }; entryReplace.Activated += delegate { UpdateSearchHistory(SearchPattern); UpdateReplaceHistory(ReplacePattern); widget.SetLastActiveEditor(textEditor); widget.Replace(); entryReplace.GrabFocus(); }; buttonReplace.Clicked += delegate { UpdateSearchHistory(SearchPattern); UpdateReplaceHistory(ReplacePattern); widget.SetLastActiveEditor(textEditor); widget.Replace(); }; buttonReplaceAll.Clicked += delegate { UpdateSearchHistory(SearchPattern); UpdateReplaceHistory(ReplacePattern); widget.SetLastActiveEditor(textEditor); widget.ReplaceAll(); }; buttonSearchForward.KeyPressEvent += OnNavigateKeyPressEvent; buttonSearchBackward.KeyPressEvent += OnNavigateKeyPressEvent; searchEntry.Entry.KeyPressEvent += OnNavigateKeyPressEvent; entryReplace.KeyPressEvent += OnNavigateKeyPressEvent; buttonReplace.KeyPressEvent += OnNavigateKeyPressEvent; buttonReplaceAll.KeyPressEvent += OnNavigateKeyPressEvent; resultInformLabelEventBox = this.searchEntry.AddLabelWidget(resultInformLabel); resultInformLabelEventBox.BorderWidth = 2; resultInformLabel.Xpad = 2; resultInformLabel.Show(); searchEntry.FilterButtonPixbuf = new Gdk.Pixbuf(typeof(SearchAndReplaceWidget).Assembly, "searchoptions.png"); }
public SourceEditorWidget (SourceEditorView view) { this.view = view; vbox.SetSizeRequest (32, 32); this.lastActiveEditor = this.textEditor = new MonoDevelop.SourceEditor.ExtensibleTextEditor (view); mainsw = new DecoratedScrolledWindow (this); this.textEditorContainer = new TextEditorContainer (textEditor); mainsw.SetTextEditor (textEditorContainer); vbox.PackStart (mainsw, true, true, 0); this.textEditor.Errors = errors; options = this.textEditor.Options; textEditorData = textEditor.GetTextEditorData (); ResetFocusChain (); UpdateLineCol (); ProjectDomService.ParsedDocumentUpdated += OnParseInformationChanged; // this.IsClassBrowserVisible = this.widget.TextEditor.Options.EnableQuickFinder; vbox.BorderWidth = 0; vbox.Spacing = 0; vbox.Focused += delegate { UpdateLineCol (); }; vbox.Destroyed += delegate { isDisposed = true; StopParseInfoThread (); KillWidgets (); this.textEditor = null; this.lastActiveEditor = null; this.splittedTextEditor = null; view = null; ProjectDomService.ParsedDocumentUpdated -= OnParseInformationChanged; IdeApp.Workbench.StatusBar.ClearCaretState (); }; vbox.ShowAll (); }