|
From: <tim...@en...> - 2007-05-07 19:31:04
|
Hans-Bernhard Bröker wrote:
> Timothée Lecomte wrote:
>
>> 1st solution, as suggested previously = use two processes:
>> - this is the design of the x11 terminal. I don't like it, because I
>> find complicated to have to handle two processes and their
>> inter-communication where we really have one program (one task).
>
> I don't really believe inter-communication between threads to be any
> easier than inter-communication between processes, in the long run.
> More efficient it may be, but it's not easier. You basically pay for
> the extra speed by extra requirements on careful coding.
I agree that both are difficult, in different places.
Inter-communication in general seems to be worth avoiding.
>
>> 3rd solution = use one thread only (the most ambitious)
>> - the one and only thread is an event loop.
>> - "a char arrived on stdin" is handled as an event (this is natural,
>> isn't it?), and passed to readline
>> - the event loop is actually the GUI loop, just extended to watch
>> stdin in addition to window events
>
> That's pretty much the way the Windows native terminal has been doing
> things since day 1 (and in a pretty nasty way, too, overriding the
> <stdio.h> functions with macros of our own making). Which means a bit
> of synergy might be achievable if you go this way.
That's true, and wxt works on Windows thanks to this ! That's also why
I've been thinking about that.
>
>> Currently, we have:
>> while( readline(); do_line(); ) {};
>>
>> Instead we would have an event loop, with the following callbacks:
>> data_is_available_in_stdin() {rl_callback_read_char ();}
>> line_is_completed() {do_line();}
>
> Not necessarily. It's possible to lace the GUI event handling into
> the readline character input function instead.
>
Right, that's somehow the way it works on Windows (since the "message
loop" - from Windows terms - is in TermGetCH), and I guess it was part
of the intent when term->waitforinput was first introduced, since it is
used as a wrapper for getch().
But in that situation the GUI loop stays at a lower level, run by a
master loop waiting for commands input. I'd like to have a global and
single loop, with everything at the same level. I agree that it's not
that different, but it seems clearer to me.
Note that it's definitely the way the GNU Readline "alternate interface"
is designed to work
(http://www.delorie.com/gnu/docs/readline/rlman_41.html) (It is already
used in gnuplot, but I don't understand why... )
Thanks for your comments,
Best regards,
Timothée
|