At present, the Qt input key logic is way more difficult than it needs
to b.  Indeed, it must produce *exactly* the same results as does
k.shortcutFromSetting.  Errors in this difficult logic will cause keys
not to work.

But there is a much simpler way: for each typed key, simply produce
*any* valid user setting, and then let k.shortcutFromSetting produce
the desired result.  Why didn't I see that earlier?

I discovered this trick now because of the following comment in
leoGui.create_key_event:

    # Do not call shortcutFromSetting here!
    # For example, this would wrongly convert Ctrl-C to Ctrl-c,
    # in effect, converting a user binding from Ctrl-Shift-C to Ctrl-
C.

As usual with the key-handling code, any change to the format of the
various strings that are passed around as key-related arguments must
be done with extreme care.  The only way to do that, imo, is to create
a KeyStroke class whose contents are guaranteed to be "canonicalized",
that is, the result of k.shortcutFromSetting.  This will allow the
code to distinguish between canonicalized and non-canonicalized
results simply by asserting isinstance(stroke,KeyStroke).

These type-check assertions will be a vital consistency check.  It
would be quite wrong to allow type-related mistakes to propagate to
cause trouble later, possibly much later.  The inability to make type
assertions is the primary reason why Leo's key logic has been so
difficult to understand. This must change, and the time to do it is
now, while I have the complications firmly in mind.

Edward

P.S.  Yes, this work will be difficult.  But that's exactly the
point.  It will be difficult because crucial distinctions are
presently hidden.  The implicit must be made explicit, no matter how
much work it takes.

EKR

-- 
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