ARCed.Scintilla.Indentation.CheckSmartIndent C# (CSharp) Method

CheckSmartIndent() private method

If Smart Indenting is enabled, this delegate will be added to the CharAdded multicast event.
private CheckSmartIndent ( char ch ) : void
ch char
return void
        internal void CheckSmartIndent(char ch)
        {
            char newline = (Scintilla.EndOfLine.Mode == EndOfLineMode.CR) ? '\r' : '\n';

            switch (this.SmartIndentType)
            {
                case SmartIndent.None:
                    return;
                case SmartIndent.Simple:
                    if (ch == newline)
                    {
                        Line curLine = Scintilla.Lines.Current;
                        curLine.Indentation = curLine.Previous.Indentation;
                        Scintilla.CurrentPos = curLine.IndentPosition;
                    }
                    break;
                case SmartIndent.CPP:
                case SmartIndent.CPP2:
                    if (ch == newline)
                    {
                        Line curLine = Scintilla.Lines.Current;
                        Line tempLine = curLine;
                        int previousIndent;
                        string tempText;

                        do
                        {
                            tempLine = tempLine.Previous;
                            previousIndent = tempLine.Indentation;
                            tempText = tempLine.Text.Trim();
                            if (tempText.Length == 0) previousIndent = -1;
                        }
                        while ((tempLine.Number > 1) && (previousIndent < 0));

                        if (tempText.EndsWith("{"))
                        {
                            int bracePos = Scintilla.CurrentPos - 1;
                            while (bracePos > 0 && Scintilla.CharAt(bracePos) != '{') bracePos--;
                            if (bracePos > 0 && Scintilla.Styles.GetStyleAt(bracePos) == 10)
                                previousIndent += this.TabWidth;
                        }
                        curLine.Indentation = previousIndent;
                        Scintilla.CurrentPos = curLine.IndentPosition;
                    }
                    else if (ch == '}')
                    {
                        int position = Scintilla.CurrentPos;
                        Line curLine = Scintilla.Lines.Current;
                        int previousIndent = curLine.Previous.Indentation;
                        int match = Scintilla.SafeBraceMatch(position - 1);
                        if (match != -1)
                        {
                            previousIndent = Scintilla.Lines.FromPosition(match).Indentation;
                            curLine.Indentation = previousIndent;
                        }
                    }
                    break;
            }
        }