1 /* $NetBSD: ip_term.c,v 1.4 2014/01/26 21:43:45 christos Exp $ */ 2 /*- 3 * Copyright (c) 1996 4 * Keith Bostic. All rights reserved. 5 * 6 * See the LICENSE file for redistribution information. 7 */ 8 9 #include "config.h" 10 11 #include <sys/cdefs.h> 12 #if 0 13 #ifndef lint 14 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 "; 15 #endif /* not lint */ 16 #else 17 __RCSID("$NetBSD: ip_term.c,v 1.4 2014/01/26 21:43:45 christos Exp $"); 18 #endif 19 20 #include <sys/types.h> 21 #include <sys/queue.h> 22 23 #include <bitstring.h> 24 #include <stdio.h> 25 #include <string.h> 26 27 #include "../common/common.h" 28 #include "../ipc/ip.h" 29 30 /* 31 * ip_term_init -- 32 * Initialize the terminal special keys. 33 * 34 * PUBLIC: int ip_term_init __P((SCR *)); 35 */ 36 int 37 ip_term_init(SCR *sp) 38 { 39 SEQ *qp; 40 41 /* 42 * Rework any function key mappings that were set before the 43 * screen was initialized. 44 */ 45 LIST_FOREACH(qp, &sp->gp->seqq, q) 46 if (F_ISSET(qp, SEQ_FUNCMAP)) 47 (void)ip_fmap(sp, qp->stype, 48 qp->input, qp->ilen, qp->output, qp->olen); 49 return (0); 50 } 51 52 /* 53 * ip_term_end -- 54 * End the special keys defined by the termcap/terminfo entry. 55 * 56 * PUBLIC: int ip_term_end __P((GS *)); 57 */ 58 int 59 ip_term_end(GS *gp) 60 { 61 SEQ *qp, *nqp; 62 63 /* Delete screen specific mappings. */ 64 LIST_FOREACH_SAFE(qp, &gp->seqq, q, nqp) { 65 if (F_ISSET(qp, SEQ_SCREEN)) 66 (void)seq_mdel(qp); 67 } 68 return (0); 69 } 70 71 /* 72 * ip_fmap -- 73 * Map a function key. 74 * 75 * PUBLIC: int ip_fmap __P((SCR *, seq_t, CHAR_T *, size_t, CHAR_T *, size_t)); 76 */ 77 int 78 ip_fmap(SCR *sp, seq_t stype, CHAR_T *from, size_t flen, CHAR_T *to, size_t tlen) 79 { 80 /* Bind a function key to a string sequence. */ 81 return (1); 82 } 83 84 /* 85 * ip_optchange -- 86 * IP screen specific "option changed" routine. 87 * 88 * PUBLIC: int ip_optchange __P((SCR *, int, const char *, u_long *)); 89 */ 90 int 91 ip_optchange(SCR *sp, int offset, const char *str, u_long *valp) 92 { 93 IP_BUF ipb; 94 OPTLIST const *opt; 95 IP_PRIVATE *ipp = IPP(sp); 96 97 switch (offset) { 98 case O_COLUMNS: 99 case O_LINES: 100 F_SET(sp->gp, G_SRESTART); 101 F_CLR(sp, SC_SCR_EX | SC_SCR_VI); 102 break; 103 case O_TERM: 104 /* Called with "ip_curses"; previously wasn't shown 105 * because switching to EX wasn't allowed 106 msgq(sp, M_ERR, "The screen type may not be changed"); 107 */ 108 return (1); 109 } 110 111 opt = optlist + offset; 112 switch (opt->type) { 113 case OPT_0BOOL: 114 case OPT_1BOOL: 115 case OPT_NUM: 116 ipb.val1 = *valp; 117 ipb.len2 = 0; 118 break; 119 case OPT_STR: 120 if (str == NULL) { 121 ipb.str2 = ""; 122 ipb.len2 = 1; 123 } else { 124 ipb.str2 = str; 125 ipb.len2 = strlen(str) + 1; 126 } 127 break; 128 } 129 130 ipb.code = SI_EDITOPT; 131 ipb.str1 = __UNCONST(opt->name); 132 ipb.len1 = STRLEN(opt->name) * sizeof(CHAR_T); 133 134 (void)vi_send(ipp->o_fd, "ab1", &ipb); 135 return (0); 136 } 137