<commit_before>package require Tk

###############################################################################
#
# about box
#
#

proc about {} {
    tk_dialog2 .about "About TclRobots" "TclRobots\n\nCopyright 2010\n<NAME>\<EMAIL>\n\nDevelopment Version\nFebruary, 2010\n" "-image iconfn" 0 dismiss

}

###############################################################################
#
# choose_file
#
proc choose_file {win filename} {
    set listsize $::numlist
    $::robotlist_lb insert end $filename
    incr ::numlist
    set dir $filename
    for {set i 0} {$i <= $listsize} {incr i} {
        set d [$::robotlist_lb get $i]
        if {[string length $d] > [string length $dir]} {
            set dir  $d
        }
    }
    set index [+ [string length [file dirname [file dirname $dir]]] 1]
    $::robotlist_lb xview $index
}


###############################################################################
#
# choose_all
#
proc choose_all {} {
    set win .f2.fl
    set lsize [$win.l.lst size]
    for {set i 0} {$i < $lsize} {incr i} {
        set f [string trim [$win.l.lst get $i]]
        if {![string match */ $f]} {
            choose_file $win $f
        }
    }

}

###############################################################################
#
# remove_file
#
proc remove_file {} {
    set index -1
    catch {set index [.f2.fr.f.lb curselection]}
    if {$index >= 0} {
        .f2.fr.f.lb delete $index
        incr  ::numlist -1
    }
}


###############################################################################
#
# remove_all
#
proc remove_all {} {
    set index $::numlist
    if {$index > 0} {
        $::robotlist_lb delete 0 end
        set ::numlist 0
    }
}

#######################################################################
# file selection box,  from my "wosql" in Oratcl
# modified not to use a toplevel
#######################################################################
# procs to support a file selection dialog box

########################
#
# fillLst
#
#    fill the fillBox listbox with selection entries
#

proc fillLst {win filt dir} {

    $win.l.lst delete 0 end

    cd $dir

    set dir [pwd]

    if {[string length $filt] == 0} {
        set filt *
    }
    set all_list [lsort -dictionary [glob -nocomplain $dir/$filt]]

    set dlist [list "$dir/../"]
    set flist ""

    foreach f $all_list {
        if {[file isfile $f]} {
            lappend flist $f
        }
        if {[file isdirectory $f]} {
            lappend dlist ${f}/
        }
    }

    foreach d $dlist {
        $win.l.lst insert end $d
    }
    foreach f $flist {
        $win.l.lst insert end $f
    }

    $win.l.lst yview 0

    set index [+ [string length [file dirname [file dirname $dir]]] 1]

    $win.l.lst xview $index
}


########################
#
# selInsert<commit_msg>Do not filter directories in file dialog.<commit_after>package require Tk

###############################################################################
#
# about box
#
#

proc about {} {
    tk_dialog2 .about "About TclRobots" "TclRobots\n\nCopyright 2010\n<NAME>\<EMAIL>\n\nDevelopment Version\nFebruary, 2010\n" "-image iconfn" 0 dismiss

}

###############################################################################
#
# choose_file
#
proc choose_file {win filename} {
    set listsize $::numlist
    $::robotlist_lb insert end $filename
    incr ::numlist
    set dir $filename
    for {set i 0} {$i <= $listsize} {incr i} {
        set d [$::robotlist_lb get $i]
        if {[string length $d] > [string length $dir]} {
            set dir  $d
        }
    }
    set index [+ [string length [file dirname [file dirname $dir]]] 1]
    $::robotlist_lb xview $index
}


###############################################################################
#
# choose_all
#
proc choose_all {} {
    set win .f2.fl
    set lsize [$win.l.lst size]
    for {set i 0} {$i < $lsize} {incr i} {
        set f [string trim [$win.l.lst get $i]]
        if {![string match */ $f]} {
            choose_file $win $f
        }
    }

}

###############################################################################
#
# remove_file
#
proc remove_file {} {
    set index -1
    catch {set index [.f2.fr.f.lb curselection]}
    if {$index >= 0} {
        .f2.fr.f.lb delete $index
        incr  ::numlist -1
    }
}


###############################################################################
#
# remove_all
#
proc remove_all {} {
    set index $::numlist
    if {$index > 0} {
        $::robotlist_lb delete 0 end
        set ::numlist 0
    }
}

#######################################################################
# file selection box,  from my "wosql" in Oratcl
# modified not to use a toplevel
#######################################################################
# procs to support a file selection dialog box

########################
#
# fillLst
#
#    fill the fillBox listbox with selection entries
#

proc fillLst {win filt dir} {

    $win.l.lst delete 0 end

    cd $dir

    set dir [pwd]

    if {[string length $filt] == 0} {
        set filt *
    }
    set all_list [lsort -dictionary [glob -nocomplain -type d $dir/*]]
    lappend all_list \
            {*}[lsort -dictionary [glob -nocomplain -type f $dir/$filt]]

    set dlist [list "$dir/../"]
    set flist ""

    foreach f $all_list {
        if {[file isfile $f]} {
            lappend flist $f
        }
        if {[file isdirectory $f]} {
            lappend dlist ${f}/
        }
    }

    foreach d $dlist {
        $win.l.lst insert end $d
    }
    foreach f $flist {
        $win.l.lst insert end $f
    }

    $win.l.lst yview 0

    set index [+ [string length [file dirname [file dirname $dir]]] 1]

    $win.l.lst xview $index
}


########################
#
# selInsert
{'fraction_non_alphanumeric': 0.306975138121547, 'fraction_numerical': 0.008977900552486187, 'mean_word_length': 2.781331592689295, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3758228', 'n_tokens_mistral': 1884, 'n_tokens_neox': 1767, 'n_words': 520}