1 ############################################################
3 # Copyright (C) 1998 William F. Schelter #
4 # For distribution under GNU public License. See COPYING. #
6 # Modified by Jaime E. Villate #
7 # Time-stamp: "2021-04-04 12:05:13 villate" #
8 ############################################################
10 proc zoomConsole
{f
} {
11 global maxima_default maxima_priv
12 set ffamily
[lindex $maxima_default(ConsoleFont
) 0]
13 set fsize
[lindex $maxima_default(ConsoleFont
) 1]
14 set fsize
[expr round
($fsize*pow
(1.2,$f))]
15 font configure ConsoleFont
-family $ffamily -size $fsize
16 set text $maxima_priv(cConsoleText
)
17 resizeSubPlotWindows
$text [winfo width
$text] [winfo height
$text]
18 resizeMaxima
$text [winfo width
$text] [winfo height
$text]
19 set maxima_default
(ConsoleFont
) [list $ffamily $fsize]
22 proc pMAXSaveTexToFile
{text} {
23 set file [tide_savefile
[M
[mc
"Save to a file"]] "" *.out
]
25 set contents
[$text get
1.0 end
]
27 if {[catch {puts $fd $contents} err
]} {
28 tide_failure
[M
[mc
"Error writing to file:\n%s"] $err]
34 proc vMAXAddBrowserMenu
{win
} {
35 global maxima_priv maxima_default
36 global tcl_platform env
38 if {[winfo exists .browser.
menu]} {destroy .browser.
menu}
41 .browser configure
-menu .browser.
menu
42 foreach m
{file edit
options help
} {
43 $bm add cascade
-label [string totitle
$m] -underline 0 \
44 -menu [menu $bm.
$m -tearoff 0]
46 $bm.
file add command
-label [mc Reload
] -underline 0 \
47 -command "OpenMathOpenUrl \[oget \[omPanel $win\] location\] -reload 1 \
48 -commandpanel \[omPanel $win\]"
49 $bm.
file add command
-label [mc Interrupt
] -underline 0 \
50 -command "omDoInterrupt \[oget \[omPanel $win\] textwin\]"
51 $bm.
file add command
-label [mc Abort
] -underline 0 \
52 -command "omDoAbort \[oget \[omPanel $win\] textwin\]"
53 $bm.
file add command
-label [mc Stop
] -underline 1 \
54 -command "omDoStop \[oget \[omPanel $win\] textwin\]"
55 $bm.
file add command
-label [mc Forget
] -underline 0 \
56 -command "forgetCurrent \[omPanel $win\]"
57 $bm.
file add command
-label [mc Save
] -underline 0\
58 -command "pMAXSaveTexToFile \[oget \[omPanel $win\] textwin\]"
59 $bm.
file add separator
60 $bm.
file add command
-label [mc
{Close
}] -underline 0 \
61 -command "destroy $win"
62 $bm.
options add command
-label [mc
{Fonts
}] -underline 0 \
63 -command {fontDialog .fontdialog
}
66 proc vMAXAddSystemMenu
{fr
text} {
67 global maxima_priv maxima_default
68 global tcl_platform env
69 set win
$fr.textcommands
72 if {[winfo exists .
menu]} {destroy .
menu}
74 . configure
-menu .
menu
77 set m
[menu .
menu.
file -tearoff 0]
78 .
menu add cascade
-label [mc
"File"] -menu $m -underline 0
79 $m add command
-underline 0 \
81 -label [set label [M
[mc
"Batch File"]]] \
82 -command [set command
[cIDECreateEvent
$text $label {
83 set file [tide_openfile
[M
[mc
"Open a file to Batch"]] "" *.mac
]
85 sendMaxima
$maxima_priv(cConsoleText
) "batch(\"$file\")\$\n"
86 gui status
[concat [mc
"Batched File "] "$file"]
89 bind $text <Alt-Key-b
> $command
90 $m add command
-underline 11 \
92 -label [set label [M
[mc
"Batch File Silently"]]] \
93 -command [set command
[cIDECreateEvent
$text $label {
94 set file [tide_openfile
[M
[mc
"Open a file to Batch Silently"]] "" *.mac
]
96 sendMaxima
$maxima_priv(cConsoleText
) "batchload(\"$file\")\$\n"
97 gui status
[concat [mc
"Batched File "] "$file"]
100 bind $text <Alt-Key-o
> $command
102 $m add command
-underline 11 \
104 -label [set label [M
[mc
"Restore Maxima State"]]] \
105 -command [set command
[cIDECreateEvent
$text $label {
106 set file [tide_openfile
[M
[mc
"Open a file to Restore State"]] "" *.lisp
]
108 sendMaxima
$maxima_priv(cConsoleText
) ":lisp-quiet (prog2 (mfuncall '\$load \"$file\") nil)\n"
109 gui status
[concat [mc
"Maxima State Restored from "] "$file"]
112 bind $text <Alt-Key-i
> $command
115 $m add command
-underline 0 \
116 -label [set label [mc
"Save Maxima State to File"]] \
118 -command [set command
[cIDECreateEvent
$text $label {
119 set file [tide_savefile
[M
[mc
"Save to a file"]] "" *.lisp
]
121 sendMaxima
$maxima_priv(cConsoleText
) ":lisp-quiet (prog2 (mfuncall '\$save \"$file\" '\$all) nil)\n"
122 gui status
[concat [mc
"Maxima State Saved to "] "$file"]
125 bind $text <Control-Key-s
> $command
127 $m add command
-underline 1 \
128 -label [set label [mc
"Save Maxima Input to File"]] \
130 -command [set command
[cIDECreateEvent
$text $label {
131 set file [tide_savefile
[M
[mc
"Save to a file"]] "" *.mac
]
133 sendMaxima
$maxima_priv(cConsoleText
) ":lisp-quiet (prog2 (mfuncall '\$stringout \"$file\" '\$input) nil)\n"
134 gui status
[concat [mc
"Maxima Input Saved to "] "$file"]
137 bind $text <Control-Key-a
> $command
139 $m add command
-underline 0 \
140 -label [mc
"Interrupt"] \
142 -command [list event generate
$text <Control-Key-g
>]
143 $m add command
-underline 0 \
144 -label [mc
"Restart"] \
145 -command [list runOneMaxima
$text]
146 $m add command
-underline 0 \
147 -label [mc
"Input prompt"] \
149 -command [list event generate
$text <Alt-Key-s
>]
152 $m add command
-underline 1 \
154 -command [list tkmaxima
exit $text]
156 # Add an Edit menubutton
157 set m
[menu .
menu.edit
-tearoff 0]
158 .
menu add cascade
-label [mc
"Edit"] -menu $m -underline 0
159 $m add command
-underline 2 \
162 -command [list event generate
$text <Control-Key-x
>]
163 $m add command
-underline 0 \
166 -command [list event generate
$text <Control-Key-c
>]
167 $m add command
-underline 0 \
168 -label [mc
"Paste"] \
170 -command [list event generate
$text <Control-Key-v
>]
171 #mike distinguish from Cut/Copy/Past and Kill/Yank
173 $m add command
-underline 0 \
176 -command [list event generate
$text <Control-Key-k
>]
177 $m add command
-underline 0 \
180 -command [list event generate
$text <Control-Key-y
>]
182 #mike FIXME: use event generate
183 $m add command
-underline 0 \
184 -label [mc
"Previous Input"] \
186 -command [list CNpreviousInput
$text -1]
187 $m add command
-underline 0 \
188 -label [mc
"Next Input"] \
190 -command [list CNpreviousInput
$text 1]
191 $m add command
-underline 9 -label [mc
"Clear input"] \
193 -command [list CNclearinput
$text]
195 $m add command
-underline 0 -label [mc
"Save Console to File"] \
196 -command [list pMAXSaveTexToFile
$maxima_priv(cConsoleText
)]
198 # Add a Options menubutton
199 set m
[menu .
menu.
options -tearoff 0]
200 .
menu add cascade
-label [mc
"Options"] -menu $m -underline 0
202 set pm
[menu $m.plot
]
203 $m add cascade
-label [mc
"Plot Windows"] -menu $pm
204 foreach elt
{ embedded separate multiple
} {
205 $pm add radio
-label [mc
[string totit
$elt]] \
206 -variable maxima_default
(plotwindow
) \
207 -value $elt -command [list SetPlotFormat
$text ]
210 # $m add command -underline 0 \
211 # -label [mc "Preferences"] \
212 # -command {fontDialog .preferences}
213 if {[info commands
console] == "console" } {
215 $m add command
-underline 0 -label [mc
"Show Tcl Console"] \
216 -command [list console show
]
219 # Add a Maxima menubutton
220 set m
[menu .
menu.maxima
-tearoff 0]
221 .
menu add cascade
-label "Maxima" -menu $m -underline 0
222 set km
[menu $m.kill
]
223 $m add cascade
-label [mc
"Clear Memory"] -menu $km
224 $km add command
-label [mc
"Kill All"] \
225 -command [list sendMaxima
$text "kill(all)\$\n"]
227 foreach elt
{labels values functions macros arrays
\
228 myoptions props aliases rules gradefs
\
229 dependencies let_rule_packages
} {
230 $km add command
-label [mc
[string totit
$elt]] \
231 -command [list sendMaxima
$text "kill($elt)\$\n"]
234 set dir
$maxima_priv(pTestsDir
)
235 if {[file isdir
$dir]} {
240 $m add command
-underline 0 \
242 -label [mc
"Run Tests"] \
243 -command [list sendMaxima
$text "run_testsuite()\$\n"]
244 $m add command
-underline 0 \
246 -label [mc
"About Maxima"] \
247 -command [list sendMaxima
$text "build_info();\n"]
249 # Add a Help menubutton
250 set m
[menu .
menu.help
-tearoff 0]
251 .
menu add cascade
-label [mc
"Help"] -menu $m -underline 0
254 set xmaximahelpfile
[file join $maxima_priv(maxima_verpkgdatadir
) xmaxima html xmaxima.html
]
255 set xmaximahelpfile
[file normalize
$xmaximahelpfile]
256 if {[file isfile
$xmaximahelpfile]} {
262 set file $maxima_priv(pReferenceToc
)
263 if {[file isfile
$file]} {
265 if {$tcl_platform(platform
) == "windows"} {
266 # decodeURL is broken and needs fixing
267 # This is a workaround
268 set file [file attrib
$file -shortname]
273 if {$tcl_platform(platform
) == "windows"} {
274 if {[string match
*maxima.chm
* $file]} {
275 $m add command
-underline 1 -label [mc
"Maxima Manual"] \
277 -command [list exec hh.exe
$file & ]
279 $m add command
-underline 1 -label [mc
"Maxima Manual (xmaxima browser)"] \
281 -command "OpenMathOpenUrl \"file:/$file\""
283 $m add command
-underline 4 -label [mc
"Xmaxima Manual (xmaxima browser)"] \
285 -command "OpenMathOpenUrl \"file:/$xmaximahelpfile\""
287 $m add command
-underline 1 -label [mc
"Maxima Manual (xmaxima browser)"] \
289 -command "OpenMathOpenUrl \"file:/$file\""
290 $m add command
-underline 4 -label [mc
"Xmaxima Manual (xmaxima browser)"] \
292 -command "OpenMathOpenUrl \"file:/$xmaximahelpfile\""
296 # FIXME: get a browser object
297 if {$tcl_platform(platform
) == "windows"} {
298 if {$tcl_platform(os
) == "Windows 95"} {
303 lappend browse cmd.exe
/c start
306 set selectedbrowser xdg-open
307 foreach b
{ xdg-open htmlview firefox chromium-browser google-chrome konqueror epiphany galeon amaya opera
} {
308 if { ! [catch {exec which
$b} ] } {
309 set selectedbrowser
$b
313 lappend browse
$selectedbrowser
316 if {$tcl_platform(platform
) != "windows"} {
317 $m add command
-underline 0 -label [mc
"Maxima Manual (web browser)"] \
318 -command [list eval $browse "file://$file" &]
320 $m add command
-underline 0 -label [mc
"Xmaxima Manual (web browser)"] \
321 -command [list eval $browse "file://$xmaximahelpfile" &]
323 $m add command
-underline 7 -label [mc
"Maxima Homepage"] \
324 -command [list eval $browse http://maxima.sourceforge.net
&]
325 $m add command
-underline 0 -label [mc
"Project Page"] \
326 -command [list eval $browse https
://sourceforge.net
/projects
/maxima
/ &]
327 $m add command
-underline 0 -label [mc
"Bug Reports"] \
328 -command [list eval $browse https
://sourceforge.net
/p
/maxima
/bugs
/ &]
329 rename vMAXAddSystemMenu
""
330 # vMAXSystemMenuHandlers $text $event
331 # Backwards compatibility
335 proc vMAXAddSystemBar
{} {
336 set tb
[frame .toolbar
-borderwidth 1]
337 pack $tb -side top
-fill x
338 button $tb.zoomin
-image ::img::zoom-in
-text [mc
"Zoom in"] \
339 -command "zoomConsole 1" -relief flat
-width 30 -height 30
340 button $tb.zoomout
-image ::img::zoom-out
-text [mc
"Zoom out"] \
341 -command "zoomConsole -1" -relief flat
-width 30 -height 30
342 pack $tb.zoomin
$tb.zoomout
-side left
345 proc SetPlotFormat
{ text } {
346 global maxima_default
347 if { $maxima_default(plotwindow
) == "embedded" } {
348 sendMaxima
$text ":lisp-quiet (prog2 (\$set_plot_option '((mlist simp) \$plot_format \$xmaxima)) nil) \n"