def textModified(self, args): '''When the marked text is modified the execution markers will be hidden, except when the code is still running.''' if args['text'] != '': bufferID = notepad.getCurrentBufferID() if self.markers.get( bufferID, None) is not None and not self.bufferActive and len( self.markers[bufferID]) > 0: iCurrentLine = editor.lineFromPosition(editor.getCurrentPos()) iLines = [] for i in self.markers[bufferID]: iLine = editor.markerLineFromHandle(i) iLines.append(iLine) if min(iLines) <= iCurrentLine <= max(iLines): self.hideMarkers(bufferID) if self.markers.get( bufferID, None) is not None and self.bufferActive and len( self.markers[bufferID]) > 0: iCurrentLine = editor.lineFromPosition(editor.getCurrentPos()) iLines = [] for i in self.markers[bufferID]: iLine = editor.markerLineFromHandle(i) iLines.append(iLine) if len(iLines) > 0 and min(iLines) <= iCurrentLine <= max( iLines): self.setMarkers(min(iLines), max(iLines), iMarker=self.m_active, bufferID=bufferID, startAnimation=False)
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_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
def changeMarkers(self, iMarker, bufferID=None): if bufferID != notepad.getCurrentBufferID(): self.bufferMarkerAction[bufferID] = iMarker return iLines = [] for i in self.markers[bufferID]: iLine = editor.markerLineFromHandle(i) #if iLine == -1: # notepad.activateBufferID(bufferID) # iLine = editor.markerLineFromHandle(i) iLines.append(iLine) if iLines: self.setMarkers(min(iLines), max(iLines), iMarker=iMarker, bufferID=bufferID)