Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / api / tcl / eltclsh.h
1 /* $LAAS: eltclsh.h,v 1.5 2003/10/23 17:10:06 mallet Exp $ */
2
3 /*
4 * Copyright (c) 2001 LAAS/CNRS -- Wed Oct 10 2001
5 * All rights reserved. Anthony Mallet
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are
9 * met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
25 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
27 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
28 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
29 * DAMAGE.
30 */
31 #ifndef H_ELTCLSH
32 #define H_ELTCLSH
33
34 #ifdef VXWORKS
35 #include <vxWorks.h>
36
37 /* priority of eltclsh (or elwish) task. */
38 #define ELTCLSH_PRIORITY (250)
39 #endif /* VXWORKS */
40
41 #include <tcl.h>
42 #include <histedit.h>
43
44 #include "parse.h"
45
46 /* A structure that groups together the various parameters that control
47 * the behavior of eltclsh/elwish */
48 typedef struct ElTclInterpInfo {
49 char *argv0; /* the basename of the program */
50 Tcl_Interp *interp; /* the main Tcl interpreter */
51
52 #define ELTCL_RDSZ 16
53 char preRead[ELTCL_RDSZ]; /* characters read on stdin and not yet
54 * processed */
55 int preReadSz; /* number of valid characters above */
56
57 EditLine *el; /* editline structure */
58 History *history; /* main command history */
59 Tcl_Obj *prompt1Name; /* name of the prompt procedures */
60 Tcl_Obj *prompt2Name;
61 Tcl_Obj *promptString; /* prompt to display if not NULL */
62
63 History *askaHistory; /* history for el::get[sc] commands */
64
65 int editmode; /* true if editline features wanted */
66 int windowSize; /* current terminal size */
67
68 int completionQueryItems; /* maximum number of items the completion
69 * engine can display before asking user
70 * it he really wants to see all these
71 * items */
72 Tcl_Obj *matchesName; /* name of the procedure that generates
73 * completion matches */
74
75 Tcl_Obj *command; /* current interactive command */
76 int gotPartial; /* true if current command is incomplete */
77 } ElTclInterpInfo;
78
79 typedef int (*ElTclAppInitProc)(ElTclInterpInfo *);
80
81
82 /*
83 * Prototypes -----------------------------------------------------------
84 */
85
86 #if TCL_MAJOR_VERSION >= 8 && TCL_MINOR_VERSION >= 4
87 void elTclshLoop(int argc, const char **argv,
88 ElTclAppInitProc appInitProc);
89 #else
90 void elTclshLoop(int argc, char **argv,
91 ElTclAppInitProc appInitProc);
92 #endif /* TCL_VERSION */
93 int elTclExit(ClientData data, Tcl_Interp *interp, int objc,
94 Tcl_Obj *const objv[]);
95
96 int elTclAppInit(ElTclInterpInfo *iinfo);
97
98 unsigned char elTclCompletion(EditLine *el, int ch);
99 int elTclBreakCommandLine(ClientData data,
100 Tcl_Interp *interp, int objc,
101 Tcl_Obj *const objv[]);
102
103 int elTclParseCommand(char *string, int numBytes, int nested,
104 ElTclParse *parsePtr);
105 void elTclFreeParse(ElTclParse *parsePtr);
106
107 int elTclHandlersInit(ElTclInterpInfo *iinfo);
108 void elTclHandlersExit(ElTclInterpInfo *iinfo);
109
110 int elTclGets(ClientData data, Tcl_Interp *interp, int objc,
111 Tcl_Obj *const objv[]);
112 int elTclGetc(ClientData data, Tcl_Interp *interp, int objc,
113 Tcl_Obj *const objv[]);
114 int elTclHistory(ClientData data, Tcl_Interp *interp,
115 int objc, Tcl_Obj *const objv[]);
116 int elTclEventLoop(EditLine *el, char *c);
117 void elTclRead(ClientData data, int mask);
118 int elTclGetWindowSize(int fd, int *lins, int *cols);
119
120
121 int rtclshWrappedPutsCmd(ClientData, Tcl_Interp *, int,
122 Tcl_Obj *const[]);
123
124 #endif /* H_ELTCLSH */