To highlight the errors sent from the program model, a new extra selections list member was added to the edit box class. The update errors slot first determines the number of errors that have been inserted or removed by taking the difference between the size of the new errors list and the size of the current extra selections list. The number of errors that changes is determined by taking the difference between the end and start change indexes plus one, then subtracting the number of errors inserted (which may be zero).
Starting at the start change index for the number of errors that changed (which may also be zero), the extra selection is replaced with the corresponding error item from the errors list. Continuing for the number of errors inserted, the new error items from the error list are inserted into the extra selections list. Finally for the number of errors removed, the extra selections are removed from the list. (There will never be both insertions and removals.)
A new support function was added for converting an error item to an extra selection. If the length of the error is negative, this indicates an alternate column (which occurs in the case where there is a syntax error in the exponent of a floating point number, where the column is the beginning of the number). For this case, the syntax error will be highlighted and not the number for a length of one character.
The format of the extra selection is set to red background. The block for the line of the error item is retrieved from the document to get its position. The cursor of the extra selection is set to the text cursor of the document and positioned to the error (position of the line plus the column of the error. The cursor is moved to the end of the error with the keep anchor option, which highlights the error with the selected format.
Once the extra selections list has been updated for the change in the errors list, the edit box extra selections are set, which causes the errors to highlight. However, there is a problem. If a program contains errors when it is loaded, the errors are not initially highlighted. I think this is because the edit box hasn't been drawn yet at the time the first errors changed signal is emitted.
[commit 24ae7f0467]
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
All comments and feedback welcomed, whether positive or negative.
(Anonymous comments are allowed, but comments with URL links or unrelated comments will be removed.)