Browse Source

Changed the incremental search wrapping behaviour. It now wraps around to the start of the document with any length of search string. Previously it would not wrap around if a character had been matched already. Code completion is now temporarily disabled whilst incrementally searching. Typing in a code completion character was previously stopping the search. Added some missing incremental search resource strings.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1846 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 19 years ago
parent
commit
f89bc1b773
  1. BIN
      data/resources/StringResources.es-mx.resources
  2. BIN
      data/resources/StringResources.es.resources
  3. 26
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/IncrementalSearch.cs
  4. BIN
      src/Main/StartUp/Project/Resources/StringResources.resources

BIN
data/resources/StringResources.es-mx.resources

Binary file not shown.

BIN
data/resources/StringResources.es.resources

Binary file not shown.

26
src/Main/Base/Project/Src/TextEditor/Gui/Editor/IncrementalSearch.cs

@ -22,8 +22,6 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
TextEditorControl textEditor; TextEditorControl textEditor;
Cursor previousCursor; Cursor previousCursor;
IFormattingStrategy previousFormattingStrategy; IFormattingStrategy previousFormattingStrategy;
string forwardsIncrementalSearchStartMessage = "Incremental Search: ";
string reverseIncrementalSearchStartMessage = "Reverse Incremental Search: ";
string incrementalSearchStartMessage; string incrementalSearchStartMessage;
StringBuilder searchText = new StringBuilder(); StringBuilder searchText = new StringBuilder();
@ -33,6 +31,8 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
Cursor cursor; Cursor cursor;
bool passedEndOfDocument; bool passedEndOfDocument;
bool codeCompletionEnabled;
// Indicates whether this is a forward search or a reverse search. // Indicates whether this is a forward search or a reverse search.
bool forwards = true; bool forwards = true;
@ -63,14 +63,19 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
/// forward from the cursor or backwards.</param> /// forward from the cursor or backwards.</param>
public IncrementalSearch(TextEditorControl textEditor, bool forwards) public IncrementalSearch(TextEditorControl textEditor, bool forwards)
{ {
this.forwards = forwards; this.forwards = forwards;
if (forwards) { if (forwards) {
incrementalSearchStartMessage = forwardsIncrementalSearchStartMessage; incrementalSearchStartMessage = StringParser.Parse("${res:ICSharpCode.SharpDevelop.DefaultEditor.IncrementalSearch.ForwardsSearchStatusBarMessage} ");
} else { } else {
incrementalSearchStartMessage = reverseIncrementalSearchStartMessage; incrementalSearchStartMessage = StringParser.Parse("${res:ICSharpCode.SharpDevelop.DefaultEditor.IncrementalSearch.ReverseSearchStatusBarMessage} ");
} }
this.textEditor = textEditor; this.textEditor = textEditor;
// Disable code completion.
codeCompletionEnabled = CodeCompletionOptions.EnableCodeCompletion;
CodeCompletionOptions.EnableCodeCompletion = false;
AddFormattingStrategy(); AddFormattingStrategy();
TextArea.KeyEventHandler += TextAreaKeyPress; TextArea.KeyEventHandler += TextAreaKeyPress;
@ -127,6 +132,8 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
void StopIncrementalSearch() void StopIncrementalSearch()
{ {
// Reset code completion state.
CodeCompletionOptions.EnableCodeCompletion = codeCompletionEnabled;
Dispose(); Dispose();
} }
@ -159,8 +166,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
{ {
string find = searchText.ToString(); string find = searchText.ToString();
int index = FindText(find, startIndex, forwards); int index = FindText(find, startIndex, forwards);
if (index == -1 && find.Length == 1) { if (index == -1) {
// First character so allow wrap around.
index = FindText(find, GetWrapAroundStartIndex(), forwards); index = FindText(find, GetWrapAroundStartIndex(), forwards);
passedEndOfDocument = true; passedEndOfDocument = true;
} }
@ -261,9 +267,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
searchText.Remove(length - 1, 1); searchText.Remove(length - 1, 1);
// Run search back at original starting point. // Run search back at original starting point.
startIndex = originalStartIndex; startIndex = originalStartIndex;
if (length == 1) { passedEndOfDocument = false;
passedEndOfDocument = false;
}
RunSearch(); RunSearch();
return true; return true;
} else { } else {
@ -289,7 +293,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
void ShowTextFound(string find) void ShowTextFound(string find)
{ {
if (passedEndOfDocument) { if (passedEndOfDocument) {
ShowMessage(String.Concat(find, " (passed end of document)"), true); ShowMessage(String.Concat(find, StringParser.Parse(" ${res:ICSharpCode.SharpDevelop.DefaultEditor.IncrementalSearch.PassedEndOfDocumentStatusBarMessage}")), true);
} else { } else {
ShowMessage(find, false); ShowMessage(find, false);
} }
@ -310,7 +314,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
/// </summary> /// </summary>
void ShowTextNotFound(string find) void ShowTextNotFound(string find)
{ {
ShowMessage(String.Concat(find, " (not found)"), true); ShowMessage(String.Concat(find, StringParser.Parse(" ${res:ICSharpCode.SharpDevelop.DefaultEditor.IncrementalSearch.NotFoundStatusBarMessage}")), true);
} }
/// <summary> /// <summary>

BIN
src/Main/StartUp/Project/Resources/StringResources.resources

Binary file not shown.
Loading…
Cancel
Save