home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / hp / 14800 < prev    next >
Encoding:
Internet Message Format  |  1993-01-12  |  2.5 KB

  1. Xref: sparky comp.sys.hp:14800 comp.lang.c:19608
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!hpscit.sc.hp.com!hpdstma!dave
  3. From: dave@hpdstma.ptp.hp.com (Dave Waller)
  4. Newsgroups: comp.sys.hp,comp.lang.c
  5. Subject: Re: capturing a keystroke
  6. Date: 13 Jan 1993 00:33:08 GMT
  7. Organization: Hewlett Packard
  8. Lines: 51
  9. Sender: dave@hpdstma (Dave Waller)
  10. Distribution: world
  11. Message-ID: <1ivo04INNhr8@hpscit.sc.hp.com>
  12. References: <1993Jan7.145947.9534@iccgcc.decnet.ab.com>
  13. NNTP-Posting-Host: hpdstma.ptp.hp.com
  14.  
  15. In article <1993Jan7.145947.9534@iccgcc.decnet.ab.com>, weisfeld@iccgcc.decnet.ab.com writes:
  16. |> Everything is working fine, except for the arrow keys. When I enter a
  17. |> single character (say an 'R'), I get the expected character code. However,
  18. |> when I enter an arrow key, the cursor simply moves on the screen and no
  19. |> character code is returned. The HP manual states that in LOCAL MODE
  20. |> the system displays control codes but does not execute them. It states that,
  21. |> if you press the left arrow key, the terminal displays an escape character
  22. |> on the screen but does not perform the cursor left function. I put the 
  23. |> machine in LOCAL MODE and the cursor still moves.
  24.  
  25. This is the normal operation of HP terminals and terminal emulators. What you
  26. need to do is turn on the transmit functions capability of the terminal or
  27. terminal emulator, which can be done is a variety of ways.
  28.  
  29. One way is to simply output the escape sequence that turns this capability
  30. on with a printf() call as follows:
  31.  
  32. printf("\033&s1A");
  33.  
  34. This will enable the transmission of escape codes representing each of the
  35. special keys (arrows, home, insert char, f1, f2, etc etc etc). The general
  36. form of this escape sequence is
  37.  
  38. \033&snA
  39.  
  40. where "n" is either 1 or 0, turning the transmit functions feature on or
  41. off respectively.
  42.  
  43. However, this method suffers from poor portability, and therefore is not
  44. a desirable way to accomplish this task. This escape code could have very
  45. undesirable consequences on a competitor's terminal.
  46.  
  47. A more portable way to turn on these keys is to use the curses library
  48. function keypad(), which will basically cause the same excape sequence to
  49. be sent on an HP machine, but will be portable to other platforms generating
  50. the correct escape sequences for the particular vendor.
  51.  
  52. A detailed discussion of HP escape codes can be found in the HP manual,
  53.  
  54. Terminal Control: Users Guide
  55. p/n  B1862-90013
  56.  
  57. with a complete listing of the excape codes in appendix C.
  58.  
  59. Hope this helps!
  60.  
  61. -- 
  62. Dave Waller
  63. Hewlett-Packard Co.
  64. Workstation Systems Division
  65. Sunnyvale Channel Partner Consulting
  66.