$stdin.gets, threads, and command-line app.

X

Xav Xav

Hi,

I am currently working on a console-based app, in which the user
interacts by entering commands from within a prompt (e.g. sort of a
bash-like app).
One thread for the prompt, some others for computation.
I allowed those threads to output to the console, but it leads to a
really not user-friendly behaviour. Example:

prompt: lis <- started to type in the "list" command
Blablabla from Thread1 <- output to $stdin by threads
prompt: <- The prompt is re-displayed, the command
"seems" lost

prompt: list <- Type again the command "list"
Error: lislist: Unknown command

See my problem?
How can I get the exact text line to be displayed after a thread output
its message? Or How can I catch a partially typed input?
I thought of syscalls, but didn't get any results yet.

[Note: Obviously, if I had only input "t" after the thread had
displayed, my command would have been correctly interpreted]
 
M

Mark

I think your problem is the same as the one I posted a few hours ago.

Please look for subject "Trouble using puts and getc in different threads".

Mark
 
X

.x av

Paul said:
By not using threads.

In this problem, one should consider the output generated by the threads
is not context-sensitive (or command-sensitive). It is a monitoring app,
I do need to be informed of any event in realtime (by "outputting" to
the console) while not messing up my input (or messing it up the least
possible ;) )

I hope I made myself a little clearer.


But I suppose you're right. I'll try building of a single-threaded-IO
based architecture. Thinking of it, maybe callback procedures may
help...
 
E

Eero Saynatkari

--56fysGXq5VVjE/ND
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi,
=20
I am currently working on a console-based app, in which the user=20
interacts by entering commands from within a prompt (e.g. sort of a=20
bash-like app).

If you are working on a shell, you are welcome to help with rs[1]. If
you are just doing it for learning purposes or implementing a command-
line program, you can use HighLine[2]

[1] http://projects.kittensoft.org/rs/rdoc/index.html
[2] http://highline.rubyforge.org

--56fysGXq5VVjE/ND
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (FreeBSD)

iD8DBQFFPYzS7Nh7RM4TrhIRAtgeAJsG5dG4N2s5qMOExG4iZrZklfHDmwCgufew
r7vPYxznDoijDsO9SFM6/ms=
=KSo8
-----END PGP SIGNATURE-----

--56fysGXq5VVjE/ND--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top