tools/llvm: Do not build with symbols
[minix3.git] / external / bsd / nvi / dist / ip / ip_term.c
bloba7e7bc01647474c9d6077646a11fba7f40656b33
1 /* $NetBSD: ip_term.c,v 1.3 2013/11/25 22:43:46 christos Exp $ */
2 /*-
3 * Copyright (c) 1996
4 * Keith Bostic. All rights reserved.
6 * See the LICENSE file for redistribution information.
7 */
9 #include "config.h"
11 #ifndef lint
12 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 ";
13 #endif /* not lint */
15 #include <sys/types.h>
16 #include <sys/queue.h>
18 #include <bitstring.h>
19 #include <stdio.h>
20 #include <string.h>
22 #include "../common/common.h"
23 #include "../ipc/ip.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 LIST_FOREACH(qp, &sp->gp->seqq, q)
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 LIST_FOREACH_SAFE(qp, &gp->seqq, q, nqp) {
60 if (F_ISSET(qp, SEQ_SCREEN))
61 (void)seq_mdel(qp);
63 return (0);
67 * ip_fmap --
68 * Map a function key.
70 * PUBLIC: int ip_fmap __P((SCR *, seq_t, CHAR_T *, size_t, CHAR_T *, size_t));
72 int
73 ip_fmap(SCR *sp, seq_t stype, CHAR_T *from, size_t flen, CHAR_T *to, size_t tlen)
75 /* Bind a function key to a string sequence. */
76 return (1);
80 * ip_optchange --
81 * IP screen specific "option changed" routine.
83 * PUBLIC: int ip_optchange __P((SCR *, int, const char *, u_long *));
85 int
86 ip_optchange(SCR *sp, int offset, const char *str, u_long *valp)
88 IP_BUF ipb;
89 OPTLIST const *opt;
90 IP_PRIVATE *ipp = IPP(sp);
92 switch (offset) {
93 case O_COLUMNS:
94 case O_LINES:
95 F_SET(sp->gp, G_SRESTART);
96 F_CLR(sp, SC_SCR_EX | SC_SCR_VI);
97 break;
98 case O_TERM:
99 /* Called with "ip_curses"; previously wasn't shown
100 * because switching to EX wasn't allowed
101 msgq(sp, M_ERR, "The screen type may not be changed");
103 return (1);
106 opt = optlist + offset;
107 switch (opt->type) {
108 case OPT_0BOOL:
109 case OPT_1BOOL:
110 case OPT_NUM:
111 ipb.val1 = *valp;
112 ipb.len2 = 0;
113 break;
114 case OPT_STR:
115 if (str == NULL) {
116 ipb.str2 = "";
117 ipb.len2 = 1;
118 } else {
119 ipb.str2 = str;
120 ipb.len2 = strlen(str) + 1;
122 break;
125 ipb.code = SI_EDITOPT;
126 ipb.str1 = __UNCONST(opt->name);
127 ipb.len1 = STRLEN(opt->name) * sizeof(CHAR_T);
129 (void)vi_send(ipp->o_fd, "ab1", &ipb);
130 return (0);