Sunday, May 12, 2013

Error Highlighting – Error Messages

To display error messages in the status bar area at the bottom of the application window required a few minor changes.  Two labels were added to the status bar of the main window, one for the current line number and column, and the other for the error message.  A signal was added to the edit box, which is emitted when the cursor positioned has changed.

A new function was added to the main window class for creating the status bar: adding the labels to the status bar and connecting the signal cursor changed signal from the edit box to a new update status bar slot in main window.  New member label pointers were added so that the labels are easily accessible when it's time to update their text.  New access functions were added to the edit box class to return the current line number, column and message for the line (if there is one) so the update slot can get the information for the status bar labels.

The new message access function of the edit box searches for the line number in the error list.  A new find index function was added to the error list class, which returns a -1 if the line number does not have an error.  The existing find function is called, which only returns an index regardless if the line has an error, so a check is made if the index returned is the line being search for.  If the line does not have an error, a blank message string is returned.

There were a couple of issues getting the error messages to be displayed in the status bar correctly.  Click Continue... for details of these issues and how they were resolved.

[commit c38cd02bd4]