MFC corrected printing of the slice number when adding a GPT partition.
[dragonfly.git] / contrib / nvi / tk / tk_term.c
blob18299a28ae77133146258b4f062f5be6be898167
1 /*-
2 * Copyright (c) 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 * Copyright (c) 1993, 1994, 1995, 1996
5 * Keith Bostic. All rights reserved.
7 * See the LICENSE file for redistribution information.
8 */
10 #include "config.h"
12 #ifndef lint
13 static const char sccsid[] = "@(#)tk_term.c 8.12 (Berkeley) 10/13/96";
14 #endif /* not lint */
16 #include <sys/types.h>
17 #include <sys/queue.h>
19 #include <bitstring.h>
20 #include <errno.h>
21 #include <limits.h>
22 #include <signal.h>
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include <termios.h>
27 #include <unistd.h>
29 #include "../common/common.h"
30 #include "tki.h"
33 * tk_term_init --
34 * Initialize the terminal special keys.
36 * PUBLIC: int tk_term_init __P((SCR *));
38 int
39 tk_term_init(sp)
40 SCR *sp;
42 SEQ *qp;
45 * Rework any function key mappings that were set before the
46 * screen was initialized.
48 for (qp = sp->gp->seqq.lh_first; qp != NULL; qp = qp->q.le_next)
49 if (F_ISSET(qp, SEQ_FUNCMAP))
50 (void)tk_fmap(sp, qp->stype,
51 qp->input, qp->ilen, qp->output, qp->olen);
52 return (0);
56 * tk_term_end --
57 * End the special keys defined by the termcap/terminfo entry.
59 * PUBLIC: int tk_term_end __P((GS *));
61 int
62 tk_term_end(gp)
63 GS *gp;
65 SEQ *qp, *nqp;
67 /* Delete screen specific mappings. */
68 for (qp = gp->seqq.lh_first; qp != NULL; qp = nqp) {
69 nqp = qp->q.le_next;
70 if (F_ISSET(qp, SEQ_SCREEN))
71 (void)seq_mdel(qp);
73 return (0);
77 * tk_fmap --
78 * Map a function key.
80 * PUBLIC: int tk_fmap __P((SCR *, seq_t, CHAR_T *, size_t, CHAR_T *, size_t));
82 int
83 tk_fmap(sp, stype, from, flen, to, tlen)
84 SCR *sp;
85 seq_t stype;
86 CHAR_T *from, *to;
87 size_t flen, tlen;
89 VI_INIT_IGNORE(sp);
91 /* Bind a Tk/Tcl function key to a string sequence. */
92 return (0);
96 * tk_optchange --
97 * Curses screen specific "option changed" routine.
99 * PUBLIC: int tk_optchange __P((SCR *, int, char *, u_long *));
102 tk_optchange(sp, opt, str, valp)
103 SCR *sp;
104 int opt;
105 char *str;
106 u_long *valp;
108 switch (opt) {
109 case O_COLUMNS:
110 case O_LINES:
112 * Changing the columns or lines require that we restart
113 * the screen.
115 F_SET(sp->gp, G_SRESTART);
116 F_CLR(sp, SC_SCR_EX | SC_SCR_VI);
117 break;
118 case O_TERM:
119 msgq(sp, M_ERR, "The screen type may not be changed");
120 return (1);
122 return (0);
126 * tk_ssize --
127 * Return the window size.
129 * PUBLIC: int tk_ssize __P((SCR *, int, size_t *, size_t *, int *));
132 tk_ssize(sp, sigwinch, rowp, colp, changedp)
133 SCR *sp;
134 int sigwinch;
135 size_t *rowp, *colp;
136 int *changedp;
138 TK_PRIVATE *tkp;
140 tkp = GTKP(__global_list);
141 (void)Tcl_Eval(tkp->interp, "tk_ssize");
144 * SunOS systems deliver SIGWINCH when windows are uncovered
145 * as well as when they change size. In addition, we call
146 * here when continuing after being suspended since the window
147 * may have changed size. Since we don't want to background
148 * all of the screens just because the window was uncovered,
149 * ignore the signal if there's no change.
151 * !!!
152 * sp may be NULL.
154 if (sigwinch && sp != NULL &&
155 tkp->tk_ssize_row == O_VAL(sp, O_LINES) &&
156 tkp->tk_ssize_col == O_VAL(sp, O_COLUMNS)) {
157 if (changedp != NULL)
158 *changedp = 0;
159 return (0);
162 if (rowp != NULL)
163 *rowp = tkp->tk_ssize_row;
164 if (colp != NULL)
165 *colp = tkp->tk_ssize_col;
166 if (changedp != NULL)
167 *changedp = 1;
168 return (0);