distrib: let automake add missing files
[nvi.git] / ip / ip_term.c
blobafc93336e0d76d64d53f2a076f5fb8bf5f3c63cb
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.9 2001/06/25 15:19:24 skimo Exp $ (Berkeley) $Date: 2001/06/25 15:19:24 $";
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(SCR *sp)
34 SEQ *qp;
37 * Rework any function key mappings that were set before the
38 * screen was initialized.
40 for (qp = sp->gp->seqq.lh_first; qp != NULL; qp = qp->q.le_next)
41 if (F_ISSET(qp, SEQ_FUNCMAP))
42 (void)ip_fmap(sp, qp->stype,
43 qp->input, qp->ilen, qp->output, qp->olen);
44 return (0);
48 * ip_term_end --
49 * End the special keys defined by the termcap/terminfo entry.
51 * PUBLIC: int ip_term_end __P((GS *));
53 int
54 ip_term_end(GS *gp)
56 SEQ *qp, *nqp;
58 /* Delete screen specific mappings. */
59 for (qp = gp->seqq.lh_first; qp != NULL; qp = nqp) {
60 nqp = qp->q.le_next;
61 if (F_ISSET(qp, SEQ_SCREEN))
62 (void)seq_mdel(qp);
64 return (0);
68 * ip_fmap --
69 * Map a function key.
71 * PUBLIC: int ip_fmap __P((SCR *, seq_t, CHAR_T *, size_t, CHAR_T *, size_t));
73 int
74 ip_fmap(SCR *sp, seq_t stype, CHAR_T *from, size_t flen, CHAR_T *to, size_t tlen)
76 /* Bind a function key to a string sequence. */
77 return (1);
81 * ip_optchange --
82 * IP screen specific "option changed" routine.
84 * PUBLIC: int ip_optchange __P((SCR *, int, char *, u_long *));
86 int
87 ip_optchange(SCR *sp, int offset, char *str, u_long *valp)
89 IP_BUF ipb;
90 OPTLIST const *opt;
91 IP_PRIVATE *ipp = IPP(sp);
92 char *np;
93 size_t nlen;
95 switch (offset) {
96 case O_COLUMNS:
97 case O_LINES:
98 F_SET(sp->gp, G_SRESTART);
99 F_CLR(sp, SC_SCR_EX | SC_SCR_VI);
100 break;
101 case O_TERM:
102 /* Called with "ip_curses"; previously wasn't shown
103 * because switching to EX wasn't allowed
104 msgq(sp, M_ERR, "The screen type may not be changed");
106 return (1);
109 opt = optlist + offset;
110 switch (opt->type) {
111 case OPT_0BOOL:
112 case OPT_1BOOL:
113 case OPT_NUM:
114 ipb.val1 = *valp;
115 ipb.len2 = 0;
116 break;
117 case OPT_STR:
118 if (str == NULL) {
119 ipb.str2 = "";
120 ipb.len2 = 1;
121 } else {
122 ipb.str2 = str;
123 ipb.len2 = strlen(str) + 1;
125 break;
128 ipb.code = SI_EDITOPT;
129 ipb.str1 = (char*)opt->name;
130 ipb.len1 = STRLEN(opt->name) * sizeof(CHAR_T);
132 (void)vi_send(ipp->o_fd, "ab1", &ipb);
133 return (0);