Skip to content

doc/intro.html#the-callback-smallprint needs more detailed/improved explanations #298

Open
@victorel-petrovich

Description

@victorel-petrovich

I found couldn't understand the topic, probably many others will find it the same. Who does understand it (at least partially), please comment.
After clarifying these, I plan to make a PR to improve it. (Or you can do it).

From earlier in the section, we get that an event is a particular kind of change that happens in Notepad++ (things like the active document changing, a file being opened or saved; a character being added, a save point being reached, the document being made dirty, etc.).
Say the focus changes from one tab (file) to another one.
When it happens, I get that the handler function (registered with notification.callback()) is called, or in other words: a notification from the event received, correct?
And the handler starts working.

Due to the nature of Scintilla events, they are by default processed internally slightly differently to Notepad++ events.

Notepad++ events are always processed synchronously, i.e. your event handler finishes before Python Script lets Notepad++ continue.

your event handler finishes before what exactly? ... lets Notepad++ continue with what?
Would it be that Notepad++ waits for hanldler to finish before responding to the user for another event/action? Sort of freezes until then?

Scintilla events are placed in a queue, and your event handlers are called as the queue is asynchronously processed - i.e. the event completes before your event handler is complete (or potentially before your event handler is even called).

What means for an event to "complete" in that sentence? When/how the event "completes"?
Is there a deadline for (a notification from) an event to be processed, so that if deadline passed than the event is considered "gone/past", and the event handler misses it ?

The only visible difference is that if you have a lot of callbacks registered, or your callbacks perform a lot of work, you might receive the event some time after it has actually occurred.

But isn't that always expected? I mean, event happens, then it is noticed. Cause and effect, laws of the universe :) .
Or is it that pythonscript can lag behind that queue with event notifications, which fills up a lot faster than pythonscript can manage. And therefore: the event handler function might receive the notification from event at a noticeably later time than when event (action from user) actually happened?

More questions on the smaller-print there about "As of version 1.0, you can use Editor.callbackSync() [...]" , but they are dependent on clarifying the above first.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions