Eskil

Diff
Login

Differences From Artifact [cd82559b74]:

To Artifact [760ce948eb]:


20
21
22
23
24
25
26
27
28


29
30
31
32
33
34
35






36
37
38
39
40




41
42
43
44

45
46
47

48
49

50
51
52
53
54
55
56






57
58
59
60

61
62
63
64
65
66
67
68
69


70
71
72


73
74
75
76
77

78
79

80
81

82
83

84
85

86
87

88
89
90
91



92
93
94
95



96
97
98
99
100

101
102
103
104
105
106
107
108

109
110
111
112
113
114
115
116
117
118
119
120
121

122
123
124
125
126
127
128
129

130
131
132
133



134
135
136
137
138
139
140
20
21
22
23
24
25
26


27
28
29






30
31
32
33
34
35
36




37
38
39
40
41
42
43

44
45
46

47
48

49
50






51
52
53
54
55
56
57
58
59

60
61
62
63
64
65
66
67


68
69
70


71
72
73
74
75
76

77
78

79
80

81
82

83
84

85
86

87
88



89
90
91
92



93
94
95
96
97
98
99

100
101
102
103
104
105
106
107

108
109
110
111
112
113
114
115
116
117
118
119
120

121
122
123
124
125
126
127
128

129
130



131
132
133
134
135
136
137
138
139
140







-
-
+
+

-
-
-
-
-
-
+
+
+
+
+
+

-
-
-
-
+
+
+
+



-
+


-
+

-
+

-
-
-
-
-
-
+
+
+
+
+
+



-
+







-
-
+
+

-
-
+
+




-
+

-
+

-
+

-
+

-
+

-
+

-
-
-
+
+
+

-
-
-
+
+
+




-
+







-
+












-
+







-
+

-
-
-
+
+
+







#
#----------------------------------------------------------------------
# $Revision$
#----------------------------------------------------------------------

