home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / misc / volume08 / keydef.fv < prev    next >
Encoding:
Internet Message Format  |  1991-08-27  |  40.2 KB

  1. From decwrl!sun-barr!cs.utexas.edu!uunet!allbery Fri Sep  8 21:40:02 PDT 1989
  2. Article 1071 of comp.sources.misc:
  3. Path: decwrl!sun-barr!cs.utexas.edu!uunet!allbery
  4. From: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  5. Newsgroups: comp.sources.misc
  6. Subject: v08i029: keydef2 - quickly, easily redefine VT[23]xx function keys
  7. Message-ID: <66799@uunet.UU.NET>
  8. Date: 7 Sep 89 02:04:03 GMT
  9. Sender: allbery@uunet.UU.NET
  10. Reply-To: fulvio@oliveb.ATC.Olivetti.Com (Fulvio MARINO)
  11. Lines: 1388
  12. Approved: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  13.  
  14. Posting-number: Volume 8, Issue 29
  15. Submitted-by: fulvio@oliveb.ATC.Olivetti.Com (Fulvio MARINO)
  16. Archive-name: keydef_fv
  17.  
  18. On 8 Aug 89 00:05:21 GMT, gordon@prls.UUCP (Gordon Vickers)
  19. submitted to "comp.sources.misc" (posting-number: Volume 7, Issue 55 -
  20. archive-name: keydef) via allbery@uunet.UU.NET (Brandon S. Allbery -
  21. comp.sources.misc) the Subject:
  22.    v07i055: keydef - quickly, easily redefine VT[23]xx function keys
  23.  
  24. This is my turn.
  25.  
  26. My keydef program makes the VT[23]xx (and compatibles) key definition
  27. in a different way than the Brandon's.  [Huh?  I just moderate.  ++bsa]
  28. I have NOT encountered the problems that he declared (half of the keys
  29. are not programmable, errors in downloading long definitions, etc.).
  30. This keydef can define the entire set of the user-defined keys; more,
  31. it can clean all the keys, and/or lock all them.
  32. Not X/OPEN (or SysV) users will need to edit one line in keydef.c to
  33. change the #include <string.h> to #include <strings.h>. I don't know
  34. if other changes are requested for the sites that are not X/OPEN.
  35.  
  36. My English is very bad, but I hope that you will read the manual page,
  37. at least to see all the features.
  38.  
  39.             Fulvio MARINO (fulvio@oliveb.ATC.Olivetti.Com)
  40.             Olivetti Ivrea, Italy- Sep 4 1989
  41.  
  42.  
  43. #! /bin/sh
  44. # This is a shell archive.  Remove anything before this line, then unpack
  45. # it by saving it into a file and typing "sh file".  To overwrite existing
  46. # files, type "sh file -c".  You can also feed this as standard input via
  47. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  48. # will see the following message at the end:
  49. #        "End of archive 1 (of 1)."
  50. # Contents:  MANIFEST NOREM README keydef.1u keydef.c keydef.man
  51. #   makefile sample
  52. # Wrapped by fulvio@xmrxos2 on Mon Sep  4 15:57:51 1989
  53. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  54. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  55.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  56. else
  57. echo shar: Extracting \"'MANIFEST'\" \(501 characters\)
  58. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  59. X   File Name        Archive #    Description
  60. X-----------------------------------------------------------
  61. X README                     1    Guess!
  62. X MANIFEST                   1    This shipping list
  63. X NOREM                1    List of precious file (see makefile)
  64. X keydef.1u                  1    Manual page
  65. X keydef.c                   1    The keydef program
  66. X keydef.man                 1    nroff -Tlp -man keydef.1u
  67. X makefile                   1    Make all, install and kit
  68. X sample                     1    A $HOME/.keydef for C-programmers
  69. END_OF_FILE
  70. if test 501 -ne `wc -c <'MANIFEST'`; then
  71.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  72. fi
  73. # end of 'MANIFEST'
  74. fi
  75. if test -f 'NOREM' -a "${1}" != "-c" ; then 
  76.   echo shar: Will not clobber existing file \"'NOREM'\"
  77. else
  78. echo shar: Extracting \"'NOREM'\" \(68 characters\)
  79. sed "s/^X//" >'NOREM' <<'END_OF_FILE'
  80. XMANIFEST
  81. XNOREM
  82. XREADME
  83. Xkeydef.1u
  84. Xkeydef.c
  85. Xkeydef.man
  86. Xmakefile
  87. Xsample
  88. END_OF_FILE
  89. if test 68 -ne `wc -c <'NOREM'`; then
  90.     echo shar: \"'NOREM'\" unpacked with wrong size!
  91. fi
  92. # end of 'NOREM'
  93. fi
  94. if test -f 'README' -a "${1}" != "-c" ; then 
  95.   echo shar: Will not clobber existing file \"'README'\"
  96. else
  97. echo shar: Extracting \"'README'\" \(883 characters\)
  98. sed "s/^X//" >'README' <<'END_OF_FILE'
  99. X
  100. XOn 8 Aug 89 00:05:21 GMT, gordon@prls.UUCP (Gordon Vickers)
  101. Xsubmitted to "comp.sources.misc" (posting-number: Volume 7, Issue 55 -
  102. Xarchive-name: keydef) via allbery@uunet.UU.NET (Brandon S. Allbery -
  103. Xcomp.sources.misc) the Subject:
  104. X   v07i055: keydef - quickly, easily redefine VT[23]xx function keys
  105. X
  106. XThis is my turn.
  107. X
  108. XMy keydef program makes the VT[23]xx (and compatibles) key definition
  109. Xin a different way than the Brandon's.
  110. XI have NOT encountered the problems that he declared (half of the keys
  111. Xare not programmable, errors in downloading long definitions, etc.).
  112. XThis keydef can define the entire set of the user-defined keys; more,
  113. Xit can clean all the keys, and/or lock all them.
  114. X
  115. XMy English is very bad, but I hope that you will read the manual page,
  116. Xat least to see all the features.
  117. X
  118. X            Fulvio MARINO (fulvio@oliveb.ATC.Olivetti.Com)
  119. X            Olivetti Ivrea, Italy- Sep 4 1989
  120. END_OF_FILE
  121. if test 883 -ne `wc -c <'README'`; then
  122.     echo shar: \"'README'\" unpacked with wrong size!
  123. fi
  124. # end of 'README'
  125. fi
  126. if test -f 'keydef.1u' -a "${1}" != "-c" ; then 
  127.   echo shar: Will not clobber existing file \"'keydef.1u'\"
  128. else
  129. echo shar: Extracting \"'keydef.1u'\" \(5314 characters\)
  130. sed "s/^X//" >'keydef.1u' <<'END_OF_FILE'
  131. X.TH KEYDEF local
  132. X.SH NAME
  133. Xkeydef - quickly / easily redefines VT2xx and VT3xx function keys.
  134. X.SH SYNTAX
  135. Xkeydef { [-c] [-l] [keyname1 keyname2 ...] }
  136. X.br
  137. Xkeydef [-f filename [keyname1 keyname2 ...]]
  138. X.SH DESCRIPTION
  139. XThe first sintax specification for the \fIkeydef\fP command is
  140. Xinteractive; at least one flag or a keyname must be specified. For
  141. Xeach \fIkeyname\fP, \fIkeydef\fP asks for its definition. The \fB-c\fP
  142. Xand \fB-l\fP flags have the same meaning, respectively, of
  143. Xthe \fIclear\fP and \fIlock\fP commands used in non-interactive mode
  144. X(see below). Definition follows the same sintax used not interactively.
  145. X.PP
  146. XUsing the 2nd form, \fIkeydef\fP reads its instructions
  147. Xfrom \fIfilename\fP; if \fIfilename\fP is "\fB-\fP", commands are taken
  148. Xfrom standard input, else if it is missing ("\fIkeydef\fP" with no
  149. Xarguments specified), then \fI$HOME/.keydef\fP is read.
  150. X.PP
  151. XCommands in \fIfilename\fP are specified in a shell-like sintax.
  152. XA command is a sequence of non-blank words separated by blanks (a blank
  153. Xis a tab or a space). The first word specifies the name of the command
  154. Xto be executed. Possible commands are \fIclear\fP (to clear all the
  155. Xdefinitions previously set), \fIlock\fP (to lock definitions: i.e.,
  156. Xall the User Defined Keys will be locked after the execution
  157. Xof \fIkeydef\fP -- keys unlock is possible only via Set-Up),
  158. Xor \fIkeyname\fP (to set a definition for \fIkeyname\fP function-key);
  159. X\fIkeyname\fP must be a valid name of a function key, and a
  160. X\fIdefinition\fP follows it.
  161. X.PP
  162. XA word beginning with \fB#\fP causes that word and all the following
  163. Xcharacters up to a new line to be ignored. Explicit null arguments
  164. X(\fB""\fP or \fB''\fP) are retained. A character may be quoted (i.e.,
  165. Xmade to stand for itself) by preceding it with a \fB\\\fP. The
  166. Xpair \fB\\newline\fP is ignored. All characters enclosed between a pair
  167. Xof quote marks (\fB''\fP or \fB""\fP), except the mark itself, are
  168. Xquoted; inside them, \fB\\\fP has no quoting properties.
  169. X.PP
  170. XValid \fIkeynames\fP are \fBF6\fP to \fBF20\f, and \fBS6\fP to \fBS20\fP
  171. X(referenced pressing both the \fBShift\fP and the function key). Some
  172. Xkeys are also referenced by the associated name (ESC, BS, LF, Help, Do).
  173. XType "\fIkeydef -\fP" to print the list of all the possible keynames.
  174. X.PP
  175. XThe (mandatory) argument of a \fIkeyname\fP command is the
  176. X\fIdefinition\fP for that key; inside it, \fB\\\fP and \fB^\fP have a
  177. Xspecial meaning. Certain characters may be represented according to the
  178. Xfollowing table:
  179. X.nf
  180. X
  181. X        CHARACTER       ASCII SYMBOL    ESCAPE SEQUENCE
  182. X
  183. X        newline(NL)          LF              \\n
  184. X        horizontal-tab       HT              \\t
  185. X        vertical-tab         VT              \\v
  186. X        backspace            BS              \\b
  187. X        carriage-return      CR              \\r
  188. X        formfeed             FF              \\f
  189. X        escape               ESC             \\e
  190. X        backslah             \\              \\\\
  191. X        single-quote         '               \\' or \\Q
  192. X        double-quote         "               \\D
  193. X        bit-pattern          ddd             \\ddd
  194. X
  195. X.fi
  196. XThe escape \fB\\ddd\fP consists of the backslash followed by 1, 2, or 3
  197. Xoctal digits, which are taken to specify the value of the desired
  198. Xcharacter. If the character following a backslash is not one of those
  199. Xspecified, the backslash is ignored. \fB^x\fP maps to a control-x for
  200. Xany appropriate x. To program a literal circumflex, preceed it with a
  201. Xbackslash.
  202. X.PP
  203. XA function key is executed by pressing one of the function keys
  204. X(\fBF*\fP), or by pressing SHIFT + function key (\fBS*\fP).
  205. X.SH WARNINGS
  206. XThere is a finite amount of memory in the terminal for storing the
  207. Xdefinitions. The exceeding characters are discharged.
  208. X.PP
  209. XTerminal is getting confused when any character is asynchronously
  210. Xreceived/typed during the execution of \fIkeydef\fP.
  211. X.PP
  212. XDepending on the terminal type and/or setting, not all the keys
  213. Xcan be programmed; typically, F11 (ESC), F12 (BS) and F13 (LF)
  214. Xcan be protected from the user's redefinition.
  215. X.PP
  216. XThis program has been developed and tested on an \fIOlivetti WS 685\fP
  217. Xdesktop video display terminal emulating DEC terminals VT220, VT100 and
  218. XVT52, connected via RS232 to an \fIOlivetti LSX-3010\fP with the \fIL2
  219. XX/OS R2.0\fP Unix System. You should not have porting problems on any
  220. XX/OPEN system.
  221. X.PP
  222. X.SH "SEE ALSO"
  223. XVT220 or VT320 Programmer Pocket Guide, and/or WS 685 User Guide.
  224. X.SH AUTHOR
  225. XFulvio MARINO, Olivetti, Ivrea, Italy (fulvio@oliveb.ATC.Olivetti.Com)
  226. X.PP
  227. XComments, suggestions, and patches welcomed.
  228. X.SH COPYRIGHT
  229. XCopyright (c) 1989 Olivetti S.p.A. Ivrea, Italy.
  230. X.br
  231. XAll rights reserved.
  232. X.PP
  233. XRedistribution and use in source and binary forms are permitted
  234. Xprovided that the above copyright notice and this paragraph are
  235. Xduplicated in all such forms and that any documentation,
  236. Xadvertising materials, and other materials related to such
  237. Xdistribution and use acknowledge that the software was developed
  238. Xby the Olivetti S.p.A., Italy.  The name of Olivetti S.p.A. may
  239. Xnot be used to endorse or promote products derived from this
  240. Xsoftware without specific prior written permission.
  241. X.br
  242. XTHIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  243. XIMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  244. XWARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  245. END_OF_FILE
  246. if test 5314 -ne `wc -c <'keydef.1u'`; then
  247.     echo shar: \"'keydef.1u'\" unpacked with wrong size!
  248. fi
  249. # end of 'keydef.1u'
  250. fi
  251. if test -f 'keydef.c' -a "${1}" != "-c" ; then 
  252.   echo shar: Will not clobber existing file \"'keydef.c'\"
  253. else
  254. echo shar: Extracting \"'keydef.c'\" \(13595 characters\)
  255. sed "s/^X//" >'keydef.c' <<'END_OF_FILE'
  256. X/*
  257. X * Copyright (c) 1989 Olivetti S.p.A. Ivrea, Italy.
  258. X * All rights reserved.
  259. X *
  260. X * Redistribution and use in source and binary forms are permitted
  261. X * provided that the above copyright notice and this paragraph are
  262. X * duplicated in all such forms and that any documentation,
  263. X * advertising materials, and other materials related to such
  264. X * distribution and use acknowledge that the software was developed
  265. X * by the Olivetti S.p.A. Ivrea, Italy.  The name of Olivetti may
  266. X * not be used to endorse or promote products derived from this
  267. X * software without specific prior written permission.
  268. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  269. X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  270. X * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  271. X */
  272. X
  273. X/*
  274. X * keydef() - easily / quickly redefine vt200, vt300 function keys
  275. X *
  276. X *        (Fulvio MARINO - Sep 4, 1989)
  277. X */
  278. X
  279. X
  280. X#if defined(lint) && defined(m68k)
  281. Xchar *strdup(a,b) char *a, *b; { return (a?a:b); }
  282. X#endif lint
  283. X
  284. X
  285. X#include <stdio.h>
  286. X#include <string.h>
  287. X#include <sys/types.h>
  288. X#include <sys/param.h>
  289. X
  290. X
  291. Xextern void    perror();
  292. Xextern char    *getenv(), *malloc(), *realloc();
  293. X
  294. X
  295. X#define Fprintf    (void)fprintf
  296. X
  297. X#define    ctrl(ch)    ((ch) & 037)
  298. X
  299. X#define ESC    ctrl('[')
  300. X#define BSe    ESC
  301. X#define BSn    '\n'
  302. X#define BSt    '\t'
  303. X#define BSv    '\v'
  304. X#define BSb    '\b'
  305. X#define BSr    '\r'
  306. X#define BSf    '\f'
  307. X#define BSbs    '\\'
  308. X#define BSq    '\''
  309. X#define BSdq    '"'
  310. X
  311. X
  312. X/*
  313. X * Error codes and messages
  314. X */
  315. X
  316. Xstatic int    Err_No = 0;
  317. X
  318. Xstatic char    *ErrTable[] = {
  319. X    "",
  320. X#define E_INT        1
  321. X    "Internal error",
  322. X#define E_INV_KN    2
  323. X    "Invalid key name",
  324. X#define E_INV_SN    3
  325. X    "Invalid string definition",
  326. X#define E_SINTAXERR    4
  327. X    "Sintax error",
  328. X#define E_INVCMD    5
  329. X    "Invalid command",
  330. X#define E_INVARG    6
  331. X    "Invalid argument",
  332. X#define E_KEXP        7
  333. X    "Key value expected",
  334. X#define E_TOO        8
  335. X    "Too many args for command",
  336. X#define E_NOSPC        9
  337. X    "Not enough space",
  338. X#define E_INV_CH    10
  339. X    "Value do not fit in a character"
  340. X};
  341. X
  342. X
  343. X/*
  344. X * Pclr values:
  345. X *    '1'    Clear only the key(s) being programmed
  346. X *    not '1'    Clear all keys before programming
  347. X */
  348. X
  349. X#define K_NOCLR        '1'
  350. X#define K_CLRALL    '0'
  351. X
  352. Xstatic u_char    Pclr = K_NOCLR;
  353. X
  354. X
  355. X/*
  356. X * Plk denotes whether or not to lock keys against redefinition:
  357. X *    '1'    Do not lock
  358. X *    '0'    Lock
  359. X */
  360. X
  361. X#define K_NOLCK        '1'
  362. X#define K_LCK        '0'
  363. X
  364. Xstatic u_char    Plk = K_NOLCK;
  365. X
  366. X
  367. X/*
  368. X * Kn: denotes the function key to be programmed; next table is mapping
  369. X * each key name on its function number.
  370. X */
  371. X
  372. Xtypedef struct {
  373. X        char    *Key;    /* Key name */
  374. X        u_char    Fn;    /* Function number */
  375. X} t_table;
  376. X
  377. Xstatic t_table    Table[] = {
  378. X    { "F6",   1 }, { "F7",   2 }, { "F8",   3 },
  379. X    { "F9",   4 }, { "F10",  5 }, { "F11",  6 },
  380. X    { "F12",  7 }, { "F13",  8 }, { "F14",  9 },
  381. X    { "F15", 10 }, { "F16", 11 }, { "F17", 12 },
  382. X    { "F18", 13 }, { "F19", 14 }, { "F20", 15 },
  383. X    { "S6",  17 }, { "S7",  18 }, { "S8",  19 },
  384. X    { "S9",  20 }, { "S10", 21 }, { "S11", 23 },
  385. X    { "S12", 24 }, { "S13", 25 }, { "S14", 26 },
  386. X    { "S15", 28 }, { "S16", 29 }, { "S17", 31 },
  387. X    { "S18", 32 }, { "S19", 33 }, { "S20", 34 },
  388. X    /* Next items to allow multiple names for some key */
  389. X    { "F-ESC", 6 }, { "F-BS", 7 }, { "F-LF", 8 },
  390. X    { "F-Help", 10 }, { "F-Do", 11 },
  391. X    { "S-ESC", 23 }, { "S-BS", 24 }, { "S-LF", 25 },
  392. X    { "S-Help", 28 }, { "S-Do", 29 }
  393. X};
  394. X
  395. X#define Tsize    (sizeof(Table) / sizeof(Table[0]))
  396. X
  397. Xstatic u_char    Kt[Tsize];
  398. X
  399. X
  400. X/*
  401. X * GetKn(Fn)
  402. X *    returns the function number of a given key name Fn;
  403. X *    on error, 0 is returned and Err_No is set.
  404. X */
  405. X
  406. Xstatic u_char
  407. XGetKn(Fn)
  408. Xchar    *Fn;
  409. X{
  410. X    int    i = 0;
  411. X
  412. X    if (Fn) {
  413. X        do {
  414. X            if (! strcmp(Fn, Table[i].Key))
  415. X                return(Table[i].Fn);
  416. X        } while (++i < Tsize);
  417. X    }
  418. X
  419. X    Err_No = E_INV_KN;
  420. X    return((u_char)0);
  421. X}
  422. X
  423. X
  424. Xstatic char    *Tokbuf = NULL;
  425. Xstatic unsigned    Toksize = 0;
  426. X
  427. Xstatic u_char    *UDKbuf = (u_char)NULL;
  428. Xstatic unsigned    UDKsize = 0;
  429. X
  430. X
  431. X/*
  432. X * Prepare_DECUDK(kinfo)
  433. X *    prepares in UDKbuf the DECUDK sequence, the format of which is
  434. X *        DCS Pclr ; Plk | K1 / S1 ; K2 / S2 ; ... ; Kn / Sn ST
  435. X *    (kinfo)(&Kn, &Str) is called to get the function number (in Kn)
  436. X *    and the programming string (in Str); (kinfo) returns 0 on end,
  437. X *    -1 (+ Err_No set) on error, or a positive value if ok.
  438. X *    Backslashes in UDKbuf are interpreted as the Green Hills
  439. X *    C-compiler does.
  440. X *    The number of character(s) in UDKbuf is returned on success,
  441. X *    else -1.
  442. X */
  443. X
  444. Xstatic int
  445. XPrepare_DECUDK(kinfo)
  446. Xint    (*kinfo)();
  447. X{
  448. X    int        n, t;
  449. X    u_char        Kn;
  450. X    u_char        *Str, c;
  451. X    u_int        d;
  452. X
  453. X    if (! UDKsize
  454. X       && (UDKbuf = (u_char *)malloc(UDKsize = BUFSIZ)) == NULL) {
  455. X        Err_No = E_NOSPC;
  456. X        return -1;
  457. X    }
  458. X    UDKbuf[0] = ESC,  UDKbuf[1] = 'P';    /* DCS */
  459. X    UDKbuf[3] = ';';            /* Pclr ender */
  460. X    UDKbuf[5] = '|';            /* Plk ender */
  461. X    n = 6;                    /* Start of Kn/Sn seq */
  462. X
  463. X    while ((t = (kinfo)(&Kn, &Str)) > 0) {
  464. X        if (!Kn)
  465. X            continue;
  466. X        /* Verify if Kn is in the selected key set */
  467. X        for (d = 0; d < Tsize; d++)
  468. X            if (Kn == Kt[d])
  469. X                break;
  470. X        if (d >= Tsize)
  471. X            continue;
  472. X
  473. X        if (! Str) {
  474. X            Err_No = E_INT;
  475. X            return (-1);
  476. X        }
  477. X
  478. X        /* Kn */
  479. X        if (Kn > 9)
  480. X            UDKbuf[n++] = (Kn / 10) + '0';
  481. X        UDKbuf[n++] = (Kn % 10) + '0';
  482. X        UDKbuf[n++] = '/';
  483. X
  484. X        /* Sn */
  485. X        t = 0;
  486. X        while (c = *Str++) {
  487. X            if (n > (UDKsize - 10) && (UDKbuf =
  488. X               (u_char *)realloc((char *)UDKbuf,
  489. X               UDKsize += BUFSIZ)) == NULL) {
  490. X                Err_No = E_NOSPC;
  491. X                return -1;
  492. X            }
  493. X            if (c == '^') {
  494. X                if (! (c = *Str++)) {
  495. X                    Err_No = E_INV_SN;
  496. X                    return (-1);
  497. X                }
  498. X                c = ctrl(c);
  499. X            } else if (c == '\\') {
  500. X                if (! (c = *Str++)) {
  501. X                    Err_No = E_INV_SN;
  502. X                    return (-1);
  503. X                }
  504. X                switch (c) {
  505. X                case '\'':
  506. X                case 'Q':    c = BSq; break;
  507. X                case '\\':    c = BSbs; break;
  508. X                case 'D':    c = BSdq; break;
  509. X                case 'b':    c = BSb; break;
  510. X                case 'e':    c = BSe; break;
  511. X                case 'f':    c = BSf; break;
  512. X                case 'n':    c = BSn; break;
  513. X                case 'r':    c = BSr; break;
  514. X                case 't':    c = BSt; break;
  515. X                case 'v':    c = BSv; break;
  516. X                default:
  517. X/*----------------------------- FOLDING ------------------------------*/
  518. X    if (c < '0' || c > '7')
  519. X        break;
  520. X    d = 0;
  521. X    for (t = 0; t++ < 3; ) {
  522. X        if ((d = 8 * d + (u_int)c - '0') > (u_int)((u_char)~0)) {
  523. X            Err_No = E_INV_CH;
  524. X            return -1;
  525. X        }
  526. X        c = *Str++;
  527. X        if (c < '0' || c > '7')
  528. X            break;
  529. X    }
  530. X    Str--;
  531. X    c = (u_char)d;
  532. X/*---------------------------- UNFOLDING -----------------------------*/
  533. X                }
  534. X            }
  535. X            UDKbuf[n] = c / 16;
  536. X            UDKbuf[n] += UDKbuf[n] > 9 ? 'a' - 10 : '0';
  537. X            UDKbuf[++n] = c % 16;
  538. X            UDKbuf[n] += UDKbuf[n] > 9 ? 'a' - 10 : '0';
  539. X            n++;
  540. X        }
  541. X        UDKbuf[n++] = ';';
  542. X    }
  543. X
  544. X    if (t < 0) {
  545. X        return (-1);
  546. X    }
  547. X
  548. X    UDKbuf[2] = Pclr;            /* Pclr value */
  549. X    UDKbuf[4] = Plk;            /* Plk value */
  550. X    UDKbuf[n] = ESC, UDKbuf[++n] = '\\';    /* ST */
  551. X
  552. X    return(n + 1);
  553. X}
  554. X
  555. X
  556. X/*
  557. X * Line Parsing
  558. X */
  559. X
  560. Xstatic int    lineno = 0;
  561. Xstatic FILE    *input = (FILE *)NULL;
  562. X
  563. X/*
  564. X * Get_Char()
  565. X *    gets a character from `input' (must be set correctly!);
  566. X *    the global lineno keeps trace of input.
  567. X */
  568. X
  569. Xstatic int
  570. XGet_Char()
  571. X{
  572. X    static int    c = 0;
  573. X
  574. X    switch (c = c == EOF ? EOF : getc(input)) {
  575. X    case '\n':    lineno++; break;
  576. X    case EOF:    return(-1);
  577. X    }
  578. X    return(c);
  579. X    
  580. X}
  581. X
  582. X#define G_EOF        -1
  583. X#define G_NULLTOK    -2
  584. X#define G_SINTAXERR    -3
  585. X
  586. X/*
  587. X * Get_Token(o)
  588. X *    scans input for next token (command, argument, ...), and writes
  589. X *    it in Tokbuf, starting at offset o; input sintax is like in
  590. X #    /bin/sh (it uses ", ', #, backslashes, and multi-line);
  591. X *    it returns the characters written in buf (>0),
  592. X *    or 0        if no token found in line
  593. X *    or G_EOF    on end-of-file detection
  594. X *    or G_NULLTOK    if there is a null token ('' or "")
  595. X *    or G_SINTAXERR    on a sintax error (in this case the global
  596. X *            Err_No is set)
  597. X */
  598. X
  599. Xstatic int
  600. XGet_Token(o)
  601. Xint    o;
  602. X{
  603. X    static int    oc = 0;
  604. X    int    c, got = 0, inside = 0, n = o, takenext = 0;
  605. X
  606. X    if (oc == '\n')
  607. X        return (oc = 0);
  608. X
  609. X    for ( ; ; ) {
  610. X        if (n >= Toksize &&
  611. X           (Tokbuf = Toksize
  612. X            ? realloc(Tokbuf, Toksize += BUFSIZ)
  613. X            : malloc(Toksize = BUFSIZ)
  614. X           ) == NULL) {
  615. X            Err_No = E_NOSPC;
  616. X            return G_SINTAXERR;
  617. X        }
  618. X        c = Get_Char();
  619. X        if (takenext) {
  620. X            if (c == -1) {
  621. X                Err_No = E_SINTAXERR;
  622. X                return(G_SINTAXERR);
  623. X            }
  624. X            if (c != '\n')
  625. X                Tokbuf[n++] = (u_char)c;
  626. X            takenext = 0;
  627. X            continue;
  628. X        }
  629. X        if (c == '\\' && ! inside) {
  630. X            takenext = 1;
  631. X            continue;
  632. X        }
  633. X        if (c == '"' || c == '\'') {
  634. X            if (c == inside) {
  635. X                got = G_NULLTOK;
  636. X                inside = 0;
  637. X                continue;
  638. X            } else if (!inside) {
  639. X                inside = c;
  640. X                continue;
  641. X            }
  642. X        }
  643. X        if (inside) {
  644. X            Tokbuf[n++] = (u_char)c;
  645. X            continue;
  646. X        }
  647. X        if (c == '#')
  648. X            while (c = Get_Char())
  649. X                if (c == '\n')
  650. X                    break;
  651. X        if ((c == ' ' || c == '\t') && ((n - o) || got)
  652. X            || c == '\n' || c == -1) {
  653. X            Tokbuf[n] = '\0';
  654. X            n -= o;
  655. X            oc = c;
  656. X            return (n ? n : (got ? got : (c == -1 ? G_EOF : 0)));
  657. X        }
  658. X        if (c != ' ' && c != '\t')
  659. X            Tokbuf[n++] = (u_char)c;
  660. X    }
  661. X
  662. X    /* NOTREACHED */
  663. X
  664. X}
  665. X
  666. X
  667. Xstatic int
  668. XFromFile(Key, Str)
  669. Xu_char    *Key;
  670. Xchar    **Str;
  671. X{
  672. X    int    n;
  673. X
  674. X    for ( ; ; ) {
  675. X        switch (n = Get_Token(0)) {
  676. X        case 0:            continue;    /* next line */
  677. X        case G_EOF:        return 0;    /* data end */
  678. X        case G_SINTAXERR:    return -1;    /* error */
  679. X        case G_NULLTOK:        break;        /* null token */
  680. X        default:        if (n < 0) {
  681. X                        /* internal error */
  682. X                        Err_No = E_INT;
  683. X                        return -1;
  684. X                    }
  685. X        }
  686. X        break;
  687. X    }
  688. X
  689. X    n = -1;
  690. X
  691. X    /*
  692. X     * Validate object token
  693. X     */
  694. X    *Key = 0;
  695. X    if (!strcmp(Tokbuf, "clear"))
  696. X        Pclr = K_CLRALL, Tokbuf[0] = '\0';
  697. X    else if (!strcmp(Tokbuf, "lock"))
  698. X        Plk = K_LCK, Tokbuf[0] = '\0';
  699. X    else if ((*Key = GetKn(Tokbuf)) == 0) {
  700. X        Err_No = E_INV_KN;
  701. X        return -1;
  702. X    } else {
  703. X        /*
  704. X         * Get key arg
  705. X         */
  706. X        switch (n = Get_Token(0)) {
  707. X        case G_EOF:
  708. X        case 0:            Err_No = E_KEXP;    /* set how ? */
  709. X        case G_SINTAXERR:
  710. X                    return -1;
  711. X        case G_NULLTOK:        n = 0;
  712. X                    Tokbuf[0] = '\0';
  713. X                    break;        /* null token */
  714. X        default:        if (n < 0) {
  715. X                        /* internal error */
  716. X                        Err_No = E_INT;
  717. X                        return -1;
  718. X                    }
  719. X        }
  720. X    }
  721. X
  722. X    /*
  723. X     * No more arguments expected
  724. X     */
  725. X    switch (n = Get_Token(n+1)) {
  726. X    case G_EOF:
  727. X    case 0:            break;        /* eof/eol are right */
  728. X    case G_SINTAXERR:    return -1;    /* error */
  729. X    case G_NULLTOK:        n = 0;        /* null token */
  730. X    default:        if (n < 0) {
  731. X                    /* internal error */
  732. X                    Err_No = E_INT;
  733. X                } else
  734. X                    Err_No = E_TOO;
  735. X                return -1;
  736. X    }
  737. X
  738. X    *Str = Tokbuf;
  739. X
  740. X    return 1;
  741. X}
  742. X
  743. X
  744. Xstatic int
  745. XFromTty(Key, Str)
  746. Xu_char    *Key;
  747. Xchar    **Str;
  748. X{
  749. X    static int    ind = 0;
  750. X    int    i, k;
  751. X
  752. X    if ((*Key = k = Kt[ind++]) == 0)
  753. X        return 0;
  754. X
  755. X    for (i = 0; k != Table[i].Fn; i++)
  756. X        ;
  757. X    Fprintf(stderr, "Key \"%s\"", Table[i].Key);
  758. X    while(++i < Tsize) {
  759. X        if (k == Table[i].Fn) {
  760. X            Fprintf(stderr, "==\"%s\"", Table[i].Key);
  761. X        }
  762. X    }
  763. X    Fprintf(stderr, ": ");
  764. X    (void)fflush(stderr);
  765. X
  766. X    /*
  767. X     * Get key arg
  768. X     */
  769. X    switch (i = Get_Token(0)) {
  770. X    case G_EOF:
  771. X    case 0:            Err_No = E_KEXP;    /* set how ? */
  772. X    case G_SINTAXERR:
  773. X                return -1;
  774. X    case G_NULLTOK:        i = 0;
  775. X                Tokbuf[0] = '\0';
  776. X                break;        /* null token */
  777. X    default:        if (i < 0) {
  778. X                    /* internal error */
  779. X                    Err_No = E_INT;
  780. X                    return -1;
  781. X                }
  782. X    }
  783. X
  784. X    /*
  785. X     * No more arguments expected
  786. X     */
  787. X    switch (i = Get_Token(i+1)) {
  788. X    case G_EOF:
  789. X    case 0:            break;        /* eof/eol are right */
  790. X    case G_SINTAXERR:    return -1;    /* error */
  791. X    case G_NULLTOK:        i = 0;        /* null token */
  792. X    default:        if (i < 0) {
  793. X                    /* internal error */
  794. X                    Err_No = E_INT;
  795. X                } else
  796. X                    Err_No = E_TOO;
  797. X                return -1;
  798. X    }
  799. X
  800. X    *Str = Tokbuf;
  801. X
  802. X    return 1;
  803. X}
  804. X
  805. X
  806. Xstatic void
  807. Xusage()
  808. X{
  809. X    Fprintf(stderr, "\
  810. XUsage: keydef [-f {filename|-}] [--] [keyname ...]\n\
  811. X       keydef [-c] [-l] keyname ...\n\
  812. X       keydef -{c|l} [keyname ...]\n");
  813. X
  814. X}
  815. X
  816. X
  817. X/*
  818. X *    MAIN
  819. X */
  820. X
  821. X#define KEYRC "/.keydef"
  822. X
  823. Xmain(argc, argv)
  824. Xint    argc;
  825. Xchar    **argv;
  826. X{
  827. X    extern int    getopt(), optind, opterr;
  828. X    extern char    *optarg;
  829. X    int        c, errflg, fflg, cflg, lflg;
  830. X    char        *ifile, *p;
  831. X    u_char        Kn;
  832. X    int        (*kinfo)();
  833. X
  834. X    opterr = 0;
  835. X    errflg = fflg = cflg = lflg = 0;
  836. X
  837. X    if (argc > 1) {
  838. X
  839. X        while ((c = getopt(argc, argv, "f:cl")) != EOF)
  840. X            switch(c) {
  841. X            case 'f':
  842. X                if ( fflg++ || cflg || lflg || ! optarg)
  843. X                    errflg = 1;
  844. X                else
  845. X                    ifile = optarg;
  846. X                break;
  847. X            case 'c':
  848. X                if (cflg++ || fflg)
  849. X                    errflg = 1;
  850. X                else
  851. X                    Pclr = K_CLRALL;
  852. X                break;
  853. X            case 'l':
  854. X                if (lflg++ || fflg)
  855. X                    errflg = 1;
  856. X                else
  857. X                    Plk = K_LCK;
  858. X                break;
  859. X            case '?':
  860. X                errflg = 1;
  861. X                break;
  862. X            }
  863. X    
  864. X    
  865. X        if (errflg) {
  866. X            usage();
  867. X            return 1;
  868. X        }
  869. X    
  870. X    } else {
  871. X
  872. X        if ((p = getenv("HOME")) == NULL) {
  873. X            Fprintf(stderr, "\"$HOME\" not found.\n");
  874. X            return 1;
  875. X        }
  876. X        if ((ifile = malloc((unsigned)(strlen(p)
  877. X            + sizeof(KEYRC)))) == NULL) {
  878. X            Fprintf(stderr, "malloc error.\n");
  879. X            return 1;
  880. X        }
  881. X        (void)strcpy(ifile, p);
  882. X        (void)strcat(ifile, KEYRC);
  883. X
  884. X        fflg = optind = 1;
  885. X
  886. X    }
  887. X
  888. X    for (c = 0; optind < argc; ) {
  889. X        p = argv[optind++];
  890. X        if ((Kn = GetKn(p)) == 0) {
  891. X            Fprintf(stderr, "\"%s\": bad key name.\n", p);
  892. X            Fprintf(stderr, "Available key names are:\n\t", p);
  893. X            c = 0;
  894. X            for ( ; ; ) {
  895. X                Fprintf(stderr, "%s ", Table[c++].Key);
  896. X                if (c == Tsize) {
  897. X                    (void)putc('\n', stderr);
  898. X                    break;
  899. X                }
  900. X                if (!(c % 5))
  901. X                    (void)putc('\n', stderr);
  902. X                (void)putc('\t', stderr);
  903. X            }
  904. X            return 1;
  905. X        }
  906. X        errflg = c; /* using errflg as temp */
  907. X        while(errflg-- > 0)
  908. X            if (Kt[errflg] == Kn)
  909. X                break;
  910. X        if (errflg < 0)    /* Not already selected */
  911. X            Kt[c++] = Kn;
  912. X    }
  913. X    if (! (Kn = c) && fflg) /* If no key args, select all keys */
  914. X        for (c = 0; c < Tsize; c++)
  915. X            Kt[c] = Table[c].Fn;
  916. X
  917. X    if (fflg) {
  918. X        if (strcmp(ifile, "-")
  919. X            && (input = freopen (ifile, "r", stdin)) == NULL) {
  920. X            perror(ifile);
  921. X            return(1);
  922. X        } else
  923. X            input = stdin;
  924. X        kinfo = FromFile;
  925. X    } else {
  926. X        input = stdin;
  927. X        kinfo = FromTty;
  928. X    }
  929. X
  930. X    if ((c = Prepare_DECUDK(kinfo)) > 0
  931. X        && write(fileno(stdout), (char *)UDKbuf, (unsigned)c) != c) {
  932. X        perror("output error");
  933. X        return 1;
  934. X    } else if (c < 0) {
  935. X        (void)Fprintf(stderr, "line %d: %s.\n", lineno, ErrTable[Err_No]);
  936. X        return 1;
  937. X    }
  938. X
  939. X#if defined(lint) && defined(m68k)
  940. X    return((int)strdup(NULL,NULL));
  941. X#else
  942. X    return 0;
  943. X#endif lint
  944. X}
  945. END_OF_FILE
  946. if test 13595 -ne `wc -c <'keydef.c'`; then
  947.     echo shar: \"'keydef.c'\" unpacked with wrong size!
  948. fi
  949. # end of 'keydef.c'
  950. fi
  951. if test -f 'keydef.man' -a "${1}" != "-c" ; then 
  952.   echo shar: Will not clobber existing file \"'keydef.man'\"
  953. else
  954. echo shar: Extracting \"'keydef.man'\" \(8947 characters\)
  955. sed "s/^X//" >'keydef.man' <<'END_OF_FILE'
  956. X
  957. X
  958. X
  959. X     KKKKEEEEYYYYDDDDEEEEFFFF((((llllooooccccaaaallll))))               UUUUNNNNIIIIXXXX 5555....0000                KKKKEEEEYYYYDDDDEEEEFFFF((((llllooooccccaaaallll))))
  960. X
  961. X
  962. X
  963. X     NNNNAAAAMMMMEEEE
  964. X          keydef - quickly / easily redefines VT2xx and VT3xx function
  965. X          keys.
  966. X
  967. X     SSSSYYYYNNNNTTTTAAAAXXXX
  968. X          keydef { [-c] [-l] [keyname1 keyname2 ...] }
  969. X          keydef [-f filename [keyname1 keyname2 ...]]
  970. X
  971. X     DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  972. X          The first sintax specification for the _k_e_y_d_e_f command is
  973. X          interactive; at least one flag or a keyname must be
  974. X          specified. For each _k_e_y_n_a_m_e, _k_e_y_d_e_f asks for its definition.
  975. X          The ----cccc and ----llll flags have the same meaning, respectively, of
  976. X          the _c_l_e_a_r and _l_o_c_k commands used in non-interactive mode
  977. X          (see below). Definition follows the same sintax used not
  978. X          interactively.
  979. X
  980. X          Using the 2nd form, _k_e_y_d_e_f reads its instructions from
  981. X          _f_i_l_e_n_a_m_e; if _f_i_l_e_n_a_m_e is "----", commands are taken from
  982. X          standard input, else if it is missing ("_k_e_y_d_e_f" with no
  983. X          arguments specified), then $_H_O_M_E/._k_e_y_d_e_f is read.
  984. X
  985. X          Commands in _f_i_l_e_n_a_m_e are specified in a shell-like sintax.
  986. X          A command is a sequence of non-blank words separated by
  987. X          blanks (a blank is a tab or a space). The first word
  988. X          specifies the name of the command to be executed. Possible
  989. X          commands are _c_l_e_a_r (to clear all the definitions previously
  990. X          set), _l_o_c_k (to lock definitions: i.e., all the User Defined
  991. X          Keys will be locked after the execution of _k_e_y_d_e_f -- keys
  992. X          unlock is possible only via Set-Up), or _k_e_y_n_a_m_e (to set a
  993. X          definition for _k_e_y_n_a_m_e function-key); _k_e_y_n_a_m_e must be a
  994. X          valid name of a function key, and a _d_e_f_i_n_i_t_i_o_n follows it.
  995. X
  996. X          A word beginning with #### causes that word and all the
  997. X          following characters up to a new line to be ignored.
  998. X          Explicit null arguments ("""""""" or '''''''') are retained. A character
  999. X          may be quoted (i.e., made to stand for itself) by preceding
  1000. X          it with a \\\\. The pair \\\\nnnneeeewwwwlllliiiinnnneeee is ignored. All characters
  1001. X          enclosed between a pair of quote marks ('''''''' or """"""""), except
  1002. X          the mark itself, are quoted; inside them, \\\\ has no quoting
  1003. X          properties.
  1004. X
  1005. X          Valid _k_e_y_n_a_m_e_s are FFFF6666 to FFFF22220000 aaaannnndddd SSSS6666 ttttoooo SSSS22220000 ((((rrrreeeeffffeeeerrrreeeennnncccceeeedddd
  1006. X          pppprrrreeeessssssssiiiinnnngggg bbbbooootttthhhh tttthhhheeee SSSShhhhiiiifffftttt aaaannnndddd tttthhhheeee ffffuuuunnnnccccttttiiiioooonnnn kkkkeeeeyyyy)))).... SSSSoooommmmeeee kkkkeeeeyyyyssss aaaarrrreeee
  1007. X          aaaallllssssoooo rrrreeeeffffeeeerrrreeeennnncccceeeedddd bbbbyyyy tttthhhheeee aaaassssssssoooocccciiiiaaaatttteeeedddd nnnnaaaammmmeeee ((((EEEESSSSCCCC,,,, BBBBSSSS,,,, LLLLFFFF,,,, HHHHeeeellllpppp,,,,
  1008. X          DDDDoooo))))....  TTTTyyyyppppeeee """"_k_e_y_d_e_f -"""" ttttoooo pppprrrriiiinnnntttt tttthhhheeee lllliiiisssstttt ooooffff aaaallllllll tttthhhheeee ppppoooossssssssiiiibbbblllleeee
  1009. X          kkkkeeeeyyyynnnnaaaammmmeeeessss....
  1010. X
  1011. X          The (mandatory) argument of a _k_e_y_n_a_m_e command is the
  1012. X          _d_e_f_i_n_i_t_i_o_n for that key; inside it, \\\\ and ^^^^ have a special
  1013. X          meaning. Certain characters may be represented according to
  1014. X          the following table:
  1015. X
  1016. X
  1017. X
  1018. X     Page 1                                           (printed 9/4/89)
  1019. X
  1020. X
  1021. X
  1022. X
  1023. X
  1024. X
  1025. X     KKKKEEEEYYYYDDDDEEEEFFFF((((llllooooccccaaaallll))))               UUUUNNNNIIIIXXXX 5555....0000                KKKKEEEEYYYYDDDDEEEEFFFF((((llllooooccccaaaallll))))
  1026. X
  1027. X
  1028. X
  1029. X                  CHARACTER       ASCII SYMBOL    ESCAPE SEQUENCE
  1030. X
  1031. X                  newline(NL)          LF              \n
  1032. X                  horizontal-tab       HT              \t
  1033. X                  vertical-tab         VT              \v
  1034. X                  backspace            BS              \b
  1035. X                  carriage-return      CR              \r
  1036. X                  formfeed             FF              \f
  1037. X                  escape               ESC             \e
  1038. X                  backslah             \               \\
  1039. X                  single-quote         '               \' or \Q
  1040. X                  double-quote         "               \D
  1041. X                  bit-pattern          ddd             \ddd
  1042. X
  1043. X          The escape \\\\dddddddddddd consists of the backslash followed by 1, 2,
  1044. X          or 3 octal digits, which are taken to specify the value of
  1045. X          the desired character. If the character following a
  1046. X          backslash is not one of those specified, the backslash is
  1047. X          ignored. ^^^^xxxx maps to a control-x for any appropriate x. To
  1048. X          program a literal circumflex, preceed it with a backslash.
  1049. X
  1050. X          A function key is executed by pressing one of the function
  1051. X          keys (FFFF****), or by pressing SHIFT + function key (SSSS****).
  1052. X
  1053. X     WWWWAAAARRRRNNNNIIIINNNNGGGGSSSS
  1054. X          There is a finite amount of memory in the terminal for
  1055. X          storing the definitions. The exceeding characters are
  1056. X          discharged.
  1057. X
  1058. X          Terminal is getting confused when any character is
  1059. X          asynchronously received/typed during the execution of
  1060. X          _k_e_y_d_e_f.
  1061. X
  1062. X          Depending on the terminal type and/or setting, not all the
  1063. X          keys can be programmed; typically, F11 (ESC), F12 (BS) and
  1064. X          F13 (LF) can be protected from the user's redefinition.
  1065. X
  1066. X          This program has been developed and tested on an _O_l_i_v_e_t_t_i _W_S
  1067. X          _6_8_5 desktop video display terminal emulating DEC terminals
  1068. X          VT220, VT100 and VT52, connected via RS232 to an _O_l_i_v_e_t_t_i
  1069. X          _L_S_X-_3_0_1_0 with the _L_2 _X/_O_S _R_2._0 Unix System. You should not
  1070. X          have porting problems on any X/OPEN system.
  1071. X
  1072. X     SSSSEEEEEEEE AAAALLLLSSSSOOOO
  1073. X          VT220 or VT320 Programmer Pocket Guide, and/or WS 685 User
  1074. X          Guide.
  1075. X
  1076. X     AAAAUUUUTTTTHHHHOOOORRRR
  1077. X          Fulvio MARINO, Olivetti, Ivrea, Italy
  1078. X          (fulvio@oliveb.ATC.Olivetti.Com)
  1079. X
  1080. X          Comments, suggestions, and patches welcomed.
  1081. X
  1082. X
  1083. X
  1084. X     Page 2                                           (printed 9/4/89)
  1085. X
  1086. X
  1087. X
  1088. X
  1089. X
  1090. X
  1091. X     KKKKEEEEYYYYDDDDEEEEFFFF((((llllooooccccaaaallll))))               UUUUNNNNIIIIXXXX 5555....0000                KKKKEEEEYYYYDDDDEEEEFFFF((((llllooooccccaaaallll))))
  1092. X
  1093. X
  1094. X
  1095. X     CCCCOOOOPPPPYYYYRRRRIIIIGGGGHHHHTTTT
  1096. X          Copyright (c) 1989 Olivetti S.p.A. Ivrea, Italy.
  1097. X          All rights reserved.
  1098. X
  1099. X          Redistribution and use in source and binary forms are
  1100. X          permitted provided that the above copyright notice and this
  1101. X          paragraph are duplicated in all such forms and that any
  1102. X          documentation, advertising materials, and other materials
  1103. X          related to such distribution and use acknowledge that the
  1104. X          software was developed by the Olivetti S.p.A., Italy.  The
  1105. X          name of Olivetti S.p.A. may not be used to endorse or
  1106. X          promote products derived from this software without specific
  1107. X          prior written permission.
  1108. X          THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS
  1109. X          OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE
  1110. X          IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A
  1111. X          PARTICULAR PURPOSE.
  1112. X
  1113. X
  1114. X
  1115. X
  1116. X
  1117. X
  1118. X
  1119. X
  1120. X
  1121. X
  1122. X
  1123. X
  1124. X
  1125. X
  1126. X
  1127. X
  1128. X
  1129. X
  1130. X
  1131. X
  1132. X
  1133. X
  1134. X
  1135. X
  1136. X
  1137. X
  1138. X
  1139. X
  1140. X
  1141. X
  1142. X
  1143. X
  1144. X
  1145. X
  1146. X
  1147. X
  1148. X
  1149. X
  1150. X     Page 3                                           (printed 9/4/89)
  1151. X
  1152. X
  1153. X
  1154. END_OF_FILE
  1155. echo shar: 1273 control characters may be missing from \"'keydef.man'\"
  1156. if test 8947 -ne `wc -c <'keydef.man'`; then
  1157.     echo shar: \"'keydef.man'\" unpacked with wrong size!
  1158. fi
  1159. # end of 'keydef.man'
  1160. fi
  1161. if test -f 'makefile' -a "${1}" != "-c" ; then 
  1162.   echo shar: Will not clobber existing file \"'makefile'\"
  1163. else
  1164. echo shar: Extracting \"'makefile'\" \(1430 characters\)
  1165. sed "s/^X//" >'makefile' <<'END_OF_FILE'
  1166. X
  1167. X########################################################################
  1168. X#
  1169. X# Copyright (c) 1989 Olivetti S.p.A. Ivrea, Italy.
  1170. X# All rights reserved.
  1171. X#
  1172. X# Redistribution and use in source and binary forms are permitted
  1173. X# provided that the above copyright notice and this paragraph are
  1174. X# duplicated in all such forms and that any documentation,
  1175. X# advertising materials, and other materials related to such
  1176. X# distribution and use acknowledge that the software was developed
  1177. X# by the Olivetti S.p.A. Ivrea, Italy.  The name of Olivetti may
  1178. X# not be used to endorse or promote products derived from this
  1179. X# software without specific prior written permission.
  1180. X# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  1181. X# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  1182. X# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  1183. X#
  1184. X########################################################################
  1185. X
  1186. XSHELL=/bin/sh
  1187. X
  1188. XBINDIR=/usr/local/bin
  1189. XMANDIR=/usr/local/man
  1190. X
  1191. XBIN=$(BINDIR)/keydef
  1192. XMAN=$(MANDIR)/keydef.1
  1193. X
  1194. X
  1195. Xall install:: keydef    # Use built-in rules
  1196. X
  1197. Xinstall:: # For super-user only
  1198. X    cp keydef $(BIN)
  1199. X    cp keydef.1u $(MAN)
  1200. X
  1201. Xclean: NOREM    # rm all files not specified in NOREM
  1202. X    @- a="`ls . | fgrep -vx -f NOREM`" \
  1203. X        || exit 0 \
  1204. X        && echo rm -rf $$a \
  1205. X        && rm -rf $$a
  1206. X
  1207. Xkeydef.man: keydef.1u
  1208. X    nroff -Tlp -man $? > $@
  1209. X
  1210. XMANIFEST: NOREM
  1211. X    makekit -m `cat $@`
  1212. X
  1213. Xkit: keydef.man MANIFEST
  1214. X    makekit -i MANIFEST -h 2
  1215. END_OF_FILE
  1216. if test 1430 -ne `wc -c <'makefile'`; then
  1217.     echo shar: \"'makefile'\" unpacked with wrong size!
  1218. fi
  1219. # end of 'makefile'
  1220. fi
  1221. if test -f 'sample' -a "${1}" != "-c" ; then 
  1222.   echo shar: Will not clobber existing file \"'sample'\"
  1223. else
  1224. echo shar: Extracting \"'sample'\" \(3610 characters\)
  1225. sed "s/^X//" >'sample' <<'END_OF_FILE'
  1226. X########################################################################
  1227. X#
  1228. X# Copyright (c) 1989 Olivetti S.p.A. Ivrea, Italy.
  1229. X# All rights reserved.
  1230. X#
  1231. X# Redistribution and use in source and binary forms are permitted
  1232. X# provided that the above copyright notice and this paragraph are
  1233. X# duplicated in all such forms and that any documentation,
  1234. X# advertising materials, and other materials related to such
  1235. X# distribution and use acknowledge that the software was developed
  1236. X# by the Olivetti S.p.A. Ivrea, Italy.  The name of Olivetti may
  1237. X# not be used to endorse or promote products derived from this
  1238. X# software without specific prior written permission.
  1239. X# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  1240. X# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  1241. X# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  1242. X#
  1243. X########################################################################
  1244. X
  1245. X
  1246. Xclear    # erase the contents of all the f-keys.
  1247. X
  1248. X#lock    # after the settings here specified, disable key definitions
  1249. X    # (enabling can be done only via Set-Up)
  1250. X
  1251. X# The following f-keys can be redefined only if your terminal setting
  1252. X# allows this.
  1253. XF-ESC    \\e
  1254. XF-BS    \\b
  1255. XF-LF    \\n
  1256. X
  1257. XS11    \\e    # Function key S11 may default to 'esc' but you can
  1258. X        # override it here
  1259. XS12    \\b
  1260. XS13    \\n
  1261. X
  1262. X#
  1263. X# Set my C-lang `vi-environment'
  1264. X#
  1265. X
  1266. XF6 \
  1267. X"Qset ai eb ic nomesg nu opt para= prompt redraw noremap"\
  1268. X" report=1 sections= shell=/bin/sh sm smd tl=0 tags=tags terse"\
  1269. X" timeout noremap
  1270. Xmap! #/ /*^V\r * ^V\r*/^V^[kA
  1271. Xmap! #in #include <>^V^[i
  1272. Xmap! #de #define \t/*  */^V^[0f a
  1273. Xmap! #un #undef\t
  1274. Xmap! #id #ifdef 
  1275. Xmap! #if #if defined()^V^[i
  1276. Xmap! #el #else
  1277. Xmap! #en #endif
  1278. Xmap! br' break;
  1279. Xmap! ca' case : /*  */^V\r\tbreak;^V^[k0f:i
  1280. Xmap! ch' char\t;^V^[i
  1281. Xmap! co' continue;
  1282. Xmap! de' default: /*  */^V\r\tbreak;^V^[O
  1283. Xmap! do' double\t;^V^[i
  1284. Xmap! dw' do {^V\r} while();^V^[O\t
  1285. Xmap! ei' else if () {^V\r}^V^[k0f(a
  1286. Xmap! el' else {^V\r}^V^[O\t
  1287. Xmap! en' enum {^V\r};^V^[O\t
  1288. Xmap! ex' extern ;^V^[i
  1289. Xmap! fl' float ;^V^[i
  1290. Xmap! fo' for (;;) {^V\r}^V^[k0f(a
  1291. Xmap! go' goto ;^V^[i
  1292. Xmap! if' if () {^V\r}^V^[k0f(a
  1293. Xmap! in' int\t;^V^[i
  1294. Xmap! lo' long\t;^V^[i
  1295. Xmap! ma' main(argc, argv, environ)^V\rint\targc;^V\rchar\t*argv[], *environ[];^V\r{^V\r}^V^[O\t
  1296. Xmap! re' return();^V^[hi
  1297. Xmap! rg' register ;^V^[i
  1298. Xmap! sc' static ;^V^[i
  1299. Xmap! sh' short ;^V^[i
  1300. Xmap! si' sizeof()^V^[i
  1301. Xmap! st' struct {^V\r};^V^[k0f a
  1302. Xmap! sw' switch () {^V\rcase : /* */^V\r\tbreak;^V\r ^V^[xr}kkk0f(a
  1303. Xmap! ty' typedef ;^V^[i
  1304. Xmap! un' union {^V\r};^V^[O\t
  1305. Xmap! us' unsigned ;^V^[i
  1306. Xmap! wh' while () {^V\r}^V^[k0f(a
  1307. Xvi .\n"
  1308. X
  1309. X#
  1310. X# Reset to my standard  `vi-environment'
  1311. X#
  1312. X
  1313. XS6 \
  1314. X"Qset notimeout
  1315. Xunmap! #/
  1316. Xunmap! #in
  1317. Xunmap! #de
  1318. Xunmap! #un
  1319. Xunmap! #id
  1320. Xunmap! #if
  1321. Xunmap! #el
  1322. Xunmap! #en
  1323. Xunmap! br'
  1324. Xunmap! ca'
  1325. Xunmap! ch'
  1326. Xunmap! co'
  1327. Xunmap! de'
  1328. Xunmap! do'
  1329. Xunmap! dw'
  1330. Xunmap! ei'
  1331. Xunmap! el'
  1332. Xunmap! en'
  1333. Xunmap! ex'
  1334. Xunmap! fl'
  1335. Xunmap! fo'
  1336. Xunmap! go'
  1337. Xunmap! if'
  1338. Xunmap! in'
  1339. Xunmap! lo'
  1340. Xunmap! ma'
  1341. Xunmap! re'
  1342. Xunmap! rg'
  1343. Xunmap! sc'
  1344. Xunmap! sh'
  1345. Xunmap! si'
  1346. Xunmap! st'
  1347. Xunmap! sw'
  1348. Xunmap! ty'
  1349. Xunmap! un'
  1350. Xunmap! us'
  1351. Xunmap! wh'
  1352. Xvi .\n"
  1353. X
  1354. X
  1355. X# I use my function key F7 for temporary, repetitive things; complicated
  1356. X# commands, sequences, etc. Real nice if application allows shell
  1357. X# escapes.  Most often used with complicated vi commands. 
  1358. X
  1359. XS7    'keydef F7\n'
  1360. X
  1361. X
  1362. XF-Help    apropos\\t
  1363. XS-Help    man\\t
  1364. X
  1365. X# Two ways to make a 'shell escape' from vi:
  1366. XF-Do    ^Z
  1367. XS-Do    :!/bin/csh
  1368. X
  1369. X# To execute remote commands on my preferred systems:
  1370. XF14    "/usr/ucb/bin/rsh icodap "
  1371. XS14    "/usr/ucb/bin/rsh newgest -l vigna "
  1372. X
  1373. X
  1374. X# Sometime I use bc with the numeric keypad; I find this useful:
  1375. XF17    ' + '
  1376. XF18    ' - '
  1377. XF19    ' * '
  1378. XF20    ' / '
  1379. END_OF_FILE
  1380. if test 3610 -ne `wc -c <'sample'`; then
  1381.     echo shar: \"'sample'\" unpacked with wrong size!
  1382. fi
  1383. # end of 'sample'
  1384. fi
  1385. echo shar: End of archive 1 \(of 1\).
  1386. cp /dev/null ark1isdone
  1387. MISSING=""
  1388. for I in 1 ; do
  1389.     if test ! -f ark${I}isdone ; then
  1390.     MISSING="${MISSING} ${I}"
  1391.     fi
  1392. done
  1393. if test "${MISSING}" = "" ; then
  1394.     echo You have the archive.
  1395.     rm -f ark[1-9]isdone
  1396. else
  1397.     echo You still need to unpack the following archives:
  1398.     echo "        " ${MISSING}
  1399. fi
  1400. ##  End of shell archive.
  1401. exit 0
  1402.  
  1403.  
  1404.