summaryrefslogtreecommitdiff
path: root/support/xtexshell/xtexsh
blob: a1c58c94f246100a018e5290303c93e9fc272f5f (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
#!/usr/X11/bin/wishx -f
#*** The previous line *must* be wishx, because we *need* TclX extensions

set  xtexsh_path  "/usr/local/src/XTeXShell-0.91"

set  auto_path    "$xtexsh_path $auto_path"
set  home_dir     $env(HOME)

#*** Syntax: xtexsh [filename] [-m mainfilename]

#***********************************************************************
#*** Setup *************************************************************
#***********************************************************************

#*** About XTeX-Shell

set version   "0.91 Beta"
set verdate   "21.2.94"

set about " \
XTeX-Shell  Version $version  ($verdate)
Copyright <C> 1994 by Michael Hofmann

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

Please send error reports, comments and flames to:
Michael T. Hofmann
Fontanestr. 5
55127 Mainz, Germany
hofmann@vipmzw.physik.uni-mainz.de"

#*** Check for proper version of TCl and Tk  and if TclX is installed

scan    [info tclversion] "%d.%d" a b
if      {$a < 7} {
        puts stderr "Wrong version of Tcl loaded ([info tclversion]): need 7.x or later"
        exit 1
}

scan    $tk_version "%d.%d" a b
if      {$a < 3} {
        puts stderr "Wrong version of Tk loaded ($tk_version): need 3.x or later"
        exit 1
}

set     a [catch {set version_tclx [infox version]}]

if      {$a} {
        puts stderr "You haven't installed TclX. Cannot continue!!!"
        puts stderr "Please install TclX. You can find help on newsboard comp.lang.tcl"
        exit 1
}

#*** Check if xtexsh_path is set correctly and that all program files are available

set     a 0
foreach pgm [list "edit.tcl" "help.tcl" "util.tcl" "exec.tcl" "ldsetup.tcl" "fileselbox.tcl"] {
        if {![file exists "$xtexsh_path/$pgm"]} {
                puts stderr "Can't find the file $xtexsh_path/$pgm."
                set a 1
        }
}
if {$a} {
        puts stderr "Did you set the variable xtexsh_path in the 5th line of xtexsh correctly?"
        puts stderr "Please refer to the file INSTALL for help."
        exit 1
}

unset   a b

#*** Load setup file

set home_path "";                       #*** Only for compatibility with xtex 0.9               
loadsetup

#***********************************************************************
#*** Set up main Window ************************************************
#***********************************************************************

CreateTopWin mainwin "CREATE"
wm title    . "XTeX-Shell (V$version)"
wm iconname . "XTeX-Shell"

set isColorX [cequal [tk colormodel "."] "color"]

frame       .mainwin       -relief raised
frame       .menu          -relief raised   -borderwidth 1
frame       .wizard        -relief raised   -border 1

pack        .menu          -side top -fill  x
pack        .wizard        -side top -fill  x
pack        .mainwin       -side top -fill  both

#*** Wizards

set     i 0
foreach command $commandlist {
        button .wizard.but$i -text [lindex $command 0] \
                             -command "ExecProg \"[lindex $command 1]\""
        pack .wizard.but$i -side left -anchor w -padx 3m -pady 1m -ipadx 0.6m
        incr i
}

button      .wizard.clear  -text "Purge"      -command "#PurgeFiles"
button      .wizard.quit   -text "Quit"       -command "EndXTeX"

pack        .wizard.quit   .wizard.clear -side right -anchor e -padx 3m -pady 1m -ipadx 0.6m

#*** Menu bar

menubutton .menu.file -text "File"       -menu .menu.file.m -underline 0
menubutton .menu.edit -text "Edit"       -menu .menu.edit.m -underline 0
menubutton .menu.cuts -text "ShortCuts"  -menu .menu.cuts.m -underline 0
menubutton .menu.main -text "Main File"  -menu .menu.main.m -underline 0
menubutton .menu.conf -text "Configure"  -menu .menu.conf.m -underline 0
menubutton .menu.help -text "Help"       -menu .menu.help.m -underline 0

pack       .menu.file .menu.edit .menu.cuts .menu.main .menu.conf -side left -padx 2m -pady 1m
pack       .menu.help -side right -padx 3m -pady 1m

#*** Pull Down Menus

menu    .menu.file.m
        .menu.file.m add command -label "New"             -underline 0 -command {Edit ""}
        .menu.file.m add command -label "Open..."         -underline 0 -command {Edit "\n"}
        .menu.file.m add cascade -label "ReOpen..."       -underline 0 -menu .menu.file.m.reopen
        .menu.file.m add command -label "Save"            -underline 0 -command {SaveFile ""}
        .menu.file.m add command -label "Save As..."      -underline 5 -command {SaveFile "AS" }
        .menu.file.m add command -label "Print"           -underline 0 -command {PrintFile $textbuf}
        .menu.file.m add separator
        .menu.file.m add command -label "Dir..."          -underline 0 -command {FileSelBox "DIR"}
        .menu.file.m add command -label "Change Dir..."   -underline 0 -command {ChangeDir}
        .menu.file.m add command -label "Shell"           -underline 0 -command {exec xterm &}
        .menu.file.m add separator
        .menu.file.m add command -label "Quit"            -underline 0 -command "EndXTeX"

menu    .menu.file.m.reopen

menu    .menu.edit.m
        .menu.edit.m add command -label "Search"          -underline 0 -command {EditSrch ""}
        .menu.edit.m add command -label "Replace"         -underline 0 -command {EditSrch "REPLACE"}
        .menu.edit.m add command -label "Continue"        -underline 0 -command {EditSrch "CONTINUE"}

menu    .menu.cuts.m

menu    .menu.main.m
        .menu.main.m add check   -label "Use Main File"   -underline 0 -variable mainflag
        .menu.main.m add command -label "Select New Main File" -underline 0 -command {SelNewMain ""}
        .menu.main.m add separator

menu    .menu.conf.m
        .menu.conf.m add radio   -label "XTeX-Edit (Built In)" -underline 0 -variable editor -value xtex

        set     a 0

        foreach command $editorlist {
                set varval [string tolower [lindex $command 1]]
                .menu.conf.m add radio   -label [lindex $command 0] -underline 0 \
                                         -variable editor -value $varval
                eval set command_editor_$varval \"[lindex $command 2]\"
                if {"$varval"=="$editor"} {
                        set a 1
                        .menu.conf.m invoke last
                }       
        }

        if {!$a} {                                              #*** If selected editor is not available, use XTeX-Edit
                .menu.conf.m invoke 0
        }

        .menu.conf.m add separator
        .menu.conf.m add cascade -label "Config XTeX-Edit" -underline 0 -menu .menu.conf.m.m
        .menu.conf.m add cascade -label "Save Options"    -underline 0 -menu .menu.conf.m.s

menu    .menu.conf.m.m
        .menu.conf.m.m add radio -label "Turbo Edit Mode" -underline 0 -variable editmode -value TURBO
        .menu.conf.m.m add radio -label "E2 Edit Mode"    -underline 0 -variable editmode -value E2
        .menu.conf.m.m add separator
        .menu.conf.m.m add check -label "Word Wrapping"   -underline 0 -variable editwrap
        .menu.conf.m.m add check -label "Character Translation" -underline 0 -variable edittrans

menu    .menu.conf.m.s
        .menu.conf.m.s add command -label "Save Global"   -underline 0 -command "writesetup 1"
        .menu.conf.m.s add command -label "Save Local"    -underline 0 -command "writesetup 0"

menu    .menu.help.m
        .menu.help.m add command -label "LaTeX Help Index" -underline 0 -command "HyperHelp Index"
        .menu.help.m add command -label "LaTeX Symbols"   -underline 0 -command "HyperHelp symbols"
        .menu.help.m add command -label "LaTeX Fonts"     -underline 0 -command "HyperHelp fonts"
        .menu.help.m add separator
        .menu.help.m add command -label "XTeX Help"       -underline 0 -command "HyperHelp _helpxtex"
        .menu.help.m add command -label "XTeX Editor Help" -underline 0 -command "HyperHelp _helpxtexedit"
        .menu.help.m add command -label "XTeX License"    -underline 0 -command "DisplayInfo \"$about\" \"$bold_font\""
        .menu.help.m add separator
        .menu.help.m add command -label "TeX/LaTeX"       -underline 0 -command "ManHelp tex"
        .menu.help.m add command -label "xdvi"            -underline 0 -command "ManHelp xdvi"
        .menu.help.m add command -label "dvips"           -underline 0 -command "ManHelp dvips"
        .menu.help.m add command -label "ghostview"       -underline 0 -command "ManHelp ghostview"
        .menu.help.m add separator
        .menu.help.m add command -label "Emacs"           -underline 0 -command "ManHelp emacs"
        .menu.help.m add command -label "Joe"             -underline 0 -command "ManHelp joe"

#*** Load short cuts

loadshortcuts

#*** Set up for keyboard-based menu traversal

bind . <Any-FocusIn> {
        if {("%d" == "NotifyVirtual") && ("%m" == "NotifyNormal")} {
                focus .menu
        }
}

tk_menuBar .menu .menu.file
tk_menuBar .menu .menu.edit
tk_menuBar .menu .menu.cuts
tk_menuBar .menu .menu.main
tk_menuBar .menu .menu.conf
tk_menuBar .menu .menu.help

#*** Scan command-line arguments

for {set i 0} {$i<$argc} {incr i} {
        if {[cequal [lindex $argv $i] "-m"]} {
                incr i          
                SelNewMain [lindex $argv $i]
                continue                
        }       
        Edit [lindex $argv $i]
}

#******************************************************************************
#*** Quit was selected. Save Data and exit ************************************
#******************************************************************************

proc EndXTeX {} {

        EndXTeXEdit
        destroy .
}