[Twisted-Python] Embedding manhole interpreter into insults widget.

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Thu Aug 7 05:53:49 MDT 2014


On 6 Aug, 06:14 pm, lacrima.maxim at gmail.com wrote:
>Hello,
>
>I have been trying to create a widget that encloses manhole 
>interpreter.
>Here is somewhat hacky implementation that I came up with at this 
>moment:

Widgets and the manhole interpreter are implemented using two pretty 
distinct approaches.

As you've figured out, these approaches can be integrated (at least in 
one direction) using a terminal emulator - 
`twisted.conch.insults.helper.TerminalBuffer`.

However, `TerminalBuffer` is an extremely low quality terminal emulator. 
Among its many flaws is that it uses a number of incredibly inefficient 
implementations for common terminal operations (many of its other flaws 
are along the lines of "it has a bug in the implementation of X").

If I were going to create a manhole widget then I would do it "natively" 
- not by bridging the existing manhole protocol to the widget system 
with TerminalBuffer but by writing a new widget that does manhole stuff 
all by itself.

I suggest that you might want to pursue this approach instead of trying 
to optimize and fix bugs in TerminalBuffer.

Ultimately it would be nice if a widget-based manhole were *the* manhole 
and the current implementation went away.

However, that said, as far as I know, no vt-style terminals support 
efficient redrawing for the "vertically scroll one portion of the 
terminal separated from another portion by a vertical divider".

You will be able to avoid the redundant work of re-rendering the Python 
buffer representing the terminal state but you'll still have to re- 
transmit the bytes representing the entire terminal display to the 
terminal on each redraw - unless you avoid vertical dividers.

Jean-Paul




More information about the Twisted-Python mailing list