From 67a4f1a7f5c778ffa23d1e562feb4cc6d52c9414 Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Sun, 12 Aug 2007 17:23:47 +1000 Subject: gitk: Fix bug causing the "can't unset idinlist(...)" error Under some circumstances, having duplicate parents in a commit could trigger a "can't unset idinlist" Tcl error. This fixes the cause (the logic in layoutrows could end up putting the same commit into rowidlist twice) and also puts a catch around the unset to ignore the error. Thanks to Jeff King for coming up with a test script to generate a repo that shows the problem. Signed-off-by: Paul Mackerras --- gitk | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'gitk') diff --git a/gitk b/gitk index 6c2be3b72..44b04f017 100755 --- a/gitk +++ b/gitk @@ -2880,6 +2880,7 @@ proc layoutrows {row endrow last} { } elseif {!$idinlist($p)} { lappend oldolds $p } + set idinlist($p) 1 } set nev [expr {[llength $idlist] + [llength $newolds] + [llength $oldolds] - $maxwidth + 1}] @@ -2952,12 +2953,10 @@ proc layoutrows {row endrow last} { lset offs $col {} } foreach i $newolds { - set idinlist($i) 1 set idrowranges($i) $id } incr col $l foreach oid $oldolds { - set idinlist($oid) 1 set idlist [linsert $idlist $col $oid] set offs [linsert $offs $col $o] makeuparrow $oid $col $row $o @@ -2998,7 +2997,7 @@ proc layouttail {} { set col [expr {[llength $idlist] - 1}] set id [lindex $idlist $col] addextraid $id $row - unset idinlist($id) + catch {unset idinlist($id)} lappend idrowranges($id) $id lappend rowrangelist $idrowranges($id) unset idrowranges($id) -- cgit v1.2.1 From bd441de4df68c4144425b1c18d323fd90f3f9617 Mon Sep 17 00:00:00 2001 From: Mark Levedahl Date: Tue, 7 Aug 2007 21:40:34 -0400 Subject: [PATCH] gitk: Enable selected patch text on Windows On windows, mouse input follows the keyboard focus, so to allow selecting text from the patch canvas we must not shift focus back to the top level. This change has no negative impact on X, so we don't explicitly test for Win32 on this change. This provides similar selection capability as already available using X-Windows. Signed-off-by: Mark Levedahl Signed-off-by: Paul Mackerras --- gitk | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'gitk') diff --git a/gitk b/gitk index 44b04f017..32206a68f 100755 --- a/gitk +++ b/gitk @@ -964,8 +964,8 @@ proc bindkey {ev script} { # set the focus back to the toplevel for any click outside # the entry widgets proc click {w} { - global entries - foreach e $entries { + global ctext entries + foreach e [concat $entries $ctext] { if {$w == $e} return } focus . @@ -4600,6 +4600,7 @@ proc sellastline {} { proc selnextline {dir} { global selectedline + focus . if {![info exists selectedline]} return set l [expr {$selectedline + $dir}] unmarkmatches @@ -4680,6 +4681,7 @@ proc godo {elt} { proc goback {} { global history historyindex + focus . if {$historyindex > 1} { incr historyindex -1 @@ -4693,6 +4695,7 @@ proc goback {} { proc goforw {} { global history historyindex + focus . if {$historyindex < [llength $history]} { set cmd [lindex $history $historyindex] -- cgit v1.2.1 From 314c30936f505f70534c619a48d99afb93451cb2 Mon Sep 17 00:00:00 2001 From: Mark Levedahl Date: Tue, 7 Aug 2007 21:40:35 -0400 Subject: [PATCH] gitk: Handle MouseWheel events on Windows Windows, unlike X-Windows, sends mousewheel events by default to the window that has keyboard focus and uses the MouseWheel event to do so. The window to be scrolled must be able to take focus, but gitk's panels are disabled so cannot take focus. For all these reasons, a different design is needed to use the mousewheel on Windows. The approach here is to bind the mousewheel events to the top level window and redirect them based upon the current mouse position. Signed-off-by: Mark Levedahl Signed-off-by: Paul Mackerras --- gitk | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'gitk') diff --git a/gitk b/gitk index 32206a68f..900038323 100755 --- a/gitk +++ b/gitk @@ -823,8 +823,13 @@ proc makewindow {} { pack .ctop -fill both -expand 1 bindall <1> {selcanvline %W %x %y} #bindall {selcanvline %W %x %y} - bindall "allcanvs yview scroll -5 units" - bindall "allcanvs yview scroll 5 units" + if {[tk windowingsystem] == "win32"} { + bind . { windows_mousewheel_redirector %W %X %Y %D } + bind $ctext { windows_mousewheel_redirector %W %X %Y %D ; break } + } else { + bindall "allcanvs yview scroll -5 units" + bindall "allcanvs yview scroll 5 units" + } bindall <2> "canvscan mark %W %x %y" bindall "canvscan dragto %W %x %y" bindkey selfirstline @@ -927,6 +932,24 @@ proc makewindow {} { -command {flist_hl 1} } +# Windows sends all mouse wheel events to the current focused window, not +# the one where the mouse hovers, so bind those events here and redirect +# to the correct window +proc windows_mousewheel_redirector {W X Y D} { + global canv canv2 canv3 + set w [winfo containing -displayof $W $X $Y] + if {$w ne ""} { + set u [expr {$D < 0 ? 5 : -5}] + if {$w == $canv || $w == $canv2 || $w == $canv3} { + allcanvs yview scroll $u units + } else { + catch { + $w yview scroll $u units + } + } + } +} + # mouse-2 makes all windows scan vertically, but only the one # the cursor is in scans horizontally proc canvscan {op w x y} { -- cgit v1.2.1 From 062d671f57a422863416ee4c746ef74c1cc45c19 Mon Sep 17 00:00:00 2001 From: Alex Riesen Date: Sun, 29 Jul 2007 22:28:40 +0200 Subject: [PATCH] gitk: Continue and show error message in new repos If there is no commit made yet, gitk just dumps a Tcl error on stderr, which sometimes is hard to see. Noticed when gitk was run from Xfce file manager (thunar's custom action). Signed-off-by: Alex Riesen Signed-off-by: Paul Mackerras --- gitk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gitk') diff --git a/gitk b/gitk index 900038323..b0a76dd22 100755 --- a/gitk +++ b/gitk @@ -427,7 +427,7 @@ proc readrefs {} { lappend idotherrefs($id) $name } } - close $refd + catch {close $refd} set mainhead {} set mainheadid {} catch { -- cgit v1.2.1 From 6c87d60cc6202d4de5ac6d136394602feefeafc6 Mon Sep 17 00:00:00 2001 From: Alex Riesen Date: Sun, 29 Jul 2007 22:29:45 +0200 Subject: [PATCH] gitk: Show an error and exit if no .git could be found This is to help people starting gitk from graphical file managers where the stderr output is hidden. Signed-off-by: Alex Riesen Signed-off-by: Paul Mackerras --- gitk | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'gitk') diff --git a/gitk b/gitk index b0a76dd22..769c79ab0 100755 --- a/gitk +++ b/gitk @@ -7636,7 +7636,10 @@ catch {source ~/.gitk} font create optionfont -family sans-serif -size -12 # check that we can find a .git directory somewhere... -set gitdir [gitdir] +if {[catch {set gitdir [gitdir]}]} { + show_error {} . "Cannot find a git repository here." + exit 1 +} if {![file isdirectory $gitdir]} { show_error {} . "Cannot find the git directory \"$gitdir\"." exit 1 -- cgit v1.2.1