string Subst(string text, int page) { var sb = new StringBuilder(text); sb.Replace("%N", (page + 1).ToString()); sb.Replace("%Q", totalPages.ToString()); //FIXME: use font width for ellipsizing better sb.Replace("%F", SourceEditorWidget.EllipsizeMiddle(filename, 60)); return(sb.ToString()); }
public StatusBox(SourceEditorWidget editor) { this.Editor = editor; PropertyService.AddPropertyHandler("CaretStatusBoxShowRealColumns", PropertyHandler); WidgetFlags |= WidgetFlags.NoWindow; layout = new Pango.Layout(this.PangoContext); measureLayout = new Pango.Layout(this.PangoContext); }
internal void SetSearchPattern() { string selectedText = SourceEditorWidget.FormatPatternToSelectionOption(textEditor.SelectedText); if (!String.IsNullOrEmpty(selectedText)) { SetSearchPattern(selectedText); SearchAndReplaceOptions.SearchPattern = selectedText; SearchAndReplaceWidget.UpdateSearchHistory(selectedText); textEditor.TextViewMargin.MainSearchResult = textEditor.SelectionRange; } }
protected override void OnDestroyed() { base.OnDestroyed(); if (measureLayout != null) { measureLayout.Dispose(); measureLayout = null; } if (layout != null) { layout.Dispose(); layout = null; } Editor = null; PropertyService.RemovePropertyHandler("CaretStatusBoxShowRealColumns", PropertyHandler); }
protected override void OnDestroyed() { this.widget.TextEditor.TextViewMargin.HideSelection = false; widget.TextEditor.Caret.PositionChanged -= HandleWidgetTextEditorCaretPositionChanged; widget.TextEditor.TextViewMargin.SearchRegionsUpdated -= HandleWidgetTextEditorTextViewMarginSearchRegionsUpdated; widget.TextEditorContainer.SizeAllocated -= HandleViewTextEditorhandleSizeAllocated; // SearchPatternChanged -= UpdateSearchPattern; ReplacePatternChanged -= UpdateReplacePattern; if (widget != null) { widget.TextEditor.QueueDraw(); widget = null; } base.OnDestroyed(); }
public NavigationBar(SourceEditorWidget editor) : base(false, 0) { PropertyService.AddPropertyHandler("HideCaretStatusBox", PropertyHandler); this.Editor = editor; this.BorderWidth = 0; this.Spacing = 0; typeCombo.DataProvider = new TypeDataProvider(this); typeCombo.ItemSet += TypeChanged; typeCombo.DrawRightBorder = true; UpdateTypeComboTip(null); this.PackStart(typeCombo); membersCombo.DataProvider = new MemberDataProvider(this); membersCombo.ItemSet += MemberChanged; membersCombo.DrawRightBorder = true; UpdateMemberComboTip(null); this.PackStart(membersCombo); regionCombo.DataProvider = new RegionDataProvider(this); regionCombo.ItemSet += RegionChanged; regionCombo.DrawRightBorder = true; UpdateRegionComboTip(null); this.PackStart(regionCombo); statusBox = new StatusBox(editor); this.PackStart(statusBox, false, false, 0); int w, h; Gtk.Icon.SizeLookup(IconSize.Menu, out w, out h); typeCombo.DefaultIconHeight = membersCombo.DefaultIconHeight = regionCombo.DefaultIconHeight = Math.Max(h, 16); typeCombo.DefaultIconWidth = membersCombo.DefaultIconWidth = regionCombo.DefaultIconWidth = Math.Max(w, 16); this.FocusChain = new Widget[] { typeCombo, membersCombo, regionCombo }; this.ShowAll(); regionCombo.DrawRightBorder = statusBox.Visible = !HideStatusBox; }
public SearchAndReplaceWidget(SourceEditorWidget widget, Widget container) { this.container = container; widget.TextEditorContainer.SizeAllocated += HandleViewTextEditorhandleSizeAllocated; widget.TextEditor.TextViewMargin.SearchRegionsUpdated += HandleWidgetTextEditorTextViewMarginSearchRegionsUpdated; widget.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(widget.TextEditor.SearchPattern)) { widget.TextEditor.SearchPattern = searchPattern; } else if (widget.TextEditor.SearchPattern != searchPattern) { searchPattern = widget.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.FindNext(false); }; buttonSearchForward.Clicked += delegate { UpdateSearchHistory(SearchPattern); widget.FindNext(false); }; buttonSearchBackward.Clicked += delegate { UpdateSearchHistory(SearchPattern); 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.Replace(); entryReplace.GrabFocus(); }; buttonReplace.Clicked += delegate { UpdateSearchHistory(SearchPattern); UpdateReplaceHistory(ReplacePattern); widget.Replace(); }; buttonReplaceAll.Clicked += delegate { UpdateSearchHistory(SearchPattern); UpdateReplaceHistory(ReplacePattern); 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 GotoLineNumberWidget(SourceEditorWidget widget, Widget container) { this.container = container; this.Build(); this.widget = widget; StoreWidgetState(); widget.TextEditorContainer.SizeAllocated += HandleViewTextEditorhandleSizeAllocated; //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 [] { eventbox1, eventbox2 }) { { eb.VisibleWindow = true; eb.ModifyBg(StateType.Normal, new Gdk.Color(230, 230, 230)); } } } } this.closeButton.Clicked += delegate { RestoreWidgetState(); widget.RemoveSearchWidget(); }; this.buttonGoToLine.Clicked += delegate { cleanExit = true; GotoLine(); widget.RemoveSearchWidget(); }; foreach (Gtk.Widget child in this.Children) { child.KeyPressEvent += delegate(object sender, Gtk.KeyPressEventArgs args) { if (args.Event.Key == Gdk.Key.Escape) { RestoreWidgetState(); widget.RemoveSearchWidget(); } }; } Gtk.Widget oldWidget = null; this.FocusChildSet += delegate(object sender, Gtk.FocusChildSetArgs args) { // only store state when the focus comes from a non child widget if (args.Widget != null && oldWidget == null) { StoreWidgetState(); } oldWidget = args.Widget; }; this.entryLineNumber.Changed += delegate { PreviewLine(); }; this.entryLineNumber.Activated += delegate { cleanExit = true; GotoLine(); widget.RemoveSearchWidget(); }; }