/// <summary>
        /// Define PHP specific smart indenting for a line :)
        /// </summary>
        protected override int SmartIndentLine(TextArea textArea, int lineNr)
        {
            if (lineNr <= 0)
            {
                return(AutoIndentLine(textArea, lineNr));
            }

            string oldText = textArea.Document.GetText(textArea.Document.GetLineSegment(lineNr));

            DocumentAccessor acc = new DocumentAccessor(textArea.Document, lineNr, lineNr);

            IndentationSettings set = new IndentationSettings();

            set.IndentString    = Tab.GetIndentationString(textArea.Document);
            set.LeaveEmptyLines = false;

            IndentationReformatter r = new IndentationReformatter();

            r.Reformat(acc, set);

            string t = acc.Text;

            if (t.Length == 0)
            {
                // use AutoIndentation for new lines in comments / verbatim strings.
                return(AutoIndentLine(textArea, lineNr));
            }
            else
            {
                int newIndentLength = t.Length - t.TrimStart().Length;
                int oldIndentLength = oldText.Length - oldText.TrimStart().Length;
                if (oldIndentLength != newIndentLength && lineNr == textArea.Caret.Position.Y)
                {
                    // fix cursor position if indentation was changed
                    int newX = textArea.Caret.Position.X - oldIndentLength + newIndentLength;
                    textArea.Caret.Position = new TextLocation(Math.Max(newX, 0), lineNr);
                }
                return(newIndentLength);
            }
        }