// Find next result
        public bool FindNext(FindReplaceOptions options)
        {
            byte[]           data = editor.GetText();
            string           text = Encoding.GetEncoding(config.CodePage).GetString(data);
            StringComparison mode = options.CaseSensitive ? StringComparison.CurrentCulture : StringComparison.CurrentCultureIgnoreCase;
            int  startpos         = Math.Max(editor.SelectionStart, editor.SelectionEnd);
            bool wrapped          = false;

            while (true)
            {
                int result = text.IndexOf(options.FindText, startpos, mode);
                if (result > -1)
                {
                    // Check to see if it is the whole word
                    if (options.WholeWord)
                    {
                        // Veryfy that we have found a whole word
                        string foundword = editor.GetWordAt(result + 1);
                        if (foundword.Length != options.FindText.Length)
                        {
                            startpos = result + 1;
                            result   = -1;
                        }
                    }

                    // Still ok?
                    if (result > -1)
                    {
                        // Select the result
                        editor.SelectionStart = result;
                        editor.SelectionEnd   = result + options.FindText.Length;
                        editor.EnsureLineVisible(editor.LineFromPosition(editor.SelectionEnd));
                        return(true);
                    }
                }
                else
                {
                    // If we haven't tried from the start, try from the start now
                    if ((startpos > 0) && !wrapped)
                    {
                        startpos = 0;
                        wrapped  = true;
                    }
                    else
                    {
                        // Can't find it
                        return(false);
                    }
                }
            }
        }
        //mxd. TODO: remove this
        internal ScriptType VerifyScriptType()
        {
            ScriptTypeParserSE parser = new ScriptTypeParserSE();
            TextResourceData   data   = new TextResourceData(new MemoryStream(editor.GetText()), new DataLocation(), config.Description);

            if (parser.Parse(data, false))
            {
                if (parser.ScriptType != ScriptType.UNKNOWN && config.ScriptType != parser.ScriptType)
                {
                    return(parser.ScriptType);
                }
            }

            if (parser.HasError)
            {
                panel.ShowErrors(new List <CompilerError> {
                    new CompilerError(parser.ErrorDescription, parser.ErrorSource, parser.ErrorLine)
                }, true);
            }

            return(ScriptType.UNKNOWN);
        }