Skip to content

Commit 904b36b

Browse files
sommerj6t
authored andcommitted
gitk: add text wrapping preferences
Add a new preference "wrapdefault" which allows enabling char/word wrap. Impacts all text in the ctext widget for which no other preference exists. Also make the (existing) preference "wrapcomment" configurable graphically. Its setting impacts only the "comment" part of the ctext widget. Signed-off-by: Christoph Sommer <[email protected]> Signed-off-by: Johannes Sixt <[email protected]>
1 parent b2490ae commit 904b36b

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

gitk

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2089,7 +2089,7 @@ proc makewindow {} {
20892089
global diffcontextstring diffcontext
20902090
global ignorespace
20912091
global maincursor textcursor curtextcursor
2092-
global rowctxmenu fakerowmenu mergemax wrapcomment
2092+
global rowctxmenu fakerowmenu mergemax wrapcomment wrapdefault
20932093
global highlight_files gdttype
20942094
global searchstring sstring
20952095
global bgcolor fgcolor bglist fglist diffcolors diffbgcolors selectbgcolor
@@ -2431,7 +2431,7 @@ proc makewindow {} {
24312431
set ctext .bleft.bottom.ctext
24322432
text $ctext -background $bgcolor -foreground $fgcolor \
24332433
-state disabled -undo 0 -font textfont \
2434-
-yscrollcommand scrolltext -wrap none \
2434+
-yscrollcommand scrolltext -wrap $wrapdefault \
24352435
-xscrollcommand ".bleft.bottom.sbhorizontal set"
24362436
if {$have_tk85} {
24372437
$ctext conf -tabstyle wordprocessor
@@ -11576,7 +11576,7 @@ proc create_prefs_page {w} {
1157611576

1157711577
proc prefspage_general {notebook} {
1157811578
global NS maxwidth maxgraphpct showneartags showlocalchanges
11579-
global tabstop limitdiffs autoselect autosellen extdifftool perfile_attrs
11579+
global tabstop wrapcomment wrapdefault limitdiffs autoselect autosellen extdifftool perfile_attrs
1158011580
global hideremotes want_ttk have_ttk maxrefs web_browser
1158111581

1158211582
set page [create_prefs_page $notebook.general]
@@ -11607,6 +11607,17 @@ proc prefspage_general {notebook} {
1160711607
${NS}::label $page.tabstopl -text [mc "Tab spacing"]
1160811608
spinbox $page.tabstop -from 1 -to 20 -width 4 -textvariable tabstop
1160911609
grid x $page.tabstopl $page.tabstop -sticky w
11610+
11611+
${NS}::label $page.wrapcommentl -text [mc "Wrap comment text"]
11612+
${NS}::combobox $page.wrapcomment -values {none char word} -state readonly \
11613+
-textvariable wrapcomment
11614+
grid x $page.wrapcommentl $page.wrapcomment -sticky w
11615+
11616+
${NS}::label $page.wrapdefaultl -text [mc "Wrap other text"]
11617+
${NS}::combobox $page.wrapdefault -values {none char word} -state readonly \
11618+
-textvariable wrapdefault
11619+
grid x $page.wrapdefaultl $page.wrapdefault -sticky w
11620+
1161011621
${NS}::checkbutton $page.ntag -text [mc "Display nearby tags/heads"] \
1161111622
-variable showneartags
1161211623
grid x $page.ntag -sticky w
@@ -11725,7 +11736,7 @@ proc doprefs {} {
1172511736
global oldprefs prefstop showneartags showlocalchanges
1172611737
global uicolor bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor
1172711738
global tabstop limitdiffs autoselect autosellen extdifftool perfile_attrs
11728-
global hideremotes want_ttk have_ttk
11739+
global hideremotes want_ttk have_ttk wrapcomment wrapdefault
1172911740

1173011741
set top .gitkprefs
1173111742
set prefstop $top
@@ -11734,7 +11745,7 @@ proc doprefs {} {
1173411745
return
1173511746
}
1173611747
foreach v {maxwidth maxgraphpct showneartags showlocalchanges \
11737-
limitdiffs tabstop perfile_attrs hideremotes want_ttk} {
11748+
limitdiffs tabstop perfile_attrs hideremotes want_ttk wrapcomment wrapdefault} {
1173811749
set oldprefs($v) [set $v]
1173911750
}
1174011751
ttk_toplevel $top
@@ -11860,7 +11871,7 @@ proc prefscan {} {
1186011871
global oldprefs prefstop
1186111872

1186211873
foreach v {maxwidth maxgraphpct showneartags showlocalchanges \
11863-
limitdiffs tabstop perfile_attrs hideremotes want_ttk} {
11874+
limitdiffs tabstop perfile_attrs hideremotes want_ttk wrapcomment wrapdefault} {
1186411875
global $v
1186511876
set $v $oldprefs($v)
1186611877
}
@@ -11874,7 +11885,8 @@ proc prefsok {} {
1187411885
global oldprefs prefstop showneartags showlocalchanges
1187511886
global fontpref mainfont textfont uifont
1187611887
global limitdiffs treediffs perfile_attrs
11877-
global hideremotes
11888+
global hideremotes wrapcomment wrapdefault
11889+
global ctext
1187811890

1187911891
catch {destroy $prefstop}
1188011892
unset prefstop
@@ -11923,6 +11935,12 @@ proc prefsok {} {
1192311935
if {$hideremotes != $oldprefs(hideremotes)} {
1192411936
rereadrefs
1192511937
}
11938+
if {$wrapcomment != $oldprefs(wrapcomment)} {
11939+
$ctext tag conf comment -wrap $wrapcomment
11940+
}
11941+
if {$wrapdefault != $oldprefs(wrapdefault)} {
11942+
$ctext configure -wrap $wrapdefault
11943+
}
1192611944
}
1192711945

1192811946
proc formatdate {d} {
@@ -12392,6 +12410,7 @@ set downarrowlen 5
1239212410
set mingaplen 100
1239312411
set cmitmode "patch"
1239412412
set wrapcomment "none"
12413+
set wrapdefault "none"
1239512414
set showneartags 1
1239612415
set hideremotes 0
1239712416
set maxrefs 20
@@ -12497,7 +12516,7 @@ config_check_tmp_exists 50
1249712516

1249812517
set config_variables {
1249912518
mainfont textfont uifont tabstop findmergefiles maxgraphpct maxwidth
12500-
cmitmode wrapcomment autoselect autosellen showneartags maxrefs visiblerefs
12519+
cmitmode wrapcomment wrapdefault autoselect autosellen showneartags maxrefs visiblerefs
1250112520
hideremotes showlocalchanges datetimeformat limitdiffs uicolor want_ttk
1250212521
bgcolor fgcolor uifgcolor uifgdisabledcolor colors diffcolors mergecolors
1250312522
markbgcolor diffcontext selectbgcolor foundbgcolor currentsearchhitbgcolor

0 commit comments

Comments
 (0)