c++ - How could I read a Shift+Inserted (pasted) string In Linux / g++? -
i know how read keyboard in linux without stopping (like kbhit()
behavior under windows). so, whenever returns, know there key-press activity.
then i'll try read key via getch()
function.
my question after hit on keyboard, how know shift+insert key combination (paste shortcut ctrl+v in windows) pressed?
as noted, there no globally portable way accomplish because:
- aside special case of linux-specific program uses special calls detect key-presses, program see pasted text — no clues how got there.
- there likewise no clue when paste ended (pastes need not end newline, can words, blanks, etc).
instead, workable solution use posix termios make program's input stream work in raw mode, , set timeout reads. then, program read characters long came "quickly enough" (your decision how quickly).
these related questions show examples of posix termios, including use of timeouts:
alternatively, there select
call:
Comments
Post a Comment