ENB: Plans for Leo's gui code

16 views
Skip to first unread message

Edward K. Ream

unread,
May 1, 2026, 8:42:41 AM (2 days ago) May 1
to leo-editor
This Engineering Notebook post discusses how I plan to complete work on Leo's gui code. This post mostly contains notes to myself. Most of this post discusses  LeoKeyEvent.__init__, the event ctor

Status

PR #4646 contains the first round of work. The highlights:

- The event ctor no longer sets event.w.
- The following code replaces the evil eventWidget method:

w = event.w if event else None
if not g.isTextWrapper(w):
   return <maybe some value>

I considered replacing the code with just:

w = event.w

But that would be extremely unwise. The guards are cheap and ensure that the protected code can't throw an exception, regardless of what its callers have done.

Code cleaning

The PR changes numerous files in harmless ways. In particular, when looking at the results of cff's, it's annoying not to know what class contains a particular method. I've added class or file names to many headlines to help. The PR lists other minor changes.

Future plans

I'll merge PR 4646 soon. I'll then create one or more PRs for more substantial work as follows.

Issue #4652 suggests fixing three smallish gui-related bugs. I could tackle those quirps at any time, but first I'd like to improve the event ctor.

In effect, this ctor is a series of tests. These tests should ensure that event.w points to a QTextMixin wrapper class if and only if the wrapped Qt widget is either QTextEdit or a QLineEdit. The details are surprisingly tricky.

At present, Leo doesn't always create wrappers for QTextEdit or QLineEdit widgets.  The event ctor creates "emergency" wrappers for such "bare" Qt text widgets. Future PRs will create such missing wrappers and ensure that all text wrappers support Leo's standard key bindings.

​A ground rule: ​future PRs will not change the signatures of any methods​, nor will they rename any ivars!

Summary

PR #4646 removes the event.widget ivar and uses the code shown above to protect all of Leo's commands. This is a milestone.

One or more future PRs will create text wrappers for all text-related Qt widgets, ensuring that Leo's standard key bindings are active in all text widgets.

Edward
Reply all
Reply to author
Forward
0 new messages