aboutsummaryrefslogtreecommitdiff
path: root/gitk-git/gitk
diff options
context:
space:
mode:
Diffstat (limited to 'gitk-git/gitk')
-rwxr-xr-xgitk-git/gitk110
1 files changed, 85 insertions, 25 deletions
diff --git a/gitk-git/gitk b/gitk-git/gitk
index c02db0194d..2730274966 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -2131,12 +2131,14 @@ proc ttk_toplevel {w args} {
return $w
}
-proc make_transient {window origin} {
+proc make_transient {window origin {geometry ""}} {
wm transient $window $origin
- # Windows fails to place transient windows normally, so
- # schedule a callback to center them on the parent.
- if {[tk windowingsystem] eq {win32}} {
+ if {$geometry ne ""} {
+ after idle [list wm geometry $window $geometry]
+ } elseif {[tk windowingsystem] eq {win32}} {
+ # Windows fails to place transient windows normally, so
+ # schedule a callback to center them on the parent.
after idle [list tk::PlaceWindow $window widget $origin]
}
}
@@ -2723,17 +2725,9 @@ proc makewindow {} {
.pwbottom add .bright
.ctop add .pwbottom
- # restore window width & height if known
+ # restore window position if known
if {[info exists geometry(main)]} {
- if {[scan $geometry(main) "%dx%d" w h] >= 2} {
- if {$w > [winfo screenwidth .]} {
- set w [winfo screenwidth .]
- }
- if {$h > [winfo screenheight .]} {
- set h [winfo screenheight .]
- }
- wm geometry . "${w}x$h"
- }
+ wm geometry . "$geometry(main)"
}
if {[info exists geometry(state)] && $geometry(state) eq "zoomed"} {
@@ -3073,6 +3067,11 @@ proc savestuff {w} {
puts $f "set geometry(pwsash1) \"[.tf.histframe.pwclist sashpos 1] 1\""
puts $f "set geometry(botwidth) [winfo width .bleft]"
puts $f "set geometry(botheight) [winfo height .bleft]"
+ unset -nocomplain geometry
+ global geometry
+ if {[info exists geometry(showrefs)]} {
+ puts $f "set geometry(showrefs) $geometry(showrefs)"
+ }
array set view_save {}
array set views {}
@@ -3788,6 +3787,34 @@ proc external_diff_get_one_file {diffid filename diffdir} {
"revision $diffid"]
}
+proc check_for_renames_in_diff {filepath} { # renames
+ global difffilestart ctext
+
+ set filename [file tail $filepath]
+ set renames {}
+
+ foreach loc $difffilestart {
+ set loclineend [string map {.0 .end} $loc]
+ set fromlineloc "$loc + 2 lines"
+ set tolineloc "$loc + 3 lines"
+ set renfromline [$ctext get $fromlineloc [string map {.0 .end} $fromlineloc]]
+ set rentoline [$ctext get $tolineloc [string map {.0 .end} $tolineloc]]
+ if {[string equal -length 12 "rename from " $renfromline]
+ && [string equal -length 10 "rename to " $rentoline]} {
+ set renfrom [string range $renfromline 12 end]
+ set rento [string range $rentoline 10 end]
+ if {[string first $filename $renfrom] != -1
+ || [string first $filename $rento] != -1} {
+ lappend renames $renfrom
+ lappend renames $rento
+ break
+ }
+ }
+ }
+
+ return $renames
+}
+
proc external_diff {} {
global nullid nullid2
global flist_menu_file
@@ -3818,8 +3845,16 @@ proc external_diff {} {
if {$diffdir eq {}} return
# gather files to diff
- set difffromfile [external_diff_get_one_file $diffidfrom $flist_menu_file $diffdir]
- set difftofile [external_diff_get_one_file $diffidto $flist_menu_file $diffdir]
+ set renames [check_for_renames_in_diff $flist_menu_file]
+ set renamefrom [lindex $renames 0]
+ set renameto [lindex $renames 1]
+ if {$renamefrom ne {} && $renameto ne {}} {
+ set difffromfile [external_diff_get_one_file $diffidfrom $renamefrom $diffdir]
+ set difftofile [external_diff_get_one_file $diffidto $renameto $diffdir]
+ } else {
+ set difffromfile [external_diff_get_one_file $diffidfrom $flist_menu_file $diffdir]
+ set difftofile [external_diff_get_one_file $diffidto $flist_menu_file $diffdir]
+ }
if {$difffromfile ne {} && $difftofile ne {}} {
set cmd [list [shellsplit $extdifftool] $difffromfile $difftofile]
@@ -6796,17 +6831,19 @@ proc drawtags {id x xt y1} {
} else {
# draw a head or other ref
if {[incr nheads -1] >= 0} {
- set col $headbgcolor
+ set refoutlinecol $headoutlinecolor
+ set reffillcol $headbgcolor
if {$tag eq $mainhead} {
set font mainfontbold
}
} else {
- set col "#ddddff"
+ set refoutlinecol black
+ set reffillcol "#ddddff"
}
set xl [expr {$xl - $delta/2}]
$canv create polygon $x $yt $xr $yt $xr $yb $x $yb \
- -width 1 -outline black -fill $col -tags tag.$id
- if {[regexp {^(remotes/.*/|remotes/)} $tag match remoteprefix]} {
+ -width 1 -outline $refoutlinecol -fill $reffillcol -tags tag.$id
+ if {[regexp {^(remotes/[^/]*/|remotes/)} $tag match remoteprefix]} {
set rwid [font measure mainfont $remoteprefix]
set xi [expr {$x + 1}]
set yti [expr {$yt + 1}]
@@ -6815,7 +6852,8 @@ proc drawtags {id x xt y1} {
-width 0 -fill $remotebgcolor -tags tag.$id
}
}
- set t [$canv create text $xl $y1 -anchor w -text $tag -fill $headfgcolor \
+ set textfgcolor [expr {$ntags >= 0 ? $tagfgcolor : $headfgcolor}]
+ set t [$canv create text $xl $y1 -anchor w -text $tag -fill $textfgcolor \
-font $font -tags [list tag.$id text]]
if {$ntags >= 0} {
$canv bind $t <1> $tagclick
@@ -8296,7 +8334,7 @@ proc parseblobdiffline {ids line} {
if {![regexp {^diff (--cc|--git) } $line m type]} {
set line [convertfrom utf-8 $line]
$ctext insert end "$line\n" hunksep
- continue
+ return
}
# start of a new file
set diffinhdr 1
@@ -8401,6 +8439,7 @@ proc parseblobdiffline {ids line} {
if {$i >= 0} {
setinlist difffilestart $i $curdiffstart
}
+ set line "rename from $fname"
} elseif {![string compare -length 10 $line "rename to "] ||
![string compare -length 8 $line "copy to "]} {
set fname [string range $line [expr 4 + [string first " to " $line] ] end]
@@ -8408,6 +8447,13 @@ proc parseblobdiffline {ids line} {
set fname [lindex $fname 0]
}
makediffhdr $fname $ids
+ set line "[lindex $line 0] to $fname"
+ } elseif {![string compare -length 10 $line "copy from "]} {
+ set fname [string range $line 10 end]
+ if {[string index $fname 0] eq "\""} {
+ set fname [lindex $fname 0]
+ }
+ set line "copy from $fname"
} elseif {[string compare -length 3 $line "---"] == 0} {
# do nothing
return
@@ -10160,6 +10206,7 @@ proc rmbranch {} {
proc showrefs {} {
global showrefstop bgcolor fgcolor selectbgcolor
global bglist fglist reflistfilter reflist maincursor
+ global geometry
set top .showrefs
set showrefstop $top
@@ -10170,7 +10217,11 @@ proc showrefs {} {
}
ttk_toplevel $top
wm title $top [mc "Tags and heads: %s" [file tail [pwd]]]
- make_transient $top .
+ if {[info exists geometry(showrefs)]} {
+ make_transient $top . $geometry(showrefs)
+ } else {
+ make_transient $top .
+ }
text $top.list -background $bgcolor -foreground $fgcolor \
-selectbackground $selectbgcolor -font mainfont \
-xscrollcommand "$top.xsb set" -yscrollcommand "$top.ysb set" \
@@ -10206,6 +10257,9 @@ proc showrefs {} {
bind $top.list <ButtonRelease-1> {sel_reflist %W %x %y; break}
set reflist {}
refill_reflist
+ # avoid <Configure> being bound to child windows
+ bindtags $top [linsert [bindtags $top] 1 bind$top]
+ bind bind$top <Configure> {set geometry(showrefs) [wm geometry %W]}
}
proc sel_reflist {w x y} {
@@ -11745,7 +11799,7 @@ proc prefspage_general {notebook} {
proc prefspage_colors {notebook} {
global bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor
- global diffbgcolors
+ global diffbgcolors linkfgcolor
global themeloader
set page [create_prefs_page $notebook.colors]
@@ -11822,6 +11876,11 @@ proc prefspage_colors {notebook} {
-command [list choosecolor selectbgcolor {} $page [mc "background"]]
grid x $page.selbgbut $page.selbgsep -sticky w
+ label $page.linkfg -padx 40 -relief sunk -background $linkfgcolor
+ ttk::button $page.linkfgbut -text [mc "Link"] \
+ -command [list choosecolor linkfgcolor {} $page [mc "link"]]
+ grid x $page.linkfgbut $page.linkfg -sticky w
+
grid columnconfigure $page 2 -weight 1
return $page
@@ -11829,7 +11888,7 @@ proc prefspage_colors {notebook} {
proc prefspage_set_colorswatches {page} {
global bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor
- global diffbgcolors
+ global diffbgcolors linkfgcolor
$page.bg configure -background $bgcolor
$page.fg configure -background $fgcolor
@@ -11840,6 +11899,7 @@ proc prefspage_set_colorswatches {page} {
$page.hunksep configure -background [lindex $diffcolors 2]
$page.markbgsep configure -background $markbgcolor
$page.selbgsep configure -background $selectbgcolor
+ $page.linkfg configure -background $linkfgcolor
}
proc prefspage_fonts {notebook} {