Re: [code] spawn: blocking

From: Mitchell <m.att.foicica.com>
Date: Wed, 7 May 2014 23:54:15 -0400 (EDT)

Hi Richard,

On Wed, 7 May 2014, Richard Philips wrote:

> Hi Mitchell,
>
> The spawn functionality is a tremendous asset for textadept!
>
>
> Thank you for that!
>
>
>
> .. and now for the inevitable questions :-)
>
>
> I'm trying to make spell checking available for textadept users on Windows.
> For Linux users, I solved this by using the ffi features of LuaJIT. This
> does not work that well on Windows. This is not a fault of LuaJIT but in
> differences in 32-bit versus 64-bit etc.
>
> So, I try a different approach:
>
> The first time the user asks for spell-checking, I launch a 'spell server'
> (hunspell.exe) by means of the spawn machinery in Textadept. From then on,
> the spell server keeps running.
>
> The idea is to query this server (writing the query on its stdin) and
> receiving the answer in its stdout.
>
> By means of the callbacks, spawn provides in everything.
>
> Except ...
>
> 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 think I can accomplish this by running an infinite loop in Lua (with a
> break based on something which is set in stdout_cb) but is this the right
> way to go?

For now that seems to be the only way. I should look into adding a
'read()' method that blocks for stdout.

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 Wed 07 May 2014 - 23:54:15 EDT

This archive was generated by hypermail 2.2.0 : Thu 08 May 2014 - 06:26:26 EDT