public int Find(string pszSearch, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out uint pResult) { if (_findTarget != null) { return(_findTarget.Find(pszSearch, grfOptions, fResetStartPoint, pHelper, out pResult)); } pResult = 0; return(VSConstants.E_NOTIMPL); }
/// <summary> /// Search for the string in the text of our editor. /// Options specify how we do the search /// </summary> /// <param name="pszSearch">Search string</param> /// <param name="grfOptions">Search options</param> /// <param name="fResetStartPoint">Is this a new search?</param> /// <param name="pHelper">We are not using it</param> /// <param name="pResult">True if we found the search string</param> public int Find(string pszSearch, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out uint pResult) { pResult = 0; /*int result = 0; bool reverse = false; // Transform the VS search options to RTF search options RichTextBoxFinds options = RichTextBoxFinds.None; if ((grfOptions & (int)__VSFINDOPTIONS.FR_WholeWord) != 0) options |= RichTextBoxFinds.WholeWord; if ((grfOptions & (int)__VSFINDOPTIONS.FR_MatchCase) != 0) options |= RichTextBoxFinds.MatchCase; if ((grfOptions & (int)__VSFINDOPTIONS.FR_Backwards) != 0) { options |= RichTextBoxFinds.Reverse; reverse = true; } // Verify if this is a new search if (fResetStartPoint != 0 || forceNewSearch || textBox1.SelectionStart != searchCursorLocation) { forceNewSearch = false; currentSearchStart = textBox1.SelectionStart + textBox1.SelectionLength; // If our start location is the end of the file, start at the beginging if (currentSearchStart == textBox1.Text.Length) currentSearchStart = 0; searchCursorLocation = currentSearchStart; // Let replace know we are starting from scratch (in case this find is for a replace) replaced = false; } else { // Continue search // Updated search position if (forceCursorWrapAround) { forceCursorWrapAround = false; // set location to begining of next part to be searched if (reverse) searchCursorLocation = -1; // -1 = end of file else searchCursorLocation = 0; } else { // increment cursor location so we search past the last found item if (reverse) --searchCursorLocation; else ++searchCursorLocation; } } // Compute search range // Note that Start < End, even when doing reverse search (-1 = end of file) int searchStart = 0; int searchEnd = -1; // First we search from cursor location. // Once we have reached the end of the file, // we search until the original start location // (we will be called a second time if we return "passed end of file") if (reverse) { searchEnd = searchCursorLocation; if (passedEndOfFile) searchStart = currentSearchStart; } else { searchStart = searchCursorLocation; if (passedEndOfFile) searchEnd = currentSearchStart; } // Perform actual search Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "About to search from {0}, to {1}", searchStart, searchEnd)); if (searchStart != searchEnd) { result = textBox1.Find(pszSearch, searchStart, searchEnd, options); } else { result = -1; } // Set result value if (result != -1) { // We found the string pResult = (uint)__VSFINDRESULT.VSFR_Found; } else { // If we searched the whole file or this is not a selection search if (passedEndOfFile || (grfOptions & (int)__VSFINDOPTIONS.FR_Selection) != 0) { // We did not find anything pResult = (uint)__VSFINDRESULT.VSFR_NotFound; passedEndOfFile = false; // if we did replace something before getting here (then this is a replace) if (replaced) { replaced = false; // adjust cursor final position if ((grfOptions & (int)__VSFINDOPTIONS.FR_Backwards) != 0) { if (textBox1.SelectionStart > 0) textBox1.SelectionStart -= 1; } else if (textBox1.SelectionStart < (textBox1.Text.Length-1)) textBox1.SelectionStart += 1; } } else { // We did not find the string, but we reached the end of the file // Let VS know, and we will get called a second time to search the rest of the document pResult = (uint)__VSFINDRESULT.VSFR_EndOfDoc; passedEndOfFile = true; forceCursorWrapAround = true; } } // Save cursor position for next call searchCursorLocation = textBox1.SelectionStart;*/ return VSConstants.S_OK; }
int IVsFindTarget.Replace(string pszSearch, string pszReplace, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out int pfReplaced) { IVsFindTarget findTarget = GetView(sourceFrame) as IVsFindTarget; if (findTarget != null) { return(findTarget.Replace(pszSearch, pszReplace, grfOptions, fResetStartPoint, pHelper, out pfReplaced)); } pfReplaced = 0; return(VSConstants.E_NOTIMPL); }
public int Find(string pszSearch, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out uint pResult) { var findTarget = (IVsFindTarget)_vsCodeWindow; return findTarget.Find(pszSearch, grfOptions, fResetStartPoint, pHelper, out pResult); }
public int Replace(string pszSearch, string pszReplace, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out int pfReplaced) { pfReplaced = 0; return EditorFindTarget == null ? 0 : EditorFindTarget.Replace(pszSearch, pszReplace, grfOptions, fResetStartPoint, pHelper, out pfReplaced); }
public int Find(string pszSearch, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out uint pResult) { pResult = 0; return EditorFindTarget == null ? 0 : EditorFindTarget.Find(pszSearch, grfOptions, fResetStartPoint, pHelper, out pResult); }
int IVsFindTarget.Replace(string pszSearch, string pszReplace, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out int pfReplaced) => ((IVsFindTarget)_editorWindow).Replace(pszSearch, pszReplace, grfOptions, fResetStartPoint, pHelper, out pfReplaced);
public int Replace(string pszSearch, string pszReplace, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out int pfReplaced) { if (_findTarget != null) { return _findTarget.Replace(pszSearch, pszReplace, grfOptions, fResetStartPoint, pHelper, out pfReplaced); } pfReplaced = 0; return VSConstants.E_NOTIMPL; }
public int Replace(string pszSearch, string pszReplace, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out int pfReplaced) { return((CommandWindow.VsCodeWindow as IVsFindTarget).Replace(pszSearch, pszReplace, grfOptions, fResetStartPoint, pHelper, out pfReplaced)); }
public int Find(string pszSearch, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out uint pResult) { return((CommandWindow.VsCodeWindow as IVsFindTarget).Find(pszSearch, grfOptions, fResetStartPoint, pHelper, out pResult)); }
/// <summary> /// Replace a string in the text. No need to implement since we implement IVsTextImage /// </summary> /// <param name="pszSearch">string containing the search text</param> /// <param name="pszReplace">string containing the replacement text</param> /// <param name="grfOptions">Search options available</param> /// <param name="fResetStartPoint">flag to reset the search start point</param> /// <param name="pHelper">IVsFindHelper interface object</param> /// <param name="pfReplaced">returns whether replacement was successful or not</param> /// <returns></returns> int IVsFindTarget.Replace(string pszSearch, string pszReplace, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out int pfReplaced) { return(((IVsFindTarget)_subCodeWindow).Replace(pszSearch, pszReplace, grfOptions, fResetStartPoint, pHelper, out pfReplaced)); }
/// <summary> /// Search for the string in the text of our editor. /// Options specify how we do the search. No need to implement this since we implement IVsTextImage /// </summary> /// <param name="pszSearch">Search string</param> /// <param name="grfOptions">Search options</param> /// <param name="fResetStartPoint">Is this a new search?</param> /// <param name="pHelper">We are not using it</param> /// <param name="pResult">True if we found the search string</param> int IVsFindTarget.Find(string pszSearch, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out uint pResult) { return(((IVsFindTarget)_subCodeWindow).Find(pszSearch, grfOptions, fResetStartPoint, pHelper, out pResult)); }
public int Replace(string pszSearch, string pszReplace, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out int pfReplaced) { return (CommandWindow.VsCodeWindow as IVsFindTarget).Replace(pszSearch, pszReplace, grfOptions, fResetStartPoint, pHelper, out pfReplaced); }
public int Find(string pszSearch, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out uint pResult) { return (CommandWindow.VsCodeWindow as IVsFindTarget).Find(pszSearch, grfOptions, fResetStartPoint, pHelper, out pResult); }
public int Replace(string pszSearch, string pszReplace, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out int pfReplaced) { pfReplaced = 0; /*// If the selection is empty, exit if ( textBox1.SelectionLength == 0) { pfReplaced = 0; return VSConstants.S_OK; } // Get the selection string sel = textBox1.SelectedText; bool ignoreCase = (grfOptions & (int)__VSFINDOPTIONS.FR_MatchCase) == 0; // Check if the selection matchs the search if ( string.Compare(sel, pszSearch, ignoreCase, CultureInfo.CurrentCulture) == 0 ) { // Recalculate search start position if we make the text longer/shorter if (textBox1.SelectionStart <= currentSearchStart) { currentSearchStart += pszReplace.Length - sel.Length; } // Do the actual replace textBox1.SelectedText = pszReplace; // Adjust position so the next find is done correctly if ((grfOptions & (int)__VSFINDOPTIONS.FR_Backwards) != 0) { textBox1.SelectionStart -= (pszReplace.Length); } else { textBox1.SelectionStart -= 1; } searchCursorLocation = textBox1.SelectionStart; pfReplaced = 1; replaced = true; } else { pfReplaced = 0; }*/ return VSConstants.S_OK; }
public int Find(string pszSearch, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out uint pResult) { var findTarget = (IVsFindTarget)_vsCodeWindow; return(findTarget.Find(pszSearch, grfOptions, fResetStartPoint, pHelper, out pResult)); }
public int Find(string pszSearch, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out uint pResult) { if (_findTarget != null) { return _findTarget.Find(pszSearch, grfOptions, fResetStartPoint, pHelper, out pResult); } pResult = 0; return VSConstants.E_NOTIMPL; }
public int Replace(string pszSearch, string pszReplace, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out int pfReplaced) { var findTarget = (IVsFindTarget)_vsCodeWindow; return(findTarget.Replace(pszSearch, pszReplace, grfOptions, fResetStartPoint, pHelper, out pfReplaced)); }
int IVsFindTarget.Find(string pszSearch, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out uint pResult) => ((IVsFindTarget)_editorWindow).Find(pszSearch, grfOptions, fResetStartPoint, pHelper, out pResult);
public int Replace(string pszSearch, string pszReplace, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out int pfReplaced) { var findTarget = (IVsFindTarget)_vsCodeWindow; return findTarget.Replace(pszSearch, pszReplace, grfOptions, fResetStartPoint, pHelper, out pfReplaced); }
public int Replace(string pszSearch, string pszReplace, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out int pfReplaced) { pfReplaced = 0; /*// If the selection is empty, exit * if ( textBox1.SelectionLength == 0) * { * pfReplaced = 0; * return VSConstants.S_OK; * } * * // Get the selection * string sel = textBox1.SelectedText; * bool ignoreCase = (grfOptions & (int)__VSFINDOPTIONS.FR_MatchCase) == 0; * * // Check if the selection matchs the search * if ( string.Compare(sel, pszSearch, ignoreCase, CultureInfo.CurrentCulture) == 0 ) * { * // Recalculate search start position if we make the text longer/shorter * if (textBox1.SelectionStart <= currentSearchStart) * { * currentSearchStart += pszReplace.Length - sel.Length; * } * // Do the actual replace * textBox1.SelectedText = pszReplace; * // Adjust position so the next find is done correctly * if ((grfOptions & (int)__VSFINDOPTIONS.FR_Backwards) != 0) * { * textBox1.SelectionStart -= (pszReplace.Length); * } * else * { * textBox1.SelectionStart -= 1; * } * searchCursorLocation = textBox1.SelectionStart; * * pfReplaced = 1; * replaced = true; * } * else * { * pfReplaced = 0; * }*/ return(VSConstants.S_OK); }
int IVsFindTarget.Find(string pszSearch, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out uint pResult) { IVsFindTarget findTarget = GetView(sourceFrame) as IVsFindTarget; if (findTarget != null) { return(findTarget.Find(pszSearch, grfOptions, fResetStartPoint, pHelper, out pResult)); } pResult = (uint)__VSFINDRESULT.VSFR_NotFound; return(VSConstants.E_NOTIMPL); }
public int Replace(string pszSearch, string pszReplace, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out int pfReplaced) { return(EditorFindTarget.Replace(pszSearch, pszReplace, grfOptions, fResetStartPoint, pHelper, out pfReplaced)); }
/// <summary> /// Search for the string in the text of our editor. /// Options specify how we do the search /// </summary> /// <param name="pszSearch">Search string</param> /// <param name="grfOptions">Search options</param> /// <param name="fResetStartPoint">Is this a new search?</param> /// <param name="pHelper">We are not using it</param> /// <param name="pResult">True if we found the search string</param> public int Find(string pszSearch, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out uint pResult) { pResult = 0; /*int result = 0; * bool reverse = false; * * // Transform the VS search options to RTF search options * RichTextBoxFinds options = RichTextBoxFinds.None; * if ((grfOptions & (int)__VSFINDOPTIONS.FR_WholeWord) != 0) * options |= RichTextBoxFinds.WholeWord; * if ((grfOptions & (int)__VSFINDOPTIONS.FR_MatchCase) != 0) * options |= RichTextBoxFinds.MatchCase; * if ((grfOptions & (int)__VSFINDOPTIONS.FR_Backwards) != 0) * { * options |= RichTextBoxFinds.Reverse; * reverse = true; * } * * // Verify if this is a new search * if (fResetStartPoint != 0 || forceNewSearch || textBox1.SelectionStart != searchCursorLocation) ||{ || forceNewSearch = false; || currentSearchStart = textBox1.SelectionStart + textBox1.SelectionLength; || // If our start location is the end of the file, start at the beginging || if (currentSearchStart == textBox1.Text.Length) || currentSearchStart = 0; || searchCursorLocation = currentSearchStart; || // Let replace know we are starting from scratch (in case this find is for a replace) || replaced = false; ||} ||else ||{ || // Continue search || // Updated search position || if (forceCursorWrapAround) || { || forceCursorWrapAround = false; || // set location to begining of next part to be searched || if (reverse) || searchCursorLocation = -1; // -1 = end of file || else || searchCursorLocation = 0; || } || else || { || // increment cursor location so we search past the last found item || if (reverse) || --searchCursorLocation; || else ++searchCursorLocation; || } ||} || || ||// Compute search range ||// Note that Start < End, even when doing reverse search (-1 = end of file) ||int searchStart = 0; ||int searchEnd = -1; ||// First we search from cursor location. ||// Once we have reached the end of the file, ||// we search until the original start location ||// (we will be called a second time if we return "passed end of file") ||if (reverse) ||{ || searchEnd = searchCursorLocation; || if (passedEndOfFile) || searchStart = currentSearchStart; ||} ||else ||{ || searchStart = searchCursorLocation; || if (passedEndOfFile) || searchEnd = currentSearchStart; ||} || ||// Perform actual search ||Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "About to search from {0}, to {1}", searchStart, searchEnd)); ||if (searchStart != searchEnd) ||{ || result = textBox1.Find(pszSearch, searchStart, searchEnd, options); ||} ||else ||{ || result = -1; ||} || ||// Set result value ||if (result != -1) ||{ || // We found the string || pResult = (uint)__VSFINDRESULT.VSFR_Found; ||} ||else ||{ || // If we searched the whole file or this is not a selection search || if (passedEndOfFile || (grfOptions & (int)__VSFINDOPTIONS.FR_Selection) != 0) || { || // We did not find anything || pResult = (uint)__VSFINDRESULT.VSFR_NotFound; || passedEndOfFile = false; || // if we did replace something before getting here (then this is a replace) || if (replaced) || { || replaced = false; || // adjust cursor final position || if ((grfOptions & (int)__VSFINDOPTIONS.FR_Backwards) != 0) || { || if (textBox1.SelectionStart > 0) || textBox1.SelectionStart -= 1; || } || else if (textBox1.SelectionStart < (textBox1.Text.Length-1)) || textBox1.SelectionStart += 1; || } || } || else || { || // We did not find the string, but we reached the end of the file || // Let VS know, and we will get called a second time to search the rest of the document || pResult = (uint)__VSFINDRESULT.VSFR_EndOfDoc; || passedEndOfFile = true; || forceCursorWrapAround = true; || } ||} || ||// Save cursor position for next call ||searchCursorLocation = textBox1.SelectionStart;*/ return(VSConstants.S_OK); }
public int Find(string pszSearch, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out uint pResult) { return(EditorFindTarget.Find(pszSearch, grfOptions, fResetStartPoint, pHelper, out pResult)); }
/// <summary> /// Replace a string in the text. No need to implement since we implement IVsTextImage /// </summary> /// <param name="pszSearch">string containing the search text</param> /// <param name="pszReplace">string containing the replacement text</param> /// <param name="grfOptions">Search options available</param> /// <param name="fResetStartPoint">flag to reset the search start point</param> /// <param name="pHelper">IVsFindHelper interface object</param> /// <param name="pfReplaced">returns whether replacement was successful or not</param> /// <returns></returns> int IVsFindTarget.Replace(string pszSearch, string pszReplace, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out int pfReplaced) { pfReplaced = 0; return VSConstants.E_NOTIMPL; }
/// <summary> /// Search for the string in the text of our editor. /// Options specify how we do the search. No need to implement this since we implement IVsTextImage /// </summary> /// <param name="pszSearch">Search string</param> /// <param name="grfOptions">Search options</param> /// <param name="fResetStartPoint">Is this a new search?</param> /// <param name="pHelper">We are not using it</param> /// <param name="pResult">True if we found the search string</param> int IVsFindTarget.Find(string pszSearch, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out uint pResult) { pResult = 0; return VSConstants.E_NOTIMPL; }
public int Replace(string pszSearch, string pszReplace, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out int pfReplaced) { if (_findTarget != null) { return(_findTarget.Replace(pszSearch, pszReplace, grfOptions, fResetStartPoint, pHelper, out pfReplaced)); } pfReplaced = 0; return(VSConstants.E_NOTIMPL); }
int IVsFindTarget.Find(string pszSearch, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out uint pResult) { List<string> options = new List<string>(); foreach (int vv in Enum.GetValues(typeof(__VSFINDOPTIONS))) { var temp = (__VSFINDOPTIONS)vv; if (temp == __VSFINDOPTIONS.FR_None) continue; if ((grfOptions & vv) == vv) options.Add(temp.ToString()); } Debug.WriteLine($"pszSearch={pszSearch}, grfOptions={string.Join("|", options)}, fResetStartPoint={fResetStartPoint}"); if (string.IsNullOrEmpty(pszSearch)) { pResult = (uint)__VSFINDRESULT.VSFR_Error; return VSConstants.E_FAIL; } bool isFind = false, isReachedSearchStart = false; try { isFind = Finded(pszSearch, grfOptions, fResetStartPoint != 0, out isReachedSearchStart); } catch { } if (isReachedSearchStart) pResult = (uint)__VSFINDRESULT.VSFR_EndOfSearch; else if (isFind) pResult = (uint)__VSFINDRESULT.VSFR_Found; else pResult = (uint)__VSFINDRESULT.VSFR_NotFound; return VSConstants.S_OK; }