def __getattr__(self, s): if s.startswith("_"): # if looking for a special method, don't try to do anything. raise exceptions.AttributeError elif s.upper() == s and "_" in s: return CScite.app_GetConstant(s) else: return lambda: CScite.app_SciteCommand(s)
def FindText(self, s, n1=0, n2=-1, wholeWord=False, matchCase=False, regExp=False, nFlags=0): if wholeWord: nFlags |= CScite.ScApp.SCFIND_WHOLEWORD if matchCase: nFlags |= CScite.ScApp.SCFIND_MATCHCASE if regExp: nFlags |= CScite.ScApp.SCFIND_REGEXP return CScite.pane_FindText(self.nPane, s, nFlags, n1, n2)
def __getattr__(self, sprop): if sprop.startswith("_"): # if looking for a special method, don't try to do anything. raise exceptions.AttributeError elif sprop.startswith("Get"): if sprop in CScite._dictIsScintillaFnNotGetter: return lambda *args: CScite.pane_ScintillaFn(self.nPane, sprop, args) else: sprop = sprop[3:] return lambda param=None: CScite.pane_ScintillaGet(self.nPane, sprop, param) elif sprop.startswith("Set"): if sprop in CScite._dictIsScintillaFnNotSetter: return lambda *args: CScite.pane_ScintillaFn(self.nPane, sprop, args) else: sprop = sprop[3:] return lambda a1, a2=None: CScite.pane_ScintillaSet(self.nPane, sprop, a1, a2) else: return lambda *args: CScite.pane_ScintillaFn(self.nPane, sprop, args) raise exceptions.AttributeError
def Write(self, txt, pos=-1): if pos == -1: pos = self.GetCurrentPos() CScite.pane_Insert(self.nPane, pos, txt) self.GotoPos(pos + len(txt))
def Trace(self, s): return CScite.app_Trace(s) def MsgBox(self, s): return CScite.app_MsgBox(s)
def Textrange(self, n1, n2): return CScite.pane_Textrange(self.nPane, n1, n2)
def LoadLexerLibrary(self, s): return CScite.pane_ScintillaFn(self.nPane, "LoadLexerLibrary", (None, s))
def InsertText(self, txt, pos): return CScite.pane_Insert(self.nPane, pos, txt)
def AutoCStops(self, s): return CScite.pane_ScintillaFn(self.nPane, "AutoCStops", (None, s))
def ReplaceSel(self, s): return CScite.pane_ScintillaFn(self.nPane, "ReplaceSel", (None, s))
def test_1_1(): CurrentPane.ClearAll() expectEqual(CurrentPane.GetAllText(), '') CurrentPane.Write('ab'); CurrentPane.Write('bc') expectEqual(CurrentPane.GetAllText(), 'abbc') # append not affected by position CurrentPane.ClearAll() CurrentPane.Append('123'); CurrentPane.GotoPos(1); CurrentPane.Append('456') expectEqual(CurrentPane.GetAllText(), '123456') # Write -is- affected by position CurrentPane.ClearAll() CurrentPane.Write('ABC'); CurrentPane.GotoPos(1); CurrentPane.Write('DEF') expectEqual(CurrentPane.GetAllText(), 'ADEFBC') CurrentPane.ClearAll() CurrentPane.Write('aaaa'); CurrentPane.InsertText('bb',2); CurrentPane.InsertText('cc',3) expectEqual(CurrentPane.GetAllText(), 'aabccbaa') CurrentPane.ClearAll() CurrentPane.Write('123456789'); CurrentPane.Remove(1,1); CurrentPane.Remove(3,5) expectEqual(CurrentPane.GetAllText(), '134789') CurrentPane.ClearAll() CurrentPane.Write('123456789'); expectEqual(CurrentPane.Textrange(1,1), ''); expectEqual(CurrentPane.Textrange(1,2), '2') expectEqual(CurrentPane.Textrange(1,3), '23'); expectEqual(CurrentPane.Textrange(2,5), '345') CurrentPane.ClearAll() CurrentPane.Write('a teststringnotwhole teststring testStringnotwhole testString end'); expectEqual( CurrentPane.FindText('testString',wholeWord=True, matchCase=True), (51,61)) expectEqual( CurrentPane.FindText('testString',matchCase=True), (32,42)) expectEqual( CurrentPane.FindText('testString',wholeWord=True), (21,31)) expectEqual( CurrentPane.FindText('testString'), (2,12)) expectThrow( (lambda:CScite.pane_ScintillaFn(3, 'a', ('b','C'))), 'Invalid pane') expectThrow( (lambda:CurrentPane.NotAValid()), 'Could not find fn.') expectThrow( (lambda:CurrentPane.SetNotAValid('f')), 'Could not find prop.') expectThrow( (lambda:CurrentPane.GetNotAValid()), 'Could not find prop.') # scintilla fns expectThrow( (lambda:CurrentPane.ClearAll(1)), 'Wrong # of args') expectThrow( (lambda:CurrentPane.SetWhitespaceBack(1,1,1)), 'Wrong # of args') expectThrow( (lambda:CurrentPane.AppendText('a','b','c','d')), 'Wrong # of args') expectThrow( (lambda:CurrentPane.AppendText('a','a')), 'int expected') expectThrow( (lambda:CurrentPane.AppendText(False,False)), 'string expected') expectThrow( (lambda:CurrentPane.MarkerAdd(1,1,1)), 'Wrong # of args') expectThrow( (lambda:CurrentPane.CanRedo(None)), 'Wrong # of args') expectThrow( (lambda:CurrentPane.CanRedo(0)), 'Wrong # of args') # scintilla get/set expectThrow( (lambda:CurrentPane.SetLineCount(4)), 'prop can\'t be set') expectThrow( (lambda:CurrentPane.GetWhitespaceChars()), 'prop can\'t be get') expectThrow( (lambda:CurrentPane.GetLineCount('a')), 'property does not take params') expectThrow( (lambda:CurrentPane.GetLineCount(1)), 'property does not take params') expectThrow( (lambda:CurrentPane.GetCharAt()), 'prop needs param') expectThrow( (lambda:CurrentPane.GetCharAt('a')), 'Int expected') expectThrow( (lambda:CurrentPane.SetStyleBold('a')), 'prop needs param') expectThrow( (lambda:CurrentPane.SetStyleBold(True)), 'prop needs param') expectThrow( (lambda:CurrentPane.SetViewEOL(1)), 'Bool expected') expectThrow( (lambda:CurrentPane.SetViewEOL(True, 45)), 'property does not take params')
def CopyText(self, s): return CScite.pane_ScintillaFn(self.nPane, "CopyText", (len(s), s))
def UpdateStatusBar(self, v=None): return CScite.app_UpdateStatusBar(v) # CScite.app_SciteCommand(self.nPane, s, *args) (see __getattr__) # CScite.app_GetConstant(self.nPane, s, *args) (see __getattr__) def __getattr__(self, s):
def UnsetProperty(self, s): return CScite.app_UnsetProperty(s) def UpdateStatusBar(self, v=None): return CScite.app_UpdateStatusBar(v)
def SetProperty(self, s, v): return CScite.app_SetProperty(s, v) def UnsetProperty(self, s): return CScite.app_UnsetProperty(s)
def OpenFile(self, s): return CScite.app_OpenFile(s) def GetProperty(self, s): return CScite.app_GetProperty(s)
def MsgBox(self, s): return CScite.app_MsgBox(s) def OpenFile(self, s): return CScite.app_OpenFile(s)
def SetText(self, s): return CScite.pane_ScintillaFn(self.nPane, "SetText", (None, s))
def Trace(self, s): return CScite.app_Trace(s)
def AutoCSelect(self, s): return CScite.pane_ScintillaFn(self.nPane, "AutoCSelect", (None, s))
def MsgBox(self, s): return CScite.app_MsgBox(s)
def SetLexerLanguage(self, s): return CScite.pane_ScintillaFn(self.nPane, "SetLexerLanguage", (None, s))
def OpenFile(self, s): return CScite.app_OpenFile(s)
def Append(self, txt): return CScite.pane_Append(self.nPane, txt)
def GetProperty(self, s): return CScite.app_GetProperty(s)
def Remove(self, npos1, npos2): return CScite.pane_Remove(self.nPane, npos1, npos2)
def SetProperty(self, s, v): return CScite.app_SetProperty(s, v)
def UnsetProperty(self, s): return CScite.app_UnsetProperty(s)
def UpdateStatusBar(self, v=None): return CScite.app_UpdateStatusBar(v)
def test_1_1(): CurrentPane.ClearAll() expectEqual(CurrentPane.GetAllText(), "") CurrentPane.Write("ab") CurrentPane.Write("bc") expectEqual(CurrentPane.GetAllText(), "abbc") # append not affected by position CurrentPane.ClearAll() CurrentPane.Append("123") CurrentPane.GotoPos(1) CurrentPane.Append("456") expectEqual(CurrentPane.GetAllText(), "123456") # Write -is- affected by position CurrentPane.ClearAll() CurrentPane.Write("ABC") CurrentPane.GotoPos(1) CurrentPane.Write("DEF") expectEqual(CurrentPane.GetAllText(), "ADEFBC") CurrentPane.ClearAll() CurrentPane.Write("aaaa") CurrentPane.InsertText("bb", 2) CurrentPane.InsertText("cc", 3) expectEqual(CurrentPane.GetAllText(), "aabccbaa") CurrentPane.ClearAll() CurrentPane.Write("123456789") CurrentPane.Remove(1, 1) CurrentPane.Remove(3, 5) expectEqual(CurrentPane.GetAllText(), "134789") CurrentPane.ClearAll() CurrentPane.Write("123456789") expectEqual(CurrentPane.Textrange(1, 1), "") expectEqual(CurrentPane.Textrange(1, 2), "2") expectEqual(CurrentPane.Textrange(1, 3), "23") expectEqual(CurrentPane.Textrange(2, 5), "345") CurrentPane.ClearAll() CurrentPane.Write("a teststringnotwhole teststring testStringnotwhole testString end") expectEqual(CurrentPane.FindText("testString", wholeWord=True, matchCase=True), (51, 61)) expectEqual(CurrentPane.FindText("testString", matchCase=True), (32, 42)) expectEqual(CurrentPane.FindText("testString", wholeWord=True), (21, 31)) expectEqual(CurrentPane.FindText("testString"), (2, 12)) expectThrow((lambda: CScite.pane_ScintillaFn(3, "a", ("b", "C"))), "Invalid pane") expectThrow((lambda: CurrentPane.NotAValid()), "Could not find fn.") expectThrow((lambda: CurrentPane.SetNotAValid("f")), "Could not find prop.") expectThrow((lambda: CurrentPane.GetNotAValid()), "Could not find prop.") # scintilla fns expectThrow((lambda: CurrentPane.ClearAll(1)), "Wrong # of args") expectThrow((lambda: CurrentPane.SetWhitespaceBack(1, 1, 1)), "Wrong # of args") expectThrow((lambda: CurrentPane.AppendText("a", "b", "c", "d")), "Wrong # of args") expectThrow((lambda: CurrentPane.AppendText("a", "a")), "int expected") expectThrow((lambda: CurrentPane.AppendText(False, False)), "string expected") expectThrow((lambda: CurrentPane.MarkerAdd(1, 1, 1)), "Wrong # of args") expectThrow((lambda: CurrentPane.CanRedo(None)), "Wrong # of args") expectThrow((lambda: CurrentPane.CanRedo(0)), "Wrong # of args") # scintilla get/set expectThrow((lambda: CurrentPane.SetLineCount(4)), "prop can't be set") expectThrow((lambda: CurrentPane.GetWhitespaceChars()), "prop can't be get") expectThrow((lambda: CurrentPane.GetLineCount("a")), "property does not take params") expectThrow((lambda: CurrentPane.GetLineCount(1)), "property does not take params") expectThrow((lambda: CurrentPane.GetCharAt()), "prop needs param") expectThrow((lambda: CurrentPane.GetCharAt("a")), "Int expected") expectThrow((lambda: CurrentPane.SetStyleBold("a")), "prop needs param") expectThrow((lambda: CurrentPane.SetStyleBold(True)), "prop needs param") expectThrow((lambda: CurrentPane.SetViewEOL(1)), "Bool expected") expectThrow((lambda: CurrentPane.SetViewEOL(True, 45)), "property does not take params")
def test_1_1(): CurrentPane.ClearAll() expectEqual(CurrentPane.GetAllText(), '') CurrentPane.Write('ab') CurrentPane.Write('bc') expectEqual(CurrentPane.GetAllText(), 'abbc') # append not affected by position CurrentPane.ClearAll() CurrentPane.Append('123') CurrentPane.GotoPos(1) CurrentPane.Append('456') expectEqual(CurrentPane.GetAllText(), '123456') # Write -is- affected by position CurrentPane.ClearAll() CurrentPane.Write('ABC') CurrentPane.GotoPos(1) CurrentPane.Write('DEF') expectEqual(CurrentPane.GetAllText(), 'ADEFBC') CurrentPane.ClearAll() CurrentPane.Write('aaaa') CurrentPane.InsertText('bb', 2) CurrentPane.InsertText('cc', 3) expectEqual(CurrentPane.GetAllText(), 'aabccbaa') CurrentPane.ClearAll() CurrentPane.Write('123456789') CurrentPane.Remove(1, 1) CurrentPane.Remove(3, 5) expectEqual(CurrentPane.GetAllText(), '134789') CurrentPane.ClearAll() CurrentPane.Write('123456789') expectEqual(CurrentPane.Textrange(1, 1), '') expectEqual(CurrentPane.Textrange(1, 2), '2') expectEqual(CurrentPane.Textrange(1, 3), '23') expectEqual(CurrentPane.Textrange(2, 5), '345') CurrentPane.ClearAll() CurrentPane.Write( 'a teststringnotwhole teststring testStringnotwhole testString end') expectEqual( CurrentPane.FindText('testString', wholeWord=True, matchCase=True), (51, 61)) expectEqual(CurrentPane.FindText('testString', matchCase=True), (32, 42)) expectEqual(CurrentPane.FindText('testString', wholeWord=True), (21, 31)) expectEqual(CurrentPane.FindText('testString'), (2, 12)) expectThrow((lambda: CScite.pane_ScintillaFn(3, 'a', ('b', 'C'))), 'Invalid pane') expectThrow((lambda: CurrentPane.NotAValid()), 'Could not find fn.') expectThrow((lambda: CurrentPane.SetNotAValid('f')), 'Could not find prop.') expectThrow((lambda: CurrentPane.GetNotAValid()), 'Could not find prop.') # scintilla fns expectThrow((lambda: CurrentPane.ClearAll(1)), 'Wrong # of args') expectThrow((lambda: CurrentPane.SetWhitespaceBack(1, 1, 1)), 'Wrong # of args') expectThrow((lambda: CurrentPane.AppendText('a', 'b', 'c', 'd')), 'Wrong # of args') expectThrow((lambda: CurrentPane.AppendText('a', 'a')), 'int expected') expectThrow((lambda: CurrentPane.AppendText(False, False)), 'string expected') expectThrow((lambda: CurrentPane.MarkerAdd(1, 1, 1)), 'Wrong # of args') expectThrow((lambda: CurrentPane.CanRedo(None)), 'Wrong # of args') expectThrow((lambda: CurrentPane.CanRedo(0)), 'Wrong # of args') # scintilla get/set expectThrow((lambda: CurrentPane.SetLineCount(4)), 'prop can\'t be set') expectThrow((lambda: CurrentPane.GetWhitespaceChars()), 'prop can\'t be get') expectThrow((lambda: CurrentPane.GetLineCount('a')), 'property does not take params') expectThrow((lambda: CurrentPane.GetLineCount(1)), 'property does not take params') expectThrow((lambda: CurrentPane.GetCharAt()), 'prop needs param') expectThrow((lambda: CurrentPane.GetCharAt('a')), 'Int expected') expectThrow((lambda: CurrentPane.SetStyleBold('a')), 'prop needs param') expectThrow((lambda: CurrentPane.SetStyleBold(True)), 'prop needs param') expectThrow((lambda: CurrentPane.SetViewEOL(1)), 'Bool expected') expectThrow((lambda: CurrentPane.SetViewEOL(True, 45)), 'property does not take params')