2 * Copyright (c) 1992, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 * Copyright (c) 1992, 1993, 1994, 1995, 1996
5 * Keith Bostic. All rights reserved.
7 * George V. Neville-Neil. All rights reserved.
9 * See the LICENSE file for redistribution information.
15 static const char sccsid
[] = "@(#)ex_tcl.c 8.10 (Berkeley) 9/15/96";
18 #include <sys/types.h>
19 #include <sys/queue.h>
21 #include <bitstring.h>
28 #include "../common/common.h"
30 #ifdef HAVE_TCL_INTERP
35 * ex_tcl -- :[line [,line]] tcl [command]
36 * Run a command through the tcl interpreter.
38 * PUBLIC: int ex_tcl __P((SCR*, EXCMD *));
45 #ifdef HAVE_TCL_INTERP
51 /* Initialize the interpreter. */
53 if (gp
->tcl_interp
== NULL
&& tcl_init(gp
))
56 /* Skip leading white space. */
58 for (p
= cmdp
->argv
[0]->bp
,
59 len
= cmdp
->argv
[0]->len
; len
> 0; --len
, ++p
)
62 if (cmdp
->argc
== 0 || len
== 0) {
63 ex_emsg(sp
, cmdp
->cmd
->usage
, EXM_USAGE
);
67 (void)snprintf(buf
, sizeof(buf
),
68 "set viScreenId %d\nset viStartLine %lu\nset viStopLine %lu",
69 sp
->id
, cmdp
->addr1
.lno
, cmdp
->addr2
.lno
);
70 if (Tcl_Eval(gp
->tcl_interp
, buf
) == TCL_OK
&&
71 Tcl_Eval(gp
->tcl_interp
, cmdp
->argv
[0]->bp
) == TCL_OK
)
74 msgq(sp
, M_ERR
, "Tcl: %s", ((Tcl_Interp
*)gp
->tcl_interp
)->result
);
77 msgq(sp
, M_ERR
, "302|Vi was not loaded with a Tcl interpreter");
79 #endif /* HAVE_TCL_INTERP */