Menu

[960b32]: / tcl / end.tcl  Maximize  Restore  History

Download this file

1461 lines (1300 with data), 52.7 kB

   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
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
# end.tcl: part of Scid.
# Copyright (C) 2000-2003 Shane Hudson.
if { ! [file isdirectory $::scidBooksDir]} {
tk_messageBox -title "Scid" -type ok -icon warning -message "Books directory not found"
}
# findNovelty:
# Searches the for first position in the current game not
# found in the selected database.
set noveltyOlder 0
proc findNovelty {} {
global noveltyBase noveltyOlder
set noveltyBase [sc_base current]
set w .noveltyWin
if {[winfo exists $w]} {
updateNoveltyWin
return
}
toplevel $w
wm title $w "Scid: $::tr(FindNovelty)"
pack [frame $w.help] -side top -fill x
text $w.help.text -width 1 -height 5 -wrap word \
-relief ridge -cursor top_left_arrow -yscrollcommand "$w.help.ybar set"
scrollbar $w.help.ybar -orient vertical -command "$w.help.text yview" \
-takefocus 0 -width 10
pack $w.help.ybar -side right -fill y
pack $w.help.text -side left -fill x -expand yes
$w.help.text insert end [string trim $::tr(NoveltyHelp)]
$w.help.text configure -state disabled
label $w.title -text $::tr(Database:) -font font_Bold
pack $w.title -side top
pack [frame $w.bases] -side top -fill x
pack [frame $w.bases.del]
addHorizontalRule $w
label $w.which -text $::tr(TwinsWhich:) -font font_Bold
pack $w.which -side top
radiobutton $w.all -text $::tr(SelectAllGames) \
-variable noveltyOlder -value 0
radiobutton $w.older -text $::tr(SelectOlderGames) \
-variable noveltyOlder -value 1
pack $w.all $w.older -side top -anchor w -padx 10
addHorizontalRule $w
label $w.status -text "" -width 1 -font font_Small -relief sunken -anchor w
pack $w.status -side bottom -fill x
pack [frame $w.b] -side top -fill x
dialogbutton $w.b.go -text $::tr(FindNovelty) -command {
destroy .noveltyWin
progressWindow "Scid" "$::tr(FindNovelty)" $::tr(Cancel)
if {$noveltyOlder} {
set err [catch {sc_game novelty -older $noveltyBase} result]
} else {
set err [catch {sc_game novelty $noveltyBase} result]
}
closeProgressWindow
if {$err} {
ERROR::MessageBox
} else {
if {$result < 0} {
tk_messageBox -message "[tr NoveltyNone]"
}
}
updateBoard -pgn
}
dialogbutton $w.b.close -textvar ::tr(Close) -command {
catch {destroy .noveltyWin}
}
packbuttons right $w.b.close $w.b.go
wm resizable $w 0 0
focus $w.b.go
bind $w <KeyPress-1> "$w.b1 invoke"
bind $w <KeyPress-2> "$w.b2 invoke"
bind $w <KeyPress-3> "$w.b3 invoke"
bind $w <KeyPress-4> "$w.b4 invoke"
updateNoveltyWin
}
proc updateNoveltyWin {} {
set w .noveltyWin
if {! [winfo exists $w]} { return }
$w.older configure -text "$::tr(SelectOlderGames) (< [sc_game info date])"
catch { destroy $w.bases.del }
pack [frame $w.bases.del]
foreach i [sc_base list] {
set name [file tail [sc_base filename $i]]
set ng [::utils::thousands [sc_base numGames $i]]
set txt "Base $i: $name ($ng $::tr(games))"
radiobutton $w.bases.del.b$i -text "$txt" -variable noveltyBase -value $i -underline 5
if {$ng == 0} { $w.bases.del.b$i configure -state disabled }
pack $w.bases.del.b$i -side top -anchor w -padx 10
}
}
set merge(ply) 40
# mergeGame:
# Produces a dialog for the user to merge a selected game into
# the current game.
#
proc mergeGame {base gnum} {
global merge
sc_game push copy
set err [catch {sc_game merge $base $gnum} result]
sc_game pop
if {$err} {
tk_messageBox -title "Scid" -type ok -icon info \
-message "Unable to merge the selected game:\n$result"
return
}
set merge(base) $base
set merge(gnum) $gnum
set w .mergeDialog
toplevel $w
wm title $w "Scid: $::tr(MergeGame)"
bind $w <Escape> "$w.b.cancel invoke"
bind $w <F1> {helpWindow GameList Browsing}
label $w.title -text $::tr(Preview:) -font font_Bold
pack $w.title -side top
pack [frame $w.b] -side bottom -fill x
frame $w.f
text $w.f.text -background white -wrap word -width 60 -height 20 \
-font font_Small -yscrollcommand "$w.f.ybar set"
scrollbar $w.f.ybar -takefocus 0 -command "$w.f.text yview"
event generate $w.f.text <ButtonRelease-1>
pack $w.f.ybar -side right -fill y
pack $w.f.text -side left -fill both -expand yes
pack $w.f -fill both -expand yes
set small font_Small
label $w.b.label -text "Up to move:" -font $small
pack $w.b.label -side left
foreach i {5 10 15 20 25 30 35 40} {
radiobutton $w.b.m$i -text $i -variable merge(ply) -value [expr {$i * 2}] \
-indicatoron 0 -padx 2 -pady 1 -font $small -command updateMergeGame
pack $w.b.m$i -side left
}
radiobutton $w.b.all -text [::utils::string::Capital $::tr(all)] \
-variable merge(ply) -value 1000 -indicatoron 0 -padx 2 -pady 1 \
-font $small -command updateMergeGame
pack $w.b.all -side left
dialogbutton $w.b.ok -text "OK" -command {
undoFeature save
sc_game merge $merge(base) $merge(gnum) $merge(ply)
catch {grab release .mergeDialog}
destroy .mergeDialog
updateBoard -pgn
}
dialogbutton $w.b.cancel -text $::tr(Cancel) \
-command "catch {grab release $w}; destroy $w"
packbuttons right $w.b.cancel $w.b.ok
grab $w
updateMergeGame
}
proc updateMergeGame {args} {
global merge
set w .mergeDialog
if {! [winfo exists $w]} { return }
sc_game push copy
sc_game merge $merge(base) $merge(gnum) $merge(ply)
set pgn [sc_game pgn -indentV 1 -short 1 -width 60]
sc_game pop
$w.f.text configure -state normal
$w.f.text tag configure red -foreground darkRed
$w.f.text tag configure blue -foreground darkBlue
$w.f.text delete 1.0 end
foreach line [split $pgn "\n"] {
if {[string index $line 0] == " "} {
$w.f.text insert end $line blue
} else {
$w.f.text insert end $line
}
$w.f.text insert end "\n"
}
$w.f.text tag add red 1.0 4.0
#$w.f.text insert end $pgn
$w.f.text configure -state disabled
}
# setExportText:
# Allows the user to modify the text printed at the start and end of a
# file for a particular export format
#
proc setExportText {exportType} {
global exportStartFile exportEndFile
switch -- $exportType {
"PGN" {
set title "Set PGN file export text"
}
"HTML" {
set title "Set HTML file export text"
}
"LaTeX" {
set title "Set LaTeX file export text"
}
default {
return
}
}
set w .setExportText$exportType
if {[winfo exists $w]} { return }
toplevel $w
wm title $w "Scid: $title"
frame $w.buttons
pack $w.buttons -side bottom -fill x -anchor e
set pane [::utils::pane::Create $w.pane start end 500 400]
::utils::pane::SetRange $w.pane 0.3 0.7
pack $pane -side top -expand true -fill both
foreach f [list $pane.start $pane.end] type {start end} {
label $f.title -font font_Bold -text "Text at $type of $exportType file:"
text $f.text -wrap none -background white \
-yscroll "$f.ybar set" -xscroll "$f.xbar set"
scrollbar $f.ybar -orient vertical -command "$f.text yview"
scrollbar $f.xbar -orient horizontal -command "$f.text xview"
bind $f.text <FocusIn> {%W configure -background lightYellow}
bind $f.text <FocusOut> {%W configure -background white}
grid $f.title -row 0 -column 0 -sticky w
grid $f.text -row 1 -column 0 -sticky nesw
grid $f.ybar -row 1 -column 1 -sticky nesw
grid $f.xbar -row 2 -column 0 -sticky nesw
grid rowconfig $f 1 -weight 1 -minsize 0
grid columnconfig $f 0 -weight 1 -minsize 0
}
$pane.start.text insert end $exportStartFile($exportType)
$pane.end.text insert end $exportEndFile($exportType)
button $w.buttons.default -text "Reset to Default" -command "
$pane.start.text delete 1.0 end
$pane.start.text insert end \$default_exportStartFile($exportType)
$pane.end.text delete 1.0 end
$pane.end.text insert end \$default_exportEndFile($exportType)
"
dialogbutton $w.buttons.ok -text "OK" -command "
set exportStartFile($exportType) \[$pane.start.text get 1.0 end-1c\]
set exportEndFile($exportType) \[$pane.end.text get 1.0 end-1c\]
focus .
destroy $w
"
dialogbutton $w.buttons.cancel -text $::tr(Cancel) -command "focus .; destroy $w"
pack $w.buttons.default -side left -padx 5 -pady 2
pack $w.buttons.cancel $w.buttons.ok -side right -padx 5 -pady 2
focus $pane.start.text
}
image create photo htmldiag0 -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
Ih2AZA5xDCmRgVDSBHzMRH1coZMI+c0MmcjhKdRFvOIED4j06CTW/nYHAcVAf2hi5QjmWIkH
lBJVK3hiOjrYAljuYpbj81AsQUmK5wwkJ5JkJEwGl68oCvOXZhgh7mRJCYdACYmE4B4KqhiY
GEBTBCfTIyQMB7iaeK864SHjGDwRNV0OBIY/gSYEzClNF6TOdnD4yEIeoE64xasn2kTBPdHV
hHp6Shr4tJNDMKTMYTLPOT3ZHTQQSlAMrGsGn8tH/hHXeKBVxkB26QgjDDLKKErRhaTSoqU2
PkmHiAzOna8ACEpLUKMYzDQOETgNQQZwGoOs7VUoqEBOC0SQBHAKniJJKE51Gsx7YbEXFiAq
cFYiArZMAyMUyFZPCsDLgzz1ElJdBQ2gOkfN/GIaKDhMr4DaKKw5hDT5EBmFoIJWL/KqV8iE
RuQwINcOHZFR50wPBg4glC2xDAAB3SsGAquTfKSBdKqJrGQ5RQK/hGOymFUNUqOxicdi9pWK
QEDicPBGIsCSE6PFwXUqwoALiCACbmrAJJrCJwq0tote/MFqxXBbhugsaRXsYiYz10QlALCU
OwPCImmwXLqk7blniy50waebXN1qTbgeHd5elfZQsN1Afg5NyPpOJ7UiGOh1/STudqWSIu/i
AL0Nrdz6WMgz815zitkVb2iD21331gCb4dXcfJlW3zAAWL77dYsZBunf/+KXpfr1GQ/rgNTy
LuHBARbKgInZ3wbDYBvDvS7ojsvhMJg4xNodMX8/12EPvwDFEQ7d0kqMgMQSzrwwFnCCZxy3
LDbXxfnVsYQD+Dn2PMK8M1GvihXcYyP/2MUIHjJF40veGy8hyjKecCYyKSUYhAAAOw==
}
# exportOptions:
# Prompts the user to select exporting options.
#
proc exportOptions {exportType} {
global exportFlags
set w .exportFlagsWin
set exportFlags(ok) -1
toplevel $w
wm title $w "Scid: [tr OptionsExport]"
# wm transient $w .
wm protocol $w WM_DELETE_WINDOW { }
bind $w <Escape> "$w.b.cancel invoke"
bind $w <Return> "$w.b.ok invoke"
bind $w <F1> {helpWindow Export}
pack [frame $w.o] -side top -fill x -pady 5 -padx 5
label $w.o.append -text $::tr(AddToExistingFile)
radiobutton $w.o.appendYes -text $::tr(Yes) \
-variable exportFlags(append) -value 1
radiobutton $w.o.appendNo -text $::tr(No) \
-variable exportFlags(append) -value 0
label $w.o.comments -text $::tr(ExportComments)
radiobutton $w.o.commentsOn -text $::tr(Yes) \
-variable exportFlags(comments) -value 1
radiobutton $w.o.commentsOff -text $::tr(No) \
-variable exportFlags(comments) -value 0
label $w.o.stripMarks -text $::tr(ExportStripMarks)
radiobutton $w.o.stripMarksOn -text $::tr(Yes) \
-variable exportFlags(stripMarks) -value 1
radiobutton $w.o.stripMarksOff -text $::tr(No) \
-variable exportFlags(stripMarks) -value 0
label $w.o.indentc -text $::tr(IndentComments)
radiobutton $w.o.indentcOn -text $::tr(Yes) \
-variable exportFlags(indentc) -value 1
radiobutton $w.o.indentcOff -text $::tr(No) \
-variable exportFlags(indentc) -value 0
label $w.o.vars -text $::tr(ExportVariations)
radiobutton $w.o.varsOn -text $::tr(Yes) -variable exportFlags(vars) -value 1
radiobutton $w.o.varsOff -text $::tr(No) -variable exportFlags(vars) -value 0
label $w.o.indentv -text $::tr(IndentVariations)
radiobutton $w.o.indentvOn -text $::tr(Yes) \
-variable exportFlags(indentv) -value 1
radiobutton $w.o.indentvOff -text $::tr(No) \
-variable exportFlags(indentv) -value 0
label $w.o.column -text $::tr(ExportColumnStyle)
radiobutton $w.o.columnOn -text $::tr(Yes) \
-variable exportFlags(column) -value 1
radiobutton $w.o.columnOff -text $::tr(No) \
-variable exportFlags(column) -value 0
label $w.o.symbols -text $::tr(ExportSymbolStyle)
radiobutton $w.o.symbolsOn -text "! +=" \
-variable exportFlags(symbols) -value 1
radiobutton $w.o.symbolsOff -text {$2 $14} \
-variable exportFlags(symbols) -value 0
grid $w.o.append -row 0 -column 0 -sticky w
grid $w.o.appendYes -row 0 -column 1 -sticky w
grid $w.o.appendNo -row 0 -column 2 -sticky w
grid $w.o.comments -row 1 -column 0 -sticky w
grid $w.o.commentsOn -row 1 -column 1 -sticky w
grid $w.o.commentsOff -row 1 -column 2 -sticky w
grid $w.o.stripMarks -row 2 -column 0 -sticky w
grid $w.o.stripMarksOn -row 2 -column 1 -sticky w
grid $w.o.stripMarksOff -row 2 -column 2 -sticky w
grid $w.o.indentc -row 3 -column 0 -sticky w
grid $w.o.indentcOn -row 3 -column 1 -sticky w
grid $w.o.indentcOff -row 3 -column 2 -sticky w
grid $w.o.vars -row 4 -column 0 -sticky w
grid $w.o.varsOn -row 4 -column 1 -sticky w
grid $w.o.varsOff -row 4 -column 2 -sticky w
grid $w.o.indentv -row 5 -column 0 -sticky w
grid $w.o.indentvOn -row 5 -column 1 -sticky w
grid $w.o.indentvOff -row 5 -column 2 -sticky w
grid $w.o.column -row 6 -column 0 -sticky w
grid $w.o.columnOn -row 6 -column 1 -sticky w
grid $w.o.columnOff -row 6 -column 2 -sticky w
grid $w.o.symbols -row 7 -column 0 -sticky w
grid $w.o.symbolsOn -row 7 -column 1 -sticky w
grid $w.o.symbolsOff -row 7 -column 2 -sticky w
# Extra option for PGN format: handling of null moves
if {$exportType == "PGN"} {
label $w.o.space -text ""
grid $w.o.space -row 8 -column 0 -sticky w
label $w.o.nullMoves -text "Convert null moves to comments"
radiobutton $w.o.convertNullMoves -text $::tr(Yes) \
-variable exportFlags(convertNullMoves) -value 1
radiobutton $w.o.keepNullMoves -text $::tr(No) \
-variable exportFlags(convertNullMoves) -value 0
grid $w.o.nullMoves -row 9 -column 0 -sticky w
grid $w.o.convertNullMoves -row 9 -column 1 -sticky w
grid $w.o.keepNullMoves -row 9 -column 2 -sticky w
}
# Extra option for HTML format: diagram image set
if {$exportType == "HTML"} {
label $w.o.space -text ""
label $w.o.hdiag -text "Diagram"
radiobutton $w.o.hb0 -text "bitmaps" \
-variable exportFlags(htmldiag) -value 0
radiobutton $w.o.hb1 -text "bitmaps2" \
-variable exportFlags(htmldiag) -value 1
label $w.o.hl0 -image htmldiag0
label $w.o.hl1 -image htmldiag1
grid $w.o.space -row 8 -column 0
grid $w.o.hdiag -row 9 -column 0 -sticky w
grid $w.o.hb0 -row 9 -column 1 -sticky w
grid $w.o.hb1 -row 9 -column 2 -sticky w
grid $w.o.hl0 -row 10 -column 1
grid $w.o.hl1 -row 10 -column 2
}
addHorizontalRule $w
pack [frame $w.b] -side top
dialogbutton $w.b.ok -text "OK" -command {
set exportFlags(ok) 1
}
dialogbutton $w.b.cancel -text $::tr(Cancel) -command {
set exportFlags(ok) 0
}
pack $w.b.ok $w.b.cancel -side left -padx 5 -pady 5
wm withdraw $w
update idletasks
set x [expr {[winfo screenwidth $w]/2 - [winfo reqwidth $w]/2 \
- [winfo vrootx [winfo parent $w]]}]
set y [expr {[winfo screenheight $w]/2 - [winfo reqheight $w]/2 \
- [winfo vrooty [winfo parent $w]]}]
wm geom $w +$x+$y
wm deiconify $w
grab $w
tkwait variable exportFlags(ok)
grab release $w
destroy $w
return $exportFlags(ok)
}
# exportGames:
# exports current game or all filtered games to a new PGN, LaTeX or Html file.
#
proc exportGames {selection exportType} {
global ::pgn::moveNumberSpaces exportStartFile exportEndFile exportFlags
if {$selection == "filter" && [sc_filter count] == 0} {
tk_messageBox -title "Scid: Filter empty" -type ok -icon info \
-message "The filter contains no games."
return
}
if {[exportOptions $exportType] == 0} { return }
sc_info html $exportFlags(htmldiag)
switch -- $exportType {
"PGN" {
set ftype {
{ "PGN files" {".pgn"} }
{ "All files" {"*"} }
}
set title "a PGN file"
set idir $::initialDir(base)
set default ".pgn"
}
"HTML" {
set ftype {
{ "HTML files" {".html" ".htm"} }
{ "All files" {"*"} }
}
set title "an HTML file"
set idir $::initialDir(html)
set default ".html"
}
"LaTeX" {
set ftype {
{ "LaTeX files" {".tex" ".ltx"} }
{ "All files" {"*"} }
}
set title "a LaTeX file"
set idir $::initialDir(tex)
set default ".tex"
}
default { return }
}
if {$exportFlags(append)} {
set getfile tk_getOpenFile
set title "Add games to $title"
} else {
set getfile tk_getSaveFile
set title "Create $title"
}
set fName [$getfile -initialdir $idir -filetypes $ftype -defaultextension $default -title $title]
if {$fName == ""} { return }
progressWindow "Scid" "Exporting games..." $::tr(Cancel)
sc_base export $selection $exportType $fName -append $exportFlags(append) \
-starttext $exportStartFile($exportType) \
-endtext $exportEndFile($exportType) \
-comments $exportFlags(comments) -variations $exportFlags(vars) \
-space $::pgn::moveNumberSpaces -symbols $exportFlags(symbols) \
-indentC $exportFlags(indentc) -indentV $exportFlags(indentv) \
-column $exportFlags(column) -noMarkCodes $exportFlags(stripMarks) \
-convertNullMoves $exportFlags(convertNullMoves)
closeProgressWindow
}
###########################################################################
### Global variables used in gameSave:
set date 0; set year 0; set month 0; set day 0; set white 0; set black 0
set resultVal 0; set event 0; set site 0; set round 0
set whiteElo 0; set blackElo 0; set eco 0; set extraTags ""
set whiteRType "Elo"; set blackRType "Elo"
set edate 0; set eyear 0; set emonth 0; set eday 0
# Traces on game-save dialog variables to ensure sane values:
trace variable resultVal w ::utils::validate::Result
trace variable whiteElo w {::utils::validate::Integer [sc_info limit elo] 0}
trace variable blackElo w {::utils::validate::Integer [sc_info limit elo] 0}
trace variable year w {::utils::validate::Integer [sc_info limit year] 1}
trace variable month w {::utils::validate::Integer 12 1}
trace variable day w {::utils::validate::Integer 31 1}
trace variable eyear w {::utils::validate::Integer [sc_info limit year] 1}
trace variable emonth w {::utils::validate::Integer 12 1}
trace variable eday w {::utils::validate::Integer 31 1}
set gsaveNum 0
set i 0; set j 0
set temp 0
array set nameMatches {}
set nameMatchCount 0
# updateMatchList:
# Called from gameSave to update the matching name list as the user
# types a player/site/event/round name.
#
proc updateMatchList { tw nametype maxMatches name el op } {
global nameMatches nameMatchCount
global $name editNameType
if {![winfo exists $tw]} return
if {$nametype == ""} { set nametype $editNameType }
if {$nametype == "rating"} { set nametype "player" }
set val [set $name]
$tw configure -state normal
$tw delete 0.0 end
set matches {}
catch {set matches [sc_name match $nametype $val $maxMatches]}
set count [llength $matches]
set nameMatchCount [expr {$count / 2}]
for {set i 0} { $i < $count } {incr i 2} {
set nameMatchCount [expr {($i / 2) + 1}]
set nameMatches($nameMatchCount) [lindex $matches [expr {$i + 1}]]
set str "$nameMatchCount:\t[lindex $matches $i]\t$nameMatches($nameMatchCount)\n"
$tw insert end $str
}
$tw configure -state disabled
}
proc clearMatchList { tw } {
global nameMatches nameMatchCount
set nameMatchCount 0
$tw configure -state normal
$tw delete 0.0 end
$tw configure -state disabled
}
# Traces to update the match list as names are typed in:
trace variable event w { updateMatchList .save.g.list e 9 }
trace variable site w { updateMatchList .save.g.list s 9 }
trace variable white w { updateMatchList .save.g.list p 9 }
trace variable black w { updateMatchList .save.g.list p 9 }
trace variable round w { updateMatchList .save.g.list r 9 }
set editName ""
set editNameNew ""
set editNameType "player"
set editNameSelect "all"
set editNameRating ""
set editNameRType "Elo"
set editDate ""
set editDateNew ""
trace variable editNameRating w {::utils::validate::Integer [sc_info limit elo] 0}
trace variable editName w { updateMatchList .nedit.g.list "" 9 }
trace variable editDate w ::utils::validate::Date
trace variable editDateNew w ::utils::validate::Date
proc editNameNewProc { tw nametype maxMatches name el op } {
global editNameNew
if {! [winfo exists .nedit]} { return }
if {[string compare $editNameNew ""]} {
.nedit.buttons.replace configure -state normal
} else {
.nedit.buttons.replace configure -state disabled
}
catch {updateMatchList $tw $nametype $maxMatches $name $el $op}
}
trace variable editNameNew w { editNameNewProc .nedit.g.list "" 9 }
set nameEditorWin 0
proc makeNameEditor {} {
if {! [winfo exists .nedit]} { nameEditor }
}
proc setNameEditorType {type} {
if {! [winfo exists .nedit]} { return }
catch {.nedit.typeButtons.$type invoke}
}
proc nameEditor {} {
global editName editNameType editNameNew nameEditorWin editNameSelect
global editNameRating editDate editDateNew
set w .nedit
if {[winfo exists $w]} {
destroy $w
return
}
toplevel $w
wm title $w "Scid: [tr FileMaintNameEditor]"
set nameEditorWin 1
setWinLocation $w
bind $w <Configure> "recordWinSize $w"
label $w.typeLabel -textvar ::tr(NameEditType:) -font font_Bold
frame $w.typeButtons
pack $w.typeLabel $w.typeButtons -side top -pady 5
foreach i { "Player" "Event" "Site" "Round"} {
set j [string tolower $i]
radiobutton $w.typeButtons.$j -textvar ::tr($i) -variable editNameType \
-value $j -indicatoron false -pady 5 -padx 5 -command {
grid remove .nedit.g.ratingE
grid remove .nedit.g.rtype
grid remove .nedit.g.fromD
grid remove .nedit.g.toD
grid .nedit.g.toL -row 1 -column 1 -sticky e
grid .nedit.g.fromE -row 0 -column 2 -sticky w
grid .nedit.g.toE -row 1 -column 2 -sticky w
}
pack $w.typeButtons.$j -side left -padx 5
}
radiobutton $w.typeButtons.rating -textvar ::tr(Rating) -variable editNameType \
-value rating -indicatoron false -pady 5 -padx 5 -command {
grid remove .nedit.g.toE
grid remove .nedit.g.toL
grid remove .nedit.g.fromD
grid remove .nedit.g.toD
grid .nedit.g.fromE -row 0 -column 2 -sticky w
grid .nedit.g.rtype -row 1 -column 0 -columnspan 2 -sticky e
grid .nedit.g.ratingE -row 1 -column 2 -sticky w
}
radiobutton $w.typeButtons.date -textvar ::tr(Date) -variable editNameType \
-value date -indicatoron false -pady 5 -padx 5 -command {
grid remove .nedit.g.toE
grid remove .nedit.g.fromE
grid remove .nedit.g.ratingE
grid remove .nedit.g.rtype
grid .nedit.g.fromD -row 0 -column 2 -sticky w
grid .nedit.g.toL -row 1 -column 1 -sticky e
grid .nedit.g.toD -row 1 -column 2 -sticky w
}
radiobutton $w.typeButtons.edate -textvar ::tr(EventDate) \
-variable editNameType -value edate -indicatoron false -pady 5 -padx 5 \
-command {
grid remove .nedit.g.toE
grid remove .nedit.g.fromE
grid remove .nedit.g.ratingE
grid remove .nedit.g.rtype
grid .nedit.g.fromD -row 0 -column 2 -sticky w
grid .nedit.g.toL -row 1 -column 1 -sticky e
grid .nedit.g.toD -row 1 -column 2 -sticky w
}
pack $w.typeButtons.rating $w.typeButtons.date $w.typeButtons.edate \
-side left -padx 5
addHorizontalRule .nedit
label $w.selectLabel -textvar ::tr(NameEditSelect) -font font_Bold
frame $w.selectButtons
pack $w.selectLabel $w.selectButtons -side top -pady 5
foreach i {all filter crosstable} row {0 1 2} text {
SelectAllGames
SelectFilterGames
SelectTournamentGames
} {
radiobutton $w.selectButtons.$i -textvar ::tr($text) \
-variable editNameSelect -value $i
grid $w.selectButtons.$i -row $row -column 0 -sticky w
}
addHorizontalRule $w
pack [frame $w.g] -side top
label $w.g.space -text " "
grid $w.g.space $w.g.space -row 0 -column 0
label $w.g.fromL -textvar ::tr(NameEditReplace:) -font font_Bold -anchor e
entry $w.g.fromE -width 40 -background white -relief sunken \
-textvariable editName
entry $w.g.fromD -width 15 -background white -relief sunken \
-textvariable editDate
grid $w.g.fromL -row 0 -column 1 -sticky e
grid $w.g.fromE -row 0 -column 2 -sticky we
label $w.g.toL -textvar ::tr(NameEditWith:) -font font_Bold -anchor e
entry $w.g.toE -width 40 -background white -relief sunken \
-textvariable editNameNew
entry $w.g.toD -width 15 -background white -relief sunken \
-textvariable editDateNew
grid $w.g.toL -row 1 -column 1 -sticky e
grid $w.g.toE -row 1 -column 2 -sticky we
entry $w.g.ratingE -width 5 -background white -relief sunken \
-textvariable editNameRating -justify right
eval tk_optionMenu $w.g.rtype editNameRType [sc_info ratings]
$w.g.rtype configure -pady 2
label $w.g.title -textvar ::tr(NameEditMatches) \
-font font_Bold
text $w.g.list -height 9 -width 40 -relief sunken \
-background grey90 -tabs {2c right 2.5c left} -wrap none
label $w.g.padding -text ""
grid $w.g.padding -row 2 -column 0
grid $w.g.title -row 3 -column 1 -columnspan 2 -sticky n
grid $w.g.list -row 4 -column 1 -rowspan 9 -columnspan 2 -sticky n
updateMatchList $w.g.list "" 9 editName "" w
foreach i {fromE toE ratingE fromD toD} {
bind $w.g.$i <FocusIn> { %W configure -background lightYellow }
bind $w.g.$i <FocusOut> { %W configure -background white }
}
foreach {i j} {.nedit.g.fromE "editName" .nedit.g.toE "editNameNew" } {
for {set z 1} {$z <= 9} {incr z} {
bind $i [format "<Control-Key-%d>" $z] \
[format "eval {if {\$nameMatchCount >= %d} { \
set %s \$nameMatches(%d)}}; break" $z $j $z ]
}
}
addHorizontalRule $w
frame $w.buttons
button $w.buttons.replace -textvar ::tr(NameEditReplace) -command {
if {$editNameType == "rating"} {
set err [catch {sc_name edit $editNameType $editNameSelect $editName $editNameRating $editNameRType} result]
} elseif {$editNameType == "date" || $editNameType == "edate"} {
set err [catch {sc_name edit $editNameType $editNameSelect $editDate $editDateNew} result]
} else {
set err [catch {sc_name edit $editNameType $editNameSelect $editName $editNameNew} result]
}
if {$err} {
ERROR::MessageBox
} else {
.nedit.status configure -text $result
}
sc_game tags reload
updateBoard -pgn
::windows::gamelist::Refresh
}
dialogbutton $w.buttons.cancel -textvar ::tr(Close) -command {focus .; destroy .nedit}
pack $w.buttons -side top -pady 5
pack $w.buttons.replace $w.buttons.cancel -side left -padx 10
label $w.status -text "" -width 1 -font font_Small -relief sunken -anchor w
pack $w.status -side bottom -fill x
wm resizable $w 0 0
bind $w <Escape> { focus .; destroy .nedit }
bind $w <Return> {.nedit.buttons.replace invoke}
bind $w <Destroy> {set nameEditorWin 0}
bind $w <F1> {helpWindow Maintenance Editing}
focus $w
$w.typeButtons.$editNameType invoke
}
# addGameSaveEntry:
# used in gameSave for setting up the simpler labels and entry boxes.
#
proc addGameSaveEntry { name row textname } {
ttk::label .save.g.label$name -textvar $textname
ttk::entry .save.g.entry$name -width 30 -textvariable $name
grid .save.g.label$name -row $row -column 0 -sticky w
grid .save.g.entry$name -row $row -column 1 -columnspan 7 -sticky w
}
# gameSave:
# The game save dialog. Used for adding and replacing games. If the
# value gnum is zero, it is to add a new game; otherwise it is to
# replace game number gnum.
#
proc gameSave { gnum } {
global date year month day white black resultVal event site round
global whiteElo blackElo whiteRType blackRType eco extraTags gsaveNum
global edate eyear emonth eday
# Make a new toplevel that contains the game save dialog:
set w .save
if {[winfo exists $w]} { return }
toplevel $w
if {$gnum == 0} {
wm title $w "Scid: [tr GameAdd]"
pack [ttk::frame $w.refdb] -side top -fill x
CreateSelectDBWidget "$w.refdb" "gameSave_toBase" [sc_base current] 0
addHorizontalRule $w
} else {
wm title $w "Scid: [tr GameReplace]"
}
set gsaveNum $gnum
catch {grab $w}
set f [ttk::frame $w.g]
pack $f -side top
ttk::label $f.title -textvar ::tr(NameEditMatches)
text $f.list -height 9 -width 40 -relief sunken -background grey90 \
-tabs {2c right 2.5c left} -wrap none
# Get current values of tags:
set year [sc_game tag get Year]; set eyear [sc_game tag get EYear]
set month [sc_game tag get Month]; set emonth [sc_game tag get EMonth]
set day [sc_game tag get Day]; set eday [sc_game tag get EDay]
set white [sc_game tag get White]; set black [sc_game tag get Black]
set event [sc_game tag get Event]; set site [sc_game tag get Site]
set resultVal [sc_game tag get Result]; set round [sc_game tag get Round]
set whiteElo [sc_game tag get WhiteElo]
set blackElo [sc_game tag get BlackElo]
set whiteRType [sc_game tag get WhiteRType]
set blackRType [sc_game tag get BlackRType]
set eco [sc_game tag get ECO]
set extraTags [sc_game tag get Extra]
if {[::board::isFlipped .main.board]} {
regsub -all {FlipB "[01]"\n} $extraTags {} extraTags
append extraTags "FlipB \"1\"\n"
} else {
regexp {FlipB "([01])"\n} $extraTags -> flipB
if {[info exists flipB] && $flipB} {
regsub -all {FlipB "[01]"\n} $extraTags {} extraTags
}
}
clearMatchList $f.list
# Use question marks instead of zero values in date:
if {$year == 0} { set year "????" }
if {$month == 0} { set month "??" }
if {$day == 0} { set day "??" }
if {$eyear == 0} { set eyear "????" }
if {$emonth == 0} { set emonth "??" }
if {$eday == 0} { set eday "??" }
addGameSaveEntry event 0 ::tr(Event:)
addGameSaveEntry site 1 ::tr(Site:)
ttk::frame $f.dateframe
ttk::label $f.datelabel -textvar ::tr(Date:)
ttk::entry $f.dateyear -width 6 -textvariable year -justify right ;# -background white -relief sunken
ttk::label $f.datedot1 -text "."
ttk::entry $f.datemonth -width 3 -textvariable month -justify right
ttk::label $f.datedot2 -text "."
ttk::entry $f.dateday -width 3 -textvariable day -justify right
grid $f.datelabel -row 2 -column 0 -sticky w
grid $f.dateframe -row 2 -column 1 -columnspan 5 -sticky w
ttk::button $f.datechoose -image tb_calendar -style Pad0.Small.TButton -command {
set newdate [::utils::date::chooser "$year-$month-$day"]
if {[llength $newdate] == 3} {
set year [lindex $newdate 0]
set month [lindex $newdate 1]
set day [lindex $newdate 2]
}
}
ttk::button $f.today -textvar ::tr(Today) -command {
set year [::utils::date::today year]
set month [::utils::date::today month]
set day [::utils::date::today day]
}
pack $f.dateyear $f.datedot1 $f.datemonth $f.datedot2 $f.dateday \
-in $f.dateframe -side left
if {$::tcl_version >= 8.3} {
pack $f.datechoose -in $f.dateframe -side left
}
pack $f.today -in $f.dateframe -side left
ttk::frame $f.edateframe
ttk::label $f.edatelabel -textvar ::tr(EventDate:)
ttk::entry $f.edateyear -width 6 -textvariable eyear -justify right
ttk::label $f.edatedot1 -text "."
ttk::entry $f.edatemonth -width 3 -textvariable emonth -justify right
ttk::label $f.edatedot2 -text "."
ttk::entry $f.edateday -width 3 -textvariable eday -justify right
grid $f.edatelabel -row 3 -column 0 -sticky w
grid $f.edateframe -row 3 -column 1 -columnspan 5 -sticky w
ttk::button $f.edatechoose -image tb_calendar -style Pad0.Small.TButton -command {
set newdate [::utils::date::chooser "$eyear-$emonth-$eday"]
if {[llength $newdate] == 3} {
set eyear [lindex $newdate 0]
set emonth [lindex $newdate 1]
set eday [lindex $newdate 2]
}
}
ttk::button $f.esame -text "=$::tr(Date)" -command {
set eyear $year
set emonth $month
set eday $day
}
pack $f.edateyear $f.edatedot1 $f.edatemonth $f.edatedot2 $f.edateday \
-in $f.edateframe -side left
if {$::tcl_version >= 8.3} {
pack $f.edatechoose -in $f.edateframe -side left
}
pack $f.esame -in $f.edateframe -side left
addGameSaveEntry round 4 ::tr(Round:)
addGameSaveEntry white 5 ::tr(White:)
addGameSaveEntry black 6 ::tr(Black:)
ttk::label $f.reslabel -textvar ::tr(Result:)
ttk::entry $f.resentry -width 2 -textvariable resultVal
ttk::label $f.rescomment -text "(1, =, 0, *)"
grid $f.reslabel -row 7 -column 0 -sticky w
grid $f.resentry -row 7 -column 1 -sticky w
grid $f.rescomment -row 7 -column 2 -columnspan 4 -sticky w
ttk::label $f.welolabel -text "$::tr(White) "
ttk::combobox $f.wrtype -values [sc_info ratings] -width 7 -textvariable whiteRType
ttk::entry $f.weloentry -width 5 -textvariable whiteElo -justify right
ttk::label $f.belolabel -text "$::tr(Black) "
ttk::combobox $f.brtype -values [sc_info ratings] -width 7 -textvariable blackRType
ttk::entry $f.beloentry -width 5 -textvariable blackElo -justify right
grid $f.welolabel -row 8 -column 0 -sticky w
grid $f.wrtype -row 8 -column 1 -sticky w
grid $f.weloentry -row 8 -column 2 -sticky w
grid $f.belolabel -row 9 -column 0 -sticky w
grid $f.brtype -row 9 -column 1 -sticky w
grid $f.beloentry -row 9 -column 2 -sticky w
ttk::label $f.ecolabel -text "ECO Code:"
ttk::entry $f.ecoentry -width 6 -textvariable eco
grid $f.ecolabel -row 10 -column 0 -sticky w
grid $f.ecoentry -row 10 -column 1 -sticky w
ttk::button $f.ecob -textvar ::tr(ClassifyGame) -command {set eco [sc_eco game]}
grid $f.ecob -row 10 -column 2 -sticky w
grid $f.title -row 0 -column 8 -sticky n -padx 10
grid $f.list -row 1 -column 8 -rowspan 9 -sticky nw -padx 10
addHorizontalRule .save
ttk::label .save.extralabel -text "Extra Tags: (example format: Annotator \"Anand, V\") "
pack .save.extralabel -side top -fill x
ttk::frame .save.extra
text .save.extra.text -height 4 -width 40 -bg white -wrap none \
-yscrollcommand ".save.extra.scroll set"
# Override tab-binding for this text widget:
bind .save.extra.text <Key-Tab> "[bind all <Key-Tab>]; break"
ttk::scrollbar .save.extra.scroll -command ".save.extra.text yview" -takefocus 0
ttk::button .save.extra.last -text "Use\nlast\ngame's\ntags" -command {
set extraTags [sc_game tag get -last Extra]
.save.extra.text delete 1.0 end
.save.extra.text insert 1.0 $extraTags
}
pack .save.extra -side top -fill both -expand 1 -ipady 10
pack .save.extra.text -side left -fill both -expand 1
if {$gnum == 0} {
pack .save.extra.last -side right -padx 10
}
pack .save.extra.scroll -side right -fill y
.save.extra.text insert 1.0 $extraTags
foreach i {entryevent entrysite dateyear datemonth dateday \
entryround entrywhite entryblack resentry \
weloentry beloentry ecoentry edateyear edatemonth edateday} {
bind $f.$i <Return> {.save.buttons.save invoke}
# bind $f.$i <FocusIn> {%W configure -background lightYellow }
# bind $f.$i <FocusOut> {%W configure -background white }
}
bind .save.extra.text <FocusIn> {%W configure -background lightYellow }
bind .save.extra.text <FocusOut> {%W configure -background white }
# Bindings so Ctrl-1 to Ctrl-9 select a matching name in the player,
# site, event and round entryboxes:
set j 0
foreach {i j} {entryevent "event" entrysite "site"
entrywhite "white" entryblack "black"
entryround "round" } {
for {set z 1} {$z <= 9} {incr z} {
bind $f.$i [format "<Control-Key-%d>" $z] \
[format "eval {if {\$nameMatchCount >= %d} \
{set %s \$nameMatches(%d)}}" $z $j $z ]
}
}
addHorizontalRule .save
ttk::frame .save.buttons
if {$gnum == 0} {
ttk::button .save.buttons.prev -text "As last game" -command {
}
}
dialogbutton .save.buttons.save -textvar ::tr(Save) -underline 0 -command {
set extraTags [.save.extra.text get 1.0 end-1c]
if { [gsave $gsaveNum] } {
destroy .save
} else {
ERROR::MessageBox
}
}
# bind .save <Alt-s> { .save.buttons.save invoke; break }
dialogbutton .save.buttons.cancel -textvar ::tr(Cancel) -command {destroy .save}
pack .save.buttons -side bottom -ipady 10 -fill both -expand 1
if {$gnum == 0} {
#pack .save.buttons.prev -side left -padx 10
}
packbuttons right .save.buttons.cancel .save.buttons.save
bind .save <Escape> { focus .; destroy .save; }
::utils::win::Centre .save
focus .save.g.entryevent
.save.g.entryevent selection range 0 end
if {$gnum > 0} { focus .save.buttons.save }
}
# gsave:
# Called by gameSave when the user presses the "Save" button
# to save the game. Attempts to save and reports the result.
#
proc gsave { gnum } {
global date year month day white black resultVal event site round
global whiteElo blackElo whiteRType blackRType eco extraTags
global edate eyear emonth eday
set date [format "%s.%s.%s" $year $month $day]
set edate [format "%s.%s.%s" $eyear $emonth $eday]
set extraTagsList [split $extraTags "\n"]
sc_game tags set -event $event -site $site -date $date -round $round \
-white $white -black $black -result $resultVal \
-whiteElo $whiteElo -whiteRatingType $whiteRType \
-blackElo $blackElo -blackRatingType $blackRType \
-eco $eco -eventdate $edate -extra $extraTagsList
if {$gnum != 0} {
if { [catch {sc_game save $gnum}] } { return 0 }
::notify::DatabaseModified [sc_base current]
::notify::GameChanged
} else {
set ply [sc_pos location]
if { [catch {sc_game save $gnum $::gameSave_toBase}] } { return 0 }
::notify::DatabaseModified $::gameSave_toBase
::file::SwitchToBase $::gameSave_toBase 0
::game::Load [sc_base numGames $::gameSave_toBase] $ply
}
return 1
}
# gameAdd:
# Calls gameSave with a game number of zero.
#
proc gameAdd {} { gameSave 0 }
proc gameAddToClipbase {} {
if {[catch {sc_game save 0 $::clipbase_db}]} {
ERROR::MessageBox
}
::notify::DatabaseModified $::clipbase_db
}
# gameReplace:
# Calls gameSave with the current game number, which should be nonzero.
#
proc gameReplace {} { gameSave [sc_game number] }
# helpAbout:
# Displays information about Scid.
#
proc helpAbout {} {
::utils::sound::PlaySound sound_move
set str {}
append str "Scid: Shane's chess information database\n\n"
append str "Version $::scidVersion, $::scidVersionDate\n"
append str "Using Tcl/Tk version: [info patchlevel]\n\n"
append str "Copyright (C) 1999-2004 Shane Hudson\n"
append str "Copyright (C) 2006-2009 Pascal Georges\n"
append str "Copyright (C) 2008-2011 Alexander Wagner\n"
append str "Copyright (C) 2011 Gerd Lorscheid\n"
append str "Copyright (C) 2009-2015 Fulvio Benini\n"
append str "\nScid is licenced under the\n"
append str "GNU General Public License.\n"
tk_messageBox -title "About Scid" -message $str -type ok
}
############################################################
#### Square Bindings:
# Pascal Georges : allow the drawing of markers directly on the board (not through comment editor)
set startArrowSquare ""
proc addMarker {sq color} {
set to [::board::san $sq]
set oldComment [sc_pos getComment]
# check if the square is already of the same color
set erase [regexp "\[\x5B\]%draw full,$to,$color\[\x5D\]" $oldComment]
regsub "\[\x5B\]%draw full,$to,(green|yellow|red)\[\x5D\]" $oldComment "" newComment
set newComment [string trim $newComment]
if {!$erase} {
append newComment " \[%draw full,$to,$color\]"
}
sc_pos setComment $newComment
::pgn::Refresh 1
updateBoard
}
proc drawArrow {sq color} {
global startArrowSquare
if {$startArrowSquare == ""} {
set startArrowSquare [::board::san $sq]
} else {
set oldComment [sc_pos getComment]
set to [::board::san $sq]
if {$startArrowSquare != $to } {
set erase [regexp "\[\x5B\]%draw arrow,$startArrowSquare,$to,$color\[\x5D\]" $oldComment]
regsub "\[\x5B\]%draw arrow,$startArrowSquare,$to,(green|yellow|red)\[\x5D\]" $oldComment "" newComment
set newComment [string trim $newComment]
if {!$erase} {
append newComment " \[%draw arrow,$startArrowSquare,$to,$color\]"
}
sc_pos setComment $newComment
::pgn::Refresh 1
updateBoard
}
set startArrowSquare ""
}
}
proc MouseWheelRedirector {W X Y D} {
# Generate an MWheel virtual event to the window that has the mouse pointer
set w [winfo containing -displayof $W $X $Y]
# For virtual events we can't use the attribute "-delta" and we get away
# without a global variable by using instead "-data" which maps to %d
event generate $w <<MWheel>> -data $D -rootx $X -rooty $Y
}
proc ShiftMouseWheelRedirector {W X Y D} {
set w [winfo containing -displayof $W $X $Y]
event generate $w <<Shift-MWheel>> -data $D -rootx $X -rooty $Y
}
# On Windows, redirect mouse wheel events to those windows that have the
# mouse pointer:
# - Disable completely MouseWheel handling for all used classes. No class or
# window should listen to MouseWheel to avoid double firing
# - Any window that receives a MouseWheel redirects these events as MWheel
# to the window with the mouse pointer
# - Rebind all classes and windows that handle mouse wheel to MWheel events.
# Bind code is from TCL 8.5
# On Linux and Macs this redirection is not necessary
if { [tk windowingsystem] == "win32" } {
# Disable MouseWheel handling
set mw_classes [list Text Listbox Treeview]
foreach class $mw_classes { bind $class <MouseWheel> {} }
# Transform MouseWheel events into MWheel
bind all <MouseWheel> { MouseWheelRedirector %W %X %Y %D }
bind all <Shift-MouseWheel> { ShiftMouseWheelRedirector %W %X %Y %D }
# Bind classes to MWheel
bind Listbox <<MWheel>> { %W yview scroll [expr {-(%d/120) * 4}] units}
bind Treeview <<MWheel>> { %W yview scroll [expr {-(%d/120)}] units }
bind Text <<MWheel>> {
if {%d >= 0} { %W yview scroll [expr {-%d/3}] pixels
} else { %W yview scroll [expr {(2-%d)/3}] pixels }
}
}
#################
# Open files and databases:
# Check for arguments starting with "-" (or "/" on Windows):
set loadAtStart(spell) 1
set loadAtStart(eco) 1
set loadAtStart(tb) 1
proc getCommandLineOptions {} {
global argc argv windowsOS loadAtStart
if { $::macOS && ([string first "-psn" [lindex $argv 0]] == 0)} {
# Remove Process Serial Number from argument list:
set argv [lrange $argv 1 end]
incr argc -1
}
while {$argc > 0} {
set arg [lindex $argv 0]
set firstChar [string index $arg 0]
if {$firstChar == "-" || ($windowsOS && $firstChar == "/")} {
# Seen option argument:
incr argc -1
set argv [lrange $argv 1 end]
# Special argument "--" means no more options:
if {$arg == "--"} { return }
# Check for known option names:
# -f (/f), -fast (/fast): Fast start with no tablebases, etc.
# -xeco, -xe: Do not load ECO file.
# -xspell, -xs: Do not load spellcheck file.
# -xtb, -xt: Do not check tablebase directory.
set argName [string range $arg 1 end]
switch $argName {
"f" -
"fast" {
::splash::add "Fast start: no tablebases, ECO or spelling file loaded."
set loadAtStart(spell) 0
set loadAtStart(eco) 0
set loadAtStart(tb) 0
}
"xt" -
"xtb" {
set loadAtStart(tb) 0
}
"xe" -
"xeco" {
set loadAtStart(eco) 0
}
"xs" -
"xspell" {
set loadAtStart(spell) 0
}
default {
::splash::add "Warning: unknown option: \"$arg\""
}
}
} else {
# Seen first non-option argument:
return
}
}
}
getCommandLineOptions
# Try to find tablebases:
if {$loadAtStart(tb)} {
if {[sc_info tb]} {
::splash::add "Checking for endgame tablebase files..."
set tbDirs {}
foreach i {1 2 3 4} {
if {$initialDir(tablebase$i) != ""} {
if {$tbDirs != ""} { append tbDirs ";" }
append tbDirs [file nativename $initialDir(tablebase$i)]
}
}
set result 0
if {$tbDirs != ""} {
set result [sc_info tb $tbDirs]
}
if {$result == 0} {
::splash::add " No tablebases were found."
} else {
::splash::add " Tablebases with up to $result pieces were found."
}
}
}
# Try to open the ECO classification file:
set result 0
set ecoFile_fullname [file nativename $ecoFile]
if {$loadAtStart(eco)} {
::splash::add "Trying to load the ECO openings file..."
if {[catch { sc_eco read $ecoFile_fullname } result]} {
# Could not load, so try "scid.eco" in the current directory:
if {[catch {sc_eco read "scid.eco"} result]} {
# Neither attempt worked, so do not use ECO classification
::splash::add " Unable to open the ECO file: $ecoFile"
} else {
::splash::add " ECO file \"./scid.eco\" loaded: $result positions."
}
} else {
::splash::add " ECO file \"[file tail $ecoFile_fullname]\" loaded: $result positions."
}
}
################################################################################
# returns a list of all toplevel windows, except some that are utilities
################################################################################
proc getTopLevel {} {
set topl {}
set exclude { ".tooltip" ".glistExtra" ".menu" "." ".pgnPopup" }
foreach c [winfo children .] {
if { $c != [winfo toplevel $c] } { continue }
# Tk report .__tk_filedialog as toplevel window even if the window has been closed
if { [ lsearch $topl $c ] == -1 && [ lsearch $exclude $c ] == -1 && ![string match "\.__tk*" $c] } {
lappend topl $c
}
}
return $topl
}
################################################################################
#
################################################################################
# showHideAllWindows:
# Arranges for all major Scid windows to be shown/hidden
# Should be called type = "iconify" or "deiconify"
#
proc showHideAllWindows {type} {
# Don't do this if user option is off:
if {! $::autoIconify} { return }
# Some window managers like KDE generate Unmap events for other
# situations like switching to another desktop, etc.
# So if the main window is still mapped, do not iconify others:
if {($type == "iconify") && ([winfo ismapped .main] == 1)} { return }
# Now iconify/deiconify all the major Scid windows that exist:
foreach w [getTopLevel] {
# .baseWin .glistWin .pgnWin .tourney .maintWin \
# .ecograph .crosstabWin .treeWin .analysisWin1 .anslysisWin2 \
# .playerInfoWin .commentWin .repWin .statsWin .tbWin \
# .sb .sh .sm .noveltyWin .emailWin .oprepWin .plist \
# .rgraph .sgraph .importWin .helpWin .tipsWin
if {[winfo exists $w]} { catch {wm $type $w} }
}
}
proc raiseAllWindows {} {
# Don't do this if auto-raise option is turned off:
if {! $::autoRaise} { return }
showHideAllWindows deiconify
foreach w [getTopLevel] {
# .baseWin .glistWin .pgnWin .tourney .maintWin \
# .ecograph .crosstabWin .treeWin .analysisWin1 .anslysisWin2 \
# .playerInfoWin .commentWin .repWin .statsWin .tbWin \
# .sb .sh .sm .noveltyWin .emailWin .oprepWin .plist \
# .rgraph .sgraph .importWin .helpWin .tipsWin
if {[winfo exists $w]} { catch { raise $w } }
}
}
proc CreateMainWin { mainWin } {
createToplevel .main
wm minsize $mainWin 0 0
wm iconname $mainWin "Scid"
wm protocol $mainWin WM_DELETE_WINDOW { ::file::Exit }
$mainWin configure -menu .menu
setWinLocation $mainWin
bind $mainWin <Configure> "recordWinSize $mainWin"
CreateGameInfo
CreateMainBoard .main
}
if { $::docking::USE_DOCKING } {
CreateMainWin .
::docking::layout_restore 1
keyboardShortcuts .
keyboardShortcuts TPanedwindow
keyboardShortcuts TNotebook
} else {
CreateMainWin .main
keyboardShortcuts .main
if {$startup(switcher)} { ::windows::switcher::Open }
if {$startup(pgn)} { ::pgn::OpenClose }
if {$startup(gamelist)} { ::windows::gamelist::Open }
if {$startup(tree)} { ::tree::make }
if {$startup(crosstable)} { crosstabWin }
if {$startup(book)} { ::book::open }
}
if {$startup(stats)} { ::windows::stats::Open }
if {$startup(tip)} { ::tip::show }
if {$startup(finder)} { ::file::finder::Open }
menuUpdateBases
setLanguageMenus
update
update idletasks
# Try to load the spellcheck file:
if {$loadAtStart(spell)} {
progressWindow "Scid - [tr Spellcheking]" "Loading $spellCheckFile ..."
set err [catch {sc_name read $spellCheckFile} result]
closeProgressWindow
}
after 1 {
::file::autoLoadBases.load
# fullname:
# Given a file name, returns its absolute name.
#
proc fullname {fname} {
if {[file pathtype $fname] == "absolute"} { return $fname }
set old [pwd]
if {[catch {cd [file dirname $fname]}]} { return $fname }
set fname [file join [pwd] [file tail $fname]]
catch {cd $old}
return $fname
}
# Loading a database if specified on the command line:
foreach cmdbase $::argv {
::file::Open "[fullname $cmdbase]"
}
# Opening files by drag & drop on Scid icon on Mac
namespace eval ::tk::mac {}
proc ::tk::mac::OpenDocument {args} {
foreach f $args {::file::Open $f}
}
}
### End of file: end.tcl