private void OnCharAdded(object sender, Scintilla.CharAddedEventArgs e)
{
// Reset to normal fillups
this.scintillaControl1.AutoCSetFillups(_fillupKeys);
if (e.Ch == 10)
{
int lineNumber = scintillaControl1.LineFromPosition(scintillaControl1.CurrentPos);
if (lineNumber > 0)
{
int previousLineIndent = scintillaControl1.GetLineIndentation(lineNumber - 1);
string previousLine = scintillaControl1.GetLine(lineNumber - 1).Trim('\r', '\n', '\0');
if (previousLine.EndsWith("{"))
{
previousLineIndent += scintillaControl1.TabWidth;
}
/*else if (previousLine.EndsWith("}"))
{
previousLineIndent -= scintillaControl1.TabWidth;
if (previousLineIndent < 0) previousLineIndent = 0;
if (_autoDedentClosingBrace)
{
scintillaControl1.SetLineIndentation(lineNumber - 1, previousLineIndent);
}
}*/
scintillaControl1.SetLineIndentation(lineNumber, previousLineIndent);
scintillaControl1.GotoPos(scintillaControl1.GetLineIndentationPosition(lineNumber));
}
}
// The following events must be piped to the UpdateUI event,
// otherwise they don't work properly
else if ((e.Ch == '}') || (e.Ch == ')'))
{
if (!InsideStringOrComment(true))
{
_doBraceMatch = true;
}
if (scintillaControl1.IsCallTipActive)
{
scintillaControl1.CallTipCancel();
}
}
else if ((e.Ch == '(') || (e.Ch == ','))
{
if ((e.Ch == ',') && (!InsideStringOrComment(true)) &&
(_autoSpaceAfterComma))
{
scintillaControl1.AddText(" ");
}
_doCalltip = true;
}
else if ((e.Ch == '.') && (!scintillaControl1.IsAutoCActive))
{
_doShowAutocomplete = true;
}
else if (((Char.IsLetterOrDigit(e.Ch)) || (e.Ch == '_') || (e.Ch == ' ')) && (!scintillaControl1.IsAutoCActive))
{
_doShowAutocomplete = true;
}
if (CharAdded != null)
{
CharAdded(e.Ch);
}
}