17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
523a1cceaSRoger A. Faulkner * Common Development and Distribution License (the "License").
623a1cceaSRoger A. Faulkner * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate *
87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate * and limitations under the License.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * CDDL HEADER END
207c478bd9Sstevel@tonic-gate */
2123a1cceaSRoger A. Faulkner
22f6db9f27Scf /*
2323a1cceaSRoger A. Faulkner * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
24f6db9f27Scf */
25f6db9f27Scf
267c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
277c478bd9Sstevel@tonic-gate /* All Rights Reserved */
287c478bd9Sstevel@tonic-gate
297c478bd9Sstevel@tonic-gate
307c478bd9Sstevel@tonic-gate /* Copyright (c) 1981 Regents of the University of California */
31f6db9f27Scf
327c478bd9Sstevel@tonic-gate #include "ex.h"
337c478bd9Sstevel@tonic-gate #include "ex_temp.h"
347c478bd9Sstevel@tonic-gate #include "ex_tty.h"
357c478bd9Sstevel@tonic-gate
367c478bd9Sstevel@tonic-gate /*
377c478bd9Sstevel@tonic-gate * Set command.
387c478bd9Sstevel@tonic-gate */
397c478bd9Sstevel@tonic-gate unsigned char optname[ONMSZ];
407c478bd9Sstevel@tonic-gate
41f6db9f27Scf void
set(void)42f6db9f27Scf set(void)
437c478bd9Sstevel@tonic-gate {
44f6db9f27Scf unsigned char *cp;
45f6db9f27Scf struct option *op;
46f6db9f27Scf int c;
477c478bd9Sstevel@tonic-gate bool no;
487c478bd9Sstevel@tonic-gate extern short ospeed;
497c478bd9Sstevel@tonic-gate #ifdef TRACE
507c478bd9Sstevel@tonic-gate int k, label;
517c478bd9Sstevel@tonic-gate line *tmpadr;
527c478bd9Sstevel@tonic-gate #endif
537c478bd9Sstevel@tonic-gate
547c478bd9Sstevel@tonic-gate setnoaddr();
557c478bd9Sstevel@tonic-gate if (skipend()) {
567c478bd9Sstevel@tonic-gate if (peekchar() != EOF)
577c478bd9Sstevel@tonic-gate ignchar();
587c478bd9Sstevel@tonic-gate propts();
597c478bd9Sstevel@tonic-gate return;
607c478bd9Sstevel@tonic-gate }
617c478bd9Sstevel@tonic-gate do {
627c478bd9Sstevel@tonic-gate cp = optname;
637c478bd9Sstevel@tonic-gate do {
647c478bd9Sstevel@tonic-gate if (cp < &optname[ONMSZ - 2])
657c478bd9Sstevel@tonic-gate *cp++ = getchar();
667c478bd9Sstevel@tonic-gate } while (isalnum(peekchar()));
677c478bd9Sstevel@tonic-gate *cp = 0;
687c478bd9Sstevel@tonic-gate cp = optname;
697c478bd9Sstevel@tonic-gate if (eq("all", cp)) {
707c478bd9Sstevel@tonic-gate if (inopen)
717c478bd9Sstevel@tonic-gate pofix();
727c478bd9Sstevel@tonic-gate prall();
737c478bd9Sstevel@tonic-gate goto next;
747c478bd9Sstevel@tonic-gate }
757c478bd9Sstevel@tonic-gate no = 0;
767c478bd9Sstevel@tonic-gate #ifdef TRACE
777c478bd9Sstevel@tonic-gate /*
787c478bd9Sstevel@tonic-gate * General purpose test code for looking at address of those
797c478bd9Sstevel@tonic-gate * invisible marks (as well as the visible ones).
807c478bd9Sstevel@tonic-gate */
81f6db9f27Scf if (eq("marks", cp)) {
82f6db9f27Scf viprintf("Marks Address\n\r");
83f6db9f27Scf viprintf(" \n");
84f6db9f27Scf viprintf("\n");
85f6db9f27Scf for (k = 0; k <= 25; k++)
86f6db9f27Scf viprintf("Mark:%c\t%d\n", k+'a', names[k]);
877c478bd9Sstevel@tonic-gate goto next;
887c478bd9Sstevel@tonic-gate }
897c478bd9Sstevel@tonic-gate
907c478bd9Sstevel@tonic-gate /*
917c478bd9Sstevel@tonic-gate * General purpose test code for looking at
927c478bd9Sstevel@tonic-gate * named registers.
937c478bd9Sstevel@tonic-gate */
947c478bd9Sstevel@tonic-gate
957c478bd9Sstevel@tonic-gate if (eq("named",cp)) {
967c478bd9Sstevel@tonic-gate if (inopen)
977c478bd9Sstevel@tonic-gate pofix();
987c478bd9Sstevel@tonic-gate shownam();
997c478bd9Sstevel@tonic-gate goto next;
1007c478bd9Sstevel@tonic-gate }
1017c478bd9Sstevel@tonic-gate
1027c478bd9Sstevel@tonic-gate /*
1037c478bd9Sstevel@tonic-gate * General purpose test code for looking at
1047c478bd9Sstevel@tonic-gate * numbered registers.
1057c478bd9Sstevel@tonic-gate */
1067c478bd9Sstevel@tonic-gate
1077c478bd9Sstevel@tonic-gate if (eq("nbrreg",cp)) {
1087c478bd9Sstevel@tonic-gate if (inopen)
1097c478bd9Sstevel@tonic-gate pofix();
1107c478bd9Sstevel@tonic-gate shownbr();
1117c478bd9Sstevel@tonic-gate goto next;
1127c478bd9Sstevel@tonic-gate }
1137c478bd9Sstevel@tonic-gate
1147c478bd9Sstevel@tonic-gate /*
1157c478bd9Sstevel@tonic-gate * General purpose test code for looking at addresses
1167c478bd9Sstevel@tonic-gate * in the edit and save areas of VI.
1177c478bd9Sstevel@tonic-gate */
1187c478bd9Sstevel@tonic-gate
1197c478bd9Sstevel@tonic-gate if (eq("buffers",cp)) {
1207c478bd9Sstevel@tonic-gate if (inopen)
1217c478bd9Sstevel@tonic-gate pofix();
122f6db9f27Scf viprintf("\nLabels Address Contents\n");
123f6db9f27Scf viprintf("====== ======= ========");
1247c478bd9Sstevel@tonic-gate for (tmpadr = zero; tmpadr <= dol; tmpadr++) {
1257c478bd9Sstevel@tonic-gate label =0;
126f6db9f27Scf if (tmpadr == zero) {
127f6db9f27Scf viprintf("ZERO:\t");
1287c478bd9Sstevel@tonic-gate label = 2;
1297c478bd9Sstevel@tonic-gate }
1307c478bd9Sstevel@tonic-gate if (tmpadr == one) {
131f6db9f27Scf if (label > 0)
132f6db9f27Scf viprintf("\nONE:\t");
133f6db9f27Scf else
134f6db9f27Scf viprintf("ONE:\t");
1357c478bd9Sstevel@tonic-gate label = 1;
1367c478bd9Sstevel@tonic-gate }
1377c478bd9Sstevel@tonic-gate if (tmpadr == dot) {
138f6db9f27Scf if (label > 0)
139f6db9f27Scf viprintf("\nDOT:\t");
140f6db9f27Scf else
141f6db9f27Scf viprintf("DOT:\t");
1427c478bd9Sstevel@tonic-gate label = 1;
1437c478bd9Sstevel@tonic-gate }
1447c478bd9Sstevel@tonic-gate if (tmpadr == undap1) {
1457c478bd9Sstevel@tonic-gate if (label > 0)
146f6db9f27Scf viprintf("\nUNDAP1:\t");
1477c478bd9Sstevel@tonic-gate else
148f6db9f27Scf viprintf("UNDAP1:\t");
1497c478bd9Sstevel@tonic-gate label = 1;
1507c478bd9Sstevel@tonic-gate }
1517c478bd9Sstevel@tonic-gate if (tmpadr == undap2) {
1527c478bd9Sstevel@tonic-gate if (label > 0)
153f6db9f27Scf viprintf("\nUNDAP2:\t");
1547c478bd9Sstevel@tonic-gate else
155f6db9f27Scf viprintf("UNDAP2:\t");
1567c478bd9Sstevel@tonic-gate label = 1;
1577c478bd9Sstevel@tonic-gate }
1587c478bd9Sstevel@tonic-gate if (tmpadr == unddel) {
1597c478bd9Sstevel@tonic-gate if (label > 0)
160f6db9f27Scf viprintf("\nUNDDEL:\t");
1617c478bd9Sstevel@tonic-gate else
162f6db9f27Scf viprintf("UNDDEL:\t");
1637c478bd9Sstevel@tonic-gate label = 1;
1647c478bd9Sstevel@tonic-gate }
1657c478bd9Sstevel@tonic-gate if (tmpadr == dol) {
1667c478bd9Sstevel@tonic-gate if (label > 0)
167f6db9f27Scf viprintf("\nDOL:\t");
1687c478bd9Sstevel@tonic-gate else
169f6db9f27Scf viprintf("DOL:\t");
1707c478bd9Sstevel@tonic-gate label = 1;
1717c478bd9Sstevel@tonic-gate }
172*55fea89dSDan Cross for (k=0; k<=25; k++)
1737c478bd9Sstevel@tonic-gate if (names[k] == (*tmpadr &~ 01)) {
1747c478bd9Sstevel@tonic-gate if (label > 0)
175f6db9f27Scf viprintf(
176f6db9f27Scf "\nMark:%c\t%d\t", k+'a', names[k]);
1777c478bd9Sstevel@tonic-gate else
178f6db9f27Scf viprintf(
179f6db9f27Scf "Mark:%c\t%d\t", k+'a', names[k]);
1807c478bd9Sstevel@tonic-gate label=1;
1817c478bd9Sstevel@tonic-gate }
182*55fea89dSDan Cross if (label == 0)
1837c478bd9Sstevel@tonic-gate continue;
1847c478bd9Sstevel@tonic-gate
1857c478bd9Sstevel@tonic-gate if (label == 2)
186f6db9f27Scf viprintf("%d\n", tmpadr);
1877c478bd9Sstevel@tonic-gate else {
188f6db9f27Scf viprintf("%d\t", tmpadr);
18923a1cceaSRoger A. Faulkner getaline(*tmpadr);
1907c478bd9Sstevel@tonic-gate pline(lineno(tmpadr));
1917c478bd9Sstevel@tonic-gate putchar('\n');
1927c478bd9Sstevel@tonic-gate }
1937c478bd9Sstevel@tonic-gate }
1947c478bd9Sstevel@tonic-gate
1957c478bd9Sstevel@tonic-gate for (tmpadr = dol+1; tmpadr <= unddol; tmpadr++) {
1967c478bd9Sstevel@tonic-gate label =0;
1977c478bd9Sstevel@tonic-gate if (tmpadr == dol+1) {
198f6db9f27Scf viprintf("DOL+1:\t");
1997c478bd9Sstevel@tonic-gate label = 1;
2007c478bd9Sstevel@tonic-gate }
2017c478bd9Sstevel@tonic-gate if (tmpadr == unddel) {
2027c478bd9Sstevel@tonic-gate if (label > 0)
203f6db9f27Scf viprintf("\nUNDDEL:\t");
2047c478bd9Sstevel@tonic-gate else
205f6db9f27Scf viprintf("UNDDEL:\t");
2067c478bd9Sstevel@tonic-gate label = 1;
2077c478bd9Sstevel@tonic-gate }
2087c478bd9Sstevel@tonic-gate if (tmpadr == unddol) {
2097c478bd9Sstevel@tonic-gate if (label > 0)
210f6db9f27Scf viprintf("\nUNDDOL:\t");
2117c478bd9Sstevel@tonic-gate else
212f6db9f27Scf viprintf("UNDDOL:\t");
2137c478bd9Sstevel@tonic-gate label = 1;
2147c478bd9Sstevel@tonic-gate }
215*55fea89dSDan Cross for (k=0; k<=25; k++)
2167c478bd9Sstevel@tonic-gate if (names[k] == (*tmpadr &~ 01)) {
2177c478bd9Sstevel@tonic-gate if (label > 0)
218f6db9f27Scf viprintf(
219f6db9f27Scf "\nMark:%c\t%d\t", k+'a', names[k]);
2207c478bd9Sstevel@tonic-gate else
221f6db9f27Scf viprintf(
222f6db9f27Scf "Mark:%c\t%d\t", k+'a', names[k]);
2237c478bd9Sstevel@tonic-gate label=1;
2247c478bd9Sstevel@tonic-gate }
2257c478bd9Sstevel@tonic-gate if (label == 0)
2267c478bd9Sstevel@tonic-gate continue;
2277c478bd9Sstevel@tonic-gate if (label == 2)
228f6db9f27Scf viprintf("%d\n", tmpadr);
2297c478bd9Sstevel@tonic-gate else {
230f6db9f27Scf viprintf("%d\t", tmpadr);
23123a1cceaSRoger A. Faulkner getaline(*tmpadr);
2327c478bd9Sstevel@tonic-gate pline(lineno(tmpadr));
2337c478bd9Sstevel@tonic-gate putchar('\n');
2347c478bd9Sstevel@tonic-gate }
2357c478bd9Sstevel@tonic-gate }
2367c478bd9Sstevel@tonic-gate goto next;
2377c478bd9Sstevel@tonic-gate }
238*55fea89dSDan Cross #endif
2397c478bd9Sstevel@tonic-gate if (cp[0] == 'n' && cp[1] == 'o' && cp[2] != 'v') {
2407c478bd9Sstevel@tonic-gate cp += 2;
2417c478bd9Sstevel@tonic-gate no++;
2427c478bd9Sstevel@tonic-gate }
2437c478bd9Sstevel@tonic-gate /* Implement w300, w1200, and w9600 specially */
2447c478bd9Sstevel@tonic-gate if (eq(cp, "w300")) {
2457c478bd9Sstevel@tonic-gate if (ospeed >= B1200) {
2467c478bd9Sstevel@tonic-gate dontset:
2477c478bd9Sstevel@tonic-gate (void)getchar(); /* = */
2487c478bd9Sstevel@tonic-gate (void)getnum(); /* value */
2497c478bd9Sstevel@tonic-gate continue;
2507c478bd9Sstevel@tonic-gate }
2517c478bd9Sstevel@tonic-gate cp = (unsigned char *)"window";
2527c478bd9Sstevel@tonic-gate } else if (eq(cp, "w1200")) {
2537c478bd9Sstevel@tonic-gate if (ospeed < B1200 || ospeed >= B2400)
2547c478bd9Sstevel@tonic-gate goto dontset;
2557c478bd9Sstevel@tonic-gate cp = (unsigned char *)"window";
2567c478bd9Sstevel@tonic-gate } else if (eq(cp, "w9600")) {
2577c478bd9Sstevel@tonic-gate if (ospeed < B2400)
2587c478bd9Sstevel@tonic-gate goto dontset;
2597c478bd9Sstevel@tonic-gate cp = (unsigned char *)"window";
2607c478bd9Sstevel@tonic-gate }
2617c478bd9Sstevel@tonic-gate for (op = options; op < &options[vi_NOPTS]; op++)
2627c478bd9Sstevel@tonic-gate if (eq(op->oname, cp) || op->oabbrev && eq(op->oabbrev, cp))
2637c478bd9Sstevel@tonic-gate break;
2647c478bd9Sstevel@tonic-gate if (op->oname == 0)
265f6db9f27Scf serror(value(vi_TERSE) ? (unsigned char *)
266f6db9f27Scf gettext("%s: No such option") :
267f6db9f27Scf (unsigned char *)
2687c478bd9Sstevel@tonic-gate gettext("%s: No such option - 'set all' gives all option values"), cp);
2697c478bd9Sstevel@tonic-gate c = skipwh();
2707c478bd9Sstevel@tonic-gate if (peekchar() == '?') {
2717c478bd9Sstevel@tonic-gate ignchar();
2727c478bd9Sstevel@tonic-gate printone:
2737c478bd9Sstevel@tonic-gate propt(op);
2747c478bd9Sstevel@tonic-gate noonl();
2757c478bd9Sstevel@tonic-gate goto next;
2767c478bd9Sstevel@tonic-gate }
2777c478bd9Sstevel@tonic-gate if (op->otype == ONOFF) {
2787c478bd9Sstevel@tonic-gate op->ovalue = 1 - no;
2797c478bd9Sstevel@tonic-gate if (op == &options[vi_PROMPT])
2807c478bd9Sstevel@tonic-gate oprompt = 1 - no;
2817c478bd9Sstevel@tonic-gate goto next;
2827c478bd9Sstevel@tonic-gate }
2837c478bd9Sstevel@tonic-gate if (no)
284f6db9f27Scf serror((unsigned char *)
285f6db9f27Scf gettext("Option %s is not a toggle"), op->oname);
2867c478bd9Sstevel@tonic-gate if (c != 0 || setend())
2877c478bd9Sstevel@tonic-gate goto printone;
2887c478bd9Sstevel@tonic-gate if (getchar() != '=')
289f6db9f27Scf serror(value(vi_TERSE) ? (unsigned char *)
290f6db9f27Scf gettext("Missing =") :
291f6db9f27Scf (unsigned char *)
292f6db9f27Scf gettext("Missing = in assignment to option %s"),
293f6db9f27Scf op->oname);
2947c478bd9Sstevel@tonic-gate switch (op->otype) {
2957c478bd9Sstevel@tonic-gate
2967c478bd9Sstevel@tonic-gate case NUMERIC:
2977c478bd9Sstevel@tonic-gate if (!isdigit(peekchar()))
2987c478bd9Sstevel@tonic-gate error(value(vi_TERSE) ?
2997c478bd9Sstevel@tonic-gate gettext("Digits required") : gettext("Digits required after ="));
3007c478bd9Sstevel@tonic-gate op->ovalue = getnum();
3017c478bd9Sstevel@tonic-gate if (value(vi_TABSTOP) <= 0)
3027c478bd9Sstevel@tonic-gate value(vi_TABSTOP) = TABS;
3037c478bd9Sstevel@tonic-gate if (op == &options[vi_WINDOW]) {
3047c478bd9Sstevel@tonic-gate if (value(vi_WINDOW) >= lines)
3057c478bd9Sstevel@tonic-gate value(vi_WINDOW) = lines-1;
3067c478bd9Sstevel@tonic-gate vsetsiz(value(vi_WINDOW));
3077c478bd9Sstevel@tonic-gate }
3087c478bd9Sstevel@tonic-gate break;
3097c478bd9Sstevel@tonic-gate
3107c478bd9Sstevel@tonic-gate case STRING:
3117c478bd9Sstevel@tonic-gate case OTERM:
3127c478bd9Sstevel@tonic-gate cp = optname;
3137c478bd9Sstevel@tonic-gate while (!setend()) {
3147c478bd9Sstevel@tonic-gate if (cp >= &optname[ONMSZ])
3157c478bd9Sstevel@tonic-gate error(value(vi_TERSE) ?
3167c478bd9Sstevel@tonic-gate gettext("String too long") : gettext("String too long in option assignment"));
3177c478bd9Sstevel@tonic-gate /* adb change: allow whitepace in strings */
3187c478bd9Sstevel@tonic-gate if( (*cp = getchar()) == '\\')
3197c478bd9Sstevel@tonic-gate if( peekchar() != EOF)
3207c478bd9Sstevel@tonic-gate *cp = getchar();
3217c478bd9Sstevel@tonic-gate cp++;
3227c478bd9Sstevel@tonic-gate }
3237c478bd9Sstevel@tonic-gate *cp = 0;
3247c478bd9Sstevel@tonic-gate if (op->otype == OTERM) {
3257c478bd9Sstevel@tonic-gate /*
3267c478bd9Sstevel@tonic-gate * At first glance it seems like we shouldn't care if the terminal type
3277c478bd9Sstevel@tonic-gate * is changed inside visual mode, as long as we assume the screen is
3287c478bd9Sstevel@tonic-gate * a mess and redraw it. However, it's a much harder problem than that.
3297c478bd9Sstevel@tonic-gate * If you happen to change from 1 crt to another that both have the same
3307c478bd9Sstevel@tonic-gate * size screen, it's OK. But if the screen size if different, the stuff
3317c478bd9Sstevel@tonic-gate * that gets initialized in vop() will be wrong. This could be overcome
3327c478bd9Sstevel@tonic-gate * by redoing the initialization, e.g. making the first 90% of vop into
3337c478bd9Sstevel@tonic-gate * a subroutine. However, the most useful case is where you forgot to do
3347c478bd9Sstevel@tonic-gate * a setenv before you went into the editor and it thinks you're on a dumb
3357c478bd9Sstevel@tonic-gate * terminal. Ex treats this like hardcopy and goes into HARDOPEN mode.
3367c478bd9Sstevel@tonic-gate * This loses because the first part of vop calls oop in this case.
3377c478bd9Sstevel@tonic-gate */
3387c478bd9Sstevel@tonic-gate if (inopen)
3397c478bd9Sstevel@tonic-gate error(gettext("Can't change type of terminal from within open/visual"));
3407c478bd9Sstevel@tonic-gate unterm();
3417c478bd9Sstevel@tonic-gate setterm(optname);
3427c478bd9Sstevel@tonic-gate } else {
3437c478bd9Sstevel@tonic-gate CP(op->osvalue, optname);
3447c478bd9Sstevel@tonic-gate op->odefault = 1;
3457c478bd9Sstevel@tonic-gate }
3467c478bd9Sstevel@tonic-gate break;
3477c478bd9Sstevel@tonic-gate }
3487c478bd9Sstevel@tonic-gate next:
3497c478bd9Sstevel@tonic-gate flush();
3507c478bd9Sstevel@tonic-gate } while (!skipend());
3517c478bd9Sstevel@tonic-gate eol();
3527c478bd9Sstevel@tonic-gate }
3537c478bd9Sstevel@tonic-gate
354f6db9f27Scf void
unterm(void)355f6db9f27Scf unterm(void)
3567c478bd9Sstevel@tonic-gate {
3577c478bd9Sstevel@tonic-gate /*
3587c478bd9Sstevel@tonic-gate * All terminal mapped statements must be deleted.
3597c478bd9Sstevel@tonic-gate * All user-defined mapped statements, cap=descr,
3607c478bd9Sstevel@tonic-gate * are left unchanged.
361*55fea89dSDan Cross */
3627c478bd9Sstevel@tonic-gate
3637c478bd9Sstevel@tonic-gate int i;
3647c478bd9Sstevel@tonic-gate
3657c478bd9Sstevel@tonic-gate for (i=0; i < MAXNOMACS; i++) {
3667c478bd9Sstevel@tonic-gate
3677c478bd9Sstevel@tonic-gate /*
368*55fea89dSDan Cross * Unmap any terminal-defined arrow keys
3697c478bd9Sstevel@tonic-gate */
3707c478bd9Sstevel@tonic-gate
371*55fea89dSDan Cross if (arrows[i].cap && arrows[i].descr &&
372*55fea89dSDan Cross strcmp(arrows[i].cap, arrows[i].descr))
3737c478bd9Sstevel@tonic-gate addmac(arrows[i].cap, NOSTR, NOSTR, arrows);
3747c478bd9Sstevel@tonic-gate
3757c478bd9Sstevel@tonic-gate /*
376*55fea89dSDan Cross * Unmap any terminal-defined function keys
3777c478bd9Sstevel@tonic-gate */
3787c478bd9Sstevel@tonic-gate
379*55fea89dSDan Cross if (immacs[i].cap && immacs[i].descr && strcmp(immacs[i].cap, immacs[i].descr))
3807c478bd9Sstevel@tonic-gate addmac(immacs[i].cap, NOSTR, NOSTR, immacs);
3817c478bd9Sstevel@tonic-gate
3827c478bd9Sstevel@tonic-gate }
3837c478bd9Sstevel@tonic-gate }
3847c478bd9Sstevel@tonic-gate
3857c478bd9Sstevel@tonic-gate
386f6db9f27Scf int
setend(void)387f6db9f27Scf setend(void)
3887c478bd9Sstevel@tonic-gate {
3897c478bd9Sstevel@tonic-gate
3907c478bd9Sstevel@tonic-gate return (iswhite(peekchar()) || endcmd(peekchar()));
3917c478bd9Sstevel@tonic-gate }
3927c478bd9Sstevel@tonic-gate
393f6db9f27Scf void
prall(void)394f6db9f27Scf prall(void)
3957c478bd9Sstevel@tonic-gate {
396f6db9f27Scf int incr = (vi_NOPTS + 2) / 3;
397f6db9f27Scf int rows = incr;
398f6db9f27Scf struct option *op = options;
3997c478bd9Sstevel@tonic-gate
4007c478bd9Sstevel@tonic-gate for (; rows; rows--, op++) {
4017c478bd9Sstevel@tonic-gate propt(op);
4027c478bd9Sstevel@tonic-gate gotab(24);
4037c478bd9Sstevel@tonic-gate propt(&op[incr]);
4047c478bd9Sstevel@tonic-gate if (&op[2*incr] < &options[vi_NOPTS]) {
4057c478bd9Sstevel@tonic-gate gotab(56);
4067c478bd9Sstevel@tonic-gate propt(&op[2 * incr]);
4077c478bd9Sstevel@tonic-gate }
4087c478bd9Sstevel@tonic-gate putNFL();
4097c478bd9Sstevel@tonic-gate }
4107c478bd9Sstevel@tonic-gate }
4117c478bd9Sstevel@tonic-gate
412f6db9f27Scf void
propts(void)413f6db9f27Scf propts(void)
4147c478bd9Sstevel@tonic-gate {
415f6db9f27Scf struct option *op;
4167c478bd9Sstevel@tonic-gate
4177c478bd9Sstevel@tonic-gate for (op = options; op < &options[vi_NOPTS]; op++) {
4187c478bd9Sstevel@tonic-gate if (op == &options[vi_TTYTYPE])
4197c478bd9Sstevel@tonic-gate continue;
4207c478bd9Sstevel@tonic-gate switch (op->otype) {
4217c478bd9Sstevel@tonic-gate
4227c478bd9Sstevel@tonic-gate case ONOFF:
4237c478bd9Sstevel@tonic-gate case NUMERIC:
4247c478bd9Sstevel@tonic-gate if (op->ovalue == op->odefault)
4257c478bd9Sstevel@tonic-gate continue;
4267c478bd9Sstevel@tonic-gate break;
4277c478bd9Sstevel@tonic-gate
4287c478bd9Sstevel@tonic-gate case STRING:
4297c478bd9Sstevel@tonic-gate if (op->odefault == 0)
4307c478bd9Sstevel@tonic-gate continue;
4317c478bd9Sstevel@tonic-gate break;
4327c478bd9Sstevel@tonic-gate }
4337c478bd9Sstevel@tonic-gate propt(op);
4347c478bd9Sstevel@tonic-gate putchar(' ');
4357c478bd9Sstevel@tonic-gate }
4367c478bd9Sstevel@tonic-gate noonl();
4377c478bd9Sstevel@tonic-gate flush();
4387c478bd9Sstevel@tonic-gate }
4397c478bd9Sstevel@tonic-gate
440f6db9f27Scf void
propt(struct option * op)441f6db9f27Scf propt(struct option *op)
4427c478bd9Sstevel@tonic-gate {
443f6db9f27Scf unsigned char *name;
4447c478bd9Sstevel@tonic-gate
4457c478bd9Sstevel@tonic-gate name = (unsigned char *)op->oname;
4467c478bd9Sstevel@tonic-gate
4477c478bd9Sstevel@tonic-gate switch (op->otype) {
4487c478bd9Sstevel@tonic-gate
4497c478bd9Sstevel@tonic-gate case ONOFF:
450f6db9f27Scf viprintf("%s%s", op->ovalue ? "" : "no", name);
4517c478bd9Sstevel@tonic-gate break;
4527c478bd9Sstevel@tonic-gate
4537c478bd9Sstevel@tonic-gate case NUMERIC:
454f6db9f27Scf viprintf("%s=%d", name, op->ovalue);
4557c478bd9Sstevel@tonic-gate break;
4567c478bd9Sstevel@tonic-gate
4577c478bd9Sstevel@tonic-gate case STRING:
4587c478bd9Sstevel@tonic-gate case OTERM:
459f6db9f27Scf viprintf("%s=%s", name, op->osvalue);
4607c478bd9Sstevel@tonic-gate break;
4617c478bd9Sstevel@tonic-gate }
4627c478bd9Sstevel@tonic-gate }
463