public ListWindow() : base(Gtk.WindowType.Popup) { vbox = new VBox(); HBox box = new HBox(); list = new ListWidget(this); list.SelectionChanged += new EventHandler(OnSelectionChanged); list.ScrollEvent += new ScrollEventHandler(OnScrolled); box.PackStart(list, true, true, 0); this.BorderWidth = 1; scrollbar = new VScrollbar(null); scrollbar.ValueChanged += new EventHandler(OnScrollChanged); box.PackStart(scrollbar, false, false, 0); list.ButtonPressEvent += delegate(object o, ButtonPressEventArgs args) { if (args.Event.Button == 1 && args.Event.Type == Gdk.EventType.TwoButtonPress) { DoubleClick(); } }; list.WordsFiltered += delegate { UpdateScrollBar(); }; list.SizeAllocated += delegate { UpdateScrollBar(); }; vbox.PackStart(box, true, true, 0); Add(vbox); this.AutoSelect = true; this.TypeHint = WindowTypeHint.Menu; }
public ListWindow(Gtk.WindowType type) : base(type) { vbox = new VBox(); list = new ListWidget(this); list.SelectionChanged += new EventHandler(OnSelectionChanged); list.ScrollEvent += new ScrollEventHandler(OnScrolled); scrollbar = new MonoDevelop.Components.CompactScrolledWindow(); scrollbar.Name = "CompletionScrolledWindow"; // use a different gtkrc style for GtkScrollBar scrollbar.Child = list; list.ButtonPressEvent += delegate(object o, ButtonPressEventArgs args) { if (args.Event.Button == 1 && args.Event.Type == Gdk.EventType.TwoButtonPress) { DoubleClick(); } }; vbox.PackEnd(scrollbar, true, true, 0); var colorBox = new EventBox(); colorBox.Add(vbox); ContentBox.Add(colorBox); this.AutoSelect = true; this.TypeHint = WindowTypeHint.Menu; Theme.CornerRadius = 0; Theme.Padding = 0; UpdateStyle(); Gui.Styles.Changed += HandleThemeChanged; IdeApp.Preferences.ColorScheme.Changed += HandleThemeChanged; }
protected int FindMatchedEntry(string partialWord, out bool hasMismatches) { // default - word with highest match rating in the list. hasMismatches = true; int idx = -1; List <KeyValuePair <int, string> > words = new List <KeyValuePair <int, string> > (); if (!string.IsNullOrEmpty(partialWord)) { for (int i = 0; i < list.filteredItems.Count; i++) { int index = list.filteredItems[i]; string text = DataProvider.GetCompletionText(index); if (!ListWidget.Matches(partialWord, text)) { continue; } words.Add(new KeyValuePair <int, string> (i, text)); } } ListWindow.WordComparer comparer = new WordComparer(partialWord); if (words.Count > 0) { words.Sort(comparer); idx = words[0].Key; hasMismatches = false; // exact match found. if (words[0].Value.ToUpper() == (partialWord ?? "").ToUpper()) { return(idx); } } if (string.IsNullOrEmpty(partialWord) || partialWord.Length <= 2) { // Search for history matches. for (int i = 0; i < wordHistory.Count; i++) { string historyWord = wordHistory[i]; if (ListWidget.Matches(partialWord, historyWord)) { for (int xIndex = 0; xIndex < list.filteredItems.Count; xIndex++) { string currentWord = DataProvider.GetCompletionText(list.filteredItems[xIndex]); if (currentWord == historyWord) { idx = xIndex; break; } } } } } return(idx); }
public int Compare(KeyValuePair <int, string> xpair, KeyValuePair <int, string> ypair) { string x = xpair.Value; string y = ypair.Value; int[] xMatches = ListWidget.Match(filterWord, x) ?? new int[0]; int[] yMatches = ListWidget.Match(filterWord, y) ?? new int[0]; if (xMatches.Length < yMatches.Length) { return(1); } if (xMatches.Length > yMatches.Length) { return(-1); } int xExact = 0; int yExact = 0; for (int i = 0; i < filterWord.Length; i++) { if (i < xMatches.Length && filterWord[i] == x[xMatches[i]]) { xExact++; } if (i < yMatches.Length && filterWord[i] == y[yMatches[i]]) { yExact++; } } if (xExact < yExact) { return(1); } if (xExact > yExact) { return(-1); } // favor words where the match starts sooner if (xMatches.Length > 0 && yMatches.Length > 0 && xMatches[0] != yMatches[0]) { return(xMatches[0].CompareTo(yMatches[0])); } int xIndex = xpair.Key; int yIndex = ypair.Key; if (x.Length == y.Length) { return(xIndex.CompareTo(yIndex)); } return(x.Length.CompareTo(y.Length)); }
bool FillList() { if ((completionDataList.Count == 0) && !IsChanging) { return(false); } Style = CompletionWidget.GtkStyle; //sort, sinking obsolete items to the bottoms //the string comparison is ordinal as that makes it an order of magnitude faster, which //which makes completion triggering noticeably more responsive if (!completionDataList.IsSorted) { completionDataList.Sort(ListWidget.GetComparerForCompletionList(completionDataList)); } Reposition(true); return(true); }
public ListWindow(Gtk.WindowType type) : base(type) { vbox = new VBox (); list = new ListWidget (this); list.SelectionChanged += new EventHandler (OnSelectionChanged); list.ScrollEvent += new ScrollEventHandler (OnScrolled); scrollbar = new MonoDevelop.Components.CompactScrolledWindow (); scrollbar.Child = list; list.ButtonPressEvent += delegate(object o, ButtonPressEventArgs args) { if (args.Event.Button == 1 && args.Event.Type == Gdk.EventType.TwoButtonPress) DoubleClick (); }; vbox.PackEnd (scrollbar, true, true, 0); ContentBox.Add (vbox); this.AutoSelect = true; this.TypeHint = WindowTypeHint.Menu; Theme.CornerRadius = 4; }
public ListWindow(Gtk.WindowType type) : base(type) { vbox = new VBox(); list = new ListWidget(this); list.SelectionChanged += new EventHandler(OnSelectionChanged); list.ScrollEvent += new ScrollEventHandler(OnScrolled); scrollbar = new MonoDevelop.Components.CompactScrolledWindow(); scrollbar.Child = list; list.ButtonPressEvent += delegate(object o, ButtonPressEventArgs args) { if (args.Event.Button == 1 && args.Event.Type == Gdk.EventType.TwoButtonPress) { DoubleClick(); } }; vbox.PackEnd(scrollbar, true, true, 0); ContentBox.Add(vbox); this.AutoSelect = true; this.TypeHint = WindowTypeHint.Menu; Theme.CornerRadius = 4; var style = SyntaxModeService.GetColorStyle(IdeApp.Preferences.ColorScheme); Theme.SetFlatColor(style.CompletionText.Background); }
internal int CompareTo(int n, int m) { return(ListWidget.CompareTo(completionDataList, n, m)); }