Пример #1
0
        public TextRange FindNext(bool viaF3, bool searchBackward, string messageIfNotFound)
        {
            if (string.IsNullOrEmpty(txtLookFor.Text))
            {
                MessageBox.Show("No string specified to look for!");
                return(null);
            }
            _lastSearchWasBackward     = searchBackward;
            _search.LookFor            = txtLookFor.Text;
            _search.MatchCase          = chkMatchCase.Checked;
            _search.MatchWholeWordOnly = chkMatchWholeWord.Checked;

            var caret = _editor.ActiveTextAreaControl.Caret;

            if (viaF3 && _search.HasScanRegion && !caret.Offset.IsInRange(_search.BeginOffset, _search.EndOffset))
            {
                // user moved outside of the originally selected region
                _search.ClearScanRegion();
                UpdateTitleBar();
            }

            int       startFrom = caret.Offset - (searchBackward ? 1 : 0);
            TextRange range     = _search.FindNext(startFrom, searchBackward, out _lastSearchLoopedAround);

            if (range != null)
            {
                SelectResult(range);
            }
            else if (messageIfNotFound != null)
            {
                MessageBox.Show(messageIfNotFound);
            }
            return(range);
        }
        private void hexViewer1_onSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // in that case, move the selection in the ASM file as well
            Console.WriteLine("Selection in hexviewer: " + e.Offset.ToString("X8"));
            int offset = _trionicFile.GetFileInfo().Filelength;

            if (offset == 0x20000)
            {
                offset = 0x60000;
            }

            int    address      = e.Offset + offset;
            string searchString = "0x" + address.ToString("X8");
            //_findForm.FindNext(true, false, string.Format("Search text «{0}» not found.", searchString));
            TextEditorSearcher _search = new TextEditorSearcher();

            _search.ClearScanRegion();
            _search.Document           = editor.Document;
            _search.LookFor            = searchString;
            _search.MatchCase          = true;
            _search.MatchWholeWordOnly = true;

            var       caret = editor.ActiveTextAreaControl.Caret;
            bool      _lastSearchLoopedAround = false;
            int       startFrom = 0;
            TextRange range     = _search.FindNext(startFrom, false, out _lastSearchLoopedAround);

            if (range != null)
            {
                SelectResult(range);
            }
            editor.Invalidate();
            editor.Refresh();
        }
        private void highlightSelectionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string LookFor = string.Empty;

            LookFor = editor.ActiveTextAreaControl.TextArea.SelectionManager.SelectedText;

            // if there's text selected, highlight all!
            if (!_highlightGroups.ContainsKey(editor))
            {
                _highlightGroups[editor] = new HighlightGroup(editor);
            }
            HighlightGroup     group   = _highlightGroups[editor];
            TextEditorSearcher _search = new TextEditorSearcher();

            _search.Document = editor.Document;

            group.ClearMarkers();


            _search.LookFor            = LookFor;
            _search.MatchCase          = true;
            _search.MatchWholeWordOnly = true;

            bool looped = false;
            int  offset = 0, count = 0;

            for (; ;)
            {
                TextRange range = _search.FindNext(offset, false, out looped);
                if (range == null || looped)
                {
                    break;
                }
                offset = range.Offset + range.Length;
                count++;

                var m = new TextMarker(range.Offset, range.Length,
                                       TextMarkerType.SolidBlock, Color.Orange, Color.Black);
                group.AddMarker(m);
            }

            editor.Invalidate();
            editor.Refresh();
        }
Пример #4
0
        private void highlightSelectionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string LookFor = string.Empty;

            LookFor = editor.ActiveTextAreaControl.TextArea.SelectionManager.SelectedText;

            // if there's text selected, highlight all!
            if (!_highlightGroups.ContainsKey(editor))
                _highlightGroups[editor] = new HighlightGroup(editor);
            HighlightGroup group = _highlightGroups[editor];
            TextEditorSearcher _search = new TextEditorSearcher();
            _search.Document = editor.Document;

            group.ClearMarkers();

            _search.LookFor = LookFor;
            _search.MatchCase = true;
            _search.MatchWholeWordOnly = true;

            bool looped = false;
            int offset = 0, count = 0;
            for (; ; )
            {
                TextRange range = _search.FindNext(offset, false, out looped);
                if (range == null || looped)
                    break;
                offset = range.Offset + range.Length;
                count++;

                var m = new TextMarker(range.Offset, range.Length,
                        TextMarkerType.SolidBlock, Color.Orange, Color.Black);
                group.AddMarker(m);
            }

            editor.Invalidate();
            editor.Refresh();
        }
Пример #5
0
        private void hexViewer1_onSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // in that case, move the selection in the ASM file as well
            Console.WriteLine("Selection in hexviewer: " + e.Offset.ToString("X8"));
            int offset = _trionicFile.GetFileInfo().Filelength;
            if (offset == 0x20000) offset = 0x60000;

            int address = e.Offset + offset;
            string searchString = "0x" + address.ToString("X8");
            //_findForm.FindNext(true, false, string.Format("Search text «{0}» not found.", searchString));
            TextEditorSearcher _search = new TextEditorSearcher();
            _search.ClearScanRegion();
            _search.Document = editor.Document;
            _search.LookFor = searchString;
            _search.MatchCase = true;
            _search.MatchWholeWordOnly = true;

            var caret = editor.ActiveTextAreaControl.Caret;
            bool _lastSearchLoopedAround = false;
            int startFrom = 0;
            TextRange range = _search.FindNext(startFrom, false, out _lastSearchLoopedAround);
            if (range != null)
                SelectResult(range);
            editor.Invalidate();
            editor.Refresh();
        }