private void handleQuotes(char ch, int cPos) { if (Scintilla.GetSelections() > 1) { return; } // Make sure the ch should be handled as is. if (ch == '"' || ch == '\'') { char prevCh = Scintilla.NativeInterface.GetCharAt(cPos - 2); char nextCh = Scintilla.NativeInterface.GetCharAt(cPos); if (nextCh != ch && !IgnoreChar(prevCh)) { return; } } if (ch == '"') { // Get the previous char. if (Scintilla.NativeInterface.GetCharAt(cPos) == '"') { if (cPos > 1) { if (Scintilla.NativeInterface.GetCharAt(cPos - 2) != '\\') { Scintilla.UndoRedo.BeginUndoAction(); Scintilla.NativeInterface.DeleteBack(); Scintilla.NativeInterface.SetSel(cPos, cPos); Scintilla.UndoRedo.EndUndoAction(); } } } else { string selText = Scintilla.Selection.Text; if (String.IsNullOrEmpty(selText)) { Scintilla.NativeInterface.AddText(1, "\""); } else { Scintilla.Selection.Text += "\""; } Scintilla.NativeInterface.SetAnchor(cPos); Scintilla.NativeInterface.SetCurrentPos(cPos); } } if (ch == '\'') { if (Scintilla.NativeInterface.GetCharAt(cPos) == '\'') { if (cPos > 1) { if (Scintilla.NativeInterface.GetCharAt(cPos - 2) != '\\') { Scintilla.UndoRedo.BeginUndoAction(); Scintilla.NativeInterface.DeleteBack(); Scintilla.NativeInterface.SetSel(cPos, cPos); Scintilla.UndoRedo.EndUndoAction(); } } } else { string selText = Scintilla.Selection.Text; if (String.IsNullOrEmpty(selText)) { Scintilla.NativeInterface.AddText(1, "'"); } else { Scintilla.Selection.Text += "'"; } Scintilla.NativeInterface.SetAnchor(cPos); Scintilla.NativeInterface.SetCurrentPos(cPos); } } }