blob: 9a2664a919801ef5a3de50be729d882d20936ece (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
implement Tclsh;
include "sys.m";
sys: Sys;
include "draw.m";
include "bufio.m";
bufmod : Bufio;
Iobuf : import bufmod;
include "tk.m";
include "../lib/tcl.m";
tcl : Tcl_Core;
Tclsh: module {
init: fn(ctxt: ref Draw->Context, argv: list of string);
};
init(ctxt: ref Draw->Context, argv : list of string){
sys=load Sys Sys->PATH;
tcl=load Tcl_Core Tcl_Core->PATH;
if (tcl==nil){
sys->print("Cannot load Tcl (%r)\n");
exit;
}
bufmod=load Bufio Bufio->PATH;
if (bufmod==nil){
sys->print("Cannot load Bufio (%r)\n");
exit;
}
lines:=chan of string;
tcl->init(ctxt,argv);
new_inp := "tcl%";
spawn tcl->grab_lines(nil,nil,lines);
for(;;){
alt{
line := <-lines =>
line = tcl->prepass(line);
msg:= tcl->evalcmd(line,0);
if (msg!=nil)
sys->print("%s\n",msg);
sys->print("%s ", new_inp);
tcl->clear_error();
}
}
}
|