public override void PreprocessMouseLeftButtonDown(MouseButtonEventArgs e) { if ((e.ClickCount == 1 && ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)) || e.ClickCount == 2) { var url = GetHotUrl(_wpfTextView, e); if (!string.IsNullOrEmpty(url)) { _shell.Services.Process().Start(url); return; } if (!_wpfTextView.Caret.InVirtualSpace) { // If this is a Ctrl+Click or double-click then post the select word command. var point = _wpfTextView.MapDownToR(_wpfTextView.Caret.Position.BufferPosition); if (point.HasValue) { var command = new SelectWordCommand(_wpfTextView, point.Value.Snapshot.TextBuffer); var o = new object(); var result = command.Invoke(); if (result.Result == CommandResult.Executed.Result) { e.Handled = true; return; } } } } base.PreprocessMouseLeftButtonDown(e); }
public override void PreprocessMouseLeftButtonDown(MouseButtonEventArgs e) { if ((e.ClickCount == 1 && ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)) || e.ClickCount == 2) { // Check if token is URL. If it is, don't try and select and instead // let core editor deal with it since it may open URL on Ctrl+Click. if (!IsOverHotUrl(_wpfTextView, e)) { // If this is a Ctrl+Click or double-click then post the select word command. var command = new SelectWordCommand(_wpfTextView, _wpfTextView.TextBuffer); var o = new object(); var result = command.Invoke(typeof(VSConstants.VSStd2KCmdID).GUID, (int)VSConstants.VSStd2KCmdID.SELECTCURRENTWORD, null, ref o); if (result.Result == CommandResult.Executed.Result) { e.Handled = true; return; } } } base.PreprocessMouseLeftButtonDown(e); }
public override void PreprocessMouseLeftButtonDown(MouseButtonEventArgs e) { if ((e.ClickCount == 1 && ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)) || e.ClickCount == 2) { var url = GetHotUrl(_wpfTextView, e); if (!string.IsNullOrEmpty(url)) { _shell.Services.GetService <IProcessServices>().Start(url); return; } // If this is a Ctrl+Click or double-click then post the select word command. var command = new SelectWordCommand(_wpfTextView, _wpfTextView.TextBuffer); var o = new object(); var result = command.Invoke(typeof(VSConstants.VSStd2KCmdID).GUID, (int)VSConstants.VSStd2KCmdID.SELECTCURRENTWORD, null, ref o); if (result.Result == CommandResult.Executed.Result) { e.Handled = true; return; } } base.PreprocessMouseLeftButtonDown(e); }
private void Match() { if (!editor.EditorSettings.MatchWords || editor.Buffer == null) { return; } var caret = editor.Buffer.Selections.Main.Caret; var range = SelectWordCommand.SelectWord(editor, caret, SelectWordCommand.Strategy.Word); var txt = range != null?CopyCommand.GetTextRange(editor, range) : null; if (txt == lastWord && finds.Count > 0) { return; } var needRedraw = InternalClearMatches(); if (caret != requestCaret || (DateTime.Now - requestTime).TotalMilliseconds < 500) { if (needRedraw) { editor.Buffer.RequestRedraw(); } return; } lastWord = txt; if (range == null) { if (needRedraw) { editor.Buffer.RequestRedraw(); } return; } var grmId = editor.AffinityManager.GetAffinityId(caret); var grm = grmId != 0 ? App.Ext.Grammars().GetGrammar(grmId) : null; var seps = (" \t" + (grm?.NonWordSymbols ?? editor.EditorSettings.NonWordSymbols)).ToCharArray(); var regex = new Regex("\\b" + Regex.Escape(txt) + "\\b"); for (var i = 0; i < editor.Lines.Count; i++) { var line = editor.Lines[i]; var ln = line.Text; foreach (Match m in regex.Matches(ln)) { if (m.Success && editor.AffinityManager.GetAffinityId(i, m.Index) == grmId) { var aps = new AppliedStyle(StandardStyle.MatchedWord, m.Index, m.Index + m.Length - 1); line.AppliedStyles.Add(aps); finds.Add(new SearchResult(i, aps)); } } } if (finds.Count == 1) { editor.Lines[finds[0].Line].AppliedStyles.Remove(finds[0].Style); finds.Clear(); } if (finds.Count > 0 || needRedraw) { editor.Buffer.RequestRedraw(); } requestCaret = Pos.Empty; }