def test_scintillawrapper_int_position_void_in_callback(self):
     editor.callback(
         lambda args: self.callback_scintillawrapper_int_position_void(
             args), [SCINTILLANOTIFICATION.MODIFIED])
     editor.write("test")
     # self.poll_for_callback()
     self.poll_for_callback()
 def test_scintillawrapper_void_bool_colour_in_callback(self):
     editor.callback(
         lambda args: self.callback_scintillawrapper_void_bool_colour(args),
         [SCINTILLANOTIFICATION.MODIFIED])
     editor.write("test")
     self.poll_for_callback()
     self.assertEqual(self.callbackCalled, True)
    def test_scintillawrapper_position_int_int(self):
        editor.write('Hello World')
        x = editor.pointXFromPosition(6)  # X position of the W
        y = editor.pointYFromPosition(6)

        position = editor.positionFromPoint(x, y)
        self.assertEqual(position, 6)
 def test_scintillawrapper_position_int_int_in_callback(self):
     editor.callback(
         lambda args: self.callback_scintillawrapper_position_int_int(args),
         [SCINTILLANOTIFICATION.MODIFIED])
     editor.write("Hello World")
     self.poll_for_callback()
     self.assertEqual(self.callbackCalled, True)
 def test_scintillawrapper_void_int_void(self):
     editor.write('one\r\ntwo\r\nthree\r\n')
     before = editor.getCurLine()
     editor.gotoLine(1)
     after = editor.getCurLine()
     self.assertEqual(after, 'two\r\n')
     self.assertNotEqual(before, after)
Beispiel #6
0
 def test_scintillawrapper_void_void_void(self):
     editor.write('Hello')
     editor.write(' world')
     before = editor.getText()
     editor.clearAll()
     after = editor.getText()
     self.assertEqual(before, 'Hello world')
     self.assertEqual(after, '')
Beispiel #7
0
 def callback_scintillawrapper_position_void_void(self, args):
     if args["modificationType"] & MODIFICATIONFLAGS.INSERTTEXT == 0:   # Ignore anything that isn't INSERTTEXT
         return
     editor.clearCallbacks()
     editor.write("1234")
     position = editor.getCurrentPos()
     self.assertEqual(position, 8)  # test1234|
     self.callbackCalled = True
Beispiel #8
0
 def callback_scintillawrapper_void_int_void(self, args):
     editor.write('one\r\ntwo\r\nthree\r\n')
     before = editor.getCurLine()
     editor.gotoLine(1)
     after = editor.getCurLine()
     self.assertEqual(after, 'two\r\n')
     self.assertNotEqual(before, after)
     self.callbackCalled = True
 def test_scintillawrapper_void_void_string_in_callback_lexerLanguage(self):
     editor.callback(
         lambda args: self.
         callback_scintillawrapper_void_void_string_lexerLanguage(args),
         [SCINTILLANOTIFICATION.MODIFIED])
     editor.write("test")
     self.poll_for_callback()
     self.assertEqual(self.callbackCalled, True)
Beispiel #10
0
 def test_annotationSetText_clear(self):
     editor.write('One\r\nTwo\r\nThree')
     editor.annotationSetText(1, 'This is line two')
     before = editor.annotationGetText(1)
     editor.annotationSetText(1, None)
     after = editor.annotationGetText(1)
     self.assertEqual(before, 'This is line two')
     self.assertEqual(after, '')
 def test_scintillawrapper_int_int_stringresult_in_callback_getLine(self):
     editor.callback(
         lambda args: self.
         callback_scintillawrapper_int_int_stringresult_getLine(args),
         [SCINTILLANOTIFICATION.MODIFIED])
     editor.write("One\r\nTwo\r\nThree")
     self.poll_for_callback()
     self.assertEqual(self.callbackCalled, True)
Beispiel #12
0
 def test_scintillawrapper_void_position_void(self):
     editor.write('Hello world 12356')
     editor.gotoPos(6)
     afterGotoPos = editor.getCurrentPos()
     editor.setCurrentPos(10)
     afterSetCurrentPos = editor.getCurrentPos()
     self.assertEqual(afterGotoPos, 6)
     self.assertEqual(afterSetCurrentPos, 10)
