This file is indexed.

/usr/share/tkgate-1.8.7/scripts/options.tcl is in tkgate-data 1.8.7-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
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
#   Copyright (C) 1987-2007 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 Thu May  6 16:54:29 2004
#
#

set solid {#define aa_width 25
#define aa_height 15
static unsigned char aa_bits[] = {
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};}

set colors {red blue magenta4 cyan4 tan4 green4 black magenta yellow RosyBrown1 white}

#
# Create color images
#
foreach c $colors {
  image create bitmap $c -foreground $c -data $solid
}

set opts_baderMode 0
set opts_trekMode 0
set opts_batMode 0
set opts_smoothScroll 0
set opts_regionUpdate 0
set opts_siteName ""
set opts_blockMoveStyle 0
set opts_helpBalloons 1
set opts_noviceMode 1
set opts_allowDebug 1
set opts_checkpointEnabled 1
set opts_checkpointFreq 300
set opts_flashCPath 1
set opts_numCPath 10
set opts_undoLength 50

set opts_instColor           $tkgdef_instColor          
set opts_moduleColor         $tkgdef_moduleColor        
set opts_modulePortColor     $tkgdef_modulePortColor    
set opts_frameColor          $tkgdef_frameColor         
set opts_commentColor        $tkgdef_commentColor       
set opts_hyperlinkColor      $tkgdef_hyperlinkColor       
set opts_wireColor           $tkgdef_wireColor          
set opts_busColor            $tkgdef_busColor           
set opts_toolColor           $tkgdef_toolColor          
set opts_cpathColor          $tkgdef_cpathColor          
set opts_gridColor           $tkgdef_gridColor          
set opts_oneColor            $tkgdef_oneColor           
set opts_zeroColor           $tkgdef_zeroColor          
set opts_floatColor          $tkgdef_floatColor         
set opts_unknownColor        $tkgdef_unknownColor       
set opts_offLedColor         $tkgdef_offLedColor
set opts_onLedColor          $tkgdef_onLedColor 
set opts_zLedColor           $tkgdef_zLedColor  


set sopts_simSortTraces $tkg_simSortTraces
set sopts_simStepSize $tkg_simStepSize
set sopts_simStepSize $tkg_simStepSize
set sopts_simClockStepSize $tkg_simClockStepSize
set sopts_simClockOverStep $tkg_simClockOverStep
set sopts_allowDebug $tkg_allowDebug
set sopts_simActClock $tkg_simActClock
set sopts_simUseActClock $tkg_simUseActClock
set sopts_simInitScript $tkg_simInitScript
set sopts_simRememberProbes $tkg_simRememberProbes
set sopts_simLogFile ""
set sopts_simDelayFile ""
set sopts_simCustomDelay 0

