Пример #1
0
        public void Find(string query)
        {
            if (string.IsNullOrEmpty(query))
            {
                lastUsedIndex = 0;
                TextScript.ScrollToLine(1);
                return;
            }

            string editorText = TextScript.Text;

            if (string.IsNullOrEmpty(editorText))
            {
                lastUsedIndex = 0;
                return;
            }

            if (lastUsedIndex >= query.Length)
            {
                lastUsedIndex = 0;
            }

            int nIndex = editorText.IndexOf(query, lastUsedIndex, StringComparison.OrdinalIgnoreCase);

            if (nIndex != -1)
            {
                TextScript.Select(nIndex, query.Length);
                var position = TextScript.TextArea.Selection.StartPosition;
                TextScript.ScrollToLine(position.Line);
                lastUsedIndex = nIndex + query.Length;
            }
            else
            {
                lastUsedIndex = 0;
                TextScript.ScrollToLine(1);
            }
        }