Skip to content

Commit 7e12f1a

Browse files
mark987paulusmack
authored andcommitted
[PATCH] gitk: Allow specifying tabstop as other than default 8 characters.
Not all projects use the convention that one tabstop = 8 characters, and a common convention is to use one tabstop = one level of indent. For such projects, using 8 characters per tabstop often shows too much whitespace per indent. This allows the user to configure the number of characters to use per tabstop. Signed-off-by: Mark Levedahl <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent 59ddaf3 commit 7e12f1a

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

gitk

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ proc confirm_popup msg {
395395

396396
proc makewindow {} {
397397
global canv canv2 canv3 linespc charspc ctext cflist
398-
global textfont mainfont uifont
398+
global textfont mainfont uifont tabstop
399399
global findtype findtypemenu findloc findstring fstring geometry
400400
global entries sha1entry sha1string sha1but
401401
global maincursor textcursor curtextcursor
@@ -615,6 +615,7 @@ proc makewindow {} {
615615
pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new -side left
616616
set ctext .bleft.ctext
617617
text $ctext -background $bgcolor -foreground $fgcolor \
618+
-tabs "[expr {$tabstop * $charspc}]" \
618619
-state disabled -font $textfont \
619620
-yscrollcommand scrolltext -wrap none
620621
scrollbar .bleft.sb -command "$ctext yview"
@@ -824,7 +825,7 @@ proc click {w} {
824825
}
825826

826827
proc savestuff {w} {
827-
global canv canv2 canv3 ctext cflist mainfont textfont uifont
828+
global canv canv2 canv3 ctext cflist mainfont textfont uifont tabstop
828829
global stuffsaved findmergefiles maxgraphpct
829830
global maxwidth showneartags
830831
global viewname viewfiles viewargs viewperm nextviewnum
@@ -838,6 +839,7 @@ proc savestuff {w} {
838839
puts $f [list set mainfont $mainfont]
839840
puts $f [list set textfont $textfont]
840841
puts $f [list set uifont $uifont]
842+
puts $f [list set tabstop $tabstop]
841843
puts $f [list set findmergefiles $findmergefiles]
842844
puts $f [list set maxgraphpct $maxgraphpct]
843845
puts $f [list set maxwidth $maxwidth]
@@ -4696,12 +4698,13 @@ proc redisplay {} {
46964698

46974699
proc incrfont {inc} {
46984700
global mainfont textfont ctext canv phase cflist
4701+
global charspc tabstop
46994702
global stopped entries
47004703
unmarkmatches
47014704
set mainfont [lreplace $mainfont 1 1 [expr {[lindex $mainfont 1] + $inc}]]
47024705
set textfont [lreplace $textfont 1 1 [expr {[lindex $textfont 1] + $inc}]]
47034706
setcoords
4704-
$ctext conf -font $textfont
4707+
$ctext conf -font $textfont -tabs "[expr {$tabstop * $charspc}]"
47054708
$cflist conf -font $textfont
47064709
$ctext tag conf filesep -font [concat $textfont bold]
47074710
foreach e $entries {
@@ -5852,7 +5855,7 @@ proc doprefs {} {
58525855
global maxwidth maxgraphpct diffopts
58535856
global oldprefs prefstop showneartags
58545857
global bgcolor fgcolor ctext diffcolors selectbgcolor
5855-
global uifont
5858+
global uifont tabstop
58565859

58575860
set top .gitkprefs
58585861
set prefstop $top
@@ -5890,6 +5893,9 @@ proc doprefs {} {
58905893
checkbutton $top.ntag.b -variable showneartags
58915894
pack $top.ntag.b $top.ntag.l -side left
58925895
grid x $top.ntag -sticky w
5896+
label $top.tabstopl -text "tabstop" -font optionfont
5897+
entry $top.tabstop -width 10 -textvariable tabstop
5898+
grid x $top.tabstopl $top.tabstop -sticky w
58935899

58945900
label $top.cdisp -text "Colors: press to choose"
58955901
$top.cdisp configure -font $uifont
@@ -5988,9 +5994,11 @@ proc prefscan {} {
59885994
proc prefsok {} {
59895995
global maxwidth maxgraphpct
59905996
global oldprefs prefstop showneartags
5997+
global charspc ctext tabstop
59915998

59925999
catch {destroy $prefstop}
59936000
unset prefstop
6001+
$ctext configure -tabs "[expr {$tabstop * $charspc}]"
59946002
if {$maxwidth != $oldprefs(maxwidth)
59956003
|| $maxgraphpct != $oldprefs(maxgraphpct)} {
59966004
redisplay
@@ -6296,6 +6304,7 @@ if {$tclencoding == {}} {
62966304
set mainfont {Helvetica 9}
62976305
set textfont {Courier 9}
62986306
set uifont {Helvetica 9 bold}
6307+
set tabstop 8
62996308
set findmergefiles 0
63006309
set maxgraphpct 50
63016310
set maxwidth 16

0 commit comments

Comments
 (0)