xref: /onnv-gate/usr/src/cmd/vi/port/ex_set.c (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
23*0Sstevel@tonic-gate /*	  All Rights Reserved  	*/
24*0Sstevel@tonic-gate 
25*0Sstevel@tonic-gate 
26*0Sstevel@tonic-gate /* Copyright (c) 1981 Regents of the University of California */
27*0Sstevel@tonic-gate #ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.14	*/
28*0Sstevel@tonic-gate 
29*0Sstevel@tonic-gate #include "ex.h"
30*0Sstevel@tonic-gate #include "ex_temp.h"
31*0Sstevel@tonic-gate #include "ex_tty.h"
32*0Sstevel@tonic-gate 
33*0Sstevel@tonic-gate /*
34*0Sstevel@tonic-gate  * Set command.
35*0Sstevel@tonic-gate  */
36*0Sstevel@tonic-gate unsigned char	optname[ONMSZ];
37*0Sstevel@tonic-gate 
38*0Sstevel@tonic-gate set()
39*0Sstevel@tonic-gate {
40*0Sstevel@tonic-gate 	register unsigned char *cp;
41*0Sstevel@tonic-gate 	register struct option *op;
42*0Sstevel@tonic-gate 	register int c;
43*0Sstevel@tonic-gate 	bool no;
44*0Sstevel@tonic-gate 	extern short ospeed;
45*0Sstevel@tonic-gate #ifdef TRACE
46*0Sstevel@tonic-gate 	int k, label;
47*0Sstevel@tonic-gate 	line *tmpadr;
48*0Sstevel@tonic-gate #endif
49*0Sstevel@tonic-gate 
50*0Sstevel@tonic-gate 	setnoaddr();
51*0Sstevel@tonic-gate 	if (skipend()) {
52*0Sstevel@tonic-gate 		if (peekchar() != EOF)
53*0Sstevel@tonic-gate 			ignchar();
54*0Sstevel@tonic-gate 		propts();
55*0Sstevel@tonic-gate 		return;
56*0Sstevel@tonic-gate 	}
57*0Sstevel@tonic-gate 	do {
58*0Sstevel@tonic-gate 		cp = optname;
59*0Sstevel@tonic-gate 		do {
60*0Sstevel@tonic-gate 			if (cp < &optname[ONMSZ - 2])
61*0Sstevel@tonic-gate 				*cp++ = getchar();
62*0Sstevel@tonic-gate 		} while (isalnum(peekchar()));
63*0Sstevel@tonic-gate 		*cp = 0;
64*0Sstevel@tonic-gate 		cp = optname;
65*0Sstevel@tonic-gate 		if (eq("all", cp)) {
66*0Sstevel@tonic-gate 			if (inopen)
67*0Sstevel@tonic-gate 				pofix();
68*0Sstevel@tonic-gate 			prall();
69*0Sstevel@tonic-gate 			goto next;
70*0Sstevel@tonic-gate 		}
71*0Sstevel@tonic-gate 		no = 0;
72*0Sstevel@tonic-gate #ifdef TRACE
73*0Sstevel@tonic-gate  		/*
74*0Sstevel@tonic-gate  		 * General purpose test code for looking at address of those
75*0Sstevel@tonic-gate  		 * invisible marks (as well as the visible ones).
76*0Sstevel@tonic-gate  		 */
77*0Sstevel@tonic-gate  		if (eq("marks",cp)) {
78*0Sstevel@tonic-gate  			printf("Marks   Address\n\r");
79*0Sstevel@tonic-gate  			printf("					\n");
80*0Sstevel@tonic-gate  			printf("\n");
81*0Sstevel@tonic-gate  			for (k=0; k<=25; k++)
82*0Sstevel@tonic-gate  				printf("Mark:%c\t%d\n",k+'a',names[k]);
83*0Sstevel@tonic-gate  		goto next;
84*0Sstevel@tonic-gate  		}
85*0Sstevel@tonic-gate 
86*0Sstevel@tonic-gate 		/*
87*0Sstevel@tonic-gate 		 * General purpose test code for looking at
88*0Sstevel@tonic-gate 		 * named registers.
89*0Sstevel@tonic-gate 		 */
90*0Sstevel@tonic-gate 
91*0Sstevel@tonic-gate 		if (eq("named",cp)) {
92*0Sstevel@tonic-gate 			if (inopen)
93*0Sstevel@tonic-gate 				pofix();
94*0Sstevel@tonic-gate 			shownam();
95*0Sstevel@tonic-gate 			goto next;
96*0Sstevel@tonic-gate 		}
97*0Sstevel@tonic-gate 
98*0Sstevel@tonic-gate 		/*
99*0Sstevel@tonic-gate 	   	 * General purpose test code for looking at
100*0Sstevel@tonic-gate 		 * numbered registers.
101*0Sstevel@tonic-gate 		 */
102*0Sstevel@tonic-gate 
103*0Sstevel@tonic-gate 		if (eq("nbrreg",cp)) {
104*0Sstevel@tonic-gate 			if (inopen)
105*0Sstevel@tonic-gate 				pofix();
106*0Sstevel@tonic-gate 			shownbr();
107*0Sstevel@tonic-gate 			goto next;
108*0Sstevel@tonic-gate 		}
109*0Sstevel@tonic-gate 
110*0Sstevel@tonic-gate 		/*
111*0Sstevel@tonic-gate  		 * General purpose test code for looking at addresses
112*0Sstevel@tonic-gate 		 * in the edit and save areas of VI.
113*0Sstevel@tonic-gate  		 */
114*0Sstevel@tonic-gate 
115*0Sstevel@tonic-gate  		if (eq("buffers",cp)) {
116*0Sstevel@tonic-gate  			if (inopen)
117*0Sstevel@tonic-gate 				pofix();
118*0Sstevel@tonic-gate 			printf("\nLabels   Address	Contents\n");
119*0Sstevel@tonic-gate  			printf("======   =======	========");
120*0Sstevel@tonic-gate 			for (tmpadr = zero; tmpadr <= dol; tmpadr++) {
121*0Sstevel@tonic-gate  				label =0;
122*0Sstevel@tonic-gate  				if (tmpadr == zero) {
123*0Sstevel@tonic-gate  					printf("ZERO:\t");
124*0Sstevel@tonic-gate  					label = 2;
125*0Sstevel@tonic-gate  				}
126*0Sstevel@tonic-gate  				if (tmpadr == one) {
127*0Sstevel@tonic-gate  					if (label > 0)
128*0Sstevel@tonic-gate  						printf("\nONE:\t");
129*0Sstevel@tonic-gate  					else
130*0Sstevel@tonic-gate  						printf("ONE:\t");
131*0Sstevel@tonic-gate  					label = 1;
132*0Sstevel@tonic-gate  				}
133*0Sstevel@tonic-gate  				if (tmpadr == dot) {
134*0Sstevel@tonic-gate  					if (label > 0)
135*0Sstevel@tonic-gate  						printf("\nDOT:\t");
136*0Sstevel@tonic-gate  					else
137*0Sstevel@tonic-gate  						printf("DOT:\t");
138*0Sstevel@tonic-gate  					label = 1;
139*0Sstevel@tonic-gate  				}
140*0Sstevel@tonic-gate  				if (tmpadr == undap1) {
141*0Sstevel@tonic-gate  					if (label > 0)
142*0Sstevel@tonic-gate  						printf("\nUNDAP1:\t");
143*0Sstevel@tonic-gate  					else
144*0Sstevel@tonic-gate  						printf("UNDAP1:\t");
145*0Sstevel@tonic-gate  					label = 1;
146*0Sstevel@tonic-gate  				}
147*0Sstevel@tonic-gate  				if (tmpadr == undap2) {
148*0Sstevel@tonic-gate  					if (label > 0)
149*0Sstevel@tonic-gate  						printf("\nUNDAP2:\t");
150*0Sstevel@tonic-gate  					else
151*0Sstevel@tonic-gate  						printf("UNDAP2:\t");
152*0Sstevel@tonic-gate  					label = 1;
153*0Sstevel@tonic-gate  				}
154*0Sstevel@tonic-gate  				if (tmpadr == unddel) {
155*0Sstevel@tonic-gate  					if (label > 0)
156*0Sstevel@tonic-gate  						printf("\nUNDDEL:\t");
157*0Sstevel@tonic-gate  					else
158*0Sstevel@tonic-gate  						printf("UNDDEL:\t");
159*0Sstevel@tonic-gate  					label = 1;
160*0Sstevel@tonic-gate  				}
161*0Sstevel@tonic-gate  				if (tmpadr == dol) {
162*0Sstevel@tonic-gate  					if (label > 0)
163*0Sstevel@tonic-gate  						printf("\nDOL:\t");
164*0Sstevel@tonic-gate  					else
165*0Sstevel@tonic-gate  						printf("DOL:\t");
166*0Sstevel@tonic-gate  					label = 1;
167*0Sstevel@tonic-gate  				}
168*0Sstevel@tonic-gate  				for (k=0; k<=25; k++)
169*0Sstevel@tonic-gate  					if (names[k] == (*tmpadr &~ 01)) {
170*0Sstevel@tonic-gate  						if (label > 0)
171*0Sstevel@tonic-gate  							printf("\nMark:%c\t%d\t",k+'a',names[k]);
172*0Sstevel@tonic-gate  						else
173*0Sstevel@tonic-gate  							printf("Mark:%c\t%d\t",k+'a',names[k]);
174*0Sstevel@tonic-gate  						label=1;
175*0Sstevel@tonic-gate  					}
176*0Sstevel@tonic-gate  				if (label == 0)
177*0Sstevel@tonic-gate  					continue;
178*0Sstevel@tonic-gate 
179*0Sstevel@tonic-gate  				if (label == 2)
180*0Sstevel@tonic-gate  					printf("%d\n",tmpadr);
181*0Sstevel@tonic-gate  				else  {
182*0Sstevel@tonic-gate  					printf("%d\t",tmpadr);
183*0Sstevel@tonic-gate  					getline(*tmpadr);
184*0Sstevel@tonic-gate  					pline(lineno(tmpadr));
185*0Sstevel@tonic-gate  					putchar('\n');
186*0Sstevel@tonic-gate  				}
187*0Sstevel@tonic-gate  			}
188*0Sstevel@tonic-gate 
189*0Sstevel@tonic-gate  			for (tmpadr = dol+1; tmpadr <= unddol; tmpadr++) {
190*0Sstevel@tonic-gate  				label =0;
191*0Sstevel@tonic-gate  				if (tmpadr == dol+1) {
192*0Sstevel@tonic-gate  					printf("DOL+1:\t");
193*0Sstevel@tonic-gate  					label = 1;
194*0Sstevel@tonic-gate  				}
195*0Sstevel@tonic-gate  				if (tmpadr == unddel) {
196*0Sstevel@tonic-gate  					if (label > 0)
197*0Sstevel@tonic-gate  						printf("\nUNDDEL:\t");
198*0Sstevel@tonic-gate  					else
199*0Sstevel@tonic-gate  						printf("UNDDEL:\t");
200*0Sstevel@tonic-gate  					label = 1;
201*0Sstevel@tonic-gate  				}
202*0Sstevel@tonic-gate  				if (tmpadr == unddol) {
203*0Sstevel@tonic-gate  					if (label > 0)
204*0Sstevel@tonic-gate  						printf("\nUNDDOL:\t");
205*0Sstevel@tonic-gate  					else
206*0Sstevel@tonic-gate  						printf("UNDDOL:\t");
207*0Sstevel@tonic-gate  					label = 1;
208*0Sstevel@tonic-gate  				}
209*0Sstevel@tonic-gate  				for (k=0; k<=25; k++)
210*0Sstevel@tonic-gate  					if (names[k] == (*tmpadr &~ 01)) {
211*0Sstevel@tonic-gate  						if (label > 0)
212*0Sstevel@tonic-gate  							printf("\nMark:%c\t%d\t",k+'a',names[k]);
213*0Sstevel@tonic-gate  						else
214*0Sstevel@tonic-gate  							printf("Mark:%c\t%d\t",k+'a',names[k]);
215*0Sstevel@tonic-gate  						label=1;
216*0Sstevel@tonic-gate  					}
217*0Sstevel@tonic-gate  				if (label == 0)
218*0Sstevel@tonic-gate  					continue;
219*0Sstevel@tonic-gate  				if (label == 2)
220*0Sstevel@tonic-gate  					printf("%d\n",tmpadr);
221*0Sstevel@tonic-gate  				else  {
222*0Sstevel@tonic-gate  					printf("%d\t",tmpadr);
223*0Sstevel@tonic-gate  					getline(*tmpadr);
224*0Sstevel@tonic-gate  					pline(lineno(tmpadr));
225*0Sstevel@tonic-gate  					putchar('\n');
226*0Sstevel@tonic-gate  				}
227*0Sstevel@tonic-gate  			}
228*0Sstevel@tonic-gate  			goto next;
229*0Sstevel@tonic-gate  		}
230*0Sstevel@tonic-gate #endif
231*0Sstevel@tonic-gate 		if (cp[0] == 'n' && cp[1] == 'o' && cp[2] != 'v') {
232*0Sstevel@tonic-gate 			cp += 2;
233*0Sstevel@tonic-gate 			no++;
234*0Sstevel@tonic-gate 		}
235*0Sstevel@tonic-gate 		/* Implement w300, w1200, and w9600 specially */
236*0Sstevel@tonic-gate 		if (eq(cp, "w300")) {
237*0Sstevel@tonic-gate 			if (ospeed >= B1200) {
238*0Sstevel@tonic-gate dontset:
239*0Sstevel@tonic-gate 				(void)getchar();	/* = */
240*0Sstevel@tonic-gate 				(void)getnum();	/* value */
241*0Sstevel@tonic-gate 				continue;
242*0Sstevel@tonic-gate 			}
243*0Sstevel@tonic-gate 			cp = (unsigned char *)"window";
244*0Sstevel@tonic-gate 		} else if (eq(cp, "w1200")) {
245*0Sstevel@tonic-gate 			if (ospeed < B1200 || ospeed >= B2400)
246*0Sstevel@tonic-gate 				goto dontset;
247*0Sstevel@tonic-gate 			cp = (unsigned char *)"window";
248*0Sstevel@tonic-gate 		} else if (eq(cp, "w9600")) {
249*0Sstevel@tonic-gate 			if (ospeed < B2400)
250*0Sstevel@tonic-gate 				goto dontset;
251*0Sstevel@tonic-gate 			cp = (unsigned char *)"window";
252*0Sstevel@tonic-gate 		}
253*0Sstevel@tonic-gate 		for (op = options; op < &options[vi_NOPTS]; op++)
254*0Sstevel@tonic-gate 			if (eq(op->oname, cp) || op->oabbrev && eq(op->oabbrev, cp))
255*0Sstevel@tonic-gate 				break;
256*0Sstevel@tonic-gate 		if (op->oname == 0)
257*0Sstevel@tonic-gate 			serror(value(vi_TERSE) ? gettext("%s: No such option") :
258*0Sstevel@tonic-gate gettext("%s: No such option - 'set all' gives all option values"), cp);
259*0Sstevel@tonic-gate 		c = skipwh();
260*0Sstevel@tonic-gate 		if (peekchar() == '?') {
261*0Sstevel@tonic-gate 			ignchar();
262*0Sstevel@tonic-gate printone:
263*0Sstevel@tonic-gate 			propt(op);
264*0Sstevel@tonic-gate 			noonl();
265*0Sstevel@tonic-gate 			goto next;
266*0Sstevel@tonic-gate 		}
267*0Sstevel@tonic-gate 		if (op->otype == ONOFF) {
268*0Sstevel@tonic-gate 			op->ovalue = 1 - no;
269*0Sstevel@tonic-gate 			if (op == &options[vi_PROMPT])
270*0Sstevel@tonic-gate 				oprompt = 1 - no;
271*0Sstevel@tonic-gate 			goto next;
272*0Sstevel@tonic-gate 		}
273*0Sstevel@tonic-gate 		if (no)
274*0Sstevel@tonic-gate 			serror(gettext("Option %s is not a toggle"), op->oname);
275*0Sstevel@tonic-gate 		if (c != 0 || setend())
276*0Sstevel@tonic-gate 			goto printone;
277*0Sstevel@tonic-gate 		if (getchar() != '=')
278*0Sstevel@tonic-gate 			serror(value(vi_TERSE) ? gettext("Missing =") :
279*0Sstevel@tonic-gate gettext("Missing = in assignment to option %s"), op->oname);
280*0Sstevel@tonic-gate 		switch (op->otype) {
281*0Sstevel@tonic-gate 
282*0Sstevel@tonic-gate 		case NUMERIC:
283*0Sstevel@tonic-gate 			if (!isdigit(peekchar()))
284*0Sstevel@tonic-gate 				error(value(vi_TERSE) ?
285*0Sstevel@tonic-gate gettext("Digits required") : gettext("Digits required after ="));
286*0Sstevel@tonic-gate 			op->ovalue = getnum();
287*0Sstevel@tonic-gate 			if (value(vi_TABSTOP) <= 0)
288*0Sstevel@tonic-gate 				value(vi_TABSTOP) = TABS;
289*0Sstevel@tonic-gate 			if (op == &options[vi_WINDOW]) {
290*0Sstevel@tonic-gate 				if (value(vi_WINDOW) >= lines)
291*0Sstevel@tonic-gate 					value(vi_WINDOW) = lines-1;
292*0Sstevel@tonic-gate 				vsetsiz(value(vi_WINDOW));
293*0Sstevel@tonic-gate 			}
294*0Sstevel@tonic-gate 			break;
295*0Sstevel@tonic-gate 
296*0Sstevel@tonic-gate 		case STRING:
297*0Sstevel@tonic-gate 		case OTERM:
298*0Sstevel@tonic-gate 			cp = optname;
299*0Sstevel@tonic-gate 			while (!setend()) {
300*0Sstevel@tonic-gate 				if (cp >= &optname[ONMSZ])
301*0Sstevel@tonic-gate 					error(value(vi_TERSE) ?
302*0Sstevel@tonic-gate gettext("String too long") : gettext("String too long in option assignment"));
303*0Sstevel@tonic-gate 				/* adb change:  allow whitepace in strings */
304*0Sstevel@tonic-gate 				if( (*cp = getchar()) == '\\')
305*0Sstevel@tonic-gate 					if( peekchar() != EOF)
306*0Sstevel@tonic-gate 						*cp = getchar();
307*0Sstevel@tonic-gate 				cp++;
308*0Sstevel@tonic-gate 			}
309*0Sstevel@tonic-gate 			*cp = 0;
310*0Sstevel@tonic-gate 			if (op->otype == OTERM) {
311*0Sstevel@tonic-gate /*
312*0Sstevel@tonic-gate  * At first glance it seems like we shouldn't care if the terminal type
313*0Sstevel@tonic-gate  * is changed inside visual mode, as long as we assume the screen is
314*0Sstevel@tonic-gate  * a mess and redraw it. However, it's a much harder problem than that.
315*0Sstevel@tonic-gate  * If you happen to change from 1 crt to another that both have the same
316*0Sstevel@tonic-gate  * size screen, it's OK. But if the screen size if different, the stuff
317*0Sstevel@tonic-gate  * that gets initialized in vop() will be wrong. This could be overcome
318*0Sstevel@tonic-gate  * by redoing the initialization, e.g. making the first 90% of vop into
319*0Sstevel@tonic-gate  * a subroutine. However, the most useful case is where you forgot to do
320*0Sstevel@tonic-gate  * a setenv before you went into the editor and it thinks you're on a dumb
321*0Sstevel@tonic-gate  * terminal. Ex treats this like hardcopy and goes into HARDOPEN mode.
322*0Sstevel@tonic-gate  * This loses because the first part of vop calls oop in this case.
323*0Sstevel@tonic-gate  */
324*0Sstevel@tonic-gate 				if (inopen)
325*0Sstevel@tonic-gate error(gettext("Can't change type of terminal from within open/visual"));
326*0Sstevel@tonic-gate 				unterm();
327*0Sstevel@tonic-gate 				setterm(optname);
328*0Sstevel@tonic-gate 			} else {
329*0Sstevel@tonic-gate 				CP(op->osvalue, optname);
330*0Sstevel@tonic-gate 				op->odefault = 1;
331*0Sstevel@tonic-gate 			}
332*0Sstevel@tonic-gate 			break;
333*0Sstevel@tonic-gate 		}
334*0Sstevel@tonic-gate next:
335*0Sstevel@tonic-gate 		flush();
336*0Sstevel@tonic-gate 	} while (!skipend());
337*0Sstevel@tonic-gate 	eol();
338*0Sstevel@tonic-gate }
339*0Sstevel@tonic-gate 
340*0Sstevel@tonic-gate unterm()
341*0Sstevel@tonic-gate {
342*0Sstevel@tonic-gate 	/*
343*0Sstevel@tonic-gate 	 *  All terminal mapped statements must be deleted.
344*0Sstevel@tonic-gate 	 *  All user-defined mapped statements, cap=descr,
345*0Sstevel@tonic-gate 	 *  are left unchanged.
346*0Sstevel@tonic-gate 	 */
347*0Sstevel@tonic-gate 
348*0Sstevel@tonic-gate 	int i;
349*0Sstevel@tonic-gate 
350*0Sstevel@tonic-gate 	for (i=0; i < MAXNOMACS; i++) {
351*0Sstevel@tonic-gate 
352*0Sstevel@tonic-gate 		/*
353*0Sstevel@tonic-gate 		 * Unmap any terminal-defined arrow keys
354*0Sstevel@tonic-gate 		 */
355*0Sstevel@tonic-gate 
356*0Sstevel@tonic-gate 		if (arrows[i].cap && arrows[i].descr &&
357*0Sstevel@tonic-gate 		    strcmp(arrows[i].cap, arrows[i].descr))
358*0Sstevel@tonic-gate 			addmac(arrows[i].cap, NOSTR, NOSTR, arrows);
359*0Sstevel@tonic-gate 
360*0Sstevel@tonic-gate 		/*
361*0Sstevel@tonic-gate 		 * Unmap any terminal-defined function keys
362*0Sstevel@tonic-gate 		 */
363*0Sstevel@tonic-gate 
364*0Sstevel@tonic-gate 		if (immacs[i].cap && immacs[i].descr && strcmp(immacs[i].cap, immacs[i].descr))
365*0Sstevel@tonic-gate 			addmac(immacs[i].cap, NOSTR, NOSTR, immacs);
366*0Sstevel@tonic-gate 
367*0Sstevel@tonic-gate 	}
368*0Sstevel@tonic-gate }
369*0Sstevel@tonic-gate 
370*0Sstevel@tonic-gate 
371*0Sstevel@tonic-gate setend()
372*0Sstevel@tonic-gate {
373*0Sstevel@tonic-gate 
374*0Sstevel@tonic-gate 	return (iswhite(peekchar()) || endcmd(peekchar()));
375*0Sstevel@tonic-gate }
376*0Sstevel@tonic-gate 
377*0Sstevel@tonic-gate prall()
378*0Sstevel@tonic-gate {
379*0Sstevel@tonic-gate 	register int incr = (vi_NOPTS + 2) / 3;
380*0Sstevel@tonic-gate 	register int rows = incr;
381*0Sstevel@tonic-gate 	register struct option *op = options;
382*0Sstevel@tonic-gate 
383*0Sstevel@tonic-gate 	for (; rows; rows--, op++) {
384*0Sstevel@tonic-gate 		propt(op);
385*0Sstevel@tonic-gate 		gotab(24);
386*0Sstevel@tonic-gate 		propt(&op[incr]);
387*0Sstevel@tonic-gate 		if (&op[2*incr] < &options[vi_NOPTS]) {
388*0Sstevel@tonic-gate 			gotab(56);
389*0Sstevel@tonic-gate 			propt(&op[2 * incr]);
390*0Sstevel@tonic-gate 		}
391*0Sstevel@tonic-gate 		putNFL();
392*0Sstevel@tonic-gate 	}
393*0Sstevel@tonic-gate }
394*0Sstevel@tonic-gate 
395*0Sstevel@tonic-gate propts()
396*0Sstevel@tonic-gate {
397*0Sstevel@tonic-gate 	register struct option *op;
398*0Sstevel@tonic-gate 
399*0Sstevel@tonic-gate 	for (op = options; op < &options[vi_NOPTS]; op++) {
400*0Sstevel@tonic-gate 		if (op == &options[vi_TTYTYPE])
401*0Sstevel@tonic-gate 			continue;
402*0Sstevel@tonic-gate 		switch (op->otype) {
403*0Sstevel@tonic-gate 
404*0Sstevel@tonic-gate 		case ONOFF:
405*0Sstevel@tonic-gate 		case NUMERIC:
406*0Sstevel@tonic-gate 			if (op->ovalue == op->odefault)
407*0Sstevel@tonic-gate 				continue;
408*0Sstevel@tonic-gate 			break;
409*0Sstevel@tonic-gate 
410*0Sstevel@tonic-gate 		case STRING:
411*0Sstevel@tonic-gate 			if (op->odefault == 0)
412*0Sstevel@tonic-gate 				continue;
413*0Sstevel@tonic-gate 			break;
414*0Sstevel@tonic-gate 		}
415*0Sstevel@tonic-gate 		propt(op);
416*0Sstevel@tonic-gate 		putchar(' ');
417*0Sstevel@tonic-gate 	}
418*0Sstevel@tonic-gate 	noonl();
419*0Sstevel@tonic-gate 	flush();
420*0Sstevel@tonic-gate }
421*0Sstevel@tonic-gate 
422*0Sstevel@tonic-gate propt(op)
423*0Sstevel@tonic-gate 	register struct option *op;
424*0Sstevel@tonic-gate {
425*0Sstevel@tonic-gate 	register unsigned char *name;
426*0Sstevel@tonic-gate 
427*0Sstevel@tonic-gate 	name = (unsigned char *)op->oname;
428*0Sstevel@tonic-gate 
429*0Sstevel@tonic-gate 	switch (op->otype) {
430*0Sstevel@tonic-gate 
431*0Sstevel@tonic-gate 	case ONOFF:
432*0Sstevel@tonic-gate 		printf("%s%s", op->ovalue ? "" : "no", name);
433*0Sstevel@tonic-gate 		break;
434*0Sstevel@tonic-gate 
435*0Sstevel@tonic-gate 	case NUMERIC:
436*0Sstevel@tonic-gate 		printf("%s=%d", name, op->ovalue);
437*0Sstevel@tonic-gate 		break;
438*0Sstevel@tonic-gate 
439*0Sstevel@tonic-gate 	case STRING:
440*0Sstevel@tonic-gate 	case OTERM:
441*0Sstevel@tonic-gate 		printf("%s=%s", name, op->osvalue);
442*0Sstevel@tonic-gate 		break;
443*0Sstevel@tonic-gate 	}
444*0Sstevel@tonic-gate }
445