This file is indexed.

/usr/share/tkgate/scripts/tkgate.tcl is in tkgate-data 2.0~b10-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
#############################################################################
#
#   Copyright (C) 1987-2009 by Jeffery P. Hansen
#
#   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.
#
# Last edit by hansen on Sat Feb 21 22:32:47 2009
#

#############################################################################
#
# This file is the entry point into the tcl/tk code executed by tkgate.  Before
# this file is executed, the following variables are set in the C portion of
# tkgate:
#
#    sd				The directory with tcl script files
#    bd				The directory with bitmaps/images
#    lang			Language code (e.g. "en", "ja", "fr", ...)
#    territory			Territory code (e.g., "US", "GB", "JP", ...)
#    simOn			Flag indicating if the simulator is active.
#    tkg_gateHome		The home directory for tkgate.
#    tkg_doSplash		Indicates if a splash window should be displayed.
#    tkg_currentFile		Name of current file being edited.
#    tkg_tutotialDir		Directory with tutorial files.
#    tkg_exampleDir		Directory with example files.
#    tkg_progVer		TkGate version number
#    tkg_description		Text descrition of tkgate
#    tkg_copyright		Copyright message
#    tkg_mailContact		E-mail address of tkgate maintainer
#    tkg_homepage		Homepage of  tkgate maintainer
#    tkg_localdoc		Location of local html format documentation


#############################################################################
#
# Minimm scripts we need to begin tkgate initialization
#
set startScriptSet { misc options optdefaults parms}

#############################################################################
#
# The rest of tkgate's scripts
#
set baseScriptSet {
  keys ipanel dragger tabbox notebook pane dropbox helpon tree
  spreadsheet wizard frame info blocktree blockops blocklist netlist
  portlist sidebar menu memview popups setselector status print scope toolbar
  message errbox editgate find circuit simulator simopts breakpoint
  scriptmgr vpd file optionsdialog cpath license undo action symboledit
  hdledit library debug init
}


proc mainWinButton12Press {w x y s b} {
  global tkg_fakeDoubleClicks
  global tkg_fakeDCInterval
  global lastKeyPressTime

  action -Press { tkg_buttonPress $w $x $y $s $b }

  if {$tkg_fakeDoubleClicks} {
    set t [clock clicks -milliseconds]
    set interval [expr $t-$lastKeyPressTime]
    if {$interval < $tkg_fakeDCInterval} {
      mainWinButton12DoublePress $w $x $y $s
    }

    set lastKeyPressTime $t
  }
}

proc mainWinButton12DoublePress {w x y s} {
  continueAction -DblPress { tkg_buttonDoublePress $w $x $y $s } 
}

proc mainWinButton12Release {w x y s} {
  continueAction - { tkg_buttonRelease $w $x $y $s } 
}

proc mainWinButtonMotion {w x y s} {
  continueAction - { tkg_buttonMotion $w $x $y $s}
}

proc mainWinButton3Press {w x y s X Y} {
  action -Select { PopupMenu::post $w $x $y $s $X $Y }
}

