reading key combinations

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Feb 2005
Posts: 2
Reputation: samyn is an unknown quantity at this point 
Solved Threads: 0
samyn's Avatar
samyn samyn is offline Offline
Newbie Poster

reading key combinations

 
0
  #1
Feb 19th, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 199
Reputation: Tight_Coder_Ex is an unknown quantity at this point 
Solved Threads: 14
Tight_Coder_Ex's Avatar
Tight_Coder_Ex Tight_Coder_Ex is offline Offline
Junior Poster

Re: reading key combinations

 
0
  #2
Feb 19th, 2005
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

  1. switch (Buffer [0]) {
  2. case 0xEC:
  3. ; Because a function key always has 3 bytes we might assume next is 7F.
  4. if (Buffer [2] == 3) {
  5. ; Do whatever is required base on F3 key
  6. }
  7. }
NOTE: This code doesn't represent actual circumstanses but rather how the key combination could be trapped base on this hypothetical situaltion.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 2
Reputation: samyn is an unknown quantity at this point 
Solved Threads: 0
samyn's Avatar
samyn samyn is offline Offline
Newbie Poster

Re: reading key combinations

 
0
  #3
Feb 19th, 2005
thanks for ur reply but i didn quite undestand the above...
how do i get the raw input??

im using dev-c++ by the way...
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC