Merge branch 'master' into bug-4403-remove-polyfill
[maxima.git] / interfaces / xmaxima / Tkmaxima / Gui.tcl
blobf81f5c40a0d83dca679fd86bb8d1e86f5fc591e9
1 ############################################################
2 # Gui.tcl #
3 # Copyright (C) 1998 William F. Schelter #
4 # For distribution under GNU public License. See COPYING. #
5 # #
6 # Modified by Jaime E. Villate #
7 # Time-stamp: "2024-04-11 16:35:46 villate" #
8 ############################################################
10 # Creates the browser if it doesn't exist
11 proc createBrowser {bname} {
12 global maxima_priv maxima_default
13 if {[winfo exists $bname]} {
14 focus $bname
15 } else {
16 toplevel $bname
17 wm title $bname [mc {Xmaxima: browser}]
18 OpenMathOpenUrl $maxima_priv(firstUrl) -toplevel $bname
19 set maxima_priv(cBrowser) $bname
20 set Maxima_default(browser) 1
21 # Adds the menubar and the toolbar to the browser
22 vMAXAddBrowserMenu $bname}}
24 # Creates the Maxima console
25 proc createConsole {cname} {
26 global maxima_priv maxima_default
27 # Makes the status panel....
28 set st .status
29 frame $st
30 set maxima_priv(cStatusWindow) $st
31 label $st.rate -width 35 -bd 1 -relief sunken -justify left \
32 -textvariable maxima_priv(load_rate) -anchor w
33 scale $st.scale -showvalue 0 -length 200 -orient horizontal
34 pack $st.rate -side left -fill x -expand 1 -anchor w
35 pack $st.scale -side left
36 pack $st -side bottom -fill x -anchor w
37 set maxima_priv(cStatusLabel) $st.rate
39 # Adds the toolbar to the Maxima console
40 vMAXAddSystemBar
41 frame $cname
42 pack $cname -expand 1 -fill both -side top
43 set w $cname.text
44 clearLocal $w
45 oset $w heightDesired 80%
46 set maxima_priv(maximaWindow) $w
47 closeMaxima $w
48 clearLocal $w
50 # oset $w program $program
51 oset $w prompt "% "
52 if {[winfo exists $w]} {catch { destroy $w }}
53 frame $cname.bottom -height 2
54 $cname.bottom config -cursor double_arrow
55 bind $cname.bottom <B1-Motion> "changeSize $w %Y"
56 pack $cname.bottom -side bottom -fill x
57 text $w -yscrollcommand "$cname.scroll set" \
58 -selectbackground yellow -selectforeground blue
59 set maxima_priv($w,inputTag) input
60 # resetMaximaFont $w
61 scrollbar $cname.scroll -command "$w yview"
62 pack $cname.scroll -side right -fill y
63 pack $cname.text -expand 1 -fill both -side left
64 $w mark set lastStart end
65 $w mark gravity lastStart left
66 bind $w <Configure> "resizeSubPlotWindows $w %w %h; resizeMaxima $w %w %h"
67 $w configure -background white
68 $w configure -foreground "#008600"
69 $w tag configure input -foreground blue
70 $w tag configure output -foreground black
71 $w tag configure mprompt -foreground red
73 # binding order will be: window bindings, CNtext bindings,
74 # OpenMathText bindings and default bindings (usually Text . all)
75 # CNtext ans OpenMathText bindings are set up in Bindings.tcl
76 bindtags $w [linsert [bindtags $w] 1 CNtext OpenMathText ]
78 if {![regexp -- input $maxima_priv(sticky)] } {
79 append maxima_priv(sticky) {|^input$}}
80 set maxima_priv(cConsoleText) $cname.text
81 vMAXSetCNTextBindings $w
82 wm protocol . WM_DELETE_WINDOW [list maxExit $w]
84 # Sets up the console size and font
85 $w configure -height $maxima_default(iConsoleHeight) \
86 -width $maxima_default(iConsoleWidth)
87 font configure ConsoleFont -family [lindex $maxima_default(ConsoleFont) 0] \
88 -size [lindex $maxima_default(ConsoleFont) 1]
89 $w configure -font ConsoleFont
91 # Adds the menu bar to the Maxima console
92 vMAXAddSystemMenu $cname $cname.text
94 # Reads the history from previous runs
95 set histfile "$maxima_priv(home)/.xmaxima_history"
96 if {[file isfile $histfile]} {
97 if {[catch {uplevel "#0" [list source $histfile]} err]} {
98 tk_messageBox -title Error -icon error -message \
99 [mc "Error sourcing %s\n%s" [file native $histfile] $err]}}
100 return $w}
102 # Updates the information in the status bar at the bottom of the console
103 proc maxStatus {mess} {
104 global maxima_priv
105 set maxima_priv(load_rate) $mess
106 $maxima_priv(cStatusLabel) configure -text $mess}