proc tkg_saveOptions {} {
  global tkg_prefFile tkg_enableBeakModes
  global tkg_trekMode tkg_batMode tkg_baderMode tkg_batRate
  global tkg_siteName tkg_regionUpdate tkg_smoothScroll
  global tkg_allowDebug tkg_blockMoveStyle tkg_helpBalloons tkg_noviceMode
  global tkg_printCommand tkg_printPgSize tkg_printPgSizeA4 tkg_printPgOrient
  global tkg_printDuplex tkg_printStyle tkg_printIndex tkg_printGraph
  global tkg_checkpointFreq tkg_checkpointEnabled
  global tkg_simStepSize tkg_simClockStepSize tkg_simClockOverStep tkg_simSortTraces
  global tkg_simActClock tkg_simUseActClock tkg_simDebugInterface tkg_contVerify
  global tkg_simInitScript tkg_simCustomDelay tkg_simDelayFile tkg_valuePopUpDelay
  global tkg_simRememberProbes

  global tkg_instColor tkg_moduleColor tkg_modulePortColor tkg_frameColor 
  global tkg_commentColor tkg_hyperlinkColor tkg_wireColor tkg_busColor tkg_toolColor
  global tkg_gridColor tkg_oneColor tkg_zeroColor tkg_floatColor tkg_cpathColor 
  global tkg_unknownColor tkg_offLedColor tkg_onLedColor tkg_zLedColor  
  global tkg_checkVersion tkg_flashCPath tkg_numCPath tkg_undoLength



  set fd [open $tkg_prefFile w]
  puts $fd "#"
  puts $fd "# Automatically generated preferences file - DO NOT EDIT"
  puts $fd "#"
  puts $fd ""

  puts $fd "#"
  puts $fd "# Basic settings"
  puts $fd "#"
  puts $fd "set tkg_siteName \"$tkg_siteName\""
  puts $fd "set tkg_smoothScroll $tkg_smoothScroll"
  puts $fd "set tkg_regionUpdate $tkg_regionUpdate"
  puts $fd "set tkg_blockMoveStyle $tkg_blockMoveStyle"
  puts $fd "set tkg_helpBalloons $tkg_helpBalloons"
  puts $fd "set tkg_noviceMode $tkg_noviceMode"
  puts $fd "set tkg_undoLength $tkg_undoLength"
  puts $fd ""
   
  puts $fd "#"
  puts $fd "# Mode settings"
  puts $fd "#"
  puts $fd "set tkg_enableBeakModes $tkg_enableBeakModes"
  puts $fd "set tkg_baderMode $tkg_baderMode"
  puts $fd "set tkg_batMode $tkg_batMode"
  puts $fd "set tkg_trekMode $tkg_trekMode"
  puts $fd "set tkg_batRate $tkg_batRate"
  puts $fd "set tkg_allowDebug $tkg_allowDebug"
  puts $fd "set tkg_contVerify $tkg_contVerify"
  puts $fd ""


  puts $fd "#"
  puts $fd "# Simulator settings"
  puts $fd "#"
  puts $fd "set tkg_simRememberProbes $tkg_simRememberProbes"
  puts $fd "set tkg_simSortTraces $tkg_simSortTraces"
  puts $fd "set tkg_simStepSize $tkg_simStepSize"
  puts $fd "set tkg_simClockStepSize $tkg_simClockStepSize"
  puts $fd "set tkg_simClockOverStep $tkg_simClockOverStep"
  puts $fd "set tkg_simDebugInterface $tkg_simDebugInterface"
  puts $fd "set tkg_simActClock \"$tkg_simActClock\""
  puts $fd "set tkg_simUseActClock $tkg_simUseActClock"
  puts $fd "set tkg_simInitScript \"$tkg_simInitScript\""
  puts $fd "set tkg_simCustomDelay $tkg_simCustomDelay"
  puts $fd "set tkg_simDelayFile [list $tkg_simDelayFile]"
  puts $fd "set tkg_valuePopUpDelay $tkg_valuePopUpDelay"
  puts $fd ""

  puts $fd "#"
  puts $fd "# Circuit Anlysis"
  puts $fd "#"
  puts $fd "set tkg_flashCPath $tkg_flashCPath"
  puts $fd "set tkg_numCPath $tkg_numCPath"
  puts $fd ""

  puts $fd "#"
  puts $fd "# Colors"
  puts $fd "#"
  puts $fd "set tkg_instColor           \"$tkg_instColor\""
  puts $fd "set tkg_moduleColor         \"$tkg_moduleColor\""        
  puts $fd "set tkg_modulePortColor     \"$tkg_modulePortColor\""    
  puts $fd "set tkg_frameColor          \"$tkg_frameColor\""         
  puts $fd "set tkg_commentColor        \"$tkg_commentColor\""       
  puts $fd "set tkg_hyperlinkColor      \"$tkg_hyperlinkColor\""       
  puts $fd "set tkg_wireColor           \"$tkg_wireColor\""          
  puts $fd "set tkg_busColor            \"$tkg_busColor\""           
  puts $fd "set tkg_toolColor           \"$tkg_toolColor\""          
  puts $fd "set tkg_cpathColor          \"$tkg_cpathColor\""          
  puts $fd "set tkg_gridColor           \"$tkg_gridColor\""          
  puts $fd "set tkg_oneColor            \"$tkg_oneColor\""           
  puts $fd "set tkg_zeroColor           \"$tkg_zeroColor\""          
  puts $fd "set tkg_floatColor          \"$tkg_floatColor\""         
  puts $fd "set tkg_unknownColor        \"$tkg_unknownColor\""       
  puts $fd "set tkg_offLedColor         \"$tkg_offLedColor\""       
  puts $fd "set tkg_onLedColor          \"$tkg_onLedColor\""       
  puts $fd "set tkg_zLedColor           \"$tkg_zLedColor\""       

  puts $fd ""

  puts $fd "#"
  puts $fd "# Pinter settings"
  puts $fd "#"
  puts $fd "set tkg_printCommand \"$tkg_printCommand\""
  puts $fd "set tkg_printPgSizeA4 $tkg_printPgSizeA4"
  puts $fd "set tkg_printPgSize $tkg_printPgSize"
  puts $fd "set tkg_printPgOrient $tkg_printPgOrient"
  puts $fd "set tkg_printDuplex $tkg_printDuplex"
  puts $fd "set tkg_printStyle $tkg_printStyle"
  puts $fd "set tkg_printIndex $tkg_printIndex"
  puts $fd "set tkg_printGraph $tkg_printGraph"
  puts $fd ""

  puts $fd "#"
  puts $fd "# Checkpointing"
  puts $fd "#"
  puts $fd "set tkg_checkpointEnabled $tkg_checkpointEnabled"
  puts $fd "set tkg_checkpointFreq $tkg_checkpointFreq"
  puts $fd ""


  puts $fd "#"
  puts $fd "# Other Options"
  puts $fd "#"
  puts $fd "set tkg_checkVersion $tkg_checkVersion"
  puts $fd ""

  close $fd
}

