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.
12 #include <sys/types.h>
13 #include <sys/queue.h>
16 #include <bitstring.h>
28 * PUBLIC: int f_altwerase(SCR *, OPTION *, char *, u_long *);
31 f_altwerase(SCR *sp, OPTION *op, char *str, u_long *valp)
34 O_CLR(sp, O_TTYWERASE);
39 * PUBLIC: int f_columns(SCR *, OPTION *, char *, u_long *);
42 f_columns(SCR *sp, OPTION *op, char *str, u_long *valp)
44 /* Validate the number. */
45 if (*valp < MINIMUM_SCREEN_COLS) {
46 msgq(sp, M_ERR, "040|Screen columns too small, less than %d",
53 * It's not uncommon for allocation of huge chunks of memory to cause
54 * core dumps on various systems. So, we prune out numbers that are
55 * "obviously" wrong. Vi will not work correctly if it has the wrong
56 * number of lines/columns for the screen, but at least we don't drop
59 #define MAXIMUM_SCREEN_COLS 500
60 if (*valp > MAXIMUM_SCREEN_COLS) {
61 msgq(sp, M_ERR, "041|Screen columns too large, greater than %d",
69 * PUBLIC: int f_lines(SCR *, OPTION *, char *, u_long *);
72 f_lines(SCR *sp, OPTION *op, char *str, u_long *valp)
74 /* Validate the number. */
75 if (*valp < MINIMUM_SCREEN_ROWS) {
76 msgq(sp, M_ERR, "042|Screen lines too small, less than %d",
83 * It's not uncommon for allocation of huge chunks of memory to cause
84 * core dumps on various systems. So, we prune out numbers that are
85 * "obviously" wrong. Vi will not work correctly if it has the wrong
86 * number of lines/columns for the screen, but at least we don't drop
89 #define MAXIMUM_SCREEN_ROWS 500
90 if (*valp > MAXIMUM_SCREEN_ROWS) {
91 msgq(sp, M_ERR, "043|Screen lines too large, greater than %d",
97 * Set the value, and the related scroll value. If no window
98 * value set, set a new default window.
100 o_set(sp, O_LINES, 0, NULL, *valp);
104 if (O_VAL(sp, O_WINDOW) == O_D_VAL(sp, O_WINDOW) ||
105 O_VAL(sp, O_WINDOW) > *valp) {
106 o_set(sp, O_WINDOW, 0, NULL, 1);
107 o_set(sp, O_WINDOW, OS_DEF, NULL, 1);
110 sp->defscroll = (*valp - 1) / 2;
112 if (O_VAL(sp, O_WINDOW) == O_D_VAL(sp, O_WINDOW) ||
113 O_VAL(sp, O_WINDOW) > *valp) {
114 o_set(sp, O_WINDOW, 0, NULL, *valp - 1);
115 o_set(sp, O_WINDOW, OS_DEF, NULL, *valp - 1);
122 * PUBLIC: int f_lisp(SCR *, OPTION *, char *, u_long *);
125 f_lisp(SCR *sp, OPTION *op, char *str, u_long *valp)
127 msgq(sp, M_ERR, "044|The lisp option is not implemented");
132 * PUBLIC: int f_msgcat(SCR *, OPTION *, char *, u_long *);
135 f_msgcat(SCR *sp, OPTION *op, char *str, u_long *valp)
137 (void)msg_open(sp, str);
142 * PUBLIC: int f_print(SCR *, OPTION *, char *, u_long *);
145 f_print(SCR *sp, OPTION *op, char *str, u_long *valp)
147 int offset = op - sp->opts;
149 /* Preset the value, needed for reinitialization of lookup table. */
150 if (offset == O_OCTAL) {
155 } else if (o_set(sp, offset, OS_STRDUP, str, 0))
158 /* Reinitialize the key fast lookup table. */
161 /* Reformat the screen. */
162 F_SET(sp, SC_SCR_REFORMAT);
167 * PUBLIC: int f_readonly(SCR *, OPTION *, char *, u_long *);
170 f_readonly(SCR *sp, OPTION *op, char *str, u_long *valp)
174 * See the comment in exf.c.
177 F_SET(sp, SC_READONLY);
179 F_CLR(sp, SC_READONLY);
184 * PUBLIC: int f_recompile(SCR *, OPTION *, char *, u_long *);
187 f_recompile(SCR *sp, OPTION *op, char *str, u_long *valp)
189 if (F_ISSET(sp, SC_RE_SEARCH)) {
191 F_CLR(sp, SC_RE_SEARCH);
193 if (F_ISSET(sp, SC_RE_SUBST)) {
194 regfree(&sp->subre_c);
195 F_CLR(sp, SC_RE_SUBST);
201 * PUBLIC: int f_reformat(SCR *, OPTION *, char *, u_long *);
204 f_reformat(SCR *sp, OPTION *op, char *str, u_long *valp)
206 F_SET(sp, SC_SCR_REFORMAT);
211 * PUBLIC: int f_ttywerase(SCR *, OPTION *, char *, u_long *);
214 f_ttywerase(SCR *sp, OPTION *op, char *str, u_long *valp)
217 O_CLR(sp, O_ALTWERASE);
222 * PUBLIC: int f_w300(SCR *, OPTION *, char *, u_long *);
225 f_w300(SCR *sp, OPTION *op, char *str, u_long *valp)
229 /* Historical behavior for w300 was < 1200. */
230 if (sp->gp->scr_baud(sp, &v))
235 return (f_window(sp, op, str, valp));
239 * PUBLIC: int f_w1200(SCR *, OPTION *, char *, u_long *);
242 f_w1200(SCR *sp, OPTION *op, char *str, u_long *valp)
246 /* Historical behavior for w1200 was == 1200. */
247 if (sp->gp->scr_baud(sp, &v))
249 if (v < 1200 || v > 4800)
252 return (f_window(sp, op, str, valp));
256 * PUBLIC: int f_w9600(SCR *, OPTION *, char *, u_long *);
259 f_w9600(SCR *sp, OPTION *op, char *str, u_long *valp)
263 /* Historical behavior for w9600 was > 1200. */
264 if (sp->gp->scr_baud(sp, &v))
269 return (f_window(sp, op, str, valp));
273 * PUBLIC: int f_window(SCR *, OPTION *, char *, u_long *);
276 f_window(SCR *sp, OPTION *op, char *str, u_long *valp)
278 if (*valp >= O_VAL(sp, O_LINES) - 1 &&
279 (*valp = O_VAL(sp, O_LINES) - 1) == 0)
285 * PUBLIC: int f_encoding(SCR *, OPTION *, char *, u_long *);
288 f_encoding(SCR *sp, OPTION *op, char *str, u_long *valp)
290 int offset = op - sp->opts;
292 return conv_enc(sp, offset, str);