void CaretPositionChanged(object sender, EventArgs e) { int offset = this.TextArea.Caret.Offset; if (offset == this.StartOffset) { if (CloseAutomatically && CloseWhenCaretAtBeginning) { Close(); } else { completionList.SelectItem(string.Empty); } return; } if (offset < this.StartOffset || offset > this.EndOffset) { if (CloseAutomatically) { Close(); } } else { TextDocument document = this.TextArea.Document; if (document != null) { completionList.SelectItem(document.GetText(this.StartOffset, offset - this.StartOffset)); } } }
public void Open(string input, bool IsNameSpaceOpen = false) { this.MinWidth = 0; this.Width = 0; this.MinHeight = 0; Height = 0; this.SizeToContent = SizeToContent.Manual; this.inputText = input; this.IsNameSpaceOpen = IsNameSpaceOpen; Show(); if (!IsNameSpaceOpen) { this.Visibility = Visibility.Hidden; } this.SizeToContent = SizeToContent.Height; this.MinHeight = 15; this.Width = 175; this.MinWidth = 30; this.Height = 270; this.Content = completionList; this.Background = (System.Windows.Media.Brush)Application.Current.Resources["MaterialDesignToolBarBackground"]; this.Foreground = (System.Windows.Media.Brush)Application.Current.Resources["MaterialDesignBody"]; completionList.ListBox.Background = (System.Windows.Media.Brush)Application.Current.Resources["MaterialDesignToolBarBackground"]; completionList.ListBox.Foreground = (System.Windows.Media.Brush)Application.Current.Resources["MaterialDesignBody"]; completionList.ListBox.BorderBrush = (System.Windows.Media.Brush)Application.Current.Resources["MaterialDesignPaper"]; if (!string.IsNullOrEmpty(input)) { if (!IsNameSpaceOpen) { completionList.SelectItem(input); this.StartOffset -= 1; } } }
protected override void OnSourceInitialized(EventArgs e) { base.OnSourceInitialized(e); if (_itemList.PreselectionLength > 0 && _itemList.SuggestedItem == null) { var preselection = TextArea.Document.GetText(StartOffset, EndOffset - StartOffset); CompletionList.SelectItem(preselection); } }
public static bool FromAST(string text, int index, Block ast, CompletionList list) { var spanningBlock = AbstractSyntaxTree.SpanningBlock(ast, index); string pre = string.Empty; var data = new List <ICompletionData>(); if (spanningBlock?.Tag == BlockTag.Meta) { pre = FindMetaPretext(text, index); data.AddRange(FromMetaModel(AppViewModel.Instance.Settings.SelectedTemplate.MetaData)); } else { char?marker = IdentifyMarker(text, index, out pre); if (marker == null || marker == FootnoteMarker) { data.AddRange(FromReferences(ast)); } if (marker == null || marker == CitationMarker) { data.AddRange(FromBibliography(ast)); } if (marker == null || marker == HtmlMarker) { data.AddRange(HtmlData()); } if (marker == null || marker == LatexMarker) { data.AddRange(LatexData()); } } data.Sort((a, b) => a.Text.CompareTo(b.Text)); foreach (var item in data) { list.CompletionData.Add(item); } if (!string.IsNullOrWhiteSpace(pre)) { list.IsFiltering = true; list.SelectItem(pre); if (list.IsEmpty()) { return(false); } } return(true); }
void CodeSnippetCompletionWindow_TextChanged(object sender, TextChangedEventArgs e) { CompletionList.SelectItem(this.snippetInput.Text); }