This post discuss the next phase of curses gui prototype. This is an 
Engineering Notebook post, of interest only to devs.

This second phase is a crucial intermediate step. It should be doable in a 
few hours.

*Phase 1 summary*1. contains three functional classes 
CursesGui, CursesFrame and CursesMenu, and one disabled class, CursesLog.

2. The cursesGui ctor set self.consoleOnly = True, which tells g.trace to 
use print immediately for traces instead of queuing up traces for Leo's log 
window.  Today's work will start with making things work when is False. This will queue traces for later.

2. GG.runMainLoop is just barely functional:

    def runMainLoop(self):
        '''The curses gui main loop.'''
        w = curses.initscr()
        w.addstr('enter characters: x quits')
        while 1:
            i = w.getch() # Returns an int.
            ch = chr(i)
            if ch == 'x': break

The call to curses.initscr() erases the entire console, including all 
traces generated by g.trace.

*Phase 2 design and process*

1. CG.runMainLoop should implement Leo's log pane in a (scrollable?) curses 
text widget of some kind. The initial contents of this widget will be the 
queued log messages generated during startup. This step will enable and 
revise the CursesLog class, which is presently commented out. This class 
started life as a copy of the LeoQtLog class.

2. CG.runMainLoop should translate key w.getch key codes to LeoKeyEvent 
objects and call c.k.masterKeyHandler, where c is the first loaded 
outline.  I'm guessing c will be available as  In effect, this 
step rewrites LeoQtEventFilter.

And that's it.  The only knowledge needed was/will be:

A. Remembering yesterday's consoleOnly workaround.
B. Knowing that we need to rewrite the keystroke portion LeoQtEventFilter 
so it calls k.masterKeyHandler.
C. Knowing that the LoadManager class is the proper place to start 
single-stepping through code to see why log messages get eaten, as they 
will when gets set back to False :-)


Phase two of the curses prototype is a crucial intermediate step.  It will 
capture all log messages in a curses text widget so that they aren't lost 
after calling curses.initscr(). More importantly, CG.runMainLoop will call 
k.masterKeyHandler.  *This will allow Leo to execute commands*. We will see 
the effects of those commands *only *via enabled traces, but *those traces 
will show up in the new curses log widget*.

I expect to finish phase two today. It should be straightforward, provided 
a proper curses text widget can be found. I am hoping that npyscreen 
<>widgets will suffice. We 
shall see...

The third and final phase of this project will be to implement most of 
Leo's gui elements using curses/npyscreen widgets. Leo's menu, icon bar and 
status areas are optional, as are most subsidiary tabs of the log widget. 
This last phase is still a big deal. It remains to be seen how useful 
npyscreen will be.


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 post to this group, send email to
Visit this group at
For more options, visit

Reply via email to