Re: [code] spawn: blocking

From: Mitchell <m.att.foicica.com>
Date: Tue, 13 May 2014 17:42:27 -0400 (EDT)

Richard,

On Wed, 7 May 2014, Richard Philips wrote:

> Hi Mitchell,
>
> The spawn functionality is a tremendous asset for textadept!
>
> [snip]
>
> I would like to have a blocking feature (= waiting feature) based on the
> contents of the spell server's reply.
>
> e.g:
>
> proc = spawn('hunspell -a',nil,stdout_cb) -- launches server
>
> proc:write('&speling') -- checks 'speling'
>
> I could do a proc:wait() but that is not the intention. I would like to
> wait until the server writes "*" on its stdout (the '*' is the end of reply
> for the hunspell server)

I've added synchronous (blocking) `proc:read()` to the lspawn module, and
it should be available in tonight's nightly build. `proc:read()` takes the
same argument as Lua's `io.read()`, except for "*n". Also, make sure you
read all stdout available at one time, as stdout_cb requires the stdout
buffer to be empty to fire. (This will be documented in the proc API
documentation.)

Cheers,
Mitchell

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Tue 13 May 2014 - 17:42:27 EDT

This archive was generated by hypermail 2.2.0 : Wed 14 May 2014 - 06:51:48 EDT