1 /* $LAAS: eltclsh.h,v 1.5 2003/10/23 17:10:06 mallet Exp $ */
4 * Copyright (c) 2001 LAAS/CNRS -- Wed Oct 10 2001
5 * All rights reserved. Anthony Mallet
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are
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
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
37 /* priority of eltclsh (or elwish) task. */
38 #define ELTCLSH_PRIORITY (250)
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 */
53 char preRead
[ELTCL_RDSZ
]; /* characters read on stdin and not yet
55 int preReadSz
; /* number of valid characters above */
57 EditLine
*el
; /* editline structure */
58 History
*history
; /* main command history */
59 Tcl_Obj
*prompt1Name
; /* name of the prompt procedures */
61 Tcl_Obj
*promptString
; /* prompt to display if not NULL */
63 History
*askaHistory
; /* history for el::get[sc] commands */
65 int editmode
; /* true if editline features wanted */
66 int windowSize
; /* current terminal size */
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
72 Tcl_Obj
*matchesName
; /* name of the procedure that generates
73 * completion matches */
75 Tcl_Obj
*command
; /* current interactive command */
76 int gotPartial
; /* true if current command is incomplete */
79 typedef int (*ElTclAppInitProc
)(ElTclInterpInfo
*);
83 * Prototypes -----------------------------------------------------------
86 #if TCL_MAJOR_VERSION >= 8 && TCL_MINOR_VERSION >= 4
87 void elTclshLoop(int argc
, const char **argv
,
88 ElTclAppInitProc appInitProc
);
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
[]);
96 int elTclAppInit(ElTclInterpInfo
*iinfo
);
98 unsigned char elTclCompletion(EditLine
*el
, int ch
);
99 int elTclBreakCommandLine(ClientData data
,
100 Tcl_Interp
*interp
, int objc
,
101 Tcl_Obj
*const objv
[]);
103 int elTclParseCommand(char *string
, int numBytes
, int nested
,
104 ElTclParse
*parsePtr
);
105 void elTclFreeParse(ElTclParse
*parsePtr
);
107 int elTclHandlersInit(ElTclInterpInfo
*iinfo
);
108 void elTclHandlersExit(ElTclInterpInfo
*iinfo
);
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
);
121 int rtclshWrappedPutsCmd(ClientData
, Tcl_Interp
*, int,
124 #endif /* H_ELTCLSH */