1 # -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
3 # $Id: Tkmaxima.tcl,v 1.7 2011-03-21 09:17:17 villate Exp $
6 # The Header.tcl is created by autoconf to make the xmaxima script
7 # auto executable. After the header the various tcl pieces are put together:
9 #mike The following files are prepended, and could be sourced instead.
10 # The only problem about sourcing them is that the way of finding
11 # the directory they're in may differ in a wrapped executable.
12 # Note that the order of required files may be important.
14 # Source Tkmaxima/COPYING.tcl ;# license info
15 # Source Tkmaxima/Cygwin.tcl ;# required - must not be autoloaded
16 # Source Utils/FileDlg.tcl
17 # Source Utils/Messages.tcl
18 # Source Utils/Misc.tcl
19 # Source ObjTcl/Object.tcl
20 # Source ObjTcl/Feedback.tcl
21 # Source Tkmaxima/Constants.tcl ;# required - must not be autoloaded
22 # Source Tkmaxima/Preamble.tcl ;# required - must not be autoloaded
23 # Source Tkmaxima/Readdata.tcl ;# can be autoloaded
24 # Source Tkmaxima/Getdata1.tcl ;# can be autoloaded
25 # Source Tkmaxima/Macros.tcl ;# can be autoloaded
26 # Source Tkmaxima/Proxy.tcl ;# can be autoloaded
27 # Source Tkmaxima/Send-some.tcl ;# sets global variables
28 # Source Tkmaxima/Plotting.tcl ;# sets global variables
29 # Source Tkmaxima/Fonts.tcl ;# sets global variables
30 # Source Tkmaxima/colors.tcl
31 # Source Tkmaxima/Private.tcl ;# can be autoloaded
32 # Source Tkmaxima/Getopt.tcl ;# can be autoloaded
33 # Source Tkmaxima/Parse.tcl ;# sets global variables
34 # Source Tkmaxima/Textinsert.tcl ;# can be autoloaded
35 # Source Tkmaxima/Printops.tcl ;# can be autoloaded
36 # Source Tkmaxima/Push.tcl ;# can be autoloaded
37 # Source Tkmaxima/Plotconf.tcl ;# can be autoloaded
38 # Source Tkmaxima/Adams.tcl ;# can be autoloaded
39 # Source Tkmaxima/Rk.tcl ;# can be autoloaded
40 # Source Tkmaxima/rk4.tcl
41 # Source Tkmaxima/Plotdf.tcl ;# can be autoloaded
42 # Source Tkmaxima/Plot2d.tcl ;# defined globals
43 # Source Tkmaxima/Matrix.tcl ;# can be autoloaded
44 # Source Tkmaxima/Plot3d.tcl ;# defined globals
45 # Source Tkmaxima/scene.tcl ;# can be autoloaded
46 # Source Tkmaxima/NPlot3d.tcl ;# can be autoloaded
47 # Source Tkmaxima/EOctave.tcl ;# can be autoloaded
48 # Source Tkmaxima/EOpenplot.tcl ;# can be autoloaded
49 # Source Tkmaxima/EMaxima.tcl ;# can be autoloaded
50 # Source Tkmaxima/EHref.tcl ;# can be autoloaded
51 # Source Tkmaxima/Browser.tcl ;# defines globals
52 # Source Tkmaxima/Bindings.tcl ;# defines bindings
53 # Source Tkmaxima/Wmenu.tcl ;# can be autoloaded
54 # Source Tkmaxima/Tryftp2.tcl ;# can be autoloaded
55 # Source Tkmaxima/Myhtml.tcl ;# defines globals and tags
56 # Source Tkmaxima/Myhtml1.tcl ;# can be autoloaded
57 # Source Tkmaxima/Base64.tcl ;# can be autoloaded
58 # Source Tkmaxima/Bitmaps.tcl ;# defines globals
59 # Source Tkmaxima/Tryembed.tcl ;# defines globals?
60 # Source Tkmaxima/OpenMath.tcl ;# active
61 # Source Tkmaxima/NConsole.tcl ;# can be autoloaded
62 # Source Tkmaxima/String.tcl ;# can be autoloaded
63 # Source Tkmaxima/Prefs.tcl ;# can be autoloaded
64 # Source Tkmaxima/RunMaxima.tcl ;# can be autoloaded
65 # Source Tkmaxima/Menu.tcl
66 # Source Tkmaxima/Paths.tcl
67 # Source Tkmaxima/Gui.tcl
68 # Source Tkmaxima/Tkmaxima.tcl
70 proc vMaxUsage
{script
{error {}}} {
71 set msg
[mc
"$error\n\nUsage: $script \[options\] \[filenames\]
75 --help Display this message
76 --url <site> Start browser at site
78 --use-version <ver> Launch maxima version ver
80 --lisp <flavor> Use lisp implementation flavor
82 --lisp-options <Lisp options> Options to be given to the underlying Lisp.
83 Option lines containing spaces have to be
84 quoted to be passed to the lisp as a whole.
86 # Originally this program output a graphical message box instead of a message
87 # on stdout - which looked nice, but is nonstandard => Replaced it by a
90 # tk_messageBox -type ok -icon info -title "Usage" -message $msg -parent .
95 proc lMaxInitSetOpts
{} {
96 global maxima_priv argv argv0
97 set maxima_priv
(opts
) {}
98 set maxima_priv
(plotfile
) {}
103 switch -regexp -- $arg {
104 {^
--help$} {vMaxUsage
$argv0}
105 {^
-h(elp
)?
$} {vMaxUsage
$argv0}
106 {^
-(-)?url
$} {set state url
}
107 {^
-u(se-version
)?
$} {set state version
}
108 {^
--use-version
$} {set state version
}
109 {^
-l(isp
)?
$} {set state lisp
}
110 {^
--lisp$} {set state lisp
}
111 {^
--lisp-options
$} {set state lispoptions
}
112 {^
-X$} {set state lispoptions
}
113 {^
--$} {set state noopts
}
114 {^
-.
*} {vMaxUsage
$argv0 "Unknown option $arg"}
116 lappend maxima_priv
(plotfile
) $arg
122 switch -glob -- $arg {
123 -* {vMaxUsage
$argv0 "Misplaced option $arg"}
124 default {lappend plotfile
$arg}
127 url
{set maxima_priv
(firstUrl
) $arg; set state key
}
128 version
{lappend maxima_priv
(opts
) -u $arg; set state key
}
129 lisp
{lappend maxima_priv
(opts
) -l $arg; set state key
}
130 lispoptions
{lappend maxima_priv
(opts
) [format " -X \"%s\" " $arg]}
131 noopts
{lappend file $arg}
136 object_class MAXTkmaxima
{
139 global tcl_platform maxima_priv
141 if {$tcl_platform(platform
) == "windows" } {
143 set dir
[file dir
[info name
]]
144 # These should be in the same directory as the xmaxima.exe
145 set maxima_priv
(kill
) [file join $dir winkill.exe
]
147 set file [file join $dir tclwinkill.dll
]
148 if {[file isfile
$file]} {
154 set maxima_priv
(kill
) kill
160 global maxima_priv argv argv0 env fontSize maxima_default
163 wm title .
[mc
{Xmaxima
: console}]
167 set w
[gui install
$fr]
169 #mike Defer looking for maxima until the interface has been built
172 #mike Defer the starting of maxima until the interface has been built
173 if {[catch {runOneMaxima
$w} err
]} {
174 tide_failure
[concat [mc
"Error starting Maxima:"] "\n$err"]
177 after idle
focus $maxima_priv(cConsoleText
)
180 method
exit {{text ""} {val
"0"}} {
182 # save user settings for future sessions
183 catch {savePreferences
}
186 if {[info exists maxima_priv
(cConsoleText
)]} {
187 set text $maxima_priv(cConsoleText
)
192 if {[catch {closeMaxima
$text} err
]} {