home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume1 / 8707 / 68 < prev    next >
Encoding:
Internet Message Format  |  1990-07-13  |  3.6 KB

  1. From: amos@nsta.UUCP (Amos Shapir)
  2. Newsgroups: comp.sources.misc
  3. Subject: Re: A Function Key maintenance program for HP2392a and clones
  4. Message-ID: <3654@ncoast.UUCP>
  5. Date: 28 Jul 87 00:24:56 GMT
  6. Sender: allbery@ncoast.UUCP
  7. Organization: National Semiconductor (Israel) Ltd. Home of the 32532
  8. Lines: 138
  9. Approved: allbery@ncoast.UUCP
  10. Summary: This one's for vt220 & clones
  11. X-Archive: comp.sources.misc/8707/68
  12.  
  13. The above-mentioned program reminded me of a program I wrote to do exactly
  14. that on a TeleVideo 9220, which is basically a vt220 clone. This program
  15. also works on a real VT220, in 7 bits mode, but only for shifted function
  16. keys (the VT220 can't program unshifted keys). I didn't check it
  17. on other clones, but it's fairly standard.
  18.  
  19.         o /        o /        o /        o /
  20. -----------------X---------------X---------------X---------------X----
  21.         o \        o \        o \        o \
  22.  
  23. #!/bin/sh
  24. # shar:    Shell Archiver
  25. #    Run the following text with /bin/sh to create:
  26. #    tvprg.1
  27. #    tvprg.c
  28. # This archive created: Sun Jul 26 09:55:59 1987
  29. sed 's/^X//' << \SHAR_EOF > tvprg.1
  30. X.TH TVPRG 1 
  31. X.SH NAME
  32. Xtvprg \- program function keys of a TeleVideo 9220 terminal
  33. X.SH SYNOPSIS
  34. X.B tvprg
  35. X[-v] f\fIn\fP string
  36. X.PP
  37. X.B tvprg
  38. XF\fIn\fP string
  39. X.SH DESCRIPTION
  40. X.I Tvprg
  41. Xgenerates the escape sequence to program function key
  42. X.I n
  43. Xon the a TeleVideo 9220 terminal's keyboard,
  44. Xto send the given
  45. X.I string
  46. Xto the host. 
  47. XIf the key name is given as F\fIn\fP, it will be programmed to send
  48. X.I string
  49. Xwhen shifted. Special (unprintable) characters are denoted by the
  50. Xback-slash ('\\') notation, as used in C.
  51. X.PP
  52. XProgrammable keys are f6 through f20;
  53. Xthe 'Help' and 'Do' keys are considered f15 and f16, respectively.
  54. X.PP
  55. XWith the
  56. X.B -v
  57. Xflag, the arguments are also echoed to the output after the programming
  58. Xsequence; this is useful as a comment when saving \fItvprg\fP's output
  59. Xin a file for future use.
  60. X.SH AUTHOR
  61. XAmos Shapir, NSTA
  62. X.SH "SEE ALSO"
  63. XTeleVideo 9220 Operator's Manual
  64. X.SH BUGS
  65. XDue to braindamage of the terminal's firmware, keys must be programmed
  66. Xin sequential order.
  67. SHAR_EOF
  68. sed 's/^X//' << \SHAR_EOF > tvprg.c
  69. X/* program TeleVideo9220's function keys */
  70. Xint vflg;
  71. Xmain(argc, argv)
  72. X    char **argv;
  73. X{
  74. X    register n, c;
  75. X    register char *s;
  76. X
  77. X    if(argc>1 && argv[1][0]=='-' && argv[1][1]=='v') {
  78. X        vflg++;
  79. X        argc--;
  80. X        argv++;
  81. X    }
  82. X    if(argc!=3 || *(s=argv[1])!='f' && *s!='F'
  83. X     || (n=atoi(s+1))<6 || n>20) {
  84. X        puts("Usage: tvprg [-v] {fn,Fn} string\n");
  85. X        exit(1);
  86. X    }
  87. X    n += 11;
  88. X    if(n>=22)
  89. X        ++n;
  90. X    if(n>=27)
  91. X        ++n;
  92. X    if(n>=30)
  93. X        ++n;
  94. X    if(*s == 'f')
  95. X        n += 20;
  96. X    puts("\033P1;1;1|");
  97. X    putb(n, 10);
  98. X    putchar('/');
  99. X    s = argv[2];
  100. X    while(c = *s++) {
  101. X        if(c=='\\')
  102. X            switch(c = *s++) {
  103. X            case 'b': c = '\b'; break;
  104. X            case 't': c = '\t'; break;
  105. X            case 'n': c = '\n'; break;
  106. X            case 'v': c = '\v'; break;
  107. X            case 'f': c = '\f'; break;
  108. X            case 'r': c = '\r'; break;
  109. X            default:
  110. X                if(c>='0' && c<='7') {
  111. X                    --s;
  112. X                    for(n=c=0; n<3 && *s>='0' && *s<='7'; n++)
  113. X                        c = (c<<3)+*s++-'0';
  114. X                }
  115. X            }
  116. X        putb(c, 16);
  117. X    }
  118. X    puts("\033\\");
  119. X    if(vflg) {
  120. X        puts(argv[1]);
  121. X        puts(" = ");
  122. X        puts(argv[2]);
  123. X    }
  124. X    puts("\n");
  125. X}
  126. X
  127. Xputb(n, b)
  128. X    register n, b;
  129. X{
  130. X    register c;
  131. X
  132. X    c = n/b;
  133. X    putchar(c+(c<=9?'0':'A'-10));
  134. X    c = n%b;
  135. X    putchar(c+(c<=9?'0':'A'-10));
  136. X}
  137. SHAR_EOF
  138. #    End of shell archive
  139. exit 0
  140.  
  141.         o /        o /        o /        o /
  142. -----------------X---------------X---------------X---------------X----
  143.         o \        o \        o \        o \
  144. May the Source be with you, always...
  145. -- 
  146.     Amos Shapir            (My other cpu is a NS32532)
  147. National Semiconductor (Israel)
  148. 6 Maskit st. P.O.B. 3007, Herzlia 46104, Israel  Tel. (972)52-522261
  149. amos%nsta@nsc.com @{hplabs,pyramid,sun,decwrl} 34 48 E / 32 10 N
  150.