############################################################################### ## Inserts right side bracket and quotation automatically. ## By: Allen Dang import pn, pypn.glue import scintilla from pypn.decorators import script mirrorChars = ('\'', '"', '(', '[') oldonCharAdded = pypn.glue.onCharAdded def onCharAdded(c, doc): """ Inserts right side bracket and quotation automatically. """ oldonCharAdded(c, doc) editor = scintilla.Scintilla(pn.CurrentDoc()) if (c in mirrorChars): pos = editor.CurrentPos leftChar = editor.GetTextRange(pos - 2, pos - 1) if (c == '\'' or c == '"'): if (leftChar != c): editor.AddText(1, c) editor.CharLeft() elif (c == '('): editor.AddText(1, ')') editor.CharLeft() elif (c == '['): editor.AddText(1, ']') editor.CharLeft() pypn.glue.onCharAdded = onCharAdded