public void ShowCompletionWindow(IEnumerable <ICompletionData> completionItems, int overlap) { if (completionItems.Any()) { completionWindow = new CompletionWindow(Editor.TextArea); completionWindow.StartOffset -= overlap; IList <ICompletionData> data = completionWindow.CompletionList.CompletionData; foreach (var item in completionItems) { data.Add(item); } completionWindow.Show(); completionWindow.CompletionList.IsFiltering = false; completionWindow.CompletionList.SelectItem(completionItems.First().Text); completionWindow.CompletionList.IsFiltering = true; completionWindow.Closed += delegate { completionWindow = null; }; } }
public ScriptEditDialog(string text) : base("Script edit", "cde.ico", SizeToContent.Manual, ResizeMode.CanResize) { InitializeComponent(); AvalonLoader.Load(_textEditor); AvalonLoader.SetSyntax(_textEditor, "Script"); string script = DbIOFormatting.ScriptFormat(text, 0); _textEditor.Text = script; _textEditor.TextArea.TextEntered += new TextCompositionEventHandler(_textArea_TextEntered); _textEditor.TextArea.TextEntering += new TextCompositionEventHandler(_textArea_TextEntering); _textEditor.TextChanged += (e, a) => OnValueChanged(); //_textEditor.TextArea.IndentationStrategy = new CSharpIndentationStrategy(); _completionWindow = new CompletionWindow(_textEditor.TextArea); _li = _completionWindow.CompletionList; ListView lv = _li.ListBox; lv.SelectionMode = SelectionMode.Single; //Image Extensions.GenerateListViewTemplate(lv, new ListViewDataTemplateHelper.GeneralColumnInfo[] { new ListViewDataTemplateHelper.ImageColumnInfo { Header = "", DisplayExpression = "Image", TextAlignment = TextAlignment.Center, FixedWidth = 22, MaxHeight = 22, SearchGetAccessor = "Commands" }, new ListViewDataTemplateHelper.GeneralColumnInfo { Header = "Commands", DisplayExpression = "Text", TextAlignment = TextAlignment.Left, IsFill = true, ToolTipBinding = "Description" } }, null, new string[] { }, "generateHeader", "false"); _completionWindow.Content = null; _completionWindow = null; WindowStartupLocation = WindowStartupLocation.CenterOwner; _textEditor.Loaded += delegate { _textEditor.Focus(); }; }
private void StartCompletionWindow(TextArea area, string text, string token = null) { if (_completionWindow != null) { return; } List <Tuple <string, string> > showKeys = null; if (string.IsNullOrEmpty(token)) { showKeys = KeyWord.GetKeyword(text); } else { showKeys = KeyWord.GetMethodword(text, token); } if (showKeys == null || showKeys.Count == 0) { return; } _completionWindow = new CompletionWindow(area) { ResizeMode = ResizeMode.NoResize }; _completionWindow.Closed += (sender, args) => _completionWindow = null; _completionWindow.CloseWhenCaretAtBeginning = false; var data = _completionWindow.CompletionList.CompletionData; foreach (var key in showKeys) { data.Add(new CompletionData(key.Item1, key.Item2)); } _completionWindow.Show(); }
private void TextEditor_TextArea_TextEntered(object sender, TextCompositionEventArgs e) { if (e.Text != "<") { return; } _completionWindow = new CompletionWindow(SourceXslt.TextArea); var data = _completionWindow.CompletionList.CompletionData; data.Add(new XmlCompletionData("xsl:choose", "xsl:choose></xsl:choose>", "Provides multiple conditional testing in conjunction with the <xsl:otherwise> element and <xsl:when> element.")); data.Add(new XmlCompletionData("xsl:for-each", "xsl:for-each select=\"temp\"></xsl:for-each>", "Applies a template repeatedly, applying it in turn to each node in a set.")); data.Add(new XmlCompletionData("xsl:if", "xsl:if test=\"temp\"></xsl:if>", "Allows simple conditional template fragments.")); data.Add(new XmlCompletionData("xsl:otherwise", "xsl:otherwise></xsl:otherwise>", "Provides multiple conditional testing in conjunction with the <xsl:choose> element and <xsl:when> element.")); data.Add(new XmlCompletionData("xsl:stylesheet", "xsl:stylesheet version=\"2.0\"\r\n xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"\r\n xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"\r\n xmlns:fn=\"http://www.w3.org/2005/xpath-functions\"\r\n exclude-result-prefixes=\"xs fn\">\r\n <xsl:output version=\"1.0\" method=\"xml\" omit-xml-declaration=\"yes\" indent=\"yes\" />\r\n\r\n <xsl:template match=\"/\">\r\n <xsl:text>temp</xsl:text>\r\n </xsl:template>\r\n</xsl:stylesheet>", "Template stylesheet.")); data.Add(new XmlCompletionData("xsl:text", "xsl:text></xsl:text>", "Generates text in the output.")); data.Add(new XmlCompletionData("xsl:value-of", "xsl:value-of select=\"temp\" />", "Inserts the value of the selected node as text.")); data.Add(new XmlCompletionData("xsl:variable", "xsl:variable name=\"temp\" select=\"temp\" />", "Specifies a value bound in an expression.")); data.Add(new XmlCompletionData("xsl:when", "xsl:when test=\"temp\"></xsl:when>", "Provides multiple conditional testing in conjunction with the <xsl:choose> element and <xsl:otherwise> element.")); int?offset = 0; _completionWindow.Show(); _completionWindow.Closed += delegate { if (_completionWindow?.CompletionList.SelectedItem != null) { offset = _completionWindow.CompletionList.SelectedItem.Text.Length - _completionWindow.CompletionList.SelectedItem.Text.IndexOf('>') - 1; } _completionWindow = null; }; _completionWindow.CompletionList.InsertionRequested += delegate { if (offset != null) { SourceXslt.CaretOffset = SourceXslt.CaretOffset - (int)offset; } }; }
private void _loadUi() { _rcm = new WpfRecentFiles(SdeAppConfiguration.ConfigAsker, 6, _miLoadRecent, "Server database editor - IronPython recent files"); _rcm.FileClicked += new RecentFilesManager.RFMFileClickedEventHandler(_rcm_FileClicked); Binder.Bind(_textEditor, () => SdeAppConfiguration.IronPythonScript); Binder.Bind(_miAutocomplete, () => SdeAppConfiguration.IronPythonAutocomplete); AvalonLoader.Load(_textEditor); AvalonLoader.SetSyntax(_textEditor, "Python"); _textEditor.TextArea.TextEntered += new TextCompositionEventHandler(_textArea_TextEntered); _textEditor.TextArea.TextEntering += new TextCompositionEventHandler(_textArea_TextEntering); this.PreviewKeyDown += new KeyEventHandler(_ironPythonDialog_PreviewKeyDown); _completionWindow = new CompletionWindow(_textEditor.TextArea); _completionWindow.Background = Application.Current.Resources["TabItemBackground"] as Brush; _li = _completionWindow.CompletionList; ListView lv = _li.ListBox; lv.SelectionMode = SelectionMode.Single; lv.Background = Application.Current.Resources["TabItemBackground"] as Brush; //Image ListViewDataTemplateHelper.GenerateListViewTemplateNew(lv, new ListViewDataTemplateHelper.GeneralColumnInfo[] { new ListViewDataTemplateHelper.ImageColumnInfo { Header = "", DisplayExpression = "Image", TextAlignment = TextAlignment.Center, FixedWidth = 22, MaxHeight = 22, SearchGetAccessor = "Commands" }, new ListViewDataTemplateHelper.GeneralColumnInfo { Header = "Commands", DisplayExpression = "Text", TextAlignment = TextAlignment.Left, IsFill = true, ToolTipBinding = "Description" } }, null, new string[] { }, "generateHeader", "false"); _completionWindow.Content = null; _completionWindow = null; _rowConsole.Height = new GridLength(0); _buttonCloseConsole.Margin = new Thickness(0, 5, SystemParameters.HorizontalScrollBarButtonWidth + 2, 0); _textEditor.Drop += new DragEventHandler(_textEditor_Drop); }
void TextPythonEntered(string text) { if (PyTextEntered != null) { List <string> list = new List <string>(); using (Py.GIL()) { PyTextEntered.Invoke(text.ToPython()); if (PyComDataList != null) { foreach (var item in PyComDataList) { list.Add(item.ToString()); } } } completionWindow = new CompletionWindow(textEditor.TextArea); completionWindow.ResizeMode = ResizeMode.NoResize; var data = completionWindow.CompletionList.CompletionData; int len; if (list.Count > 0 && int.TryParse(list[0], out len)) { list.RemoveAt(0); foreach (var item in list) { data.Add(new IOCompletionData(item, len)); } if (data.Count > 0) { completionWindow.Show(); completionWindow.Closed += delegate { completionWindow = null; }; } } } }
void textEditor_TextArea_TextEntered(object sender, TextCompositionEventArgs e) { try { if (e.Text == ".") { completionWindow = new CompletionWindow(editWindow.editText.TextArea); var data = completionWindow.CompletionList.CompletionData; var completions = completionProvider.GetCompletionData(editWindow.editText.Text.Substring(0, editWindow.editText .CaretOffset)); if (completions.Length == 0) { return; } foreach (var ele in completions) { data.Add(ele); } completionWindow.Show(); completionWindow.Closed += delegate { completionWindow = null; }; } } catch (Exception ex) { DynamoLogger.Instance.Log("Failed to perform python autocomplete with exception:"); DynamoLogger.Instance.Log(ex.Message); DynamoLogger.Instance.Log(ex.StackTrace); } }
public override void Complete(TextArea textArea, ISegment completionSegment, EventArgs insertionRequestEventArgs) { if (_values.Count == 0) { textArea.Document.Replace(completionSegment, Text + '}'); return; } textArea.Document.Replace(completionSegment, Text + ' '); _argCompletionWindow = new CompletionWindow(textArea); IList <ICompletionData> data = _argCompletionWindow.CompletionList.CompletionData; foreach (CompletionData value in _values) { data.Add(value); } _argCompletionWindow.Closed += (sender, args) => _argCompletionWindow = null; _argCompletionWindow.Show(); }
void textEditor_TextArea_TextEntered1(object sender, TextCompositionEventArgs e) { if (e.Text == @"\") { // open code completion after the user has pressed dot: completionWindow = new CompletionWindow(textEditor.TextArea); // provide AvalonEdit with the data: IList <ICompletionData> data = completionWindow.CompletionList.CompletionData; string[] sss = new string[] { "b", "a" }; foreach (string s in sss) // TexHelper.TexEntries()["Greek letters"]) { MyCompletionData d = new MyCompletionData(s); data.Add(new MyCompletionData(s.Substring(1, s.Length - 1))); } completionWindow.Show(); completionWindow.Closed += delegate { completionWindow = null; }; } }
private void LetterCompletion(TextArea textArea, TriggerMode triggerMode) { string token = GetToken(textArea); if (token != "") { // 获取token的parent string parent = GetParent(textArea); // 生成补全窗口实例 completionWindow = GetCompletionWindow(textArea, token); IList <ICompletionData> data = completionWindow.CompletionList.CompletionData; // 从数据库里寻找匹配到的补全条目 GetDataFromSnippets(parent, token, data); if (parent == "") { GetDataFromPossibleVarNames(token, textArea.TextView.Document.Text, data); GetDataFromPredefindTypes(token, data); GetDataFromPredefindKeyWords(token, data); } if (triggerMode == TriggerMode.Active) { GetDataFromAPI(textArea, data); } GetDataFromReflection(textArea, data); // 补全数据不为空,则显示补全窗口 if (data.Count() > 0) { completionWindow.Show(); } // 绑定退出事件 completionWindow.Closed += delegate { completionWindow = null; }; } }
private void inserting(object s, EventArgs Arg) { Dispatcher.Invoke(RefreshLexer); completion = new CompletionWindow(TextArea); var dataref = completion.CompletionList.CompletionData; if (Arg is TextCompositionEventArgs textarg) { if (textarg.Text[0] == ':') { foreach (var F in funclist) { dataref.Add(F); } } else { foreach (var kw in keywords) { dataref.Add(kw); } foreach (var V in varlist) { dataref.Add(V); } foreach (var F in funclist) { dataref.Add(F); } } completion.Show(); completion.Closed += (object lambdasender, EventArgs arg) => { completion = null; //completion = new CompletionWindow(TextArea); }; //dataref.sort } }
public override CompletionWindow Complete(TextArea textArea) { CompletionWindow completionWindow = new CompletionWindow(textArea); string lineLeft = textArea.Document.GetLineLeftOf(textArea.Caret.Offset); string tableName = lineLeft.EverythingBetweenNarrow("Table(\"", "\""); if (string.IsNullOrWhiteSpace(tableName)) { return(null); } List <string> tableColumns = AllTables.GetColumns(tableName); IList <ICompletionData> data = completionWindow.CompletionList.CompletionData; foreach (string tableColumn in tableColumns) { data.Add(new TextStringCompletionData(tableColumn)); } return(completionWindow); }
private void OpenCompletionWindow(IEnumerable <CompletionData> completions) { if (this._completionWindow != null) { return; } var wnd = new CompletionWindow(this.TextArea); wnd.Closed += (o, e) => { if (this._completionWindow == wnd) { this._completionWindow = null; } }; var elems = wnd.CompletionList.CompletionData; completions.ForEach(wnd.CompletionList.CompletionData.Add); // insert elements this._completionWindow = wnd; wnd.Show(); }
private void Compelet() { string path = ""; Regex reBiblio = new Regex(@"(?<!%)(?<=\\bibliography\{)([^\{]+)(?=\})", RegexOptions.IgnoreCase); Match m = reBiblio.Match(txtEditor.Text); if (m.Success) { path = this.CurrentFileInfo.Directory + "\\" + m.Groups[1].Captures[0].Value.ToString() + ".bib"; } if (!File.Exists(path)) { return; } //if (e.Text == @"\ref{") //{ // open code completion after the user has pressed dot: completionWindow = new CompletionWindow(txtEditor.TextArea); // provide AvalonEdit with the data: IList <ICompletionData> data = completionWindow.CompletionList.CompletionData; StringBuilder entry = new StringBuilder(); foreach (BibTex b in BibTex.Parse(path)) { MyCompletionData d = new MyCompletionData(b.UID); d.Data = b.Text; //d.Description = "des"; //d.Content = "content"; data.Add(d); } completionWindow.Show(); completionWindow.Closed += delegate { completionWindow = null; }; //} }
void ShowCompletionWindow() { // Open code completion after the user has pressed anything: completionWindow = new CompletionWindow(editor.TextArea); completionWindow.StartOffset--; completionWindow.CloseWhenCaretAtBeginning = true; IList <ICompletionData> data = completionWindow.CompletionList.CompletionData; foreach (var item in OpcodeDescriptions) { data.Add(new MasmCompletionData(item.Key, item.Value, 2)); } for (int i = 0; i < labels.Count; i++) { data.Add(new MasmCompletionData(labels[i], "Label")); } completionWindow.Show(); completionWindow.Closed += (sender2, e2) => completionWindow = null; }
void ShowCodeCompletionWindow() { string Code = EditorCode.Dispatcher.Invoke(new Func <string>(() => { return(EditorCode.Text); })); IEnumerable <string> AutocompletionList = CodeHelper.GetCodeAutocompletionList(Code, EditorCode.CaretOffset); if (AutocompletionList != null && AutocompletionList.Count() > 0) { CodeCompletionWindow = new CompletionWindow(EditorCode.TextArea); CodeCompletionWindow.Closed += delegate { CodeCompletionWindow = null; }; CodeCompletionWindow.CompletionList.InsertionRequested += delegate { CodeHelper.CodeAutocompletion_AlreadyEnteredStrLen = 0; }; IList <ICompletionData> data = CodeCompletionWindow.CompletionList.CompletionData; foreach (var str in AutocompletionList) { data.Add(new CodeCompletionData(str, CodeHelper.CodeAutocompletion_AlreadyEnteredStrLen)); } if (CodeCompletionWindow != null) { CodeCompletionWindow.Show(); } } }
private void textEditor_TextArea_TextEntered(object sender, TextCompositionEventArgs e) { if (e.Text != ".") { return; } // open code completion after the user has pressed dot: completionWindow = new CompletionWindow(TextEditor.TextArea); // provide AvalonEdit with the data: var data = completionWindow.CompletionList.CompletionData; data.Add(new MyCompletionData("Item1")); data.Add(new MyCompletionData("Item2")); data.Add(new MyCompletionData("Item3")); data.Add(new MyCompletionData("Another item")); completionWindow.Show(); completionWindow.Closed += delegate { completionWindow = null; completionWindow = null; }; }
private void OnTextEntered(object sender, TextCompositionEventArgs e) { if (e.Text != ":") { return; } // Open code completion after the user has pressed ':': _completionWindow = new CompletionWindow(TextEditor.TextArea); var data = _completionWindow.CompletionList.CompletionData; var word = TextEditor.GetTextBeforeCaret(); data.AutoCompleteFor(word); if (!data.Any()) { return; } _completionWindow.Show(); _completionWindow.Closed += delegate { _completionWindow = null; }; }
public void ShowCompletionWindow() { var completionItems = GetCompletionListAsync( AddDocument.Text.Length + TextArea.Caret.Offset, AddDocument.Text + Document.Text ); if (completionItems != null) { _CompletionWindow = new CompletionWindow(TextArea); IList <ICompletionData> data = _CompletionWindow.CompletionList.CompletionData; foreach (var item in completionItems) { data.Add(item); } _CompletionWindow.Show(); _CompletionWindow.Closed += delegate { _CompletionWindow = null; }; } }
private void DotComletion(TextArea textArea, TriggerMode triggerMode) { var parent = GetParent(textArea); completionWindow = GetCompletionWindow(textArea); IList <ICompletionData> data = completionWindow.CompletionList.CompletionData; GetDataFromSnippets(parent, "", data); if (!GetDataFromReflection(textArea, data) || triggerMode == TriggerMode.Active) { GetDataFromAPI(textArea, data); } // 补全数据不为空,则显示补全窗口 if (data.Count() > 0) { completionWindow.Show(); } completionWindow.Closed += delegate { completionWindow = null; }; }
/// <summary> /// Shows the completion window. /// </summary> /// <param name="completionDataProvider">The completion data provider.</param> /// <param name="ch">The character that was typed - or <c>'\0'</c> if no character was typed.</param> /// <param name="closeAutomatically"><see langword="true"/> to close the completion wnidow automatically.</param> public void ShowCompletionWindow(ICompletionDataProvider completionDataProvider, char ch, bool closeAutomatically) { completionDataProvider.PreSelection = String.Empty; // Make default pre-selection string previousWord = TextHelper.GetWordBeforeCaret(ActiveTextAreaControl.TextArea); if (!String.IsNullOrEmpty(previousWord)) { char lastChar = previousWord[previousWord.Length - 1]; if (TextHelper.IsLetterDigitOrUnderscore(lastChar)) { completionDataProvider.PreSelection = previousWord; } } completionWindow = CompletionWindow.ShowCompletionWindow(ParentForm, this, "", completionDataProvider, ch, true, false, closeAutomatically); if (completionWindow != null) { completionWindow.Closed += OnCompletionWindowClosed; } }
private void ShowCompletionWindow(IEnumerable <ICompletionData> completions, bool completeWhenTyping = false) { // TODO: Need to make this more efficient by instantiating 'completionWindow' // just once and updating its contents each time // This implementation has been referenced from // http://www.codeproject.com/Articles/42490/Using-AvalonEdit-WPF-Text-Editor completionWindow = new CompletionWindow(this.InnerTextEditor.TextArea); completionWindow.AllowsTransparency = true; completionWindow.SizeToContent = SizeToContent.WidthAndHeight; if (completeWhenTyping) { // As opposed to complete on '.', in complete while typing mode // the first character typed should also be considered for matches // while generating options in completion window completionWindow.StartOffset--; // As opposed to complete on '.', in complete while typing mode // erasing the first character of the string being completed // should close the completion window completionWindow.CloseWhenCaretAtBeginning = true; } var data = completionWindow.CompletionList.CompletionData; foreach (var completion in completions) { data.Add(completion); } completionWindow.Show(); completionWindow.Closed += delegate { completionWindow = null; }; }
private void InitializaCompletionWindow() { // Set properties. var converter = new System.Windows.Media.BrushConverter(); var bg = (System.Windows.Media.Brush)converter.ConvertFromString("#FF303032"); _completionWindow = new CompletionWindow(txtScript.TextArea); _completionWindow.SizeToContent = SizeToContent.WidthAndHeight; _completionWindow.Background = bg; _completionWindow.WindowStyle = WindowStyle.None; _completionWindow.CompletionList.ListBox.Background = System.Windows.Media.Brushes.Transparent; _completionWindow.CompletionList.ListBox.Foreground = this.Foreground; _completionWindow.Closed += delegate { _completionWindow = null; }; _completionWindow.CloseAutomatically = true; _completionWindow.CloseWhenCaretAtBeginning = true; // Add completion data to the list. IList <ICompletionData> data = _completionWindow.CompletionList.CompletionData; // Static Items. foreach (var item in _staticCompletionData) { data.Add(item); } // Dynamic Script Items. foreach (var item in _dynamicScriptCompletionData) { data.Add(item); } // Dynamic Global Items. foreach (var item in _dynamicGlobalCompletionData) { data.Add(item); } }
private void ShowCompletionWindow(List <string> showDatas) { if (showDatas == null || showDatas.Count == 0) { return; } _completionWindow = new CompletionWindowEx(_partTextEditor.TextArea); _completionWindow.Resources = Resources; _completionWindow.MinWidth = 300; _completionWindow.MaxHeight = 300; _completionWindow.SizeToContent = SizeToContent.WidthAndHeight; _completionWindow.CompletionList.InsertionRequested += CompletionList_InsertionRequested; var datas = _completionWindow.CompletionList.CompletionData; showDatas.ForEach(d => datas.Add(new EditorCompletionData(d))); EventHandler handler = null; handler = (s, e) => { if (_completionWindow != null) { _completionWindow.CompletionList.InsertionRequested -= CompletionList_InsertionRequested; _completionWindow.Closed -= handler; _completionWindow.Resources = null; _completionWindow = null; } }; _completionWindow.Closed -= handler; _completionWindow.Closed += handler; _completionWindow.Show(); }
private void TextArea_TextEntered(object sender, TextCompositionEventArgs e) { if (completionWindow == null) { bool showCompletion = false; if (ValidPreviousChar()) { foreach (ICompletionData data in completionDatas) { if ((data.Content as string).StartsWith(e.Text)) { showCompletion = true; break; } } } if (showCompletion) { completionWindow = new CompletionWindow(m_textEditor.TextArea); IList <ICompletionData> dataList = completionWindow.CompletionList.CompletionData; foreach (ICompletionData data in completionDatas) { dataList.Add(data); } completionWindow.Show(); completionWindow.Closed += delegate { completionWindow = null; }; //completionWindow.CompletionList. completionWindow.StartOffset = completionWindow.StartOffset - 1; completionWindow.CompletionList.IsFiltering = true; completionWindow.CompletionList.SelectItem(e.Text); } } }
void textEditor_TextArea_TextEntered(object sender, TextCompositionEventArgs e) { // if (e.Text == ".") if (_completion_window == null && false) { var bc = new BrushConverter(); _completion_window = new CompletionWindow(Editor.TextArea) { Width = 300 }; _completion_window.CompletionList.Background = (Brush)bc.ConvertFrom("#FF252526"); _completion_window.CompletionList.ListBox.Background = (Brush)bc.ConvertFrom("#FF252526"); _completion_window.CompletionList.ListBox.Foreground = new SolidColorBrush(Colors.White); _completion_window.CompletionList.ListBox.BorderBrush = (Brush)bc.ConvertFrom("#FF252526"); Add_data = _completion_window.CompletionList.CompletionData; if (Add_data.Count == 0) { //foreach (string t in Completions) //{ // Add_data.Add(new MyCompletionData(t.na)); //} // Add_data.Add(new MyCompletionData("Item1")); // data.Add(new MyCompletionData("Item2")); // data.Add(new MyCompletionData("Item3")); // data.Add(new MyCompletionData("Another item")); // _completion_window.CompletionList. _completion_window.Show(); } _completion_window.Closed += delegate { _completion_window = null; }; } }
private void OnTextAreaTextEntered(object sender, TextCompositionEventArgs e) { try { if (e.Text == ".") { var subString = editText.Text.Substring(0, editText.CaretOffset); var completions = completionProvider.GetCompletionData(subString, false); if (completions.Length == 0) { return; } completionWindow = new CompletionWindow(editText.TextArea); var data = completionWindow.CompletionList.CompletionData; foreach (var completion in completions) { data.Add(completion); } completionWindow.Show(); completionWindow.Closed += delegate { completionWindow = null; }; } } catch (Exception ex) { dynamoViewModel.Model.Logger.Log("Failed to perform python autocomplete with exception:"); dynamoViewModel.Model.Logger.Log(ex.Message); dynamoViewModel.Model.Logger.Log(ex.StackTrace); } }
private void TextEntered(object sender, TextCompositionEventArgs e) { var text = _viewModel.Editor.Text; if (e.Text == ".") { var index = _viewModel.Editor.CaretOffset - 1; while (index > 0) { if (Char.IsLetterOrDigit(text[index]) || text[index] == '.') { index--; } else { break; } } var s = text.Substring(index + 1, _viewModel.Editor.CaretOffset - index - 1); _completionWindow = new CompletionWindow(_viewModel.Editor.TextArea) { CloseWhenCaretAtBeginning = true, StartOffset = index + 1 }; foreach (var item in _completionDatas.AsParallel().Where(x => x.Text.Contains(s))) { _completionWindow.CompletionList.CompletionData.Add(item); } if (_completionWindow.CompletionList.CompletionData.Count == 0) { return; } _completionWindow.Show(); _completionWindow.Closed += delegate { _completionWindow = null; }; } Update(text); }
private void OnKeyReleased(object sender, KeyEventArgs e) { // If we press the backspace key when completionWindow is open, we // close the window. if ((e.Key == Key.Back || e.Key == Key.Space) && _completionWindow != null) { _completionWindow.Close(); _completionWindow = null; return; } // If enter or tab is pressed when the completionWindow is open, // request insertion of the selected word. if ((e.Key == Key.Enter || e.Key == Key.Tab) && _completionWindow != null) { _completionWindow.CompletionList.RequestInsertion(e); return; } // Debugging if (_debuggerService.IsActiveDebugging) { switch (e.Key) { case Key.F10: _debuggerService.StepOver(); break; case Key.F11: _debuggerService.StepInto(); break; } } }
private void hook_KeyDown(object sender, KeyEventArgs e) { if (AutoCompleteData == null) { return; } var isKey1Down = e.KeyValue == (int)Keys.Q && (int)Control.ModifierKeys == (int)Keys.Control; var isKey2Down = e.KeyValue == (int)Keys.T && (int)Control.ModifierKeys == (int)Keys.Control; if (isKey2Down) { completionWindow = new CompletionWindow(mainEditor.TextArea); var k = completionWindow.CompletionList.CompletionData; completionWindow.Width = 500; foreach (var item in AutoCompleteData) { k.Add(item); } completionWindow.Show(); completionWindow.Closed += delegate { completionWindow = null; }; } if (isKey1Down) { if (reoGridControl3.Visible) { 回到资源包ToolStripMenuItem_Click_1(this, null); } else { 打开CardCommandToolStripMenuItem_Click_1(this, null); } } }
public void ShowCompletionWindow(IEnumerable<ICompletionData> completionItems, int overlap) { if (completionItems.Any()) { //if (completionWindow != null) // completionWindow.Close(); completionWindow = new CompletionWindowEx(Editor.TextArea); completionWindow.StartOffset -= overlap; IList<ICompletionData> data = completionWindow.CompletionList.CompletionData; foreach (var item in completionItems) { data.Add(item); } completionWindow.Show(); completionWindow.CompletionList.IsFiltering = false; completionWindow.CompletionList.SelectItem(completionItems.First().Text); completionWindow.CompletionList.IsFiltering = true; completionWindow.Closed += delegate { completionWindow = null; }; } }