(revert local fix)
[git/git.git] / gitk
CommitLineData
1db95b00
PM
1#!/bin/sh
2# Tcl ignores the next line -*- tcl -*- \
3exec wish "$0" -- "${1+$@}"
4
5# Copyright (C) 2005 Paul Mackerras. All rights reserved.
6# This program is free software; it may be used, copied, modified
7# and distributed under the terms of the GNU General Public Licence,
8# either version 2, or (at your option) any later version.
9
73b6a6cb
JH
10proc gitdir {} {
11 global env
12 if {[info exists env(GIT_DIR)]} {
13 return $env(GIT_DIR)
14 } else {
15 return ".git"
16 }
17}
18
1db95b00 19proc getcommits {rargs} {
e2ede2b9 20 global commits commfd phase canv mainfont env
9ccbdfbf 21 global startmsecs nextupdate
b490a991 22 global ctext maincursor textcursor leftover
9ccbdfbf 23
e2ede2b9 24 # check that we can find a .git directory somewhere...
73b6a6cb 25 set gitdir [gitdir]
e2ede2b9
PM
26 if {![file isdirectory $gitdir]} {
27 error_popup "Cannot find the git directory \"$gitdir\"."
28 exit 1
29 }
1db95b00 30 set commits {}
1d10f36d 31 set phase getcommits
9ccbdfbf
PM
32 set startmsecs [clock clicks -milliseconds]
33 set nextupdate [expr $startmsecs + 100]
2efef4b9 34 if [catch {
b490a991 35 set parse_args [concat --default HEAD $rargs]
2efef4b9
PM
36 set parsed_args [split [eval exec git-rev-parse $parse_args] "\n"]
37 }] {
b490a991 38 # if git-rev-parse failed for some reason...
2efef4b9
PM
39 if {$rargs == {}} {
40 set rargs HEAD
41 }
b490a991 42 set parsed_args $rargs
2efef4b9
PM
43 }
44 if [catch {
4ef17537 45 set commfd [open "|git-rev-list --header --topo-order $parsed_args" r]
2efef4b9 46 } err] {
cfb4563c 47 puts stderr "Error executing git-rev-list: $err"
1d10f36d
PM
48 exit 1
49 }
b490a991
PM
50 set leftover {}
51 fconfigure $commfd -blocking 0 -translation binary
52 fileevent $commfd readable "getcommitlines $commfd"
1d10f36d
PM
53 $canv delete all
54 $canv create text 3 3 -anchor nw -text "Reading commits..." \
55 -font $mainfont -tags textitems
ea13cba1
PM
56 . config -cursor watch
57 $ctext config -cursor watch
1d10f36d
PM
58}
59
b490a991 60proc getcommitlines {commfd} {
a823a911 61 global commits parents cdate children nchildren
9ccbdfbf 62 global commitlisted phase commitinfo nextupdate
b490a991 63 global stopped redisplaying leftover
9ccbdfbf 64
b490a991
PM
65 set stuff [read $commfd]
66 if {$stuff == {}} {
1d10f36d 67 if {![eof $commfd]} return
f0654861 68 # set it blocking so we wait for the process to terminate
df3d83b1 69 fconfigure $commfd -blocking 1
1d10f36d 70 if {![catch {close $commfd} err]} {
9ccbdfbf 71 after idle finishcommits
1d10f36d
PM
72 return
73 }
9a40c50c 74 if {[string range $err 0 4] == "usage"} {
9ccbdfbf
PM
75 set err \
76{Gitk: error reading commits: bad arguments to git-rev-list.
77(Note: arguments to gitk are passed to git-rev-list
78to allow selection of commits to be displayed.)}
9a40c50c 79 } else {
df3d83b1 80 set err "Error reading commits: $err"
9a40c50c 81 }
df3d83b1 82 error_popup $err
1d10f36d 83 exit 1
9a40c50c 84 }
b490a991
PM
85 set start 0
86 while 1 {
87 set i [string first "\0" $stuff $start]
88 if {$i < 0} {
7e952e79 89 append leftover [string range $stuff $start end]
b490a991 90 return
9ccbdfbf 91 }
b490a991
PM
92 set cmit [string range $stuff $start [expr {$i - 1}]]
93 if {$start == 0} {
94 set cmit "$leftover$cmit"
7e952e79 95 set leftover {}
b490a991
PM
96 }
97 set start [expr {$i + 1}]
98 if {![regexp {^([0-9a-f]{40})\n} $cmit match id]} {
7e952e79
PM
99 set shortcmit $cmit
100 if {[string length $shortcmit] > 80} {
101 set shortcmit "[string range $shortcmit 0 80]..."
102 }
103 error_popup "Can't parse git-rev-list output: {$shortcmit}"
b490a991
PM
104 exit 1
105 }
106 set cmit [string range $cmit 41 end]
107 lappend commits $id
108 set commitlisted($id) 1
109 parsecommit $id $cmit 1
110 drawcommit $id
111 if {[clock clicks -milliseconds] >= $nextupdate} {
112 doupdate
113 }
114 while {$redisplaying} {
115 set redisplaying 0
116 if {$stopped == 1} {
117 set stopped 0
118 set phase "getcommits"
119 foreach id $commits {
120 drawcommit $id
121 if {$stopped} break
122 if {[clock clicks -milliseconds] >= $nextupdate} {
123 doupdate
124 }
9ccbdfbf
PM
125 }
126 }
127 }
128 }
129}
130
131proc doupdate {} {
132 global commfd nextupdate
133
134 incr nextupdate 100
135 fileevent $commfd readable {}
136 update
b490a991 137 fileevent $commfd readable "getcommitlines $commfd"
1db95b00
PM
138}
139
140proc readcommit {id} {
b490a991
PM
141 if [catch {set contents [exec git-cat-file commit $id]}] return
142 parsecommit $id $contents 0
143}
144
145proc parsecommit {id contents listed} {
9ccbdfbf 146 global commitinfo children nchildren parents nparents cdate ncleft
9ccbdfbf 147
1db95b00
PM
148 set inhdr 1
149 set comment {}
150 set headline {}
151 set auname {}
152 set audate {}
153 set comname {}
154 set comdate {}
cfb4563c
PM
155 if {![info exists nchildren($id)]} {
156 set children($id) {}
157 set nchildren($id) 0
9ccbdfbf 158 set ncleft($id) 0
cfb4563c
PM
159 }
160 set parents($id) {}
161 set nparents($id) 0
df3d83b1 162 foreach line [split $contents "\n"] {
1db95b00
PM
163 if {$inhdr} {
164 if {$line == {}} {
165 set inhdr 0
166 } else {
167 set tag [lindex $line 0]
cfb4563c
PM
168 if {$tag == "parent"} {
169 set p [lindex $line 1]
170 if {![info exists nchildren($p)]} {
171 set children($p) {}
172 set nchildren($p) 0
9ccbdfbf 173 set ncleft($p) 0
cfb4563c
PM
174 }
175 lappend parents($id) $p
176 incr nparents($id)
a823a911 177 # sometimes we get a commit that lists a parent twice...
b490a991 178 if {$listed && [lsearch -exact $children($p) $id] < 0} {
cfb4563c
PM
179 lappend children($p) $id
180 incr nchildren($p)
9ccbdfbf 181 incr ncleft($p)
cfb4563c
PM
182 }
183 } elseif {$tag == "author"} {
1db95b00
PM
184 set x [expr {[llength $line] - 2}]
185 set audate [lindex $line $x]
186 set auname [lrange $line 1 [expr {$x - 1}]]
187 } elseif {$tag == "committer"} {
188 set x [expr {[llength $line] - 2}]
189 set comdate [lindex $line $x]
190 set comname [lrange $line 1 [expr {$x - 1}]]
191 }
192 }
193 } else {
194 if {$comment == {}} {
806ce097 195 set headline [string trim $line]
1db95b00
PM
196 } else {
197 append comment "\n"
198 }
806ce097
PM
199 if {!$listed} {
200 # git-rev-list indents the comment by 4 spaces;
201 # if we got this via git-cat-file, add the indentation
202 append comment " "
203 }
1db95b00
PM
204 append comment $line
205 }
206 }
207 if {$audate != {}} {
208 set audate [clock format $audate -format "%Y-%m-%d %H:%M:%S"]
209 }
210 if {$comdate != {}} {
cfb4563c 211 set cdate($id) $comdate
1db95b00
PM
212 set comdate [clock format $comdate -format "%Y-%m-%d %H:%M:%S"]
213 }
e5c2d856
PM
214 set commitinfo($id) [list $headline $auname $audate \
215 $comname $comdate $comment]
1db95b00
PM
216}
217
887fe3c4 218proc readrefs {} {
c2f6a022 219 global tagids idtags headids idheads
73b6a6cb 220 set tags [glob -nocomplain -types f [gitdir]/refs/tags/*]
887fe3c4
PM
221 foreach f $tags {
222 catch {
223 set fd [open $f r]
224 set line [read $fd]
225 if {[regexp {^[0-9a-f]{40}} $line id]} {
9ccbdfbf
PM
226 set direct [file tail $f]
227 set tagids($direct) $id
228 lappend idtags($id) $direct
887fe3c4
PM
229 set contents [split [exec git-cat-file tag $id] "\n"]
230 set obj {}
231 set type {}
232 set tag {}
233 foreach l $contents {
234 if {$l == {}} break
235 switch -- [lindex $l 0] {
236 "object" {set obj [lindex $l 1]}
237 "type" {set type [lindex $l 1]}
238 "tag" {set tag [string range $l 4 end]}
239 }
240 }
241 if {$obj != {} && $type == "commit" && $tag != {}} {
242 set tagids($tag) $obj
243 lappend idtags($obj) $tag
244 }
245 }
c2f6a022
PM
246 close $fd
247 }
248 }
73b6a6cb 249 set heads [glob -nocomplain -types f [gitdir]/refs/heads/*]
c2f6a022
PM
250 foreach f $heads {
251 catch {
252 set fd [open $f r]
253 set line [read $fd 40]
254 if {[regexp {^[0-9a-f]{40}} $line id]} {
255 set head [file tail $f]
256 set headids($head) $line
257 lappend idheads($line) $head
258 }
259 close $fd
887fe3c4
PM
260 }
261 }
262}
263
df3d83b1
PM
264proc error_popup msg {
265 set w .error
266 toplevel $w
267 wm transient $w .
268 message $w.m -text $msg -justify center -aspect 400
269 pack $w.m -side top -fill x -padx 20 -pady 20
270 button $w.ok -text OK -command "destroy $w"
271 pack $w.ok -side bottom -fill x
272 bind $w <Visibility> "grab $w; focus $w"
273 tkwait window $w
274}
275
1db95b00 276proc makewindow {} {
e5c2d856 277 global canv canv2 canv3 linespc charspc ctext cflist textfont
b74fd579 278 global findtype findtypemenu findloc findstring fstring geometry
887fe3c4 279 global entries sha1entry sha1string sha1but
ea13cba1 280 global maincursor textcursor
9d2a52ec 281 global rowctxmenu gaudydiff mergemax
9a40c50c
PM
282
283 menu .bar
284 .bar add cascade -label "File" -menu .bar.file
285 menu .bar.file
1d10f36d 286 .bar.file add command -label "Quit" -command doquit
9a40c50c
PM
287 menu .bar.help
288 .bar add cascade -label "Help" -menu .bar.help
289 .bar.help add command -label "About gitk" -command about
290 . configure -menu .bar
291
0fba86b3
PM
292 if {![info exists geometry(canv1)]} {
293 set geometry(canv1) [expr 45 * $charspc]
294 set geometry(canv2) [expr 30 * $charspc]
295 set geometry(canv3) [expr 15 * $charspc]
296 set geometry(canvh) [expr 25 * $linespc + 4]
297 set geometry(ctextw) 80
298 set geometry(ctexth) 30
299 set geometry(cflistw) 30
300 }
0327d27a 301 panedwindow .ctop -orient vertical
0fba86b3
PM
302 if {[info exists geometry(width)]} {
303 .ctop conf -width $geometry(width) -height $geometry(height)
17386066
PM
304 set texth [expr {$geometry(height) - $geometry(canvh) - 56}]
305 set geometry(ctexth) [expr {($texth - 8) /
306 [font metrics $textfont -linespace]}]
0fba86b3 307 }
98f350e5
PM
308 frame .ctop.top
309 frame .ctop.top.bar
310 pack .ctop.top.bar -side bottom -fill x
311 set cscroll .ctop.top.csb
312 scrollbar $cscroll -command {allcanvs yview} -highlightthickness 0
313 pack $cscroll -side right -fill y
314 panedwindow .ctop.top.clist -orient horizontal -sashpad 0 -handlesize 4
315 pack .ctop.top.clist -side top -fill both -expand 1
316 .ctop add .ctop.top
317 set canv .ctop.top.clist.canv
0fba86b3 318 canvas $canv -height $geometry(canvh) -width $geometry(canv1) \
b5721c72
PM
319 -bg white -bd 0 \
320 -yscrollincr $linespc -yscrollcommand "$cscroll set"
98f350e5
PM
321 .ctop.top.clist add $canv
322 set canv2 .ctop.top.clist.canv2
0fba86b3 323 canvas $canv2 -height $geometry(canvh) -width $geometry(canv2) \
b5721c72 324 -bg white -bd 0 -yscrollincr $linespc
98f350e5
PM
325 .ctop.top.clist add $canv2
326 set canv3 .ctop.top.clist.canv3
0fba86b3 327 canvas $canv3 -height $geometry(canvh) -width $geometry(canv3) \
b5721c72 328 -bg white -bd 0 -yscrollincr $linespc
98f350e5 329 .ctop.top.clist add $canv3
43bddeb4 330 bind .ctop.top.clist <Configure> {resizeclistpanes %W %w}
98f350e5
PM
331
332 set sha1entry .ctop.top.bar.sha1
887fe3c4
PM
333 set entries $sha1entry
334 set sha1but .ctop.top.bar.sha1label
335 button $sha1but -text "SHA1 ID: " -state disabled -relief flat \
336 -command gotocommit -width 8
337 $sha1but conf -disabledforeground [$sha1but cget -foreground]
98f350e5 338 pack .ctop.top.bar.sha1label -side left
887fe3c4
PM
339 entry $sha1entry -width 40 -font $textfont -textvariable sha1string
340 trace add variable sha1string write sha1change
98f350e5 341 pack $sha1entry -side left -pady 2
d698206c
PM
342
343 image create bitmap bm-left -data {
344 #define left_width 16
345 #define left_height 16
346 static unsigned char left_bits[] = {
347 0x00, 0x00, 0xc0, 0x01, 0xe0, 0x00, 0x70, 0x00, 0x38, 0x00, 0x1c, 0x00,
348 0x0e, 0x00, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0x0e, 0x00, 0x1c, 0x00,
349 0x38, 0x00, 0x70, 0x00, 0xe0, 0x00, 0xc0, 0x01};
350 }
351 image create bitmap bm-right -data {
352 #define right_width 16
353 #define right_height 16
354 static unsigned char right_bits[] = {
355 0x00, 0x00, 0xc0, 0x01, 0x80, 0x03, 0x00, 0x07, 0x00, 0x0e, 0x00, 0x1c,
356 0x00, 0x38, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0x00, 0x38, 0x00, 0x1c,
357 0x00, 0x0e, 0x00, 0x07, 0x80, 0x03, 0xc0, 0x01};
358 }
359 button .ctop.top.bar.leftbut -image bm-left -command goback \
360 -state disabled -width 26
361 pack .ctop.top.bar.leftbut -side left -fill y
362 button .ctop.top.bar.rightbut -image bm-right -command goforw \
363 -state disabled -width 26
364 pack .ctop.top.bar.rightbut -side left -fill y
365
98f350e5
PM
366 button .ctop.top.bar.findbut -text "Find" -command dofind
367 pack .ctop.top.bar.findbut -side left
368 set findstring {}
df3d83b1 369 set fstring .ctop.top.bar.findstring
887fe3c4 370 lappend entries $fstring
df3d83b1 371 entry $fstring -width 30 -font $textfont -textvariable findstring
df3d83b1 372 pack $fstring -side left -expand 1 -fill x
98f350e5 373 set findtype Exact
b74fd579
PM
374 set findtypemenu [tk_optionMenu .ctop.top.bar.findtype \
375 findtype Exact IgnCase Regexp]
98f350e5
PM
376 set findloc "All fields"
377 tk_optionMenu .ctop.top.bar.findloc findloc "All fields" Headline \
b74fd579 378 Comments Author Committer Files Pickaxe
98f350e5
PM
379 pack .ctop.top.bar.findloc -side right
380 pack .ctop.top.bar.findtype -side right
b74fd579
PM
381 # for making sure type==Exact whenever loc==Pickaxe
382 trace add variable findloc write findlocchange
b5721c72 383
5ad588de
PM
384 panedwindow .ctop.cdet -orient horizontal
385 .ctop add .ctop.cdet
d2610d11
PM
386 frame .ctop.cdet.left
387 set ctext .ctop.cdet.left.ctext
0fba86b3
PM
388 text $ctext -bg white -state disabled -font $textfont \
389 -width $geometry(ctextw) -height $geometry(ctexth) \
d2610d11
PM
390 -yscrollcommand ".ctop.cdet.left.sb set"
391 scrollbar .ctop.cdet.left.sb -command "$ctext yview"
392 pack .ctop.cdet.left.sb -side right -fill y
393 pack $ctext -side left -fill both -expand 1
394 .ctop.cdet add .ctop.cdet.left
395
f0654861
PM
396 $ctext tag conf filesep -font [concat $textfont bold] -back "#aaaaaa"
397 if {$gaudydiff} {
398 $ctext tag conf hunksep -back blue -fore white
399 $ctext tag conf d0 -back "#ff8080"
400 $ctext tag conf d1 -back green
401 } else {
402 $ctext tag conf hunksep -fore blue
403 $ctext tag conf d0 -fore red
404 $ctext tag conf d1 -fore "#00a000"
9d2a52ec
PM
405 $ctext tag conf m0 -fore red
406 $ctext tag conf m1 -fore blue
407 $ctext tag conf m2 -fore green
408 $ctext tag conf m3 -fore purple
409 $ctext tag conf m4 -fore brown
410 $ctext tag conf mmax -fore darkgrey
411 set mergemax 5
412 $ctext tag conf mresult -font [concat $textfont bold]
413 $ctext tag conf msep -font [concat $textfont bold]
f0654861
PM
414 $ctext tag conf found -back yellow
415 }
e5c2d856 416
d2610d11
PM
417 frame .ctop.cdet.right
418 set cflist .ctop.cdet.right.cfiles
17386066 419 listbox $cflist -bg white -selectmode extended -width $geometry(cflistw) \
d2610d11
PM
420 -yscrollcommand ".ctop.cdet.right.sb set"
421 scrollbar .ctop.cdet.right.sb -command "$cflist yview"
422 pack .ctop.cdet.right.sb -side right -fill y
423 pack $cflist -side left -fill both -expand 1
424 .ctop.cdet add .ctop.cdet.right
0fba86b3 425 bind .ctop.cdet <Configure> {resizecdetpanes %W %w}
d2610d11 426
0327d27a 427 pack .ctop -side top -fill both -expand 1
1db95b00 428
c8dfbcf9
PM
429 bindall <1> {selcanvline %W %x %y}
430 #bindall <B1-Motion> {selcanvline %W %x %y}
cfb4563c
PM
431 bindall <ButtonRelease-4> "allcanvs yview scroll -5 units"
432 bindall <ButtonRelease-5> "allcanvs yview scroll 5 units"
b5721c72
PM
433 bindall <2> "allcanvs scan mark 0 %y"
434 bindall <B2-Motion> "allcanvs scan dragto 0 %y"
17386066
PM
435 bind . <Key-Up> "selnextline -1"
436 bind . <Key-Down> "selnextline 1"
cfb4563c
PM
437 bind . <Key-Prior> "allcanvs yview scroll -1 pages"
438 bind . <Key-Next> "allcanvs yview scroll 1 pages"
439 bindkey <Key-Delete> "$ctext yview scroll -1 pages"
440 bindkey <Key-BackSpace> "$ctext yview scroll -1 pages"
441 bindkey <Key-space> "$ctext yview scroll 1 pages"
df3d83b1
PM
442 bindkey p "selnextline -1"
443 bindkey n "selnextline 1"
cfb4563c
PM
444 bindkey b "$ctext yview scroll -1 pages"
445 bindkey d "$ctext yview scroll 18 units"
446 bindkey u "$ctext yview scroll -18 units"
b74fd579
PM
447 bindkey / {findnext 1}
448 bindkey <Key-Return> {findnext 0}
df3d83b1 449 bindkey ? findprev
39ad8570 450 bindkey f nextfile
1d10f36d 451 bind . <Control-q> doquit
98f350e5 452 bind . <Control-f> dofind
b74fd579 453 bind . <Control-g> {findnext 0}
98f350e5 454 bind . <Control-r> findprev
1d10f36d
PM
455 bind . <Control-equal> {incrfont 1}
456 bind . <Control-KP_Add> {incrfont 1}
457 bind . <Control-minus> {incrfont -1}
458 bind . <Control-KP_Subtract> {incrfont -1}
e5c2d856 459 bind $cflist <<ListboxSelect>> listboxsel
0fba86b3 460 bind . <Destroy> {savestuff %W}
df3d83b1 461 bind . <Button-1> "click %W"
17386066 462 bind $fstring <Key-Return> dofind
887fe3c4 463 bind $sha1entry <Key-Return> gotocommit
ee3dc72e 464 bind $sha1entry <<PasteSelection>> clearsha1
ea13cba1
PM
465
466 set maincursor [. cget -cursor]
467 set textcursor [$ctext cget -cursor]
84ba7345 468
c8dfbcf9
PM
469 set rowctxmenu .rowctxmenu
470 menu $rowctxmenu -tearoff 0
471 $rowctxmenu add command -label "Diff this -> selected" \
472 -command {diffvssel 0}
473 $rowctxmenu add command -label "Diff selected -> this" \
474 -command {diffvssel 1}
74daedb6 475 $rowctxmenu add command -label "Make patch" -command mkpatch
bdbfbe3d 476 $rowctxmenu add command -label "Create tag" -command mktag
4a2139f5 477 $rowctxmenu add command -label "Write commit to file" -command writecommit
df3d83b1
PM
478}
479
480# when we make a key binding for the toplevel, make sure
481# it doesn't get triggered when that key is pressed in the
482# find string entry widget.
483proc bindkey {ev script} {
887fe3c4 484 global entries
df3d83b1
PM
485 bind . $ev $script
486 set escript [bind Entry $ev]
487 if {$escript == {}} {
488 set escript [bind Entry <Key>]
489 }
887fe3c4
PM
490 foreach e $entries {
491 bind $e $ev "$escript; break"
492 }
df3d83b1
PM
493}
494
495# set the focus back to the toplevel for any click outside
887fe3c4 496# the entry widgets
df3d83b1 497proc click {w} {
887fe3c4
PM
498 global entries
499 foreach e $entries {
500 if {$w == $e} return
df3d83b1 501 }
887fe3c4 502 focus .
0fba86b3
PM
503}
504
505proc savestuff {w} {
506 global canv canv2 canv3 ctext cflist mainfont textfont
8d858d1a 507 global stuffsaved findmergefiles gaudydiff maxgraphpct
4ef17537 508
0fba86b3 509 if {$stuffsaved} return
df3d83b1 510 if {![winfo viewable .]} return
0fba86b3
PM
511 catch {
512 set f [open "~/.gitk-new" w]
f0654861
PM
513 puts $f [list set mainfont $mainfont]
514 puts $f [list set textfont $textfont]
515 puts $f [list set findmergefiles $findmergefiles]
516 puts $f [list set gaudydiff $gaudydiff]
8d858d1a 517 puts $f [list set maxgraphpct $maxgraphpct]
0fba86b3
PM
518 puts $f "set geometry(width) [winfo width .ctop]"
519 puts $f "set geometry(height) [winfo height .ctop]"
df3d83b1
PM
520 puts $f "set geometry(canv1) [expr [winfo width $canv]-2]"
521 puts $f "set geometry(canv2) [expr [winfo width $canv2]-2]"
522 puts $f "set geometry(canv3) [expr [winfo width $canv3]-2]"
523 puts $f "set geometry(canvh) [expr [winfo height $canv]-2]"
0fba86b3
PM
524 set wid [expr {([winfo width $ctext] - 8) \
525 / [font measure $textfont "0"]}]
0fba86b3 526 puts $f "set geometry(ctextw) $wid"
0fba86b3
PM
527 set wid [expr {([winfo width $cflist] - 11) \
528 / [font measure [$cflist cget -font] "0"]}]
529 puts $f "set geometry(cflistw) $wid"
530 close $f
531 file rename -force "~/.gitk-new" "~/.gitk"
532 }
533 set stuffsaved 1
1db95b00
PM
534}
535
43bddeb4
PM
536proc resizeclistpanes {win w} {
537 global oldwidth
538 if [info exists oldwidth($win)] {
539 set s0 [$win sash coord 0]
540 set s1 [$win sash coord 1]
541 if {$w < 60} {
542 set sash0 [expr {int($w/2 - 2)}]
543 set sash1 [expr {int($w*5/6 - 2)}]
544 } else {
545 set factor [expr {1.0 * $w / $oldwidth($win)}]
546 set sash0 [expr {int($factor * [lindex $s0 0])}]
547 set sash1 [expr {int($factor * [lindex $s1 0])}]
548 if {$sash0 < 30} {
549 set sash0 30
550 }
551 if {$sash1 < $sash0 + 20} {
552 set sash1 [expr $sash0 + 20]
553 }
554 if {$sash1 > $w - 10} {
555 set sash1 [expr $w - 10]
556 if {$sash0 > $sash1 - 20} {
557 set sash0 [expr $sash1 - 20]
558 }
559 }
560 }
561 $win sash place 0 $sash0 [lindex $s0 1]
562 $win sash place 1 $sash1 [lindex $s1 1]
563 }
564 set oldwidth($win) $w
565}
566
567proc resizecdetpanes {win w} {
568 global oldwidth
569 if [info exists oldwidth($win)] {
570 set s0 [$win sash coord 0]
571 if {$w < 60} {
572 set sash0 [expr {int($w*3/4 - 2)}]
573 } else {
574 set factor [expr {1.0 * $w / $oldwidth($win)}]
575 set sash0 [expr {int($factor * [lindex $s0 0])}]
576 if {$sash0 < 45} {
577 set sash0 45
578 }
579 if {$sash0 > $w - 15} {
580 set sash0 [expr $w - 15]
581 }
582 }
583 $win sash place 0 $sash0 [lindex $s0 1]
584 }
585 set oldwidth($win) $w
586}
587
b5721c72
PM
588proc allcanvs args {
589 global canv canv2 canv3
590 eval $canv $args
591 eval $canv2 $args
592 eval $canv3 $args
593}
594
595proc bindall {event action} {
596 global canv canv2 canv3
597 bind $canv $event $action
598 bind $canv2 $event $action
599 bind $canv3 $event $action
600}
601
9a40c50c
PM
602proc about {} {
603 set w .about
604 if {[winfo exists $w]} {
605 raise $w
606 return
607 }
608 toplevel $w
609 wm title $w "About gitk"
610 message $w.m -text {
c8dfbcf9 611Gitk version 1.2
9a40c50c
PM
612
613