Skip to content

Commit d882f38

Browse files
committed
* 'master' of https://github.com/j6t/gitk: gitk: offer "Copy commit ID to X11 selection" only on X11 gitk: support auto-copy comit ID to primary clipboard gitk: prefs dialog: refine Auto-select UI gitk: UI text: change "SHA1 ID" to "Commit ID" gitk: add text wrapping preferences gitk: make headings of preferences bold gitk: check main window visibility before waiting for it to show gitk: sv.po: Update Swedish translation (323t)
2 parents 063bceb + 661734e commit d882f38

File tree

2 files changed

+439
-381
lines changed

2 files changed

+439
-381
lines changed

gitk-git/gitk

Lines changed: 62 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1969,6 +1969,10 @@ proc confirm_popup {msg {owner .}} {
19691969
return $confirm_ok
19701970
}
19711971

1972+
proc haveselectionclipboard {} {
1973+
return [expr {[tk windowingsystem] eq "x11"}]
1974+
}
1975+
19721976
proc setoptions {} {
19731977
global use_ttk
19741978

@@ -2089,7 +2093,7 @@ proc makewindow {} {
20892093
global diffcontextstring diffcontext
20902094
global ignorespace
20912095
global maincursor textcursor curtextcursor
2092-
global rowctxmenu fakerowmenu mergemax wrapcomment
2096+
global rowctxmenu fakerowmenu mergemax wrapcomment wrapdefault
20932097
global highlight_files gdttype
20942098
global searchstring sstring
20952099
global bgcolor fgcolor bglist fglist diffcolors diffbgcolors selectbgcolor
@@ -2223,7 +2227,7 @@ proc makewindow {} {
22232227
set sha1entry .tf.bar.sha1
22242228
set entries $sha1entry
22252229
set sha1but .tf.bar.sha1label
2226-
button $sha1but -text "[mc "SHA1 ID:"] " -state disabled -relief flat \
2230+
button $sha1but -text "[mc "Commit ID:"] " -state disabled -relief flat \
22272231
-command gotocommit -width 8
22282232
$sha1but conf -disabledforeground [$sha1but cget -foreground]
22292233
pack .tf.bar.sha1label -side left
@@ -2431,7 +2435,7 @@ proc makewindow {} {
24312435
set ctext .bleft.bottom.ctext
24322436
text $ctext -background $bgcolor -foreground $fgcolor \
24332437
-state disabled -undo 0 -font textfont \
2434-
-yscrollcommand scrolltext -wrap none \
2438+
-yscrollcommand scrolltext -wrap $wrapdefault \
24352439
-xscrollcommand ".bleft.bottom.sbhorizontal set"
24362440
if {$have_tk85} {
24372441
$ctext conf -tabstyle wordprocessor
@@ -7344,7 +7348,7 @@ proc selectline {l isnew {desired_loc {}} {switch_to_patch 0}} {
73447348
global mergemax numcommits pending_select
73457349
global cmitmode showneartags allcommits
73467350
global targetrow targetid lastscrollrows
7347-
global autoselect autosellen jump_to_here
7351+
global autocopy autoselect autosellen jump_to_here
73487352
global vinlinediff
73497353

73507354
unset -nocomplain pending_select
@@ -7410,9 +7414,13 @@ proc selectline {l isnew {desired_loc {}} {switch_to_patch 0}} {
74107414

74117415
$sha1entry delete 0 end
74127416
$sha1entry insert 0 $id
7413-
if {$autoselect} {
7417+
if {$autoselect && [haveselectionclipboard]} {
74147418
$sha1entry selection range 0 $autosellen
74157419
}
7420+
if {$autocopy} {
7421+
clipboard clear
7422+
clipboard append [string range $id 0 [expr $autosellen - 1]]
7423+
}
74167424
rhighlight_sel $id
74177425

74187426
$ctext conf -state normal
@@ -8756,7 +8764,7 @@ proc sha1change {n1 n2 op} {
87568764
if {$state == "normal"} {
87578765
$sha1but conf -state normal -relief raised -text "[mc "Goto:"] "
87588766
} else {
8759-
$sha1but conf -state disabled -relief flat -text "[mc "SHA1 ID:"] "
8767+
$sha1but conf -state disabled -relief flat -text "[mc "Commit ID:"] "
87608768
}
87618769
}
87628770

@@ -8775,7 +8783,7 @@ proc gotocommit {} {
87758783
set matches [longid $id]
87768784
if {$matches ne {}} {
87778785
if {[llength $matches] > 1} {
8778-
error_popup [mc "Short SHA1 id %s is ambiguous" $id]
8786+
error_popup [mc "Short commit ID %s is ambiguous" $id]
87798787
return
87808788
}
87818789
set id [lindex $matches 0]
@@ -8792,7 +8800,7 @@ proc gotocommit {} {
87928800
return
87938801
}
87948802
if {[regexp {^[0-9a-fA-F]{4,}$} $sha1string]} {
8795-
set msg [mc "SHA1 id %s is not known" $sha1string]
8803+
set msg [mc "Commit ID %s is not known" $sha1string]
87968804
} else {
87978805
set msg [mc "Revision %s is not in the current view" $sha1string]
87988806
}
@@ -11576,12 +11584,13 @@ proc create_prefs_page {w} {
1157611584

1157711585
proc prefspage_general {notebook} {
1157811586
global NS maxwidth maxgraphpct showneartags showlocalchanges
11579-
global tabstop limitdiffs autoselect autosellen extdifftool perfile_attrs
11587+
global tabstop wrapcomment wrapdefault limitdiffs
11588+
global autocopy autoselect autosellen extdifftool perfile_attrs
1158011589
global hideremotes want_ttk have_ttk maxrefs web_browser
1158111590

1158211591
set page [create_prefs_page $notebook.general]
1158311592

11584-
${NS}::label $page.ldisp -text [mc "Commit list display options"]
11593+
${NS}::label $page.ldisp -text [mc "Commit list display options"] -font mainfontbold
1158511594
grid $page.ldisp - -sticky w -pady 10
1158611595
${NS}::label $page.spacer -text " "
1158711596
${NS}::label $page.maxwidthl -text [mc "Maximum graph width (lines)"]
@@ -11594,19 +11603,38 @@ proc prefspage_general {notebook} {
1159411603
${NS}::checkbutton $page.showlocal -text [mc "Show local changes"] \
1159511604
-variable showlocalchanges
1159611605
grid x $page.showlocal -sticky w
11597-
${NS}::checkbutton $page.autoselect -text [mc "Auto-select SHA1 (length)"] \
11598-
-variable autoselect
11599-
spinbox $page.autosellen -from 1 -to 40 -width 4 -textvariable autosellen
11600-
grid x $page.autoselect $page.autosellen -sticky w
1160111606
${NS}::checkbutton $page.hideremotes -text [mc "Hide remote refs"] \
1160211607
-variable hideremotes
1160311608
grid x $page.hideremotes -sticky w
1160411609

11605-
${NS}::label $page.ddisp -text [mc "Diff display options"]
11610+
${NS}::checkbutton $page.autocopy -text [mc "Copy commit ID to clipboard"] \
11611+
-variable autocopy
11612+
grid x $page.autocopy -sticky w
11613+
if {[haveselectionclipboard]} {
11614+
${NS}::checkbutton $page.autoselect -text [mc "Copy commit ID to X11 selection"] \
11615+
-variable autoselect
11616+
grid x $page.autoselect -sticky w
11617+
}
11618+
spinbox $page.autosellen -from 1 -to 40 -width 4 -textvariable autosellen
11619+
${NS}::label $page.autosellenl -text [mc "Length of commit ID to copy"]
11620+
grid x $page.autosellenl $page.autosellen -sticky w
11621+
11622+
${NS}::label $page.ddisp -text [mc "Diff display options"] -font mainfontbold
1160611623
grid $page.ddisp - -sticky w -pady 10
1160711624
${NS}::label $page.tabstopl -text [mc "Tab spacing"]
1160811625
spinbox $page.tabstop -from 1 -to 20 -width 4 -textvariable tabstop
1160911626
grid x $page.tabstopl $page.tabstop -sticky w
11627+
11628+
${NS}::label $page.wrapcommentl -text [mc "Wrap comment text"]
11629+
${NS}::combobox $page.wrapcomment -values {none char word} -state readonly \
11630+
-textvariable wrapcomment
11631+
grid x $page.wrapcommentl $page.wrapcomment -sticky w
11632+
11633+
${NS}::label $page.wrapdefaultl -text [mc "Wrap other text"]
11634+
${NS}::combobox $page.wrapdefault -values {none char word} -state readonly \
11635+
-textvariable wrapdefault
11636+
grid x $page.wrapdefaultl $page.wrapdefault -sticky w
11637+
1161011638
${NS}::checkbutton $page.ntag -text [mc "Display nearby tags/heads"] \
1161111639
-variable showneartags
1161211640
grid x $page.ntag -sticky w
@@ -11635,7 +11663,7 @@ proc prefspage_general {notebook} {
1163511663
pack configure $page.webbrowserf.l -padx 10
1163611664
grid x $page.webbrowserf $page.webbrowser -sticky ew
1163711665

11638-
${NS}::label $page.lgen -text [mc "General options"]
11666+
${NS}::label $page.lgen -text [mc "General options"] -font mainfontbold
1163911667
grid $page.lgen - -sticky w -pady 10
1164011668
${NS}::checkbutton $page.want_ttk -variable want_ttk \
1164111669
-text [mc "Use themed widgets"]
@@ -11654,7 +11682,7 @@ proc prefspage_colors {notebook} {
1165411682

1165511683
set page [create_prefs_page $notebook.colors]
1165611684

11657-
${NS}::label $page.cdisp -text [mc "Colors: press to choose"]
11685+
${NS}::label $page.cdisp -text [mc "Colors: press to choose"] -font mainfontbold
1165811686
grid $page.cdisp - -sticky w -pady 10
1165911687
label $page.ui -padx 40 -relief sunk -background $uicolor
1166011688
${NS}::button $page.uibut -text [mc "Interface"] \
@@ -11712,7 +11740,7 @@ proc prefspage_colors {notebook} {
1171211740
proc prefspage_fonts {notebook} {
1171311741
global NS
1171411742
set page [create_prefs_page $notebook.fonts]
11715-
${NS}::label $page.cfont -text [mc "Fonts: press to choose"]
11743+
${NS}::label $page.cfont -text [mc "Fonts: press to choose"] -font mainfontbold
1171611744
grid $page.cfont - -sticky w -pady 10
1171711745
mkfontdisp mainfont $page [mc "Main font"]
1171811746
mkfontdisp textfont $page [mc "Diff display font"]
@@ -11725,7 +11753,7 @@ proc doprefs {} {
1172511753
global oldprefs prefstop showneartags showlocalchanges
1172611754
global uicolor bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor
1172711755
global tabstop limitdiffs autoselect autosellen extdifftool perfile_attrs
11728-
global hideremotes want_ttk have_ttk
11756+
global hideremotes want_ttk have_ttk wrapcomment wrapdefault
1172911757

1173011758
set top .gitkprefs
1173111759
set prefstop $top
@@ -11734,7 +11762,7 @@ proc doprefs {} {
1173411762
return
1173511763
}
1173611764
foreach v {maxwidth maxgraphpct showneartags showlocalchanges \
11737-
limitdiffs tabstop perfile_attrs hideremotes want_ttk} {
11765+
limitdiffs tabstop perfile_attrs hideremotes want_ttk wrapcomment wrapdefault} {
1173811766
set oldprefs($v) [set $v]
1173911767
}
1174011768
ttk_toplevel $top
@@ -11860,7 +11888,7 @@ proc prefscan {} {
1186011888
global oldprefs prefstop
1186111889

1186211890
foreach v {maxwidth maxgraphpct showneartags showlocalchanges \
11863-
limitdiffs tabstop perfile_attrs hideremotes want_ttk} {
11891+
limitdiffs tabstop perfile_attrs hideremotes want_ttk wrapcomment wrapdefault} {
1186411892
global $v
1186511893
set $v $oldprefs($v)
1186611894
}
@@ -11874,7 +11902,8 @@ proc prefsok {} {
1187411902
global oldprefs prefstop showneartags showlocalchanges
1187511903
global fontpref mainfont textfont uifont
1187611904
global limitdiffs treediffs perfile_attrs
11877-
global hideremotes
11905+
global hideremotes wrapcomment wrapdefault
11906+
global ctext
1187811907

1187911908
catch {destroy $prefstop}
1188011909
unset prefstop
@@ -11923,6 +11952,12 @@ proc prefsok {} {
1192311952
if {$hideremotes != $oldprefs(hideremotes)} {
1192411953
rereadrefs
1192511954
}
11955+
if {$wrapcomment != $oldprefs(wrapcomment)} {
11956+
$ctext tag conf comment -wrap $wrapcomment
11957+
}
11958+
if {$wrapdefault != $oldprefs(wrapdefault)} {
11959+
$ctext configure -wrap $wrapdefault
11960+
}
1192611961
}
1192711962

1192811963
proc formatdate {d} {
@@ -12392,6 +12427,7 @@ set downarrowlen 5
1239212427
set mingaplen 100
1239312428
set cmitmode "patch"
1239412429
set wrapcomment "none"
12430+
set wrapdefault "none"
1239512431
set showneartags 1
1239612432
set hideremotes 0
1239712433
set maxrefs 20
@@ -12400,6 +12436,7 @@ set maxlinelen 200
1240012436
set showlocalchanges 1
1240112437
set limitdiffs 1
1240212438
set datetimeformat "%Y-%m-%d %H:%M:%S"
12439+
set autocopy 0
1240312440
set autoselect 1
1240412441
set autosellen 40
1240512442
set perfile_attrs 0
@@ -12497,7 +12534,8 @@ config_check_tmp_exists 50
1249712534

1249812535
set config_variables {
1249912536
mainfont textfont uifont tabstop findmergefiles maxgraphpct maxwidth
12500-
cmitmode wrapcomment autoselect autosellen showneartags maxrefs visiblerefs
12537+
cmitmode wrapcomment wrapdefault autocopy autoselect autosellen
12538+
showneartags maxrefs visiblerefs
1250112539
hideremotes showlocalchanges datetimeformat limitdiffs uicolor want_ttk
1250212540
bgcolor fgcolor uifgcolor uifgdisabledcolor colors diffcolors mergecolors
1250312541
markbgcolor diffcontext selectbgcolor foundbgcolor currentsearchhitbgcolor
@@ -12687,7 +12725,7 @@ catch {
1268712725
wm iconphoto . -default gitlogo gitlogo32
1268812726
}
1268912727
# wait for the window to become visible
12690-
tkwait visibility .
12728+
if {![winfo viewable .]} {tkwait visibility .}
1269112729
set_window_title
1269212730
update
1269312731
readrefs

0 commit comments

Comments
 (0)