#############################################################################
#
# This is the function that is called to start up tkgate.
#
proc startTkGate {argv} {
  global tkgate_isInitialized mode tkg_allowDebug
  global tkg_progName tkg_progVer tkg_gateHome tkg_prefFile
  global main_w tkg_checkpointFreq tkg_keyBindings
  global tkg_minWidth tkg_minHeight
  global tkg_fontSet
  global bd sd
  global tkg_fakeDoubleClicks
  global startScriptSet baseScriptSet

  #############################################################################
  #
  # Set flag to indicate that initialization is not complete. 
  #
  set tkgate_isInitialized 0

  #############################################################################
  #
  # If argument list starts with "--", remove it. 
  #
  if { [lindex $argv 0] == "--" } {
    set argv [lrange $argv 1 end]
  }

  #############################################################################
  #
  # If the tcl/tk version is less than 8.4, then there are certain
  # unsupported options for menus that we must remember.
  #
  global menu_forbidden
  if {[info tclversion] < 8.4} {
    set menu_forbidden {-compound -image -selectimage}
  } else {
    set menu_forbidden {}
  }

  #############################################################################
  #
  # Set up pointers to important directories.
  #
  set sd [file dirname [info script]]
  set bd [file dirname $sd]/images

  #############################################################################
  #
  # Run tkgate's main
  #
  eval tkgate_main $argv
  catch { package require Tk }
  tkgate_posttk

  #############################################################################
  #
  # Load in the minimum tcl files we need to start the splash screen.
  #
  foreach f $startScriptSet {
    uplevel "source $sd/${f}.tcl"
  }

  #############################################################################
  #
  # Read the site default preferences (global to all users)
  #
  if {[file exists $tkg_gateHome/site-preferences]} {
    uplevel "source $tkg_gateHome/site-preferences"
  }

  #############################################################################
  #
  # Read the user specific preferences (in user's home directory)
  #
  if {[file exists $tkg_prefFile]} {
    uplevel "source $tkg_prefFile"
  }


  #############################################################################
  #
  # Begin display of the splash window (if it has not been disabled)
  #
  start_splash


  #############################################################################
  #
  # Load the rest of the tcl/tk code for tkgate.
  #
  foreach f $baseScriptSet {
    uplevel "source $sd/${f}.tcl"
  }


  #############################################################################
  #
  # Define fonts to be used.
  #
  setFontSet ${tkg_fontSet}

  #############################################################################
  #
  # Initialize the options database 
  #
  setupOptions


  #############################################################################
  #
  # Printer dialog box initializations
  #
  printDlgInit
  
  #############################################################################
  #
  # Make all of the popup menus
  #
  makePopups

  #############################################################################
  #
  # If debugging is enabled, set up debugging key bindings.
  #
  if { $tkg_allowDebug } {
    KeyBinding::new <F7>		Action::dumpWires
    KeyBinding::new <Alt-v>		Action::verify
    KeyBinding::new <F6>		Action::debugMode
  }

  #############################################################################
  #
  # Set up hex and number entry tags
  #
  hexEntrySetup
  numEntrySetup
  floatEntrySetup

  #############################################################################
  #
  # Set up main window panes.
  #
  setupMainWindowPanes
  wm title . "$tkg_progName $tkg_progVer"
  wm minsize . $tkg_minWidth $tkg_minHeight
  setupIconWindow


  #############################################################################
  #
  # Side bar setup
  #
  SideBar::new .pane.sbar

  #############################################################################
  #
  # Status bar setup
  #
  makeStatus .status
  after [expr $tkg_checkpointFreq * 1000] tkg_checkpointReq

  #############################################################################
  #
  # Set key bindings
  #
  KeyBinding::loadBindings $tkg_gateHome/bindings/$tkg_keyBindings

  #############################################################################
  #
  # Toolbar initialization
  #
  ToolBar::init
  if { $tkg_allowDebug } {
    Menu::setFlags D
  }


  #############################################################################
  #
  # Create the main canvas and define bindings for mouse activity actions.
  #
  tkg_gatewin $main_w.main   -width 100 -height 100 -takefocus 0 \
      -xscrollcommand "$main_w.horz set" -yscrollcommand "$main_w.vert set" -bg seashell
  grid $main_w.main -row 0 -column 0 -sticky nsew

  bind $main_w.main <Button-1> 		{ mainWinButton12Press %W %x %y %s %b }
  bind $main_w.main <Button-2> 		{ mainWinButton12Press %W %x %y %s %b }
  if {!$tkg_fakeDoubleClicks} {
    bind $main_w.main <Double-Button-1>	{ mainWinButton12DoublePress %W %x %y %s }
    bind $main_w.main <Double-Button-2>	{ mainWinButton12DoublePress %W %x %y %s }
  }
  bind $main_w.main <ButtonRelease-1>	{ mainWinButton12Release %W %x %y %s }
  bind $main_w.main <ButtonRelease-2>	{ mainWinButton12Release %W %x %y %s }
  bind $main_w.main <Motion>		{ mainWinButtonMotion %W %x %y %s }
  bind $main_w.main <Button-3>		{ mainWinButton3Press %W %x %y %s %X %Y }
  bind $main_w.main <MouseWheel>	{ puts mouseWheel } 

  #############################################################################
  #
  # The focus should stay here automatically, but in case it doesn't make sure
  # a click restores focus to the menu bar to key commands can be processed
  # properly.
  #
  bind $main_w.main <Button-1>	{+ focus .tbar.m }
  bind $main_w.main <Button-2>	{+ focus .tbar.m }

  #############################################################################
  #
  # This forces the forces the focus to be returned to the menu bar (which
  # processes keyboard commands) any time the mouse is pressed in the main
  # window.  In most cases, the focus should stay there automatically.  This
  # handler is a contingency.
  #
  bind $main_w <Button> ToolBar::takeFocus


  #############################################################################
  #
  # Start the cpath flasher (currently disabled)
  #
  #tkg_flashCPath

  #############################################################################
  #
  # Set up initial mode.
  #
  ToolBar::modeChanged $mode
  Menu::setState edit

  #############################################################################
  #
  # Do additional initialization required on the C interface side.
  #
  gat_init

  #############################################################################
  #
  # Create the keyboard shortcuts for creating gates.
  #
  gat_makeMakeShortcuts

  #############################################################################
  #
  # Load any VPD scripts in the current VPD path.
  #
  VPD::loadScripts

  #############################################################################
  #
  # We are done with the splash window so we can take it down now.
  #
  end_splash

  #############################################################################
  #
  # Set the flag to indicate that tkgate is initialized, then do an update to
  # force tcl/tk to execute any idle commands.
  #
  set tkgate_isInitialized 1
  update
}

#############################################################################
#
# Start the tkgate interface.
#
startTkGate $argv