On Saturday, April 14, 2018 at 6:06:05 AM UTC-5, Edward K. Ream wrote:
This post discusses my present thinking about key handling.
>
The project is going well. My recent cff studies have given me a deep
knowledge of what needs to be done.
I am proceeding methodically: Investigate using cff, make a small change,
run pylint and unit tests, commit. No more using crashes as the primary
form of testing :-)
*Names and renaming*
The Naming of Cats is a difficult matter,
It isn't just one of your holiday games;
Yesterday I did the renaming mentioned in the first post. The term
"shortcut" is on its way out. I also eliminated unnecessary asserts. Using
names to indicate intent is much more flexible than using asserts.
One change in plan: I changed si to bi, *not *binding_info. It was annoying
to use binding_info. It is used enough to deserve a shorter name.
When I awoke today I saw that we needed these new methods:
- *k.parse_binding(aString)*
Convert a user binding line (from a setting), to a modifier list and the
"tail". This will collapse the complexity of k.strokeFromSetting, because
it won't need to "canonicalize" anything.
*The name is important*: it will *not* create a g.KeyStroke, but only the
args used to create a stroke. Indeed, p.parse_binding certainly should know
*nothing* about strokes.
*- ks.finalize()*This will do all last-minute munging needed to "normalize"
ks.char. Leo's core should not have to know picky keystroke-related
details, like those for MacOS and German keyboards.
*- ks.isPlain()*
Will replace k.isPlainKey. The KeyStroke class is the logical place for
this method, and can compute its result more easily than k.isPlainKey.
*Refactor filter.toTkKey to filter.parse_event*
k.parse_binding will handle user setting lines. The "other end" of key
handing is filter.toTkKey. At present, this converts a Qt QKeyEvent into a
*fragile* (*canonicalized*) string (tkKey). The docstring says:
tkKey: the Tk spelling of the event used to look up bindings in
k.masterGuiBindingsDict.
**This must not ever change!**
Hah! This docstring is out of date. The keys of the
k.masterGuiBindingsDict are *already* KeyStroke objects. ks.__hash__
already exists.
I'll rename filter.toTkKey to filter.parse_event. This will return the
*components* of a KeyStroke, just like k.parse_binding will do. Not having
to "canonicalize" anything will simplify the code and make the code more
robust.
Other refactorings and simplifications should be possible. In particular,
I'll move as many key-related dicts from the KeyHandlerClass into the
LeoQtEventFilter class. Putting dicts where they are belong will help.
*Summary*
Renaming has already clarified the code significantly. Ditto for
eliminating sclerotic asserts.
k.parse_binding will collapse the complexity of the "settings end" of key
handling.
filter.parse_event will simplify the "Qt end" of key handling.
An improved KeyStroke class will provide a "target" for both ends of key
handling.
Simplifying the *construction *of KeyStroke objects is paramount. However,
it may be possible to simplify how Leo's core *uses* KeyStroke objects. We
shall see.
These plans are base on deep knowledge of the code, gained by many cff's. I
have been consulting the code as I write this post.
This project should be completed in 3 days to a week. We can then begin
prolonged testing in the keys2 branch. Only when all is clear will I merge
keys2 into master.
Edward
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.