Re: Optimize Notification processing

Mitchell <[email protected]> Sun, 18 May 2025 15:56:48 -0400
Newsgroups gmane.comp.lib.scintilla.devel
Message-ID <[email protected]>
Hi,

> On May 18, 2025, at 3:40 PM, Jean Lalonde <[email protected]> wrote:
> 
> Hi,
> 
> I'd like to check with you if I have the optimal setting to minimize the number of notifications but get all those I need to update the status bar with the length of text in the editor, length of selected text, position of the caret (line, column), etc. and to process line auto-indentation (as explained in Scintilla Usage Notes).
> 
> I'm setting this event mask:
> 
> o_Sci.SETMODEVENTMASK(SCN_MODIFIED) ; eventMask can be SCN_MODIFIED or SC_MOD_INSERTTEXT|SC_MOD_DELETETEXT

I could be wrong, but you may be able to get away with just listening for `SCN_UPDATEUI` and `SCN_CHARADDED` and setting the mod mask to 0 to ignore them all:
- For `SCN_UPDATEUI`, `updated & (SC_UPDATE_CONTENT | SC_UPDATE_SELECTION) > 0` can be used for detecting position, content and selection changes.
- For `SCN_CHARADDED`, if `ch` is 10, the user pressed enter and you can perform auto-indent.

Cheers,
Mitchell

> 
> I'm setting the notification handler with this:
> 
> o_Sci.NOTIFY := "SciOnNotify"
> 
> And inside SciOnNotify(), I first update the status bar:
> 
> if (obj.SCNCode == SCN_CHARADDED and obj.Modifiers = 10) ; SCN_CHARADDED:=2001, 10 for LF
> {
> Gosub, AutoIndent
> }
> 
> ... and update the status bar:
> 
> if (obj.SCNCode = SCN_MODIFIED) ; SCN_MODIFIED:=2008
> and (obj.ModType != 20) ; SC_MOD_CHANGESTYLE := 0x4 | SC_PERFORMED_USER := 0x10 = 0x14 = 20
> {
> Gosub, UpdateStatusbar
> }
> 
> This works for what I need. But can it be optimized?
> 
> Thanks you for your input.
> 
> -- 
> You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
> To view this discussion visit https://groups.google.com/d/msgid/scintilla-interest/ea0c2cfa-4f75-450a-bf53-6ca85121e586n%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/scintilla-interest/169B274F-8112-41EA-97DC-E6918D0076BD%40foicica.com.