Highlighting errors using parse results
In a BuffEditableTextList
component, the fire()
method is called whenever the content is changed, as well as whenever the cursor moves. When content is changed, it sets a flag named doReparse
, indicating that the code should be syntax-checked. The check does not occur until the cursor is moved. The code for the fire()
method is shown here:
method fire(type, param)
self$Connectable.fire(type, param)
if type === CONTENT_CHANGED_EVENT then
doReparse := 1
if type === CURSOR_MOVED_EVENT &
old_cursor_y ~= cursor_y then
ReparseCode()
end
In the preceding code, the ReparseCode()
method is occasionally called in the Unicon IDE in response to a cursor move, in order to see whether editing has resulted in a syntax error. Only cursor moves that change the current line (old_cursor_y ~= cursor_y
) trigger the ReparseCode()
method, as shown here:
method ReparseCode ()
local s, rv, x...