Пример #1
0
 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)
Пример #2
0
 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)
Пример #3
0
 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
Пример #4
0
 def Write(self, txt, pos=-1):
     if pos == -1:
         pos = self.GetCurrentPos()
     CScite.pane_Insert(self.nPane, pos, txt)
     self.GotoPos(pos + len(txt))
Пример #5
0
	def Trace(self, s): return CScite.app_Trace(s)
	def MsgBox(self, s): return CScite.app_MsgBox(s)
Пример #6
0
 def Textrange(self, n1, n2):
     return CScite.pane_Textrange(self.nPane, n1, n2)
Пример #7
0
 def LoadLexerLibrary(self, s):
     return CScite.pane_ScintillaFn(self.nPane, "LoadLexerLibrary", (None, s))
Пример #8
0
 def InsertText(self, txt, pos):
     return CScite.pane_Insert(self.nPane, pos, txt)
Пример #9
0
 def AutoCStops(self, s):
     return CScite.pane_ScintillaFn(self.nPane, "AutoCStops", (None, s))
Пример #10
0
 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')
Пример #12
0
 def CopyText(self, s):
     return CScite.pane_ScintillaFn(self.nPane, "CopyText", (len(s), s))
Пример #13
0
	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):
Пример #14
0
	def UnsetProperty(self, s): return CScite.app_UnsetProperty(s)
	def UpdateStatusBar(self, v=None): return CScite.app_UpdateStatusBar(v)
Пример #15
0
	def SetProperty(self, s, v): return CScite.app_SetProperty(s, v)
	def UnsetProperty(self, s): return CScite.app_UnsetProperty(s)
Пример #16
0
	def OpenFile(self, s): return CScite.app_OpenFile(s)
	def GetProperty(self, s): return CScite.app_GetProperty(s)
Пример #17
0
	def MsgBox(self, s): return CScite.app_MsgBox(s)
	def OpenFile(self, s): return CScite.app_OpenFile(s)
Пример #18
0
 def SetText(self, s):
     return CScite.pane_ScintillaFn(self.nPane, "SetText", (None, s))
Пример #19
0
 def Trace(self, s):
     return CScite.app_Trace(s)
Пример #20
0
 def AutoCSelect(self, s):
     return CScite.pane_ScintillaFn(self.nPane, "AutoCSelect", (None, s))
Пример #21
0
 def MsgBox(self, s):
     return CScite.app_MsgBox(s)
Пример #22
0
 def SetLexerLanguage(self, s):
     return CScite.pane_ScintillaFn(self.nPane, "SetLexerLanguage", (None, s))
Пример #23
0
 def OpenFile(self, s):
     return CScite.app_OpenFile(s)
Пример #24
0
 def Append(self, txt):
     return CScite.pane_Append(self.nPane, txt)
Пример #25
0
 def GetProperty(self, s):
     return CScite.app_GetProperty(s)
Пример #26
0
 def Remove(self, npos1, npos2):
     return CScite.pane_Remove(self.nPane, npos1, npos2)
Пример #27
0
 def SetProperty(self, s, v):
     return CScite.app_SetProperty(s, v)
Пример #28
0
 def UnsetProperty(self, s):
     return CScite.app_UnsetProperty(s)
Пример #29
0
 def UpdateStatusBar(self, v=None):
     return CScite.app_UpdateStatusBar(v)
Пример #30
0
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")
Пример #31
0
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')