proc tkg_optsGet {} {
  global lang

  copyVar opts_siteName tkg_siteName
  copyVar opts_regionUpdate tkg_regionUpdate
  copyVar opts_smoothScroll tkg_smoothScroll
  copyVar opts_blockMoveStyle tkg_blockMoveStyle
  copyVar opts_helpBalloons tkg_helpBalloons
  copyVar opts_noviceMode tkg_noviceMode
  copyVar opts_allowDebug tkg_allowDebug
  copyVar opts_checkpointEnabled tkg_checkpointEnabled
  copyVar opts_checkpointFreq tkg_checkpointFreq

  copyVar opts_instColor           tkg_instColor          
  copyVar opts_moduleColor         tkg_moduleColor        
  copyVar opts_modulePortColor     tkg_modulePortColor    
  copyVar opts_frameColor          tkg_frameColor         
  copyVar opts_commentColor        tkg_commentColor       
  copyVar opts_hyperlinkColor      tkg_hyperlinkColor       
  copyVar opts_wireColor           tkg_wireColor          
  copyVar opts_busColor            tkg_busColor           
  copyVar opts_toolColor           tkg_toolColor          
  copyVar opts_cpathColor          tkg_cpathColor          
  copyVar opts_gridColor           tkg_gridColor          
  copyVar opts_oneColor            tkg_oneColor           
  copyVar opts_zeroColor           tkg_zeroColor          
  copyVar opts_floatColor          tkg_floatColor         
  copyVar opts_unknownColor        tkg_unknownColor       
  copyVar opts_offLedColor         tkg_offLedColor
  copyVar opts_onLedColor          tkg_onLedColor
  copyVar opts_zLedColor           tkg_zLedColor

  copyVar opts_checkVersion        tkg_checkVersion

  copyVar opts_flashCPath          tkg_flashCPath
  copyVar opts_numCPath            tkg_numCPath
  copyVar opts_undoLength	   tkg_undoLength

  copyVar sopts_valuePopUpDelay tkg_valuePopUpDelay
  copyVar sopts_simSortTraces tkg_simSortTraces
  copyVar sopts_simRememberProbes tkg_simRememberProbes
  copyVar sopts_simStepSize tkg_simStepSize
  copyVar sopts_simClockStepSize tkg_simClockStepSize
  copyVar sopts_simClockOverStep tkg_simClockOverStep
  copyVar sopts_simDebugInterface tkg_simDebugInterface
  copyVar sopts_contVerify tkg_contVerify
  copyVar sopts_simActClock tkg_simActClock
  copyVar sopts_simUseActClock tkg_simUseActClock
  copyVar sopts_simInitScript tkg_simInitScript
  copyVar sopts_simCustomDelay tkg_simCustomDelay
  copyVar sopts_simDelayFile tkg_simDelayFile

  copyVar pd_print tkg_printCommand

  if { $lang == "en" } {
    copyVar pd_paper tkg_printPgSize
  } else {
    copyVar pd_paper tkg_printPgSizeA4
  }

  copyVar pd_orient tkg_printPgOrient
  copyVar pd_duplexMode tkg_printDuplex
  copyVar pd_style tkg_printStyle
  copyVar pd_index tkg_printIndex
  copyVar pd_graph tkg_printGraph

  copyVar opts_baderMode tkg_baderMode
  copyVar opts_trekMode tkg_trekMode
  copyVar opts_batMode tkg_batMode
}

