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.