* Copyright (c) 1983 Regents of the University of California.
* This code is derived from software contributed to Berkeley by
* Edward Wang at The University of California, Berkeley.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
static char sccsid
[] = "@(#)lcmd1.c 3.36 (Berkeley) 6/6/90";
struct lcmd_arg arg_window
[] = {
{ "column", 1, ARG_NUM
},
{ "nlines", 2, ARG_NUM
},
{ "keepopen", 1, ARG_ANY
},
{ "smooth", 1, ARG_ANY
},
{ "shell", 1, ARG_STR
|ARG_LIST
},
register struct value
*a
;
int col
, row
, ncol
, nrow
, id
, nline
;
char haspty
, hasframe
, mapnl
, keepopen
, smooth
;
char *argv
[sizeof default_shell
/ sizeof *default_shell
];
row
= a
->v_type
== V_ERR
? 1 : a
->v_num
;
col
= a
->v_type
== V_ERR
? 0 : a
->v_num
;
nrow
= a
->v_type
== V_ERR
? wwnrow
- row
: a
->v_num
;
ncol
= a
->v_type
== V_ERR
? wwncol
- col
: a
->v_num
;
nline
= a
->v_type
== V_ERR
? default_nline
: a
->v_num
;
label
= a
->v_type
== V_ERR
? 0 : a
->v_str
;
if ((haspty
= vtobool(++a
, 1, -1)) < 0)
if ((hasframe
= vtobool(++a
, 1, -1)) < 0)
if ((mapnl
= vtobool(++a
, !haspty
, -1)) < 0)
if ((keepopen
= vtobool(++a
, 0, -1)) < 0)
if ((smooth
= vtobool(++a
, default_smooth
, -1)) < 0)
if ((++a
)->v_type
!= V_ERR
) {
for (pp
= argv
; a
->v_type
!= V_ERR
&&
pp
< &argv
[sizeof argv
/sizeof *argv
-1]; pp
++, a
++)
if (*sh
= rindex(shf
, '/'))
if ((w
= openwin(id
, row
, col
, nrow
, ncol
, nline
, label
, haspty
,
hasframe
, shf
, sh
)) == 0)
w
->ww_keepopen
= keepopen
;
w
->ww_noupdate
= !smooth
;
struct lcmd_arg arg_def_nline
[] = {
{ "nlines", 1, ARG_NUM
},
register struct value
*v
, *a
;
v
->v_num
= default_nline
;
default_nline
= a
->v_num
;
struct lcmd_arg arg_smooth
[] = {
{ "window", 1, ARG_NUM
},
register struct value
*v
, *a
;
if ((w
= vtowin(a
++, selwin
)) == 0)
v
->v_num
= !w
->ww_noupdate
;
w
->ww_noupdate
= !vtobool(a
, v
->v_num
, v
->v_num
);
struct lcmd_arg arg_def_smooth
[] = {
register struct value
*v
, *a
;
v
->v_num
= default_smooth
;
default_smooth
= vtobool(a
, v
->v_num
, v
->v_num
);
struct lcmd_arg arg_select
[] = {
{ "window", 1, ARG_NUM
},
register struct value
*v
, *a
;
v
->v_num
= selwin
? selwin
->ww_id
+ 1 : -1;
if ((w
= vtowin(a
, (struct ww
*)0)) == 0)
struct lcmd_arg arg_debug
[] = {
register struct value
*v
, *a
;
debug
= vtobool(a
, debug
, debug
);
struct lcmd_arg arg_escape
[] = {
{ "escapec", 1, ARG_STR
},
register struct value
*v
, *a
;
if ((v
->v_str
= str_cpy(buf
)) == 0) {
struct lcmd_arg arg_label
[] = {
{ "window", 1, ARG_NUM
},
register struct value
*a
;
if ((w
= vtowin(a
, selwin
)) == 0)
if ((++a
)->v_type
!= V_ERR
&& setlabel(w
, a
->v_str
) < 0)
struct lcmd_arg arg_foreground
[] = {
{ "window", 1, ARG_NUM
},
register struct value
*v
, *a
;
if ((w
= vtowin(a
, selwin
)) == 0)
flag
= vtobool(++a
, v
->v_num
, v
->v_num
);
struct lcmd_arg arg_terse
[] = {
register struct value
*v
, *a
;
setterse(vtobool(a
, terse
, terse
));
struct lcmd_arg arg_source
[] = {
{ "filename", 1, ARG_STR
},
register struct value
*v
, *a
;
if (a
->v_type
!= V_ERR
&& dosource(a
->v_str
) < 0) {
error("Can't open %s.", a
->v_str
);
struct lcmd_arg arg_write
[] = {
{ "window", 1, ARG_NUM
},
{ "", 0, ARG_ANY
|ARG_LIST
},
register struct value
*a
;
if ((w
= vtowin(a
++, selwin
)) == 0)
while (a
->v_type
!= V_ERR
) {
if (a
->v_type
== V_NUM
) {
(void) sprintf(buf
, "%d", a
->v_num
);
(void) write(w
->ww_pty
, buf
, strlen(buf
));
(void) write(w
->ww_pty
, a
->v_str
, strlen(a
->v_str
));
if ((++a
)->v_type
!= V_ERR
)
(void) write(w
->ww_pty
, " ", 1);
struct lcmd_arg arg_close
[] = {
{ "window", 1, ARG_ANY
|ARG_LIST
},
register struct value
*a
;
if (a
->v_type
== V_STR
&& str_match(a
->v_str
, "all", 3))
closewin((struct ww
*)0);
for (; a
->v_type
!= V_ERR
; a
++)
if ((w
= vtowin(a
, (struct ww
*)0)) != 0)
struct lcmd_arg arg_cursormodes
[] = {
register struct value
*v
, *a
;
v
->v_num
= wwcursormodes
;
wwsetcursormodes(a
->v_num
);
struct lcmd_arg arg_unset
[] = {
{ "variable", 1, ARG_ANY
},
register struct value
*v
, *a
;
if ((a
->v_str
= str_itoa(a
->v_num
)) == 0) {
v
->v_num
= var_unset(a
->v_str
);
register struct value
*v
;
error("No window specified.");
error("%s: No such window.", v
->v_str
);
if (v
->v_num
< 1 || v
->v_num
> NWINDOW
|| (w
= window
[v
->v_num
- 1]) == 0) {
error("%d: No such window.", v
->v_num
);
register struct value
*v
;
if (str_match(v
->v_str
, "true", 1)
|| str_match(v
->v_str
, "on", 2)
|| str_match(v
->v_str
, "yes", 1))
else if (str_match(v
->v_str
, "false", 1)
|| str_match(v
->v_str
, "off", 2)
|| str_match(v
->v_str
, "no", 1))
error("%s: Illegal boolean value.", v
->v_str
);