proc tkg_optsStore {} {
  global opts_siteName lang
  global tkg_batRate
  global tkg_siteName 

  set tkg_siteName [tr-d [string trim $opts_siteName " \t"] "\""]
  copyVar tkg_regionUpdate opts_regionUpdate
  copyVar tkg_smoothScroll opts_smoothScroll
  copyVar tkg_blockMoveStyle opts_blockMoveStyle
  copyVar tkg_helpBalloons opts_helpBalloons
  copyVar tkg_noviceMode opts_noviceMode
  copyVar tkg_allowDebug opts_allowDebug
  copyVar tkg_checkpointEnabled opts_checkpointEnabled
  checkCopyVar tkg_checkpointFreq opts_checkpointFreq 1 9999

  copyVar tkg_flashCPath          opts_flashCPath
  copyVar tkg_numCPath            opts_numCPath
  checkCopyVar tkg_undoLength          opts_undoLength 1 9999

  checkCopyVar tkg_valuePopUpDelay sopts_valuePopUpDelay	1 10000
  checkCopyVar tkg_simStepSize sopts_simStepSize		1 1000000
  checkCopyVar tkg_simClockStepSize sopts_simClockStepSize	1 1000000
  checkCopyVar tkg_simClockOverStep sopts_simClockOverStep	0 1000000
  copyVar tkg_simSortTraces sopts_simSortTraces	
  copyVar tkg_simRememberProbes sopts_simRememberProbes	
  copyVar tkg_simDebugInterface sopts_simDebugInterface	
  copyVar tkg_contVerify sopts_contVerify	
  copyVar tkg_simActClock sopts_simActClock
  copyVar tkg_simUseActClock sopts_simUseActClock
  copyVar tkg_simInitScript sopts_simInitScript
  copyVar tkg_simCustomDelay sopts_simCustomDelay
  copyVar tkg_simDelayFile sopts_simDelayFile

  copyVar tkg_instColor          opts_instColor           
  copyVar tkg_moduleColor        opts_moduleColor         
  copyVar tkg_modulePortColor    opts_modulePortColor     
  copyVar tkg_frameColor         opts_frameColor          
  copyVar tkg_commentColor       opts_commentColor          
  copyVar tkg_hyperlinkColor     opts_hyperlinkColor        
  copyVar tkg_wireColor          opts_wireColor           
  copyVar tkg_busColor           opts_busColor            
  copyVar tkg_toolColor          opts_toolColor           
  copyVar tkg_cpathColor         opts_cpathColor           
  copyVar tkg_gridColor          opts_gridColor           
  copyVar tkg_oneColor           opts_oneColor            
  copyVar tkg_zeroColor          opts_zeroColor           
  copyVar tkg_floatColor         opts_floatColor          
  copyVar tkg_unknownColor       opts_unknownColor        
  copyVar tkg_offLedColor        opts_offLedColor
  copyVar tkg_onLedColor         opts_onLedColor
  copyVar tkg_zLedColor          opts_zLedColor

  copyVar tkg_checkVersion       opts_checkVersion

  copyVar tkg_printCommand pd_print

  if { $lang == "en" } {
    copyVar tkg_printPgSize pd_paper
  } else {
    copyVar tkg_printPgSizeA4 pd_paper
  }
  copyVar tkg_printPgOrient pd_orient
  copyVar tkg_printDuplex pd_duplexMode
  copyVar tkg_printStyle pd_style
  copyVar tkg_printIndex pd_index
  copyVar tkg_printGraph pd_graph

  copyVar tkg_baderMode		opts_baderMode
  copyVar tkg_trekMode		opts_trekMode
  copyVar tkg_batMode		opts_batMode

  gat_reinitDelay
  gat_setcolors
  tkg_saveOptions
}

proc tkg_eoBasic {w} {
  frame $w -relief groove -bd 2

  label $w.siteL -text "[m opt.site]:" -anchor w
  entry $w.siteE -width 30 -textvariable opts_siteName

  pack $w.siteL -padx 5 -pady 5 -side left
  pack $w.siteE -padx 5 -pady 5 -fill x -expand 1

  helpon $w.siteL [m ho.opt.site]
}

proc setColor {w c vname} {
  global $vname

  set $vname $c
  $w configure -image $c
}

proc colorselector {w vname} {
  global colors $vname

  set c [set $vname]

  menubutton $w -image $c -bd 2 -relief raised -menu $w.menu -indicatoron 1

  menu $w.menu -tearoff 0
  foreach c $colors {
#    $w.menu add command -image $c -command "setColor $w $c $vname"
    $w.menu add radiobutton -image $c -value $c -variable $vname -command "setColor $w $c $vname"
  }

}

proc colorDefaults {w} {
  global opts_instColor opts_moduleColor opts_modulePortColor opts_frameColor 
  global opts_commentColor opts_hyperlinkColor opts_wireColor opts_busColor opts_toolColor 
  global opts_gridColor opts_oneColor opts_zeroColor opts_floatColor  opts_cpathColor 
  global opts_unknownColor opts_offLedColor opts_onLedColor opts_zLedColor 

  copyVar opts_instColor           tkgdef_instColor          
  copyVar opts_moduleColor         tkgdef_moduleColor        
  copyVar opts_modulePortColor     tkgdef_modulePortColor    
  copyVar opts_frameColor          tkgdef_frameColor         
  copyVar opts_commentColor        tkgdef_commentColor       
  copyVar opts_hyperlinkColor      tkgdef_hyperlinkColor       
  copyVar opts_wireColor           tkgdef_wireColor          
  copyVar opts_busColor            tkgdef_busColor           
  copyVar opts_toolColor           tkgdef_toolColor          
  copyVar opts_cpathColor          tkgdef_cpathColor          
  copyVar opts_gridColor           tkgdef_gridColor          
  copyVar opts_oneColor            tkgdef_oneColor           
  copyVar opts_zeroColor           tkgdef_zeroColor          
  copyVar opts_floatColor          tkgdef_floatColor         
  copyVar opts_unknownColor        tkgdef_unknownColor       
  copyVar opts_offLedColor         tkgdef_offLedColor
  copyVar opts_onLedColor          tkgdef_onLedColor
  copyVar opts_zLedColor           tkgdef_zLedColor

  $w.instc    configure -image $opts_instColor
  $w.modc     configure -image $opts_moduleColor
  $w.modpc    configure -image $opts_modulePortColor
  $w.framec   configure -image $opts_frameColor
  $w.commc    configure -image $opts_commentColor
  $w.hlinkc   configure -image $opts_hyperlinkColor
  $w.wirec    configure -image $opts_wireColor
  $w.busc     configure -image $opts_busColor
  $w.toolc    configure -image $opts_toolColor
  $w.cpathc   configure -image $opts_cpathColor
  $w.gridc    configure -image $opts_gridColor
  $w.onec     configure -image $opts_oneColor
  $w.zeroc    configure -image $opts_zeroColor
  $w.floatc   configure -image $opts_floatColor
  $w.unknownc configure -image $opts_unknownColor
  $w.offledc  configure -image $opts_offLedColor
  $w.onledc   configure -image $opts_onLedColor
  $w.zledc    configure -image $opts_zLedColor
}

