On Jul 27, 6:08 am, "Edward K. Ream" <[email protected]> wrote:

> We can't have timers in event handlers.

Let me explain what was an automatic, reflexive, response. There are
three reasons why I don't want timers in event handlers.

First, event handlers are inherently difficult code.  We want to keep
them as simple as we possibly can, and to change them only to fix
major bugs.  As I have said many times before, Leo's event handlers
are more difficult than in other apps because Leo's command can
generate events.  In turn, this requires that the event handlers use
lockout's to maintain sanity.   Adding timer-generated events simply
increases the odds that weird edge cases will cause harm.

Second, there is a much better alternative to timers for most
"difficult" situations: use idle-time event handlers.  The great
advantage of idle-time processing (compared to timers) is that idle
time is *defined* in terms of events, namely that time at which no
further events are pending.  Not only is the definition more apt, idle
time-events have two important characteristics not shared by timing
code:  they are guaranteed to happen as soon as possible after the
event queue is empty, and more importantly, they are guaranteed *not*
to happen until the event queue really is empty.

Third, in most cases, there is no need at all for changes to Leo's low-
level event handlers.  Instead, user-level event handlers can call
c.endEditing or c.outerUpdate or any other method to put focus where
it is needed.  Having extolled the virtues of idle-time code, I want
to use that kind of code as a last resort, and to avoid idle-time code
unless it is absolutely necessary.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en.

Reply via email to