Beispiel #13
0
 def test_scintillawrapper_int_void_textrange_in_callback(self):
     notepad.setLangType(LANGTYPE.XML)
     editor.write('<test attrib="unit" />')
     time.sleep(0.1)  # lexing and threading don't seem to mix
     editor.callback(lambda args: self.callback_scintillawrapper_int_void_textrange(args), [SCINTILLANOTIFICATION.SAVEPOINTREACHED])
     editor.setSavePoint()
     self.poll_for_callback()
     self.assertEqual(self.callbackCalled, True)
 def test_scintillawrapper_int_int_string_in_callback(self):
     editor.write('ABC This is a some ABC text we are going to search')
     editor.callback(
         lambda args: self.callback_scintillawrapper_int_int_string(args),
         [SCINTILLANOTIFICATION.SAVEPOINTREACHED])
     editor.setSavePoint()
     self.poll_for_callback()
     self.assertEqual(self.callbackCalled, True)
 def test_scintillawrapper_int_int_stringresult_in_callback_styleGetFont(
         self):
     editor.callback(
         lambda args: self.
         callback_scintillawrapper_int_int_stringresult_styleGetFont(args),
         [SCINTILLANOTIFICATION.MODIFIED])
     editor.write("test")
     self.poll_for_callback()
     self.assertEqual(self.callbackCalled, True)
 def test_scintillawrapper_int_int_int(self):
     editor.write('line 1\r\nline 2\r\nline 3\r\nline 4\r\n')
     handle = editor.markerAdd(2, 1)
     self.assertNotEqual(
         handle, -1
     )  # markerAdd() returns -1 if the line number is invalid or out of memory
     editor.insertText(0, 'inserted line 1\r\n')
     newLineNumber = editor.markerLineFromHandle(handle)
     self.assertEqual(newLineNumber, 3)
 def test_scintillawrapper_void_int_cells_in_callback(self):
     editor.write('Hi')
     editor.setText('')
     editor.callback(
         lambda args: self.callback_scintillawrapper_void_int_cells(args),
         [SCINTILLANOTIFICATION.SAVEPOINTREACHED])
     editor.setSavePoint()
     self.poll_for_callback()
     self.assertEqual(self.callbackCalled, True)
Beispiel #18
0
 def test_scintillawrapper_int_void_position(self):
     # This test is actually identical to position_int_int
     # That test is for positionFromPoint(), this is for pointXFromPosition()
     # I'm leaving this in, so we've definitely got a covering test for int_void_position
     editor.write('Hello World');
     x = editor.pointXFromPosition(6) # X position of the W
     y = editor.pointYFromPosition(6)
     position = editor.positionFromPoint(x, y)
     self.assertEqual(position, 6)
 def test_scintillawrapper_void_void_int_in_callback(self):
     notepad.outputDebugString(
         'test_scintillawrapper_void_void_int_in_callback')
     editor.write('test')
     editor.callback(
         lambda args: self.callback_scintillawrapper_void_void_int(args),
         [SCINTILLANOTIFICATION.SAVEPOINTREACHED])
     editor.setSavePoint()
     self.poll_for_callback()
     self.assertEqual(self.callbackCalled, True)
Beispiel #20
0
    def test_scintillawrapper_void_int_int(self):
        editor.write('One\r\nTwo\r\nThree\r\nFour')
        editor.markerAddSet(2, 0x11) # marker 4 (0x10) and 0 (0x01) on line 2
        markersBeforeMove = editor.markerGet(2)
        editor.insertText(0, 'Inserted\r\n')
        markersAfterMove = editor.markerGet(2)
        markersAfterMoveLine3 = editor.markerGet(3)

        self.assertEqual(markersBeforeMove, 0x11)
        self.assertEqual(markersAfterMove, 0)
        self.assertEqual(markersAfterMoveLine3, 0x11)
 def test_scintillawrapper_int_void_textrange(self):
     notepad.setLangType(LANGTYPE.XML)
     editor.write('<test attrib="unit" />')
     time.sleep(
         0.1
     )  # let the lexer do it's thang. The getStyledText appears to fail occassionally, returns a bunch of zeroes for the styles
     # I'm assuming it's a timing bug, as it "normally" works. Added the sleep to see if it makes a difference.
     result = editor.getStyledText(0, 19)
     self.assertEqual(
         ('<test attrib="unit"',
          [1, 1, 1, 1, 1, 8, 3, 3, 3, 3, 3, 3, 8, 6, 6, 6, 6, 6, 6]),
         result)