proc tkg_eoColors {w} {
  frame $w

  frame $w.c

  label $w.c.inst -text [m opt.inst]
  colorselector $w.c.instc opts_instColor

  label $w.c.mod -text [m opt.mods]
  colorselector $w.c.modc opts_moduleColor

  label $w.c.modp -text [m opt.modports]
  colorselector $w.c.modpc opts_modulePortColor

  label $w.c.frame -text [m opt.frames]
  colorselector $w.c.framec opts_frameColor

  label $w.c.comm -text [m opt.comment]
  colorselector $w.c.commc opts_commentColor

  label $w.c.hlink -text [m opt.hlink]
  colorselector $w.c.hlinkc opts_hyperlinkColor

  label $w.c.wire -text [m opt.wire]
  colorselector $w.c.wirec opts_wireColor

  label $w.c.bus -text [m opt.bus]
  colorselector $w.c.busc opts_busColor

  label $w.c.tool -text [m opt.tools]
  colorselector $w.c.toolc opts_toolColor

  label $w.c.cpath -text [m opt.cpath]
  colorselector $w.c.cpathc opts_cpathColor

  label $w.c.grid -text [m opt.grid]
  colorselector $w.c.gridc opts_gridColor

  label $w.c.one -text [m opt.logic1]
  colorselector $w.c.onec opts_oneColor

  label $w.c.zero -text [m opt.logic0]
  colorselector $w.c.zeroc opts_zeroColor

  label $w.c.float -text [m opt.float]
  colorselector $w.c.floatc opts_floatColor

  label $w.c.unknown -text [m opt.unknown]
  colorselector $w.c.unknownc opts_unknownColor

  label $w.c.offled -text [m opt.offled]
  colorselector $w.c.offledc opts_offLedColor

  label $w.c.onled -text [m opt.onled]
  colorselector $w.c.onledc opts_onLedColor

  label $w.c.zled -text [m opt.zled]
  colorselector $w.c.zledc opts_zLedColor

  set colorItem { inst mod modp frame comm hlink wire bus tool cpath grid one zero float unknown offled onled zled }
  set r 0
  set c 0

  foreach ci $colorItem {
    grid $w.c.$ci     -row $r  -column $c -padx 5 -pady 3 -sticky w
    grid $w.c.${ci}c     -row $r  -column [expr $c+1] -padx 5 -pady 3 -sticky w

    if { $c == 0 } {
      set c 3
    } else {
      set c 0
      incr r
    }
  }

  grid columnconfigure $w.c 2 -minsize 30

  pack $w.c -anchor w -padx 5 -pady 5

  frame $w.pad
  pack $w.pad -fill both -expand 1
  
  button $w.def -text [m opt.restdef] -command "colorDefaults $w.c"
  pack $w.def -anchor sw -padx 5 -pady 5
}

