develooper Front page | perl.perl5.porters | Postings from January 2012

Re: [perl #108470] Term::ReadLine should use AE instead of Tk for event looping

Darin McBride
January 20, 2012 12:01
Re: [perl #108470] Term::ReadLine should use AE instead of Tk for event looping
Message ID:
On Wednesday January 18 2012 3:44:47 PM you wrote:
> Unless you can get someone else familiar with this to sign off on the
> patch, I would have to spend some time studying it myself before I feel
> comfortable applying it.

Not sure who that'd be :-)

> It would make testing easier if you could avoid non-core modules (fewer
> modules for people to install to make sure they don’t break things).

Fair enough.  I'll obviously need AE and Tk for the AE and Tk tests, but I've 
avoided all other non-core modules.

> It would make testing even easier if you could use a mock object
> (preferably in addition to the AE/Tk tests).

I'm not entirely clear how.  I need to ensure that the loop is called at all.

A couple things I noticed.  First, T::RL::Stub has its own get_line.  This 
does not honour the tkRunning flag at all.  If I remove it, it's fine.  My new 
patch does so.

Second, get_line only calls the event loop prior to any characters being 
typed.  That is, once you start typing, the event loop stops.  I expect this 
to be a limitation of a "stub" readline.  I do not plan on fixing this, though 
it is a bug/limitation.  It would be far too complex for what has been a 
trying thread already :-)  A fix could be to have get_line call get_c for each 
character (implicitly trying the event loop again), but then it would have to 
handle special characters (at least \b and \n, though <- and -> would be 
nice).  I'll leave that to another day, as I expect most people that are 
running event loops with T::RL are going to be interested in a full RL 
implementation (::Gnu or ::Perl).

Please find attached the new patch.  It includes the get_line removal above 
plus three brand new .t files.  I first attempted to feed stuff in through a pipe 
- it wasn't working.  So then I realised that I just need to test that the 
event loop is called at all, so I could really exit immediately from there.  
Thus, that's what I'm doing here. Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About