update from From: Sven Verdoolaege <skimo@breughel.ufsia.ac.be>
[nvi.git] / ip / ip_term.c
blob9a971ef5f6f5adccbd6b1c7e6e5e55a33e2fce2c
1 /*-
2 * Copyright (c) 1996
3 * Keith Bostic. All rights reserved.
5 * See the LICENSE file for redistribution information.
6 */
8 #include "config.h"
10 #ifndef lint
11 static const char sccsid[] = "$Id: ip_term.c,v 8.5 1996/12/18 10:28:04 bostic Exp $ (Berkeley) $Date: 1996/12/18 10:28:04 $";
12 #endif /* not lint */
14 #include <sys/types.h>
15 #include <sys/queue.h>
17 #include <bitstring.h>
18 #include <stdio.h>
19 #include <string.h>
21 #include "../common/common.h"
22 #include "../ipc/ip.h"
23 #include "extern.h"
26 * ip_term_init --
27 * Initialize the terminal special keys.
29 * PUBLIC: int ip_term_init __P((SCR *));
31 int
32 ip_term_init(sp)
33 SCR *sp;
35 SEQ *qp;
38 * Rework any function key mappings that were set before the
39 * screen was initialized.
41 for (qp = sp->gp->seqq.lh_first; qp != NULL; qp = qp->q.le_next)
42 if (F_ISSET(qp, SEQ_FUNCMAP))
43 (void)ip_fmap(sp, qp->stype,
44 qp->input, qp->ilen, qp->output, qp->olen);
45 return (0);
49 * ip_term_end --
50 * End the special keys defined by the termcap/terminfo entry.
52 * PUBLIC: int ip_term_end __P((GS *));
54 int
55 ip_term_end(gp)
56 GS *gp;
58 SEQ *qp, *nqp;
60 /* Delete screen specific mappings. */
61 for (qp = gp->seqq.lh_first; qp != NULL; qp = nqp) {
62 nqp = qp->q.le_next;
63 if (F_ISSET(qp, SEQ_SCREEN))
64 (void)seq_mdel(qp);
66 return (0);
70 * ip_fmap --
71 * Map a function key.
73 * PUBLIC: int ip_fmap __P((SCR *, seq_t, CHAR_T *, size_t, CHAR_T *, size_t));
75 int
76 ip_fmap(sp, stype, from, flen, to, tlen)
77 SCR *sp;
78 seq_t stype;
79 CHAR_T *from, *to;
80 size_t flen, tlen;
82 /* Bind a function key to a string sequence. */
83 return (1);
87 * ip_optchange --
88 * IP screen specific "option changed" routine.
90 * PUBLIC: int ip_optchange __P((SCR *, int, char *, u_long *));
92 int
93 ip_optchange(sp, offset, str, valp)
94 SCR *sp;
95 int offset;
96 char *str;
97 u_long *valp;
99 IP_BUF ipb;
100 OPTLIST const *opt;
102 switch (offset) {
103 case O_COLUMNS:
104 case O_LINES:
105 F_SET(sp->gp, G_SRESTART);
106 F_CLR(sp, SC_SCR_EX | SC_SCR_VI);
107 break;
108 case O_TERM:
109 msgq(sp, M_ERR, "The screen type may not be changed");
110 return (1);
113 opt = optlist + offset;
114 switch (opt->type) {
115 case OPT_0BOOL:
116 case OPT_1BOOL:
117 case OPT_NUM:
118 ipb.val1 = *valp;
119 ipb.len2 = 0;
120 break;
121 case OPT_STR:
122 if (str == NULL) {
123 ipb.str2 = "";
124 ipb.len2 = 1;
125 } else {
126 ipb.str2 = str;
127 ipb.len2 = strlen(str) + 1;
129 break;
132 ipb.code = SI_EDITOPT;
133 ipb.str1 = opt->name;
134 ipb.len1 = strlen(opt->name);
136 (void)vi_send("ab1", &ipb);
137 return (0);