"paste" problem when reading user command from console

K

kimso.zhao

Hi all,

When I tried reading user command from console, I use "select" to wait
for user input in order to improve efficiency. But when it comes to
dealing with user pasting a command, there is a problem. Only the first
character of the pasted command can be displayed. But the command is
actually there, if you typed any one more key, the whole pasted command
will be displayed. Here is the code. Do you have any way to get through
this? Thanks.

while {
select_result = select (1, &read_fds, 0, 0 , NULL); // listen
for user input from stdin
// error handling for select function.
ch = getch();
printf("%c",ch);
}


Problem - when you paste a comand, e.g. activate, only the first
charcter 'a' is printed, and if you type any one more key, the whole
command "activate" will be printed.
 
H

Howard

Hi all,

When I tried reading user command from console, I use "select" to wait
for user input in order to improve efficiency. But when it comes to
dealing with user pasting a command, there is a problem. Only the first
character of the pasted command can be displayed. But the command is
actually there, if you typed any one more key, the whole pasted command
will be displayed. Here is the code. Do you have any way to get through
this? Thanks.

while {
select_result = select (1, &read_fds, 0, 0 , NULL); // listen
for user input from stdin
// error handling for select function.
ch = getch();
printf("%c",ch);
}


Problem - when you paste a comand, e.g. activate, only the first
charcter 'a' is printed, and if you type any one more key, the whole
command "activate" will be printed.

Those look like platform-specific commands to me. You should ask in a
newsgroup devoted to your platform. Windows, perhaps?

-Howard
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top