5 set spellcheckType Player
11 set spell_maxCorrections 0
13 set spellcheckSurnames 1
14 set spellcheckAmbiguous 0
29 proc readSpellCheckFile {{message 1}} {
31 set ftype { { "Scid Spellcheck files" {".ssp"} } }
32 set fullname [
tk_getOpenFile -initialdir [
pwd] -filetypes $ftype -title "Open Spellcheck file"]
33 if {![
string compare $fullname ""]} {
return 0}
36 set err [
catch {
sc_name read $fullname} result]
40 tk_messageBox -title "ERROR: Unable to read file" -type ok \
41 -icon error -message "Scid could not correctly read the spellcheck file you selected:\n\n$result"
45 set spellCheckFile $fullname
47 tk_messageBox -title "Spellcheck file loaded." -type ok -icon info \
48 -message "Spellcheck file [
file tail $fullname] loaded:\n[
lindex $result 0] players, [
lindex $result 1] events, [
lindex $result 2] sites, [
lindex $result 3] rounds.\n\nTo have this file automatically loaded every time you start Scid, select the \"Save Options\" from the Options menu before exiting."
55 proc startScanning {} {
61 set spellstate scanning
66 .spellcheckWin.buttons.ambig configure -state disabled
67 .spellcheckWin.buttons.ok configure -state disabled
68 .spellcheckWin.buttons.cancel configure -text "Stop"
69 bind .spellcheckWin <Alt-s> ".spellcheckWin.buttons.cancel invoke; break"
70 if {$spellcheckType == "Player"} {
71 .spellcheckWin.buttons.surnames configure -state disabled
77 proc stopScanning {} {
87 .spellcheckWin.buttons.ambig configure -state enabled
88 .spellcheckWin.buttons.ok configure -state enabled
89 .spellcheckWin.buttons.cancel configure -text $::tr(Cancel)
90 bind .spellcheckWin <Alt-c> ".spellcheckWin.buttons.cancel invoke; break"
91 if {$spellcheckType == "Player"} {
92 .spellcheckWin.buttons.surnames configure -state enabled
99 proc startCorrecting {} {
101 global spellcheckType
105 set spellstate correcting
109 .spellcheckWin.buttons.ambig configure -state disabled
110 .spellcheckWin.buttons.ok configure -state disabled
111 .spellcheckWin.buttons.cancel configure -state disabled
113 if {$spellcheckType == "Player"} {
114 .spellcheckWin.buttons.surnames configure -state disabled
126 proc updateSpellCheckWin {type} {
127 global spellcheckType spell_maxCorrections spellcheckSurnames
128 global spellcheckAmbiguous
130 .spellcheckWin.text.text delete 1.0 end
131 .spellcheckWin.text.text insert end "Scid is finding spelling corrections.\nPlease wait..."
140 set err [
catch {
sc_name spellcheck -max $spell_maxCorrections \
141 -surnames $spellcheckSurnames \
142 -ambiguous $spellcheckAmbiguous $type} result]
149 .spellcheckWin.text.text delete 1.0 end
150 .spellcheckWin.text.text insert end $result
157 proc openSpellCheckWin {type {parent .}} {
158 global spellcheckType spellcheckSurnames
159 global spellcheckAmbiguous
164 if {[
winfo exists $w]} {
165 tk_messageBox -type ok -icon info -title "Scid: Spellcheck error" \
167 -message "The spellcheck window is already open; close it first."
171 if {[
lindex [
sc_name read] 0] == 0} {
177 set spellcheckType $type
180 wm title $w "Scid: $::tr(Spellchecking) $::tr(Result)"
183 bind $w <F1> { helpWindow Maintenance }
184 bind $w <Configure> "recordWinSize $w"
188 set f [ttk::frame $w.text]
189 pack $w.text -side top -expand true -fill both
190 ttk::scrollbar $f.ybar -command "$f.text yview"
191 ttk::scrollbar $f.xbar -orient horizontal -command "$f.text xview"
192 text $f.text -yscrollcommand "$f.ybar set" -xscrollcommand "$f.xbar set" \
193 -setgrid 1 -width $::winWidth($w) -height $::winHeight($w) \
194 -background white -wrap none
195 $f.text configure -tabs \
196 [font measure font_Regular "xxxxxxxxxxxxxxxxxxxxxxxxx"]
198 grid $f.text -row 0 -column 0 -sticky nswe
199 grid $f.ybar -row 0 -column 1 -sticky nswe
200 grid $f.xbar -row 1 -column 0 -sticky nswe
202 grid rowconfig $w.text 0 -weight 1 -minsize 0
203 grid columnconfig $w.text 0 -weight 1 -minsize 0
209 canvas $w.progress -width 450 -height 20 -bg white -relief solid -border 1
210 $w.progress create rectangle 0 0 0 0 -fill blue -outline blue -tags bar
211 $w.progress create text 445 10 -anchor e -font font_Regular -tags time \
212 -fill black -text "0:00 / 0:00"
213 pack $w.progress -side top -pady 5
217 set f [ttk::frame $w.buttons]
218 pack $f -side bottom -fill x
222 ttk::checkbutton $f.ambig -variable spellcheckAmbiguous \
223 -text $::tr(Ambiguous) -command "updateSpellCheckWin $type"
224 pack $f.ambig -side left -padx 2 -ipady 2 -ipadx 3
228 if {$type == "Player"} {
232 ttk::checkbutton $f.surnames -variable spellcheckSurnames \
233 -text $::tr(Surnames) -command "updateSpellCheckWin Player"
234 pack $f.surnames -side left -padx 2 -ipady 2 -ipadx 3
239 ttk::button $f.ok -text $::tr(MakeCorrections) -underline 0 -command {
242 catch {set spelltext [.spellcheckWin.text.text get 1.0 end-1c]}
243 .spellcheckWin.text.text delete 1.0 end
244 .spellcheckWin.text.text insert end \
245 "Scid is making the spelling corrections.\nPlease wait..."
247 # Enable the progress bar
252 progressBarSet .spellcheckWin.progress 451 21
253 set err [catch {sc_name correct $spellcheckType $spelltext} spell_result]
257 set msg "Number of names to be corrected: "
258 append msg "[lindex $spell_result 0] \n"
259 append msg "Number of names errors: "
260 append msg "[lindex $spell_result 1] \n\n"
261 append msg "Number of games corrected: "
262 append msg "[lindex $spell_result 2] \n"
263 append msg "Number of games NOT corrected (date<birth or >death): "
264 append msg "[lindex $spell_result 3]"
265 tk_messageBox -type ok -parent .spellcheckWin \
266 -title "Scid: $::tr(Spellchecking) $::tr(Result)" -message $msg
270 destroy .spellcheckWin
273 ::windows::gamelist::Refresh
275 bind $w <Alt-m> "$f.ok invoke; break"
281 ttk::button $f.cancel -text $::tr(Cancel) -underline 0 -command {
282 if {$spellstate == "scanning" || $spellstate == "correcting"} {
286 destroy .spellcheckWin
289 bind $w <Alt-c> "$f.cancel invoke; break"
290 pack $f.cancel $f.ok -side right -padx 5 -fill x