Ejemplo n.º 1
0
        /// <summary>
        /// Return a cursor that point to the next visible tag
        /// Ignore non-Visible tag and last character of TextTag (except if it's last tag in current line)
        /// </summary>
        public MiniHtmlCursor RightShiftText()
        {
            MiniHtmlCursor currentCursor = new MiniHtmlCursor(parentHtml);

            currentCursor.SetCursor(CursorPosition());
            try
            {
                MiniHtmlCursor.rightShiftVisible(ref currentCursor);
            }
            catch
            {
                currentCursor.SetCursor(CursorPosition());
            }

            if (currentCursor.selectedTag is TextTag)
            {
                bool shiftAgain = true;

                shiftAgain = MiniHtmlCursor.isLastChar(currentCursor) &&
                             MiniHtmlCursor.isLastTag(currentCursor) &&
                             !(currentCursor.selectedTag.nextTag() is ElementTag);

                if (shiftAgain)
                {
                    MiniHtmlCursor.rightShiftVisible(ref currentCursor);
                }
            }

            return(currentCursor);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Return a cursor that point to the last visible tag
        /// Ignore non-Visible tag and last character of TextTag (except if it's last tag in current line)
        /// </summary>
        public MiniHtmlCursor LeftShiftText()
        {
            if (selectedTag.TagIndex() < 0)
            {
                return(null);
            }

            MiniHtmlCursor currentCursor = new MiniHtmlCursor(parentHtml);

            currentCursor.SetCursor(CursorPosition());
            MiniHtmlCursor tempCursor = new MiniHtmlCursor(parentHtml);

            MiniHtmlCursor.leftShiftVisible(ref currentCursor);

            if (currentCursor.selectedTag is TextTag)
            {
                bool    shiftAgain = true;
                TextTag currentTag = (TextTag)(currentCursor.selectedTag);
                tempCursor.SetCursor(currentCursor.CursorPosition());
                try
                {
                    MiniHtmlCursor.leftShiftVisible(ref tempCursor);
                }
                catch
                {
                    if (currentCursor == null)
                    {
                        currentCursor.SetCursor(CursorPosition());
                    }
                }


                if (tempCursor != null)
                {
                    shiftAgain = (MiniHtmlCursor.isLastChar(currentCursor) &&
                                  MiniHtmlCursor.isLastTag(tempCursor)) &&
                                 !(currentCursor.selectedTag.nextTag() is ElementTag);

                    if (shiftAgain)
                    {
                        return(tempCursor);
                    }
                }
            }

            return(currentCursor);
        }