diff --git a/SourceGen/MainController.cs b/SourceGen/MainController.cs index e577ca2..25ca581 100644 --- a/SourceGen/MainController.cs +++ b/SourceGen/MainController.cs @@ -151,6 +151,12 @@ namespace SourceGen { /// private int mFindStartIndex = -1; + /// + /// True if previous search was backward, so we can tell if we changed direction + /// (otherwise we think we immediately wrapped around and the search stops). + /// + private bool mFindBackward = false; + /// /// Used to highlight the line that is the target of the selected line. /// @@ -2077,30 +2083,45 @@ namespace SourceGen { if (dlg.ShowDialog() == true) { mFindString = dlg.TextToFind; mFindStartIndex = -1; - FindText(); + FindText(dlg.IsBackward); } } public void FindNext() { - FindText(); + FindText(false); } - private void FindText() { + public void FindPrevious() { + FindText(true); + } + + private void FindText(bool goBackward) { if (string.IsNullOrEmpty(mFindString)) { return; } + int incr = goBackward ? -1 : 1; + + // If we reversed direction, reset the "start index" so we don't tell the user + // we've wrapped around. + if (mFindBackward != goBackward) { + mFindStartIndex = -1; + mFindBackward = goBackward; + } // Start from the topmost selected line, or the start of the file if nothing // is selected. + // TODO(maybe): if multiple lines are selected, search only within the selected set. int index = mMainWin.CodeListView_GetFirstSelectedIndex(); if (index < 0) { index = 0; } // Start one past the selected item. - index++; + index += incr; if (index == CodeLineList.Count) { index = 0; + } else if (index == -1) { + index = CodeLineList.Count - 1; } //Debug.WriteLine("FindText index=" + index + " start=" + mFindStartIndex + // " str=" + mFindString); @@ -2118,12 +2139,19 @@ namespace SourceGen { mMainWin.CodeListView_EnsureVisible(index); mMainWin.CodeListView_DeselectAll(); mMainWin.CodeListView_SelectRange(index, 1); + // TODO(someday): I think we need to do something with the ListView + // keyboard nav state here. Otherwise Shift+F3 is regarded as selection + // movement with shift held down, and it does a range select. Currently + // working around this by using Ctrl+F3 instead. See also maybe the + // ItemContainerGenerator stuff in MainWindow. return; } - index++; + index += incr; if (index == CodeLineList.Count) { index = 0; + } else if (index == -1) { + index = CodeLineList.Count - 1; } } diff --git a/SourceGen/RuntimeData/Help/mainwin.html b/SourceGen/RuntimeData/Help/mainwin.html index c7c1f6f..0ab159f 100644 --- a/SourceGen/RuntimeData/Help/mainwin.html +++ b/SourceGen/RuntimeData/Help/mainwin.html @@ -329,7 +329,10 @@ can also use PgUp/PgDn and the arrow keys.

Use Edit > Find to search for text. This performs a case-insensitive text search on the label, opcode, operand, and comment fields. -Use Edit > Find Next to find the next match.

+Use Edit > Find Next to find the next match, and +Edit > Find Previous to find the previous match. Note "next" is +always downward, and "previous" is always upward, regardless of the +direction of the initial search chosen in the Find dialog.

Use Edit > Go To to jump to an offset, address, or label. Remember that offsets and addresses are always hexadecimal, and offsets start diff --git a/SourceGen/RuntimeData/Help/settings.html b/SourceGen/RuntimeData/Help/settings.html index a0ef34d..76a35bc 100644 --- a/SourceGen/RuntimeData/Help/settings.html +++ b/SourceGen/RuntimeData/Help/settings.html @@ -223,6 +223,8 @@ not part of the chip specification, but most of them have consistent behavior and can be used. If the box is not checked, the instructions are treated as invalid and cause the code analyzer to assume that it has run into a data area. This option has no effect on the 65816.

+

The "treat BRK as two-byte instruction" checkbox determines whether +BRK instructions should be handled as if they have an operand.

The entry flags determine the initial value for the processor status flag register. Code that is unreachable internally (requiring a code diff --git a/SourceGen/WpfGui/FindBox.xaml b/SourceGen/WpfGui/FindBox.xaml index cb815ba..004a573 100644 --- a/SourceGen/WpfGui/FindBox.xaml +++ b/SourceGen/WpfGui/FindBox.xaml @@ -26,9 +26,15 @@ limitations under the License. ShowInTaskbar="False" WindowStartupLocation="CenterOwner" ContentRendered="Window_ContentRendered" PreviewKeyDown="Window_KeyEventHandler"> - - -