Re: RDS! ed in FreeBSD
- Posted by "C. K. Lester" <euphoric at cklester.com> Oct 16, 2003
- 456 views
Robert Craig wrote: > C. K. Lester wrote: > >> Rob, I've found the problem. >> >> ed.ex uses wait_key() to get user input. >> key.ex uses get_key() to get user input. >> >> get_key() returns the right keycode. wait_key() returns something else. >> >> When I substitute "wait_key()" for "get_key()" in key.ex, I get THREE >> codes output. For instance, when get_key() receives an up arrow, it >> outputs 259. When wait_key() receives an up arrow, I get 27, 79, 65, all >> one after the other. > > Some systems generate a series of 3 codes for certain special > keys. The function next_key() in ed.ex has the logic for > handling single or triple key codes, but it doesn't expect > the arrow keys to come through as triples. I guess you'll have > to modify next_key() to detect when the sets of three codes > that represent arrow keys come through. > Right now it only handles Home and End. It looks > for 27 then 79, then 0 for Home or 101 for End. You'll have > to add elsif's for 65 and and the other keys. > > Maybe you can trace ed.ex and see what it does > when you hit an arrow key. You mean you don't know?! It's your program! :) Okay, the arrow keys also return the 27 then 79 then a special number, so that should be easy to modify. However, I tested out the CTRL+Home and CTRL+End (keystrokes which I must have) and they have FIVE returned numbers! whew.