Eskil

Diff
Login

Differences From Artifact [b985bb52cf]:

To Artifact [a8dfbcae80]:


307
308
309
310
311
312
313

314
315

316
317
318
319
320
321
322
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324







+


+








    variable AfterId ""
    variable DebugCh ""
    variable DebugTime {}
    variable PauseBgProcessing 0
    variable ScheduledRestart 0
    variable AfterTime 1
    variable WorkTime 200
    variable IdleQueue {}
    variable IdleQueueArr
    variable NodeStatus
    variable leftMark ""
    variable rightMark ""
    variable leftDir ""
    variable rightDir ""
    variable protect {left 0 right 0}

    constructor {args} {
462
463
464
465
466
467
468

469
470
471
472
473
474
475
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478







+







        if {$d1 eq $d2} {
            $tree cellconfigure $topIndex,structure -text $d1
        } else {
            $tree cellconfigure $topIndex,structure -text "$d1 vs $d2"
        }
        $tree cellconfigure $topIndex,structure -image $::img(open)
        $tree rowattrib $topIndex type directory
        set NodeStatus($topIndex) ""
        $self SetNodeStatus $topIndex empty
        $tree rowattrib $topIndex leftfull $leftDir
        $tree rowattrib $topIndex rightfull $rightDir

        $self UpdateDirNode $topIndex
    }

508
509
510
511
512
513
514
515

516
517
518
519
520
521
522
511
512
513
514
515
516
517

518
519
520
521
522
523
524
525







-
+







    method PruneEqual {} {
        $self busyCursor
        set todo [$tree childkeys root]
        while {[llength $todo] > 0} {
            set todoNow $todo
            set todo {}
            foreach node $todoNow {
                set status [$tree rowattrib $node status]
                set status $NodeStatus($node)
                if {$status eq "equal"} {
                    $tree delete $node
                } else {
                    lappend todo {*}[$tree childkeys $node]
                }
            }
        }
858
859
860
861
862
863
864

865

866
867
868
869
870
871
872
861
862
863
864
865
866
867
868

869
870
871
872
873
874
875
876







+
-
+







            }
            if {$sts} {
                lappend errors $node $err
                break
            }
            # Work for at least 200 ms to keep things efficient
            set post [clock clicks -milliseconds]
            #puts "$pre $post [expr {$post - $pre}]"
            if {($post - $pre) > 200} break
            if {($post - $pre) > $WorkTime} break
        }
        #if {($post - $pre) > 1000} {
            #puts "[expr $post - $pre] ms for [$tree set $node leftfull]"
        #}

        # Update the status variable to track progress
        if {$options(-statusvar) ne ""} {
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
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







-
+

-
+














-
+




-
+

















-
+







            set statusvar ""
            set AfterId ""
        }
    }

    method SetNodeStatus {node status} {
        variable color
        set old [$tree rowattrib $node status]
        set old $NodeStatus($node)
        if {$old eq $status} return
        $tree rowattrib $node status $status
        set NodeStatus($node) $status
        $tree rowconfigure $node -foreground $color($status) \
                -selectforeground $color($status)
        #puts "Set [$tree item $node -text] to $status"

        # Loop through children to update parent
        set parent [$tree parentkey $node]
        if {$parent eq "" || $parent eq "root"} { return }

        # If this is only present on one side, there is no need to update
        set lf [$tree rowattrib $parent leftfull]
        set rf [$tree rowattrib $parent rightfull]
        if {$lf eq "" || $rf eq ""} { return }

        # If parent is being filled, do not update yet
        if {[$tree rowattrib $parent status] eq "unknown2"} {
        if {$NodeStatus($parent) eq "unknown2"} {
            return
        }
        set pstatus equal
        foreach child [$tree childkeys $parent] {
            set status [$tree rowattrib $child status]
            set status $NodeStatus($child)
            switch $status {
                unknown - unknown2 {
                    set pstatus unknown
                }
                new - old - change {
                    set pstatus change
                    break
                }
            }
        }
        $self SetNodeStatus $parent $pstatus
    }

    method UpdateDirNode {node} {
        if {[$tree rowattrib $node type] ne "directory"} {
            return
        }
        if {[$tree rowattrib $node status] ne "empty"} {
        if {$NodeStatus($node) ne "empty"} {
            #puts "Dir [$tree set $node leftfull] already done"
            return
        }
        $tree delete [$tree childkeys $node]

        set leftfull [$tree rowattrib $node leftfull]
        set rightfull [$tree rowattrib $node rightfull]
1028
1029
1030
1031
1032
1033
1034
1035

1036
1037
1038
1039
1040
1041
1042
1032
1033
1034
1035
1036
1037
1038

1039
1040
1041
1042
1043
1044
1045
1046







-
+







            # TODO: Configurable large file value?
            if {$size1 > 1000000 && $size2 > 1000000} {
                set largeFile 1
            }
        }
        set id [$tree insertchild $node end $values]
        $tree rowattrib $id type $type
        $tree rowattrib $id status unknown
        set NodeStatus($id) unknown
        $tree rowattrib $id leftfull $df1
        $tree rowattrib $id rightfull $df2
        $tree rowattrib $id largefile $largeFile
        if {$type ne "directory"} {
            if {$type eq "link"} {
                $tree cellconfigure $id,structure -image $::img(link)
            } else {
1054
1055
1056
1057
1058
1059
1060
1061

1062
1063
1064
1065
1066
1067

1068
1069
1070
1071
1072
1073
1074
1058
1059
1060
1061
1062
1063
1064

1065
1066
1067
1068
1069
1070

1071
1072
1073
1074
1075
1076
1077
1078







-
+





-
+







            $self SetNodeStatus $id new
        } elseif {$size2 == ""} {
            $self SetNodeStatus $id old
        } else {
            $self SetNodeStatus $id unknown
            $self AddNodeToIdle $id
        }
        return [$tree rowattrib $id status]
        return $NodeStatus($id)
    }

    method addCmdCol {tbl row col w} {
        variable widgets
        set key [$tree getfullkeys $row]
        set status [$tree rowattrib $row status]
        set status $NodeStatus($key)
        set type   [$tree rowattrib $row type]
        set lf [$tree rowattrib $row leftfull]
        set rf [$tree rowattrib $row rightfull]
        set bg [$tbl cget -background]
        ttk::style configure Apa.TFrame -background $bg
        ttk::style configure Apa.My.Toolbutton -background $bg
        ttk::frame $w -style Apa.TFrame