Beispiel #22
0
    def test_scintillawrapper_void_int_position(self):
        editor.write('abc123 def456 ghi789 jk12 lmnop3456')
        editor.setSel(7, 13)
        editor.addSelection(14, 20)
        editor.setSelectionNCaret(1, 16)
        editor.setSelectionNAnchor(1, 18)
        # Note: Do not attempt to call setSelectionNCaret on a selection that doesn't exist - it causes a crash.
        # Always call addSelection first
        caret = editor.getSelectionNCaret(1)
        anchor = editor.getSelectionNAnchor(1)

        self.assertEqual(caret, 16)
        self.assertEqual(anchor, 18)
Beispiel #23
0
    def test_scintillawrapper_int_int_void(self):
        editor.write('One\r\nTwo\r\nThree\r\nFour')

        handle = editor.markerAdd(3, 4)  # Add marker 4 at line 3

        beforeMoveMarker = editor.markerGet(3)
        editor.insertText(0, 'Add a line\r\n')
        afterMove3 = editor.markerGet(3)
        afterMove4 = editor.markerGet(4)
        lineNumber = editor.markerLineFromHandle(handle)

        self.assertEqual(beforeMoveMarker & 0x10, 0x10)  # marker 4 is 0x10, and there could be other markers on the line
        self.assertEqual(afterMove3 & 0x10, 0)           # after the insert, line 3 should not contain the marker
        self.assertEqual(afterMove4 & 0x10, 0x10)        # it should be on line 4
        self.assertEqual(lineNumber, 4)                  # The lineNumber obtained from the handle, should also be 4
Beispiel #24
0
    def test_scintillawrapper_void_bool_void(self):
        editor.setUndoCollection(False)
        editor.emptyUndoBuffer()   # recommended when disabling undo collection
        editor.write('test_void_bool_void')
        editor.setUndoCollection(True)
        editor.undo()
        afterUndoWithUndoDisabled = editor.getText()

        # Now check undo is back on again
        editor.write('extra')
        beforeUndo = editor.getText()
        editor.undo()
        afterUndo = editor.getText()

        self.assertEqual(afterUndoWithUndoDisabled, 'test_void_bool_void')
        self.assertEqual(beforeUndo, 'test_void_bool_voidextra')
        self.assertEqual(afterUndo, 'test_void_bool_void')
 def setUp(self):
     notepad.new()
     notepad.runMenuCommand("Encoding", "Convert to ANSI")
     editor.write(
         u'Here is some text\r\nWith some umlauts XäXüXö\r\n'.encode(
             'windows-1252'))
 def test_simple_text_output(self):
     editor.write(u'test123äöü')
     text = editor.getText()
     self.assertEqual(text, u'test123äöü')
Beispiel #27
0
# -*- coding: utf-8 -*-
Beispiel #28
0
 def test_deleteLine_end_no_eol(self):
     editor.write('Line 1\r\nLine 2\r\nLine 3')
     editor.deleteLine(2)
     text = editor.getText();
     self.assertEqual(text, 'Line 1\r\nLine 2\r\n')
Beispiel #29
0
 def test_deleteLine_middle_no_contents(self):
     editor.write('Line 1\r\n\r\nLine 3\r\n')
     editor.deleteLine(1)
     text = editor.getText();
     self.assertEqual(text, 'Line 1\r\nLine 3\r\n')
Beispiel #30
0
 def test_getCharacterPointer(self):
     editor.write('Hello world char pointer')
     text = editor.getCharacterPointer()
     self.assertEqual(text, 'Hello world char pointer')