proc tkg_eoDisplay {w} {
  frame $w -relief groove -bd 2

  frame $w.f
  frame $w.f.f1
  frame $w.f.pad
  frame $w.f.f2
  pack $w.f.f1 -side left -anchor nw
  pack $w.f.pad -side left -anchor nw -padx 10
  pack $w.f.f2 -side left -anchor nw

  checkbutton $w.f.f1.ss -variable opts_smoothScroll -text [m opt.smoothscroll]
  checkbutton $w.f.f1.ru -variable opts_regionUpdate -text [m opt.regudate]
  checkbutton $w.f.f1.om -variable opts_blockMoveStyle -text [m opt.outmove]
  checkbutton $w.f.f1.hb -variable opts_helpBalloons -text [m opt.balloon]

  pack $w.f.f1.ss -anchor w
  pack $w.f.f1.ru -anchor w
  pack $w.f.f1.om -anchor w
  pack $w.f.f1.hb -anchor w
  pack $w.f -padx 10 -pady 10 -anchor w

  helpon $w.f.f1.ss [m ho.opt.smooth]
  helpon $w.f.f1.ru [m ho.opt.clip]
  helpon $w.f.f1.om [m ho.opt.outmove]
  helpon $w.f.f1.hb [m ho.opt.bhelp]


  checkbutton $w.f.f2.db -variable opts_allowDebug -text [m opt.debug]
  checkbutton $w.f.f2.nv -variable opts_noviceMode -text [m opt.novice]

  frame $w.f.f2.cpe
  checkbutton $w.f.f2.cpe.b -variable opts_checkpointEnabled -text [m opt.ckpoint]
  label $w.f.f2.cpe.l -text "   [m opt.freq]:"
  entry $w.f.f2.cpe.e -textvariable opts_checkpointFreq -width 4
  pack $w.f.f2.cpe.b $w.f.f2.cpe.l $w.f.f2.cpe.e -side left

  frame $w.f.f2.ud
  label $w.f.f2.ud.l -text "[m opt.undolen]:"
  entry $w.f.f2.ud.e -textvariable opts_undoLength -width 4
  pack  $w.f.f2.ud.l  $w.f.f2.ud.e -side left

  pack $w.f.f2.db -anchor w
  pack $w.f.f2.nv -anchor w
  pack $w.f.f2.cpe -anchor nw
  pack $w.f.f2.ud -anchor nw

  helpon $w.f.f2.db [m ho.opt.debug]
  helpon $w.f.f2.nv [m ho.opt.novice]
  helpon $w.f.f2.cpe.b [m ho.opt.ckpt]
  helpon $w.f.f2.cpe.l [m ho.opt.ckptfreq]
  helpon $w.f.f2.ud [m ho.opt.undolen]
}

proc tkg_eoModes {w} {
  frame $w -relief groove -bd 2
  checkbutton $w.enable -text [m opt.beak] -variable tkg_enableBeakModes
  frame $w.f
  label $w.f.lab -text [m opt.mode]:
  checkbutton $w.f.bat -text [m opt.bat] -variable opts_batMode
  checkbutton $w.f.trek -text [m opt.trek] -variable opts_trekMode
  checkbutton $w.f.miles -text [m opt.miles] -variable opts_baderMode

  grid $w.f.lab -row 0 -column 0 -sticky e
  grid $w.f.bat -row 0 -column 1 -sticky w
  grid $w.f.trek -row 1 -column 1 -sticky w
  grid $w.f.miles -row 2 -column 1 -sticky w

  pack $w.enable -padx 5 -pady 5 -anchor w
  pack $w.f -padx 5 -pady 5 -anchor w

  helpon $w.enable [m ho.opt.beak]
  helpon $w.f.miles [m ho.opt.miles]
  helpon $w.f.bat [m ho.opt.bat]
  helpon $w.f.trek [m ho.opt.trek]
}

#############################################################################
#
# simulator options
#

proc tkg_eoDebugOpts {w} {

  frame $w

  frame $w.flags -relief groove -bd 2
  frame $w.intf -relief groove -bd 2

  checkbutton $w.flags.cvfy -variable sopts_contVerify -text [m opt.contver] -anchor w
  checkbutton $w.intf.dbg -variable sopts_simDebugInterface -text [m opt.showsimcmd] -anchor w

  frame $w.intf.i
  label $w.intf.i.logl -text "[m opt.logfile]:" -anchor w
  entry $w.intf.i.loge -width 40 -textvariable sopts_simLogFile

  pack $w.flags.cvfy  -padx 5 -pady 5 -fill x -anchor w
  pack $w.intf.dbg  -padx 5 -pady 5 -fill x -anchor w

  pack $w.intf.i -padx 5 -pady 5 -anchor w -fill x
  pack $w.intf.i.logl -anchor w
  pack $w.intf.i.loge -anchor w -fill x

  pack $w.flags $w.intf -fill x -pady 5

  helpon $w.flags.cvfy [m ho.contver]
  helpon $w.intf.dbg [m ho.simwatch]
  helpon $w.intf.i.logl [m ho.simlog]
}

