示例#1
0
        void ReverseSearch()
        {
            int p;

            if (cursor == text.Length)
            {
                // The cursor is at the end of the string

                p = text.ToString().LastIndexOf(search);
                if (p != -1)
                {
                    match_at = p;
                    cursor   = p;
                    ForceCursor(cursor);
                    return;
                }
            }
            else
            {
                // The cursor is somewhere in the middle of the string
                int start = (cursor == match_at) ? cursor - 1 : cursor;
                if (start != -1)
                {
                    p = text.ToString().LastIndexOf(search, start);
                    if (p != -1)
                    {
                        match_at = p;
                        cursor   = p;
                        ForceCursor(cursor);
                        return;
                    }
                }
            }

            // Need to search backwards in history
            HistoryUpdateLine();
            string s = history.SearchBackward(search);

            if (s != null)
            {
                match_at = -1;
                SetText(s);
                ReverseSearch();
            }
        }