# A simple window for displaying e.g. help.
# Returns the frame where things can be put.
proc helpWin {w title} {
    destroy $w
proc helpWin {W title} {
    destroy $W

    toplevel $w -padx 2 -pady 2
    wm title $w $title
    bind $w <Key-Return> [list destroy $w]
    bind $w <Key-Escape> [list destroy $w]
    ttk::frame $w.f
    ttk::button $w.b -text "Close" -command [list destroy $w] -width 10 \
    toplevel $W -padx 2 -pady 2
    wm title $W $title
    bind $W <Key-Return> [list destroy $W]
    bind $W <Key-Escape> [list destroy $W]
    ttk::frame $W.f
    ttk::button $W.b -text "Close" -command [list destroy $W] -width 10 \
            -default active
    pack $w.b -side bottom -pady 2
    pack $w.f -side top -expand y -fill both -padx 2 -pady 2
    focus $w
    return $w.f
    pack $W.b -side bottom -pady 2
    pack $W.f -side top -expand y -fill both -padx 2 -pady 2
    focus $W
    return $W.f
}

proc makeAboutWin {} {
    set w [helpWin .ab "About Eskil"]
    set W [helpWin .ab "About Eskil"]

    set bg [ttk::style configure . -background]
    text $w.t -width 45 -height 11 -wrap none -relief flat \
    text $W.t -width 45 -height 11 -wrap none -relief flat \
            -background $bg
    pack $w.t -side top -expand y -fill both
    pack $W.t -side top -expand y -fill both

    $w.t insert end "A graphical frontend to diff\n\n"
    $w.t insert end "$::eskil(diffver)\n\n"
    $w.t insert end "Made by Peter Spjuth\n"
    $w.t insert end "E-Mail: peter.spjuth@gmail.com\n"
    $w.t insert end "\nURL: http://eskil.tcl.tk\n"
    $w.t insert end "\nTcl version: [info patchlevel]\n"
    $W.t insert end "A graphical frontend to diff\n\n"
    $W.t insert end "$::eskil(diffver)\n\n"
    $W.t insert end "Made by Peter Spjuth\n"
    $W.t insert end "E-Mail: peter.spjuth@gmail.com\n"
    $W.t insert end "\nURL: http://eskil.tcl.tk\n"
    $W.t insert end "\nTcl version: [info patchlevel]\n"

    set du $::DiffUtil::version
    append du " ($::DiffUtil::implementation)"
    $w.t insert end "DiffUtil version: $du\n"
    $W.t insert end "DiffUtil version: $du\n"

    # Provide debug info to help when DiffUtil does not load.
    if {[info exists ::DiffUtil::DebugLibFile]} {
        set lf $::DiffUtil::DebugLibFile
        set exist [file exists $lf]
        set lf [file join {*}[lrange [file split $lf] end-1 end]]
        if {$exist} {
            $w.t insert end "  DiffUtil debug: Could not load\n"
            $w.t insert end "    $lf\n"
            $W.t insert end "  DiffUtil debug: Could not load\n"
            $W.t insert end "    $lf\n"
        } else {
            $w.t insert end "  DiffUtil debug: Could not find\n"
            $w.t insert end "    $lf\n"
            $W.t insert end "  DiffUtil debug: Could not find\n"
            $W.t insert end "    $lf\n"
        }
    }

    if {[catch {package require pdf4tcl} pdf4tclVer]} { set pdf4tclVer None }
    $w.t insert end "Pdf4Tcl version: $pdf4tclVer\n"
    $W.t insert end "Pdf4Tcl version: $pdf4tclVer\n"
    if {[catch {package require snit} snitVer]} { set snitVer None }
    $w.t insert end "Snit version: $snitVer\n"
    $W.t insert end "Snit version: $snitVer\n"
    if {[catch {package require vfs} vfsVer]} { set vfsVer None }
    $w.t insert end "Vfs version: $vfsVer\n"
    $W.t insert end "Vfs version: $vfsVer\n"
    if {[catch {package require wcb} wcbVer]} { set wcbVer None }
    $w.t insert end "Wcb version: $wcbVer\n"
    $W.t insert end "Wcb version: $wcbVer\n"
    if {[catch {package require tablelist_tile} tblVer]} { set tblVer None }
    $w.t insert end "Tablelist version: $tblVer\n"
    $W.t insert end "Tablelist version: $tblVer\n"
    if {[catch {package require tkdnd} tkdndVer]} { set tkdndVer None }
    $w.t insert end "TkDnd version: $tkdndVer\n"
    $W.t insert end "TkDnd version: $tkdndVer\n"

    $w.t insert end "\nCredits:\n"
    $w.t insert end "Ideas for scrollbar map and merge function\n"
    $w.t insert end "taken from TkDiff"
    $W.t insert end "\nCredits:\n"
    $W.t insert end "Ideas for scrollbar map and merge function\n"
    $W.t insert end "taken from TkDiff"

    set last [lindex [split [$w.t index end] "."] 0]
    $w.t configure -height $last
    $w.t configure -state disabled
    set last [lindex [split [$W.t index end] "."] 0]
    $W.t configure -height $last
    $W.t configure -state disabled
}

# Insert a text file into a text widget.
# Any XML-style tags in the file are used as tags in the text window.
proc insertTaggedText {w file} {
proc insertTaggedText {W file} {
    set ch [open $file r]
    set data [read $ch]
    close $ch

    set tags {}
    while {$data != ""} {
        if {[regexp {^([^<]*)<(/?)([^>]+)>(.*)$} $data -> pre sl tag post]} {
            $w insert end [subst -nocommands -novariables $pre] $tags
            $W insert end [subst -nocommands -novariables $pre] $tags
            set i [lsearch $tags $tag]
            if {$sl != ""} {
                # Remove tag
                if {$i >= 0} {
                    set tags [lreplace $tags $i $i]
                }
            } else {
                # Add tag
                lappend tags $tag
            }
            set data $post
        } else {
            $w insert end [subst -nocommands -novariables $data] $tags
            $W insert end [subst -nocommands -novariables $data] $tags
            set data ""
        }
    }
}

proc makeHelpWin {} {
    set doc [file join $::eskil(thisDir) .. doc/eskil.txt]
    if {![file exists $doc]} return
    if { ! [file exists $doc]} return

    set w [helpWin .he "Eskil Help"]
    set t [Scroll y text $w.t -width 85 -height 35]
    pack $w.t -side top -expand 1 -fill both
    set W [helpWin .he "Eskil Help"]
    set t [Scroll y text $W.t -width 85 -height 35]
    pack $W.t -side top -expand 1 -fill both

    configureDocWin $t

    # Set up tags for change marks
    $t tag configure new1 -foreground $::Pref(colornew1) \
            -background $::Pref(bgnew1)
    $t tag configure new2 -foreground $::Pref(colornew2) \
164
165
166
167
168
169
170
171

172
173
174
175
176
177





178
179

180
181

182
183
184
185
186
187
188



189
190
191
192

193
194
195
196
197
198
199
200
201
202
203
204
205

206
207
208
209
210
211
212
213
214
215
216
217
218
219

220
221
222
223
224




225
226

227
228
229
230
231
232




233
234
235


236
164
165
166
167
168
169
170

171
172





173
174
175
176
177
178

179
180

181
182
183
184
185



186
187
188
189
190
191

192
193
194
195
196
197
198
199
200
201
202
203
204

205
206
207
208
209
210
211
212
213
214
215
216
217
218

219
220




221
222
223
224
225

226
227
228




229
230
231
232
233


234
235
236







-
+

-
-
-
-
-
+
+
+
+
+

-
+

-
+




-
-
-
+
+
+



-
+












-
+













-
+

-
-
-
-
+
+
+
+

-
+


-
-
-
-
+
+
+
+

-
-
+
+

    for {} {$t > -20} {incr t -1} {
        font configure docFontP -size $t
        if {[font metrics docFontP -linespace] >= $h} break
    }
}

# Configure a text window as Doc viewer
proc configureDocWin {w} {
proc configureDocWin {W} {
    createDocFonts
    $w configure -font docFont -wrap word
    $w tag configure ul -underline 1
    $w tag configure b -font docFontB
    $w tag configure bullet -tabs "1c" -lmargin2 "1c"
    $w tag configure pre -font docFontP
    $W configure -font docFont -wrap word
    $W tag configure ul -underline 1
    $W tag configure b -font docFontB
    $W tag configure bullet -tabs "1c" -lmargin2 "1c"
    $W tag configure pre -font docFontP

    set top [winfo toplevel $w]
    set top [winfo toplevel $W]
    foreach event {<Key-Prior> <Key-Next>} {
        bind $top $event [string map [list "%W" $w] [bind Text $event]]
        bind $top $event [string map [list "%W" $W] [bind Text $event]]
    }
}

proc makeDocWin {fileName} {
    set w [helpWin .doc "Eskil Help"]
    set t [Scroll y text $w.t -width 80 -height 25]
    pack $w.t -side top -expand 1 -fill both
    set W [helpWin .doc "Eskil Help"]
    set t [Scroll y text $W.t -width 80 -height 25]
    pack $W.t -side top -expand 1 -fill both

    configureDocWin $t

    if {![file exists $::eskil(thisDir)/../doc/$fileName]} {
    if { ! [file exists $::eskil(thisDir)/../doc/$fileName]} {
        $t insert end "ERROR: Could not find doc file "
        $t insert end \"$fileName\"
        return
    }
    insertTaggedText $t $::eskil(thisDir)/../doc/$fileName

    #focus $t
    $t configure -state disabled
}

proc makeTutorialWin {} {
    set doc [file join $::eskil(thisDir) .. doc/tutorial.txt]
    if {![file exists $doc]} return
    if { ! [file exists $doc]} return

    if {[catch {cd [file join $::eskil(thisDir) .. examples]}]} {
        tk_messageBox -icon error -title "Eskil Error" -message \
                "Could not locate examples directory." \
                -type ok
        return
    }

    # Start up a dirdiff in the examples directory
    set ::dirdiff(leftDir) [file join [pwd] dir1]
    set ::dirdiff(rightDir) [file join [pwd] dir2]
    makeDirDiffWin

    set w [helpWin .ht "Eskil Tutorial"]
    set W [helpWin .ht "Eskil Tutorial"]

    text $w.t -width 82 -height 35 -yscrollcommand "$w.sb set"
    ttk::scrollbar $w.sb -orient vert -command "$w.t yview"
    pack $w.sb -side right -fill y
    pack $w.t -side left -expand 1 -fill both
    text $W.t -width 82 -height 35 -yscrollcommand "$W.sb set"
    ttk::scrollbar $W.sb -orient vert -command "$W.t yview"
    pack $W.sb -side right -fill y
    pack $W.t -side left -expand 1 -fill both

    configureDocWin $w.t
    configureDocWin $W.t

    # Move border properties to frame
    set bw [$w.t cget -borderwidth]
    set relief [$w.t cget -relief]
    $w configure -relief $relief -borderwidth $bw
    $w.t configure -borderwidth 0
    set bw [$W.t cget -borderwidth]
    set relief [$W.t cget -relief]
    $W configure -relief $relief -borderwidth $bw
    $W.t configure -borderwidth 0

    insertTaggedText $w.t $doc
    $w.t configure -state disabled
    insertTaggedText $W.t $doc
    $W.t configure -state disabled
}