Eskil

Check-in [b1509ddd59]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added edit file on context menu.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b1509ddd5915c6a11c73357f9d9a325267c2d7c7
User & Date: spjutp 2002-04-12 10:51:17.000
Context
2002-04-12
11:02
Removed code for supporting Tk < 8.3. check-in: 1c55ec033b user: spjutp tags: trunk
10:51
Added edit file on context menu. check-in: b1509ddd59 user: spjutp tags: trunk
10:48
Fixed CVS on windows. check-in: a94ed66d1e user: spjutp tags: trunk
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to dirdiff.tcl.
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
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


-
+

+
+
+














+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







#!/bin/sh
#
# Copyright (C) 1999-2000 Peter Spjuth
# Copyright (C) 1999-2002 Peter Spjuth
#
#-----------------------------------------------
# $Revision$
#-----------------------------------------------
# the next line restarts using wish \
exec wish "$0" "$@"

set thisScript [file join [pwd] [info script]]
set thisDir [file dirname $thisScript]
if {[file type $thisScript] == "link"} {
    set tmplink [file readlink $thisScript]
    set thisDir [file dirname [file join $thisDir $tmplink]]
    unset tmplink
}

if {$tcl_platform(platform) == "windows"} {
    package require dde
}

if {$::tcl_platform(platform) == "unix"} {
    set editor emacs
    set diffExe diff
} else {
    set editor wordpad
    foreach dir [lsort -decreasing -dictionary [glob c:/apps/emacs*]] {
        set em [file join $dir bin runemacs.exe]
        if {[file exists $em]} {
            set editor $em
            break
        }
    }
    set diffExe [file join $::thisDir diff.exe]
}

if {[info patchlevel] == "8.3.0"} {
    catch {source /home/spjutp/choosedir.tcl}
}

if {[info commands tk_chooseDirectory] == ""} {
    catch {
51
52
53
54
55
56
57



58
59
60
61
62
63
64
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85







+
+
+







proc compareFiles {file1 file2} {
    global Pref
    file stat $file1 stat1
    file stat $file2 stat2

    if {[file isdirectory $file1] != [file isdirectory $file2]} {
	return 0
    }
    if {$stat1(size) == $stat2(size) && $Pref(comparelevel) == 0} {
        return 1
    }
    if {$stat1(size) == $stat2(size) && $stat1(mtime) == $stat2(mtime)} {
	return 1
    }
    if {$Pref(comparelevel) == 0} { #Do not check contents
        return 0
    }
88
89
90
91
92
93
94
95

96
97
98

99
100
101

102
103
104

105
106
107
108
109
110
111
109
110
111
112
113
114
115

116
117
118

119
120
121

122
123
124

125
126
127
128
129
130
131
132







-
+


-
+


-
+


-
+







            if {([eof $ch1] + [eof $ch2]) < 2} {
                set eq 0
            }
            close $ch1
            close $ch2
        }
        2 { #Simple external diff
            set eq [expr {![catch {exec diff $file1 $file2}]}]
            set eq [expr {![catch {exec $::diffExe $file1 $file2}]}]
        }
        3 { #Ignore space
            set eq [expr {![catch {exec diff -w $file1 $file2}]}]
            set eq [expr {![catch {exec $::diffExe -w $file1 $file2}]}]
        }
        4 { #Ignore case
            set eq [expr {![catch {exec diff -i $file1 $file2}]}]
            set eq [expr {![catch {exec $::diffExe -i $file1 $file2}]}]
        }
        5 { #Ignore RCS
            set eq [expr {![catch {exec diff {--ignore-matching-lines=RCS: @(#) $Id} $file1 $file2} differr]}]
            set eq [expr {![catch {exec $::diffExe {--ignore-matching-lines=RCS: @(#) $Id} $file1 $file2} differr]}]
        }
    }
    return $eq
}

# infoFiles: 1= noLeft 2 = noRight 4=left is dir  8= right is dir 16=diff
proc listFiles {df1 df2 diff level} {
185
186
187
188
189
190
191
192

193
194

195
196
197
198
199
200
201
206
207
208
209
210
211
212

213
214

215
216
217
218
219
220
221
222







-
+

-
+







    lappend infoFiles $info
}

proc compareDirs {dir1 dir2 {level 0}} {
    global Pref
    set olddir [pwd]
    cd $dir1
    set files1 [flsort [glob -nocomplain *]]
    set files1 [flsort [glob -nocomplain * {.[a-zA-Z]*}]]
    cd $dir2
    set files2 [flsort [glob -nocomplain *]]
    set files2 [flsort [glob -nocomplain * {.[a-zA-Z]*}]]
    cd $olddir

    set len1 [llength $files1]
    set len2 [llength $files2]

    set p1 0
    set p2 0
324
325
326
327
328
329
330


331
332
333
334


335
336
337
338
339
340
341
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366







+
+




+
+







    } elseif {($i & 3) == 0} { # Both exists
        .m add command -label "Compare Files" -command [list \
                remoteDiff $lf $rf]
    }
    if {$w == ".t1" && ($i & 13) == 0} {
        .m add command -label "Copy File" -command [list \
                copyFile $row right]
        .m add command -label "Edit File" -command [list \
                editFile $row left]
    }
    if {$w == ".t2" && ($i & 14) == 0} {
        .m add command -label "Copy File" -command [list \
                copyFile $row left]
        .m add command -label "Edit File" -command [list \
                editFile $row right]
    }

    tk_popup .m $X $Y
}

proc copyFile {row to} {
    global leftDir rightDir leftFiles rightFiles infoFiles Pref
360
361
362
363
364
365
366














367
368
369
370
371
372
373
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







+
+
+
+
+
+
+
+
+
+
+
+
+
+







    } else {
        if {[tk_messageBox -icon question -title "Copy file?" -message \
                "Copy\n$src\nto\n$dst ?" -type yesno] == "yes"} {
            file copy $src $dst
        }
    }
}

proc editFile {row from} {
    global leftDir rightDir leftFiles rightFiles infoFiles Pref

    if {$from == "left"} {
        set src [file join $leftDir [lindex $leftFiles $row]]
    } elseif {$from == "right"} {
        set src [file join $rightDir [lindex $rightFiles $row]]
    } else {
        error "Bad from argument to editFile: $from"
    }

    exec $::editor $src &
}

proc remoteDiff {file1 file2} {
    global tcl_platform
    set cmd [list remoteDiff $file1 $file2]

    if {$tcl_platform(platform) == "unix"} {
        #send -async Diff $cmd