mirror of
https://github.com/fadden/6502bench.git
synced 2025-07-16 03:24:08 +00:00
Add "find all" feature
This uses the same (very weak) string search as the current Find feature, but does it over the entire file. Matches are added to a table of results and displayed in the same dialog used by the References panel "copy out" feature. The reference table now jumps to a Location rather than just the closest offset, so that we can jump to the middle of a multi-line comment.
This commit is contained in:
@@ -3220,7 +3220,7 @@ namespace SourceGen {
|
||||
}
|
||||
|
||||
public void Find() {
|
||||
FindBox dlg = new FindBox(mMainWin, mFindString);
|
||||
FindBox dlg = new FindBox(mMainWin, mFindString, false);
|
||||
if (dlg.ShowDialog() == true) {
|
||||
mFindString = dlg.TextToFind;
|
||||
mFindStartIndex = -1;
|
||||
@@ -3304,6 +3304,58 @@ namespace SourceGen {
|
||||
//mMainWin.CodeListView_Focus();
|
||||
}
|
||||
|
||||
// Finds all matches in the file. Does not alter the the current position.
|
||||
public void FindAll() {
|
||||
FindBox dlg = new FindBox(mMainWin, mFindString, true);
|
||||
if (dlg.ShowDialog() == false) {
|
||||
return;
|
||||
}
|
||||
mFindString = dlg.TextToFind;
|
||||
string SEARCH_SEP_STR = "" + LineListGen.SEARCH_SEP;
|
||||
|
||||
List<ReferenceTable.ReferenceTableItem> items =
|
||||
new List<ReferenceTable.ReferenceTableItem>();
|
||||
for (int index = 0; index < CodeLineList.Count; index++) {
|
||||
string searchStr = CodeLineList.GetSearchString(index);
|
||||
int matchPos = searchStr.IndexOf(mFindString,
|
||||
StringComparison.InvariantCultureIgnoreCase);
|
||||
if (matchPos >= 0) {
|
||||
int offset = CodeLineList[index].FileOffset;
|
||||
string offsetStr, addrStr, msgStr;
|
||||
|
||||
if (offset >= 0) {
|
||||
offsetStr = mFormatter.FormatOffset24(offset);
|
||||
Anattrib attr = mProject.GetAnattrib(offset);
|
||||
if (attr.Address >= 0) {
|
||||
addrStr = mFormatter.FormatAddress(attr.Address, attr.Address > 0xffff);
|
||||
} else {
|
||||
addrStr = string.Empty;
|
||||
}
|
||||
} else {
|
||||
offsetStr = "-";
|
||||
addrStr = string.Empty;
|
||||
}
|
||||
msgStr = searchStr.Replace(SEARCH_SEP_STR, " ");
|
||||
// Create a reference table entry.
|
||||
int lineDelta = index - CodeLineList.FindLineIndexByOffset(offset);
|
||||
bool isNote = (CodeLineList[index].LineType == LineListGen.Line.Type.Note);
|
||||
NavStack.Location loc = new NavStack.Location(offset, lineDelta,
|
||||
isNote ? NavStack.GoToMode.JumpToNote : NavStack.GoToMode.JumpToAdjIndex);
|
||||
|
||||
items.Add(new ReferenceTable.ReferenceTableItem(loc,
|
||||
offsetStr, addrStr, msgStr));
|
||||
}
|
||||
}
|
||||
|
||||
if (items.Count > 0) {
|
||||
ShowReferenceTable(items);
|
||||
} else {
|
||||
MessageBox.Show(Res.Strings.FIND_ALL_NO_MATCH,
|
||||
Res.Strings.FIND_ALL_CAPTION, MessageBoxButton.OK,
|
||||
MessageBoxImage.Information);
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanFormatAsWord() {
|
||||
EntityCounts counts = SelectionAnalysis.mEntityCounts;
|
||||
// This is insufficient -- we need to know how many bytes are selected, and
|
||||
|
Reference in New Issue
Block a user