On Friday, August 1, 2014 9:25:45 AM UTC-5, Edward K. Ream wrote:
> Just two or three more comments and then I'll be on to coding...
Two or three or four more:
1. It's easy to find the hooks for (interface to) vim mode. Just look for
c.vim_mode (or even just c.vim) in leoKeys.py. This is how I'll find the
hooks two months from now ;-)
2. Each hook has the following general form::
if c.vim_mode and c.vimCommands:
c.vimCommands.do_something()
return
This pattern is why we can be *absolutely* sure that vim emulation has no
effect on Leo if @bool vim_mode = False.
The all-important call to vc.do_key in k.masterKeyHandler is::
if c.vim_mode and c.vimCommands:
ok = c.vimCommands.do_key(event)
if trace: g.trace('vc.do_key returns',ok)
if ok: return
That is, do_key returns True if it claims to have completely handled the
key. Otherwise, k.masterKeyHandler handles the key *exactly* as before. I
emphasize these simple-seeming lines because they (and their location!) are
the heart of the clean interface.
3. There is a small, simple, important hack in vc.do_key. In one place we
need the following lines::
val = f() # This may set vc.next_func again.
# A hack. A simple return implies we have handled the key fully.
if val is None: val = True
The effect that handlers for particular *single* keys usually just return.
They only need to return "False" if they have discovered that they can't
really handle the key. Alternatively, I suppose they could set a "fail"
flag.
In any case, communication between the various mode handlers and their
delegates is tricky and crucial. It's possible that it will be completely
rewritten. Even so, the code in k.masterKeyHandler is likely to remain
unchanged.
4. Eventually, I plan to create leoVimUnitTests.leo. It will have @bool
vim_mode = True, and will contain all vim-mode-specific unit tests. I
expect to build in support for such commands in leoVim.py...
That's all that's in the bean for now...
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 http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.