SCN_MODIFIED and styles

42 views
Skip to first unread message

Chinh Nguyen

unread,
Nov 10, 2016, 1:04:48 PM11/10/16
to scintilla-interest
I'm doing some post processing after a SCN_MODIFIED notification. For speed purposes, I use SCI_GETSTYLEAT to determine if I want to process a line. I'm finding that even though the text is updated, the styles are stale. I'm currently using SCNotification's position and linesAdded to determine the range of text and SCI_COLOURISE to ensure that the styles are updated. Is this the right approach or is there a way to flush the colorizing?

Neil Hodgson

unread,
Nov 10, 2016, 5:14:33 PM11/10/16
to scintilla...@googlegroups.com
Chinh Nguyen:

> I'm doing some post processing after a SCN_MODIFIED notification. For speed purposes, I use SCI_GETSTYLEAT to determine if I want to process a line. I'm finding that even though the text is updated, the styles are stale. I'm currently using SCNotification's position and linesAdded to determine the range of text and SCI_COLOURISE to ensure that the styles are updated. Is this the right approach or is there a way to flush the colorizing?

Styling is asynchronous and occurs well after the modification has been processed. It most commonly occurs during the next paint. There are also optimisations that try to avoid style changes that may not be visible. An SC_MOD_CHANGESTYLE will be sent when some text has been styled but must be requested by setting its bit in the event mask ad there may be multiple SC_MOD_CHANGESTYLE messages for one change to the text.

Its likely the best approach is to post your code a low priority idle message or start a timer or similar and perform your processing then. Request styling before your processing with SCI_COLOURISE.

Neil

Chinh Nguyen

unread,
Nov 11, 2016, 11:22:46 AM11/11/16
to scintilla-interest, nyama...@me.com
On Thursday, November 10, 2016 at 4:14:33 PM UTC-6, Neil Hodgson wrote:
   Its likely the best approach is to post your code a low priority idle message or start a timer or similar and perform your processing then. Request styling before your processing with SCI_COLOURISE.

I queued my post processing method on the main thread and that seems to have allowed the styling to be performed first. I need to do more testing but I think I'm good. Thanks.

Reply all
Reply to author
Forward
0 new messages