| | |
reading key combinations
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
hi .. im doin an assignment on edlin text editor..
while implementing the insert new line function i need to exit a loop when a key combination is pressed..
inside the loop there will be some lines reading input from the user..so will be somting like below
while( ? )
{
getline(........
}
for example when user presses "<ctrl> + c" it should exit the loop.
........i cant figure out how to implement this .... some one plz help me .... my assignment is due dayafter. ..thanks
while implementing the insert new line function i need to exit a loop when a key combination is pressed..
inside the loop there will be some lines reading input from the user..so will be somting like below
while( ? )
{
getline(........
}
for example when user presses "<ctrl> + c" it should exit the loop.
........i cant figure out how to implement this .... some one plz help me .... my assignment is due dayafter. ..thanks
There are many solutions to this problem, but I'm going to assume you are not using curses or terminal libraries.
With gdb, break just after the getline (..) statement as see what the input buffer contains and then formulate your code based on that. For example let's say pressing F3 sends a 3 byte combination (EC 7F 03). Then
NOTE: This code doesn't represent actual circumstanses but rather how the key combination could be trapped base on this hypothetical situaltion.
With gdb, break just after the getline (..) statement as see what the input buffer contains and then formulate your code based on that. For example let's say pressing F3 sends a 3 byte combination (EC 7F 03). Then
C++ Syntax (Toggle Plain Text)
switch (Buffer [0]) { case 0xEC: ; Because a function key always has 3 bytes we might assume next is 7F. if (Buffer [2] == 3) { ; Do whatever is required base on F3 key } }
![]() |
Similar Threads
- Sony Vaio Fn key problem (USB Devices and other Peripherals)
- Broken Fn Key (USB Devices and other Peripherals)
- Keyboard Problem (USB Devices and other Peripherals)
- Seeking Consultant (Internet Marketing Job Offers)
- reading a key without stoping the loop (C++)
- Boot probs (Windows 95 / 98 / Me)
- BitchX + Terminal issue (Mac Software)
Other Threads in the C++ Forum
- Previous Thread: fstream and saving to a:\
- Next Thread: Ze SDL way to do multimedia programming
| Thread Tools | Search this Thread |
api array arrays based binary bitmap c++ c/c++ calculator char char* class code coding compile console conversion count data database delete deploy desktop developer dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math matrix memory multiple news node number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





