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

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

Binary file not shown.
Loading…
Cancel
Save