def showErrorLine(self, lineNumber):

	#remove any old error highlighting, because we only want to show one error
	# at a time.  Plus, the system only keeps track of one error, so we need to
	# unhighlight the old error before setting the new one (AW 5/15/03)
	if self.errorLineStart >= 0:
	    self.removeErrorHighlighting()

        #Search for the start offset of the error line
        docText = self.getText(0, self.getLength())

        line   = 1
        offset = 0

        while line < lineNumber:
            offset = docText.find('\n', offset) + 1
            line += 1

        #Search for the end offset of the error line
        #offset += 1
        endOffset = docText.find('\n', offset)

        if endOffset == -1:
            endOffset = len(docText)

        #Set error line position and length object variables
        self.errorLineStart = offset
        self.errorLineLen   = endOffset - offset

        #Set the correct text attribute for the error line
        HighlightingStyledDocument.setCharacterAttributes(self, self.errorLineStart,
                                    self.errorLineLen,
                                    self.errorLineAttrib,
                                    1)

        #Set cusor to error line to ensure that the error line will be visible
        self.editor.setCaretPosition(self.errorLineStart)
示例#2
0
    def showErrorLine(self, lineNumber):

        #remove any old error highlighting, because we only want to show one error
        # at a time.  Plus, the system only keeps track of one error, so we need to
        # unhighlight the old error before setting the new one (AW 5/15/03)
        if self.errorLineStart >= 0:
            self.removeErrorHighlighting()

    #Search for the start offset of the error line
        docText = self.getText(0, self.getLength())

        line = 1
        offset = 0

        while line < lineNumber:
            offset = docText.find('\n', offset) + 1
            line += 1

    #Search for the end offset of the error line
    #offset += 1
        endOffset = docText.find('\n', offset)

        if endOffset == -1:
            endOffset = len(docText)

    #Set error line position and length object variables
        self.errorLineStart = offset
        self.errorLineLen = endOffset - offset

        #Set the correct text attribute for the error line
        HighlightingStyledDocument.setCharacterAttributes(
            self, self.errorLineStart, self.errorLineLen, self.errorLineAttrib,
            1)

        #Set cusor to error line to ensure that the error line will be visible
        self.editor.setCaretPosition(self.errorLineStart)