Esempio n. 1
0
        private void OnCaretOnPositionChanged(object x, EventArgs y)
        {
            _marker.ClearMarks();
            int offset = _editor.CaretOffset;

            if (offset >= 0 && offset < _editor.Text.Length)
            {
                char c = _editor.Text[offset];
                if (_supportedBrackets.Contains(c))
                {
                    try
                    {
                        int matching = findMatchingBrackets(_editor.Text, c, offset);
                        if (matching >= 0)
                        {
                            _marker.AddOffsetToMark(new MarkBackgroundRenderer.Mark
                            {
                                Offset = offset, Length = 1, Brush = CYAN
                            });
                            _marker.AddOffsetToMark(new MarkBackgroundRenderer.Mark
                            {
                                Offset = matching, Length = 1, Brush = CYAN
                            });
                        }
                    }
                    catch (Exception e)
                    {
                        Debug.Fail(e.Message);
                    }
                }
            }
        }
Esempio n. 2
0
        private void startSearch()
        {
            _marker.ClearMarks();
            _foundOffsets.Clear();

            string word = _edtSearchText.Text;

            if (string.IsNullOrEmpty(word))
            {
                return;
            }

            int startIdx = 0;

            while (true)
            {
                int idx = _editor.Text.IndexOf(word, startIdx, StringComparison.InvariantCultureIgnoreCase);

                if (idx < 0)
                {
                    break;
                }
                startIdx = idx + 1;

                _foundOffsets.Add(idx);
                _marker.AddOffsetToMark(new MarkBackgroundRenderer.Mark
                {
                    Offset = idx,
                    Length = word.Length,
                    Brush  = new SolidColorBrush(Colors.Yellow)
                });
            }
        }
Esempio n. 3
0
        private void highlightWord(string word)
        {
            if (string.IsNullOrWhiteSpace(word))
            {
                return;
            }

            int startIdx = 0;

            while (true)
            {
                int idx = _editor.Text.IndexOf(word, startIdx);

                if (idx < 0)
                {
                    break;
                }
                startIdx = idx + 1;

                _marker.AddOffsetToMark(new MarkBackgroundRenderer.Mark
                {
                    Offset = idx,
                    Length = word.Length,
                    Brush  = Brushes.MediumSpringGreen
                });
            }
            _highlightedWord = word;
        }