[Twisted-Python] using stdio with Twisted

Neurophyre listbox at evernex.com
Tue Mar 20 13:02:36 MDT 2007


On Mar 20, 2007, at 4:13 AM, Jean-Paul Calderone wrote:

> Take a look at what twisted.conch.stdio.runWithProtocol does to the  
> terminal.
> That's more or less what's necessary to kick it out of line  
> buffered mode and
> give you each keystroke as it arrives.

Thanks for this pointer.  I'm going to try rewriting my terminal I/O  
code, what little of it there is, to use that this morning.

> TerminalProtocol is meant to be used with ServerProtocol from the  
> same module.
> ServerProtocol will interpret various terminal control sequences  
> and translate
> them into calls onto whatever ITerminalProtocol you supply to it.   
> It probably

After looking at your invective code a second time (somebody in  
#twisted pointed me to it last night) I'm still not entirely sure how  
ServerProtocol integrates.  It seems like you're mainly just using it  
as a sort of container of constants to interpret special keystrokes  
(like alt-whatever, or backspace or similar) and in the test cases to  
produce such sequences.  Is that its main use?

> what to do with.  There are a couple other things you might be  
> interested in
> though, like twisted.conch.recvline.RecvLine or a class in a  
> project I've been
> working on a bit on and off, invective.widgets.LineInputWidget,  
> which uses
> insults' widget system to implement a more re-usable line input  
> class (you can
> find invective in my Twisted sandbox,

Yep, I think twisted.conch.recvline.RecvLine may be what I'm looking  
for.  My program needs to respond to keystrokes in some cases, and  
allow line editing in others -- message entry, for example.

Thanks again for your help and I'll probably be back here with more  
questions at some point.

--Neuro





More information about the Twisted-Python mailing list