gitk: Fix the tab setting in the diff display window
This fixes the bug where we were using the wrong font to calculate the width of the tab stops in the diff display window. If we're running on Tk 8.5 we also use the new -tabstyle wordprocessor option that makes tabs work as expected, i.e. a tab moves the cursor to the right until the next tab stop is reached. On Tk 8.5 we also get fancy and set the first tab stop at column 1 for a normal diff or column N for a merge diff with N parents. On Tk8.4 we can't do that because the tabs work in the "tabular" style, i.e. the nth tab character moves to the location of the nth tab position, *unless* you ask for the default tab setting, which gives 8-column tabs that work in the "wordprocessor" mode. So on Tk8.4 if the tab setting is 8 we ask for default tabs. This means that a tab setting of 7 or 9 can look quite different to 8 in some cases. Signed-off-by: Paul Mackerras <paulus@samba.org>main
parent
bb3edc8b04
commit
32f1b3e4a4
37
gitk
37
gitk
|
|
@ -626,6 +626,7 @@ proc makewindow {} {
|
||||||
global bgcolor fgcolor bglist fglist diffcolors selectbgcolor
|
global bgcolor fgcolor bglist fglist diffcolors selectbgcolor
|
||||||
global headctxmenu progresscanv progressitem progresscoords statusw
|
global headctxmenu progresscanv progressitem progresscoords statusw
|
||||||
global fprogitem fprogcoord lastprogupdate progupdatepending
|
global fprogitem fprogcoord lastprogupdate progupdatepending
|
||||||
|
global have_tk85
|
||||||
|
|
||||||
menu .bar
|
menu .bar
|
||||||
.bar add cascade -label "File" -menu .bar.file
|
.bar add cascade -label "File" -menu .bar.file
|
||||||
|
|
@ -845,9 +846,11 @@ proc makewindow {} {
|
||||||
pack .bleft.mid.labeldiffcontext .bleft.mid.diffcontext -side left
|
pack .bleft.mid.labeldiffcontext .bleft.mid.diffcontext -side left
|
||||||
set ctext .bleft.ctext
|
set ctext .bleft.ctext
|
||||||
text $ctext -background $bgcolor -foreground $fgcolor \
|
text $ctext -background $bgcolor -foreground $fgcolor \
|
||||||
-tabs "[expr {$tabstop * $charspc}]" \
|
|
||||||
-state disabled -font $textfont \
|
-state disabled -font $textfont \
|
||||||
-yscrollcommand scrolltext -wrap none
|
-yscrollcommand scrolltext -wrap none
|
||||||
|
if {$have_tk85} {
|
||||||
|
$ctext conf -tabstyle wordprocessor
|
||||||
|
}
|
||||||
scrollbar .bleft.sb -command "$ctext yview"
|
scrollbar .bleft.sb -command "$ctext yview"
|
||||||
pack .bleft.top -side top -fill x
|
pack .bleft.top -side top -fill x
|
||||||
pack .bleft.mid -side top -fill x
|
pack .bleft.mid -side top -fill x
|
||||||
|
|
@ -1135,7 +1138,7 @@ proc doprogupdate {} {
|
||||||
}
|
}
|
||||||
|
|
||||||
proc savestuff {w} {
|
proc savestuff {w} {
|
||||||
global canv canv2 canv3 ctext cflist mainfont textfont uifont tabstop
|
global canv canv2 canv3 mainfont textfont uifont tabstop
|
||||||
global stuffsaved findmergefiles maxgraphpct
|
global stuffsaved findmergefiles maxgraphpct
|
||||||
global maxwidth showneartags showlocalchanges
|
global maxwidth showneartags showlocalchanges
|
||||||
global viewname viewfiles viewargs viewperm nextviewnum
|
global viewname viewfiles viewargs viewperm nextviewnum
|
||||||
|
|
@ -5092,6 +5095,7 @@ proc showfile {f} {
|
||||||
$ctext insert end "$f\n" filesep
|
$ctext insert end "$f\n" filesep
|
||||||
$ctext config -state disabled
|
$ctext config -state disabled
|
||||||
$ctext yview $commentend
|
$ctext yview $commentend
|
||||||
|
settabs 0
|
||||||
}
|
}
|
||||||
|
|
||||||
proc getblobline {bf id} {
|
proc getblobline {bf id} {
|
||||||
|
|
@ -5133,6 +5137,7 @@ proc mergediff {id l} {
|
||||||
fconfigure $mdf -blocking 0
|
fconfigure $mdf -blocking 0
|
||||||
set mdifffd($id) $mdf
|
set mdifffd($id) $mdf
|
||||||
set np [llength [lindex $parentlist $l]]
|
set np [llength [lindex $parentlist $l]]
|
||||||
|
settabs $np
|
||||||
filerun $mdf [list getmergediffline $mdf $id $np]
|
filerun $mdf [list getmergediffline $mdf $id $np]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5210,6 +5215,7 @@ proc getmergediffline {mdf id np} {
|
||||||
proc startdiff {ids} {
|
proc startdiff {ids} {
|
||||||
global treediffs diffids treepending diffmergeid nullid nullid2
|
global treediffs diffids treepending diffmergeid nullid nullid2
|
||||||
|
|
||||||
|
settabs 1
|
||||||
set diffids $ids
|
set diffids $ids
|
||||||
catch {unset diffmergeid}
|
catch {unset diffmergeid}
|
||||||
if {![info exists treediffs($ids)] ||
|
if {![info exists treediffs($ids)] ||
|
||||||
|
|
@ -5515,6 +5521,23 @@ proc clear_ctext {{first 1.0}} {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
proc settabs {{firstab {}}} {
|
||||||
|
global firsttabstop tabstop textfont ctext have_tk85
|
||||||
|
|
||||||
|
if {$firstab ne {} && $have_tk85} {
|
||||||
|
set firsttabstop $firstab
|
||||||
|
}
|
||||||
|
set w [font measure $textfont "0"]
|
||||||
|
if {$firsttabstop != 0} {
|
||||||
|
$ctext conf -tabs [list [expr {$firsttabstop * $w}] \
|
||||||
|
[expr {($firsttabstop + $tabstop) * $w}]]
|
||||||
|
} elseif {$have_tk85 || $tabstop != 8} {
|
||||||
|
$ctext conf -tabs [expr {$tabstop * $w}]
|
||||||
|
} else {
|
||||||
|
$ctext conf -tabs {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
proc incrsearch {name ix op} {
|
proc incrsearch {name ix op} {
|
||||||
global ctext searchstring searchdirn
|
global ctext searchstring searchdirn
|
||||||
|
|
||||||
|
|
@ -5666,13 +5689,12 @@ proc redisplay {} {
|
||||||
|
|
||||||
proc incrfont {inc} {
|
proc incrfont {inc} {
|
||||||
global mainfont textfont ctext canv phase cflist showrefstop
|
global mainfont textfont ctext canv phase cflist showrefstop
|
||||||
global charspc tabstop
|
|
||||||
global stopped entries
|
global stopped entries
|
||||||
unmarkmatches
|
unmarkmatches
|
||||||
set mainfont [lreplace $mainfont 1 1 [expr {[lindex $mainfont 1] + $inc}]]
|
set mainfont [lreplace $mainfont 1 1 [expr {[lindex $mainfont 1] + $inc}]]
|
||||||
set textfont [lreplace $textfont 1 1 [expr {[lindex $textfont 1] + $inc}]]
|
set textfont [lreplace $textfont 1 1 [expr {[lindex $textfont 1] + $inc}]]
|
||||||
setcoords
|
setcoords
|
||||||
$ctext conf -font $textfont -tabs "[expr {$tabstop * $charspc}]"
|
settabs
|
||||||
$cflist conf -font $textfont
|
$cflist conf -font $textfont
|
||||||
$ctext tag conf filesep -font [concat $textfont bold]
|
$ctext tag conf filesep -font [concat $textfont bold]
|
||||||
foreach e $entries {
|
foreach e $entries {
|
||||||
|
|
@ -5876,6 +5898,7 @@ proc lineclick {x y id isnew} {
|
||||||
# fill the details pane with info about this line
|
# fill the details pane with info about this line
|
||||||
$ctext conf -state normal
|
$ctext conf -state normal
|
||||||
clear_ctext
|
clear_ctext
|
||||||
|
settabs 0
|
||||||
$ctext insert end "Parent:\t"
|
$ctext insert end "Parent:\t"
|
||||||
$ctext insert end $id link0
|
$ctext insert end $id link0
|
||||||
setlink $id link0
|
setlink $id link0
|
||||||
|
|
@ -7780,6 +7803,7 @@ proc showtag {tag isnew} {
|
||||||
}
|
}
|
||||||
$ctext conf -state normal
|
$ctext conf -state normal
|
||||||
clear_ctext
|
clear_ctext
|
||||||
|
settabs 0
|
||||||
set linknum 0
|
set linknum 0
|
||||||
if {![info exists tagcontents($tag)]} {
|
if {![info exists tagcontents($tag)]} {
|
||||||
catch {
|
catch {
|
||||||
|
|
@ -7951,11 +7975,10 @@ proc prefscan {} {
|
||||||
proc prefsok {} {
|
proc prefsok {} {
|
||||||
global maxwidth maxgraphpct
|
global maxwidth maxgraphpct
|
||||||
global oldprefs prefstop showneartags showlocalchanges
|
global oldprefs prefstop showneartags showlocalchanges
|
||||||
global charspc ctext tabstop
|
|
||||||
|
|
||||||
catch {destroy $prefstop}
|
catch {destroy $prefstop}
|
||||||
unset prefstop
|
unset prefstop
|
||||||
$ctext configure -tabs "[expr {$tabstop * $charspc}]"
|
settabs
|
||||||
if {$showlocalchanges != $oldprefs(showlocalchanges)} {
|
if {$showlocalchanges != $oldprefs(showlocalchanges)} {
|
||||||
if {$showlocalchanges} {
|
if {$showlocalchanges} {
|
||||||
doshowlocalchanges
|
doshowlocalchanges
|
||||||
|
|
@ -8360,6 +8383,7 @@ if {$i >= [llength $argv] && $revtreeargs ne {}} {
|
||||||
set nullid "0000000000000000000000000000000000000000"
|
set nullid "0000000000000000000000000000000000000000"
|
||||||
set nullid2 "0000000000000000000000000000000000000001"
|
set nullid2 "0000000000000000000000000000000000000001"
|
||||||
|
|
||||||
|
set have_tk85 [expr {[package vcompare $tk_version "8.5"] >= 0}]
|
||||||
|
|
||||||
set runq {}
|
set runq {}
|
||||||
set history {}
|
set history {}
|
||||||
|
|
@ -8376,6 +8400,7 @@ set markingmatches 0
|
||||||
set linkentercount 0
|
set linkentercount 0
|
||||||
set need_redisplay 0
|
set need_redisplay 0
|
||||||
set nrows_drawn 0
|
set nrows_drawn 0
|
||||||
|
set firsttabstop 0
|
||||||
|
|
||||||
set nextviewnum 1
|
set nextviewnum 1
|
||||||
set curview 0
|
set curview 0
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue