<commit_before>
proc clear {} {
    global sinfo s2s mode
    .sotalog.call delete 0 end
    .sotalog.rsts delete 0 end
    .sotalog.rstr delete 0 end
    .sotalog.rem delete 0 end
    .loghist.box selection clear 0 end
    .sotalog.info configure -text "$sinfo Mode: $mode" -fg black
    .sotalog.s2s configure -text ""
    set s2s ""
    focus .sotalog.call
}

proc initCounter {} {
    global qsocount bandlist

    foreach {wl fq} $bandlist {
        set qsocount($wl) 0
    }
}

proc modeToggle {} {
    global mode modes sinfo
    set pos [lsearch -exact $modes $mode]
    incr pos
    if {$pos == [llength $modes]} { set pos 0}
    set mode [lindex $modes $pos]
    .sotalog.info configure -text "$sinfo Mode: $mode"
}

proc bandSwitch {up} {
    global band bandlist

    set pos [lsearch -exact $bandlist $band]
    if {$up && $pos == [expr [llength $bandlist] - 2]} {
        set pos -2
    }
    if {! $up && $pos == 0} {
        set pos [llength $bandlist]
    }
    if {$up} {
        incr pos 2
    } else {
        incr pos -2
    }	
    set band [lindex $bandlist $pos]
}

proc updateSuggestions {part} {

    global sotacalls

    set suggest [lsearch -all -glob -inline $sotacalls "*${part}*"]
    .suggest.txt configure -state normal
    .suggest.txt delete 1.0 end
    .suggest.txt insert end $suggest
    .suggest.txt configure -state disabled
}

proc pickSuggestion {x y} {

    set index [lindex [split [.suggest.txt index @$x,$y] .] 1]
    set s [.suggest.txt get 1.0 1.end]
    while {[string index $s $index] != " " && $index > 0} { incr index -1}
    regexp {[A-Za-z0-9/]+} [string range $s $index end] pick
    if {[info exists pick]} {
        .sotalog.call delete 0 end
        .sotalog.call insert end $pick
        focus .sotalog.rsts
    }
}

proc insertLog {utc call rsts rstr rem} {

    global box band qsocount s2s
    
    if {[string length $s2s]} {
        set rem $s2s
    }

    set log [format %-7s%-20s%-10s%-10s%-20s $utc $call $rsts $rstr $rem]
    set box [linsert $box 0 $log]
    if {[expr [llength $box] %2]} { set s 0 } else { set s 1 }

    for {set i 0} {$i < [llength $box]} {incr i} {
	if {$s} {
	    .loghist.box itemconfigure $i -background grey
	} else {
	    .loghist.box itemconfigure $i -background white
	}
	set s [expr $s ^ 1]
    }
    incr qsocount($band)
    .bandmap.l$band configure -text "($qsocount($band))" -font sotamicro
}

proc logwindow {ref info} {

    global band box qsocount bandlist tcl_platform mode

    wm title . "SOTALog by HB9TVK"
    wm geometry . "800x480+0+0"
    update idletasks

    set band 40m

    bind . <Return> { saveLog }
    bind . <Escape> { clear }
    bind . <comma> { clear }
    bind . <Prior> { bandSwitch 0 }
    bind . <Next> { bandSwitch 1 }
    bind . <F10> { configDialog }
    bind . <F9> { s2sDialog }
    bind . <Up> { s2sDialog }
    bind . <F8> { modeToggle }
    bind . <Home> { focus [tk_focusPrev [focus]]}
    bind . <End> { focus [tk_focusNext [focus]]}

    frame .top

    frame .sotalog
    label .sotalog.ref -text $ref -font sotabig
    label .sotalog.info -text $info -font sotabig 

    label .sotalog.lcall -text Call
    label .sotalog.lrsts -text RSTs
    label .sotalog.lrstr -text RSTr
    label .sotalog.lrem -text Remarks
    label .sotalog.s2s -text "" -font sotamini

    entry .sotalog.call -font sotahuge -width 12 -highlightthickness 4 -highlightcolor red -validatecommand {processCall %v %d %S %V %P} -validate all
    entry .sotalog.rsts -width 3 -font sotahuge -highlightthickness 4 -highlightcolor red -validatecommand {processRSTs %v %d %S %V} -validate all
    entry .sotalog.rstr -width 3 -font sotahuge -highlightthickness 4 -highlightcolor red -validatecommand {processRSTr %v %d %S %V} -validate all
    entry .sotalog.rem  -width 6 -font sotahuge -highlightthickness 4 -highlightcolor red -validate key -validatecommand {filterRemark %d %S}

    grid .sotalog.ref -row 0 -column 0 -columnspan 4 -sticky n
    grid .sotalog.info -row 1 -column 0 -columnspan 4 -sticky n
    grid .sotalog.s2s -row 2 -column 0 -columnspan 4 -sticky n
    grid .sotalog.call -row 3 -column 0 -sticky w
    grid .sotalog.rsts -row 3 -column 1
    grid .sotalog.rstr -row 3 -column 2
    grid .sotalog.rem -row 3 -column 3
    grid .sotalog.lcall -row 4 -column 0 -sticky w
    grid .sotalog.lrsts -row 4 -column 1
    grid .sotalog.lrstr -row 4 -column 2
    grid .sotalog.lrem -row 4 -column 3

    frame .bandmap
    set i 0
    foreach {wl fq} $bandlist {
        radiobutton .bandmap.w$wl -text "$wl" -variable band -value "$wl" -font sotamicro \
            -takefocus 0 -selectcolor yellow -indicatoron 0 -pady -2
    	label .bandmap.l$wl -text "($qsocount($band))" -font sotamicro
        grid .bandmap.l$wl -row $i -column 0
        grid .bandmap.w$wl -row $i -column 1 -sticky w
    	incr i
    }

    frame .loghist
    listbox .loghist.box -width 60 -height 5 -listvariable box -selectmode single \
	-font sotamono -activestyle none -takefocus 0 -yscrollcommand {.loghist.scy set}
    scrollbar .loghist.scy -command ".loghist.box yview" -orient v -takefocus 0
    grid .loghist.box -row 0 -column 0
    grid .loghist.scy -row 0 -column 1 -sticky nsew

    frame .suggest
    if {[string match Linux* $tcl_platform(os)]} {
        text .suggest.txt -background white -tabs 15 -wrap word -font sotamono -foreground blue \
	-width 60 -height 7
    } else {
        text .suggest.txt -background white -tabs 15 -wrap word -font sotamono -foreground blue \
	-width 60 -height 4
    }
    .suggest.txt configure -state disabled
    grid .suggest.txt -row 0 -column 0

    bind .suggest.txt <ButtonPress> {pickSuggestion %x %y}
    bind .suggest.txt <ButtonRelease> { focus .sotalog.rsts }
    
    label .footer -text "F9: S2S entry   F10: Configuration" -font sotamicro
    
    grid .sotalog -in .top -row 0 -column 0 -sticky s
    grid .bandmap -in .top -row 0 -column 1 -sticky e
    grid .loghist -in .top -row 1 -column 0 -columnspan 2 -sticky wens
    grid .suggest -in .top -row 2 -column 0 -columnspan 2 -sticky wens
    grid .footer -in .top -row 3 -column 0 -columnspan 2 -sticky s

    pack .top
    focus .sotalog.call

}<commit_msg>- added F8: to footer line info<commit_after>
proc clear {} {
    global sinfo s2s mode
    .sotalog.call delete 0 end
    .sotalog.rsts delete 0 end
    .sotalog.rstr delete 0 end
    .sotalog.rem delete 0 end
    .loghist.box selection clear 0 end
    .sotalog.info configure -text "$sinfo Mode: $mode" -fg black
    .sotalog.s2s configure -text ""
    set s2s ""
    focus .sotalog.call
}

proc initCounter {} {
    global qsocount bandlist

    foreach {wl fq} $bandlist {
        set qsocount($wl) 0
    }
}

proc modeToggle {} {
    global mode modes sinfo
    set pos [lsearch -exact $modes $mode]
    incr pos
    if {$pos == [llength $modes]} { set pos 0}
    set mode [lindex $modes $pos]
    .sotalog.info configure -text "$sinfo Mode: $mode"
}

proc bandSwitch {up} {
    global band bandlist

    set pos [lsearch -exact $bandlist $band]
    if {$up && $pos == [expr [llength $bandlist] - 2]} {
        set pos -2
    }
    if {! $up && $pos == 0} {
        set pos [llength $bandlist]
    }
    if {$up} {
        incr pos 2
    } else {
        incr pos -2
    }	
    set band [lindex $bandlist $pos]
}

proc updateSuggestions {part} {

    global sotacalls

    set suggest [lsearch -all -glob -inline $sotacalls "*${part}*"]
    .suggest.txt configure -state normal
    .suggest.txt delete 1.0 end
    .suggest.txt insert end $suggest
    .suggest.txt configure -state disabled
}

proc pickSuggestion {x y} {

    set index [lindex [split [.suggest.txt index @$x,$y] .] 1]
    set s [.suggest.txt get 1.0 1.end]
    while {[string index $s $index] != " " && $index > 0} { incr index -1}
    regexp {[A-Za-z0-9/]+} [string range $s $index end] pick
    if {[info exists pick]} {
        .sotalog.call delete 0 end
        .sotalog.call insert end $pick
        focus .sotalog.rsts
    }
}

proc insertLog {utc call rsts rstr rem} {

    global box band qsocount s2s
    
    if {[string length $s2s]} {
        set rem $s2s
    }

    set log [format %-7s%-20s%-10s%-10s%-20s $utc $call $rsts $rstr $rem]
    set box [linsert $box 0 $log]
    if {[expr [llength $box] %2]} { set s 0 } else { set s 1 }

    for {set i 0} {$i < [llength $box]} {incr i} {
	if {$s} {
	    .loghist.box itemconfigure $i -background grey
	} else {
	    .loghist.box itemconfigure $i -background white
	}
	set s [expr $s ^ 1]
    }
    incr qsocount($band)
    .bandmap.l$band configure -text "($qsocount($band))" -font sotamicro
}

proc logwindow {ref info} {

    global band box qsocount bandlist tcl_platform mode

    wm title . "SOTALog by HB9TVK"
    wm geometry . "800x480+0+0"
    update idletasks

    set band 40m

    bind . <Return> { saveLog }
    bind . <Escape> { clear }
    bind . <comma> { clear }
    bind . <Prior> { bandSwitch 0 }
    bind . <Next> { bandSwitch 1 }
    bind . <F10> { configDialog }
    bind . <F9> { s2sDialog }
    bind . <Up> { s2sDialog }
    bind . <F8> { modeToggle }
    bind . <Home> { focus [tk_focusPrev [focus]]}
    bind . <End> { focus [tk_focusNext [focus]]}

    frame .top

    frame .sotalog
    label .sotalog.ref -text $ref -font sotabig
    label .sotalog.info -text $info -font sotabig 

    label .sotalog.lcall -text Call
    label .sotalog.lrsts -text RSTs
    label .sotalog.lrstr -text RSTr
    label .sotalog.lrem -text Remarks
    label .sotalog.s2s -text "" -font sotamini

    entry .sotalog.call -font sotahuge -width 12 -highlightthickness 4 -highlightcolor red -validatecommand {processCall %v %d %S %V %P} -validate all
    entry .sotalog.rsts -width 3 -font sotahuge -highlightthickness 4 -highlightcolor red -validatecommand {processRSTs %v %d %S %V} -validate all
    entry .sotalog.rstr -width 3 -font sotahuge -highlightthickness 4 -highlightcolor red -validatecommand {processRSTr %v %d %S %V} -validate all
    entry .sotalog.rem  -width 6 -font sotahuge -highlightthickness 4 -highlightcolor red -validate key -validatecommand {filterRemark %d %S}

    grid .sotalog.ref -row 0 -column 0 -columnspan 4 -sticky n
    grid .sotalog.info -row 1 -column 0 -columnspan 4 -sticky n
    grid .sotalog.s2s -row 2 -column 0 -columnspan 4 -sticky n
    grid .sotalog.call -row 3 -column 0 -sticky w
    grid .sotalog.rsts -row 3 -column 1
    grid .sotalog.rstr -row 3 -column 2
    grid .sotalog.rem -row 3 -column 3
    grid .sotalog.lcall -row 4 -column 0 -sticky w
    grid .sotalog.lrsts -row 4 -column 1
    grid .sotalog.lrstr -row 4 -column 2
    grid .sotalog.lrem -row 4 -column 3

    frame .bandmap
    set i 0
    foreach {wl fq} $bandlist {
        radiobutton .bandmap.w$wl -text "$wl" -variable band -value "$wl" -font sotamicro \
            -takefocus 0 -selectcolor yellow -indicatoron 0 -pady -2
    	label .bandmap.l$wl -text "($qsocount($band))" -font sotamicro
        grid .bandmap.l$wl -row $i -column 0
        grid .bandmap.w$wl -row $i -column 1 -sticky w
    	incr i
    }

    frame .loghist
    listbox .loghist.box -width 60 -height 5 -listvariable box -selectmode single \
	-font sotamono -activestyle none -takefocus 0 -yscrollcommand {.loghist.scy set}
    scrollbar .loghist.scy -command ".loghist.box yview" -orient v -takefocus 0
    grid .loghist.box -row 0 -column 0
    grid .loghist.scy -row 0 -column 1 -sticky nsew

    frame .suggest
    if {[string match Linux* $tcl_platform(os)]} {
        text .suggest.txt -background white -tabs 15 -wrap word -font sotamono -foreground blue \
	-width 60 -height 7
    } else {
        text .suggest.txt -background white -tabs 15 -wrap word -font sotamono -foreground blue \
	-width 60 -height 4
    }
    .suggest.txt configure -state disabled
    grid .suggest.txt -row 0 -column 0

    bind .suggest.txt <ButtonPress> {pickSuggestion %x %y}
    bind .suggest.txt <ButtonRelease> { focus .sotalog.rsts }
    
    label .footer -text "F8: Toggle Mode   F9: S2S entry   F10: Configuration" -font sotamicro
    
    grid .sotalog -in .top -row 0 -column 0 -sticky s
    grid .bandmap -in .top -row 0 -column 1 -sticky e
    grid .loghist -in .top -row 1 -column 0 -columnspan 2 -sticky wens
    grid .suggest -in .top -row 2 -column 0 -columnspan 2 -sticky wens
    grid .footer -in .top -row 3 -column 0 -columnspan 2 -sticky s

    pack .top
    focus .sotalog.call

}
{'fraction_non_alphanumeric': 0.11538461538461539, 'fraction_numerical': 0.023222060957910014, 'mean_word_length': 2.3118825100133513, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5350273', 'n_tokens_mistral': 4779, 'n_tokens_neox': 4425, 'n_words': 1545}