This post discusses the next step of the curses gui project. It will be of 
interest only to devs.

The Null gui uses Null (string-based) widgets. The Qt gui uses actual Qt 
widgets. The curses gui uses npyscreen widgets. Leo's core knows *nothing* 
about these actual widgets.

Instead, Leo's core accesses and controls the underlying widgets of 
whatever gui is in effect using *wrapper objects*.  The wrapper objects 
hide the details of the underlying widgets.

The CursesBody class in cursesGui2.py contains just a single wrapper for 
the body pane, set during startup.

The CursesTree class has a more complex task. Here are the wrapper methods 
that must be defined in subclasses, with their present do-nothing 
definitions.  

    def editLabel(self, p, selectAll=False, selection=None):
        pass
    
    def edit_widget(self, p):
        return None
    
    def redraw(self, p=None, scroll=True, forceDraw=False):
        pass
    
    def redraw_now(self, p=None, scroll=True, forceDraw=False):
        pass
    
    def scrollTo(self, p):
        pass
    
    def setHeadline(self, p, s):
        pass

In particular, the editLabel, edit_widget and setHeadline methods require 
access to the wrappers for *individual* headlines.  The edit_widget method 
must "deliver" an *abstract* widget, that is, *another* wrapper.  This will 
be an instance of the CursesLineEditWrapper class, a subclass of the 
CursesTextMixin class.

Actually getting and setting headline text, insert point and selection 
range is straightforward. The CursesTextMixin class will handle that. The 
complex part will be associating lines of the npyscreen tree widget with 
CursesLineEditWrapper instances.  This will require various Python dicts, 
set (iirc) by LeoTree.redraw.

It's pointless to go into more detail.  It's only necessary for devs to 
note the general complications.

*Summary*

The CursesTree class a subclass of the leoFrame.LeoTree class, defined in 
leoFrame.py.  Leo's core uses the interface in leoFrame.LeoTree to control 
the outline pane.  Implementing the CursesTree class involves dynamically 
creating headline wrappers (CursesLineEditWrapper objects) for all nodes of 
the outline, visible or not. The CursesTree class will maintain Python 
dicts referencing these headline wrappers so the wrapper for any position p 
can be found without searching the outline.

The CursesBody class is much simpler, but its purpose is exactly the same: 
to allow Leo's core to drive the underlying gui widgets.

These wrapper classes allow new guis to be created *without changing a 
single line* of Leo's core. If you doubt this statement, check the git logs.

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.

Reply via email to