proc tkg_eoSimBaseOpts {w} {
  global simscr_w

  frame $w -relief groove -bd 2

  frame $w.t

  label $w.t.simstepL -text "[m opt.estepsz]:"
  entry $w.t.simstepE -width 5 -textvariable sopts_simStepSize

  label $w.t.clkstepL -text "[m opt.cstepsz]:"
  entry $w.t.clkstepE -width 5 -textvariable sopts_simClockStepSize

  label $w.t.clkostepL -text "[m opt.overstep]:"
  entry $w.t.clkostepE -width 5 -textvariable sopts_simClockOverStep

  label $w.t.vpopL -text "[m opt.vpopupdelay]:"
  entry $w.t.vpopE -width 5 -textvariable sopts_valuePopUpDelay

  frame $w.opt
  checkbutton $w.opt.dosort -text "[m opt.sorttraces]" -variable sopts_simSortTraces
  checkbutton $w.opt.rememberp -text "[m opt.rememberprobes]" -variable sopts_simRememberProbes

  frame $w.i
  label $w.i.initL -text "[m opt.initscript]:"
  entry $w.i.initE -width 40 -textvariable sopts_simInitScript
  set simscr_w $w.i.initE

  button $w.i.browse -text [m b.browse]  -command {
    set file [tk_getOpenFile -defaultextension $simScript_filter -filetypes $simScript_filetypes -parent $simscr_w]
    if { $file != "" } { 
      set sopts_simInitScript $file
      $simscr_w  icursor end
      $simscr_w  xview end
    }
  }

  grid $w.t.simstepL	-row 0 -column 0 -sticky e -padx 3 -pady 5
  grid $w.t.simstepE	-row 0 -column 1 -sticky w -padx 3 -pady 5
  grid $w.t.clkstepL	-row 0 -column 2 -sticky e -padx 3 -pady 5
  grid $w.t.clkstepE	-row 0 -column 3 -sticky w -padx 3 -pady 5 
  grid $w.t.clkostepL	-row 0 -column 4 -sticky e -padx 3 -pady 5
  grid $w.t.clkostepE	-row 0 -column 5 -sticky w -padx 3 -pady 5 
  grid $w.t.vpopL	-row 1 -column 0 -sticky e -padx 3 -pady 5
  grid $w.t.vpopE	-row 1 -column 1 -sticky w -padx 3 -pady 5 

  pack $w.t -anchor w

  pack $w.opt -anchor w 
  pack $w.opt.dosort -padx 5 -pady 5 -anchor w -side left
  pack $w.opt.rememberp -padx 5 -pady 5 -anchor w -side left


  pack $w.i -padx 5 -pady 5 -fill x -expand 1
  pack $w.i.initL -anchor w
  pack $w.i.browse -anchor w -fill x -padx 5 -pady 3 -side right
  pack $w.i.initE -anchor w -fill x -expand 1

  helpon $w.t.simstepL [m ho.opt.simstep]
  helpon $w.t.clkstepL [m ho.opt.ckstep]
  helpon $w.t.clkostepL [m ho.opt.ckover]
  helpon $w.t.vpopL [m ho.opt.vpopupdelay]
  helpon $w.i.initL [m ho.opt.init]
  helpon $w.opt.dosort [m ho.opt.sorttraces]
  helpon $w.opt.rememberp [m ho.opt.rememberprobes]
}

proc tkg_eoSimClock {w} {
  global sopts_simUseActClock
  frame $w -relief groove -bd 2

  radiobutton $w.all -text [m opt.posedge] -variable sopts_simUseActClock -value 0 -command "$w.actNam configure -state disabled -foreground gray"
  radiobutton $w.act -text "[m opt.setclock]:" -variable sopts_simUseActClock -value 1 -command "$w.actNam configure -state normal -foreground black"
  entry $w.actNam -width 15 -textvariable sopts_simActClock

  if { $sopts_simUseActClock == 0 } {
    $w.actNam configure -state disabled
  }

  helpon $w.all [m ho.opt.ckall]
  helpon $w.act [m ho.opt.ckspec]

  pack $w.all -padx 5 -pady 5 -anchor w
  pack $w.act -side left -padx 5 -pady 5 -anchor w 
  pack $w.actNam -side left -padx 5 -pady 5 -anchor w -fill x -expand 1
}

proc addDelayFile {w} {
  global gdf_filter gdf_filetypes sopts_simDelayFile

  set filename [tk_getOpenFile -defaultextension $gdf_filter -filetypes $gdf_filetypes -parent $w]
  if {$filename != "" } {
    $w.dirs.lb insert end $filename
  }

  set sopts_simDelayFile [$w.dirs.lb get 0 end]
}

proc delDelayFile {w} {
  global gdf_filter gdf_filetypes sopts_simDelayFile

  set idx [$w.dirs.lb curselection]
  if { $idx != "" } {
    catch { $w.dirs.lb delete $idx }
  }

  set sopts_simDelayFile [$w.dirs.lb get 0 end]
}

