Change History (6)

I have started doing some work on speeding up the PPI-based syntax highlighter. The basic idea is that PPI should parse as little as possible on each EVT_STC_STYLENEEDED event. Here is a simplified overview of the algorithm I am trying to implement.

Figure out which portions (lines) of the code need styling. This can be done in two ways:

with each EVT_STC_STYLENEEDED event we can access the stat and end positions in the editor that wxSTC thinks need styling.

we can alternatively use information from the EVT_STC_MODIFIED event, and figure out which parts of the code have been changed. This may also reduce the number of calls to the PPI parser since EVT_STC_STYLENEEDED appears to be raised much more often than EVT_STC_MODIFIED.

After we have a bunch (normally only a few) of lines that need restyling we have to figure out if we can just feed them to PPI. First we have to take care of quote-like strings:

if the last token before the text we need to restyle is an unfinished quote-like token, we include the text of this token in the string we feed to PPI.

if the last token in the text we need to restyle is an unfinished quote-like token, we search forward for the end of this token and include that in the string we feed to PPI.

A similar logic is applied to pod sections:

if the last token before the text we need to restyle is an unfinished pod token, we include the text of this token in the string we feed to PPI.

if the last token in the text we need to restyle is an unfinished pod token, we search forward for the end of this token and include that in the string we feed to PPI.