コード例 #1
0
 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)
コード例 #2
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
コード例 #3
0
 def calculate_checksum(self):
     '''
         Calculates the checksum of the caret line
         Args:
             None
         Returns:
             None
     '''
     line = editor.getCurLine().strip()
     line_length = len(line)
     record_length = line_length - 1
     if line.startswith(':') and line_length > 10 and (record_length % 2
                                                       == 0):
         if record_length == int(line[1:3], 16) * 2 + 8:
             length_assumed = True
             x = line[1:].decode('hex')
         else:
             length_assumed = False
             x = line[1:-2].decode('hex')
         total = sum(struct.unpack('<' + 'B' * len(x), x))
         int_checksum = ~total & 0xFF
         checksum = format(0 if int_checksum == 0xFF else int_checksum + 1,
                           '02X')
         if self.debug_mode:
             print('calculated checksum is {}'.format(checksum))
         if checksum != line[-2:]:
             self.__set_annotation(
                 editor.lineFromPosition(editor.getCurrentPos()),
                 '{}{}'.format(
                     ' ' * line_length if length_assumed else ' ' *
                     (line_length - 2), checksum))
         else:
             editor.annotationClearAll()
コード例 #4
0
 def callback_scintillawrapper_int_int_stringresult_getCurLine(self, args):
     editor.gotoPos(6)
     line = editor.getCurLine()
     self.assertEqual(line, 'Two\r\n')
     self.callbackCalled = True
コード例 #5
0
 def test_scintillawrapper_int_int_stringresult_getCurLine(self):
     editor.write('One\r\nTwo\r\nThree\r\n')
     editor.gotoPos(6)
     line = editor.getCurLine()
     self.assertEqual(line, 'Two\r\n')