proc tkg_eoSimDelay {w} {
  global sopts_simDelayFile

  frame $w -relief groove -bd 2

  label $w.l -text [m opt.delayfilepath]

  frame $w.dirs
  listbox $w.dirs.lb -height 3 -xscrollcommand "$w.dirs.hb set" -yscrollcommand "$w.dirs.vb set"
  scrollbar $w.dirs.vb -orient vertical -command "$w.dirs.lb yview"
  scrollbar $w.dirs.hb -orient horizontal  -command "$w.dirs.lb xview"

  grid rowconfigure $w.dirs 0 -weight 1
  grid columnconfigure $w.dirs 0 -weight 1
  grid  $w.dirs.lb -row 0 -column 0 -sticky nsew
  grid  $w.dirs.vb -row 0 -column 1 -sticky ns
  grid  $w.dirs.hb -row 1 -column 0 -sticky ew

  button $w.add -text [m b.add] -command "addDelayFile $w"
  button $w.del -text [m b.delete] -command "delDelayFile $w"

  pack  $w.l -padx 5 -pady 3 -anchor w
  pack  $w.dirs -padx 5 -pady 3 -side left -expand 1 -fill x
  pack $w.add -padx 5 -pady 3 -fill x
  pack $w.del -padx 5 -pady 3 -fill x

  foreach f $sopts_simDelayFile {
    $w.dirs.lb insert end $f
  }

#  checkbutton $w.l -text [m opt.delayfile] -anchor w -variable sopts_simCustomDelay
#  entry $w.e -textvariable sopts_simDelayFile
#  pack $w.l $w.e -padx 5 -pady 3 -fill both -anchor w
}

proc tkg_eoOther {w} {
  frame $w -relief groove -bd 2
  checkbutton $w.l -text [m opt.vercheck] -anchor w -variable opts_checkVersionn -justify left
  pack $w.l -padx 5 -pady 3 -fill both -anchor w
}

proc tkg_eoAnalysis {w} {
  global opts_numCPath tkg_cpathListLengths

  frame $w -relief groove -bd 2

  label $w.cp -text [m opt.cpopts]
  checkbutton $w.flash -text [m opt.cpflash] -variable opts_flashCPath

  frame $w.num
  label $w.num.l -text [m opt.maxpath]
  menubutton $w.num.v -text $opts_numCPath -indicatoron 1 -relief raised -bd 2 -menu $w.num.v.m -width 3
  menu $w.num.v.m -tearoff 0
  set path_maxes $tkg_cpathListLengths
  foreach n $path_maxes {
    $w.num.v.m add command -label $n -command "$w.num.v configure -text $n; set opts_numCPath $n"
  }
  pack $w.num.l  $w.num.v -side left

  pack $w.cp -padx 5 -pady 3 -anchor w
  pack $w.flash -padx 20 -pady 3 -anchor w
  pack $w.num -padx 20 -pady 3 -anchor w
}

proc tkg_editOptions {} {
  global tkg_allowDebug

  tkg_optsGet

  set w .opts
  if { [catch {toplevel $w}] } { return }

  wm resizable $w 0 0
  wm title $w "TkGate: Options"
  wm geometry $w [offsetgeometry . 50 50]
  wm transient $w .

  frame $w.t -relief raised -bd 2

  set tabs {General Print Analysis Simulator Colors}
  set labels [list [m opt.general] [m opt.print] [m opt.analysis] [m opt.simulate] [m opt.color]]

  if { $tkg_allowDebug } {
    lappend tabs Debug
    lappend labels [m debug]
  }

  tabbox $w.t.tab -width 600 -height 450 -tabwidth 95 -tabs $tabs -command options_tab -tablabels $labels

  pack $w.t.tab -padx 5 -pady 5

  okcancel $w.b { tkg_optsStore; destroy .opts } { destroy .opts }
  
  pack $w.t $w.b -fill both

  bind $w <Return> { tkg_optsStore; destroy .opts }

  grab set $w
  tkwait window $w
  grab release $w
}

proc options_tab {w tab} {
  global tkg_enableBeakModes

  switch $tab {
    General {
      frame $w
      tkg_eoBasic $w.b
      tkg_eoDisplay $w.d
      pack  $w.b $w.d -padx 5 -pady 5 -fill both -anchor w

      if { $tkg_enableBeakModes } {
	tkg_eoModes $w.bm
	pack $w.bm -fill both -padx 5 -pady 5
      }
    }
    Print {
      frame		$w

      tkg_prntLprSel $w.lpr groove
      tkg_prntPaperSel $w.pap groove
      tkg_prntStyleSel $w.sty groove
      pack $w.lpr -fill x -pady 3 -padx 5
      pack $w.pap -fill x -pady 3 -padx 5
      pack $w.sty -fill x -pady 3 -padx 5

    }
    Analysis {
      frame $w
      tkg_eoAnalysis $w.analy
      pack $w.analy -fill x  -padx 5 -pady 3
    }
    Simulator {
      frame		$w

      tkg_eoSimBaseOpts $w.base
      pack $w.base -fill x -padx 5 -pady 3

      tkg_eoSimClock $w.clock
      pack $w.clock -fill x  -padx 5 -pady 3

      tkg_eoSimDelay $w.delay
      pack $w.delay -fill x  -padx 5 -pady 3

      frame $w.pad
      pack $w.pad -fill both -expand 1

    }
    Colors {
      tkg_eoColors $w
    }
    Debug {
      frame $w
      tkg_eoDebugOpts $w.opts
      pack $w.opts -fill x  -padx 5 -pady 3
    }
  }
}