@@ -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+
19721976proc setoptions {} {
19731977 global use_ttk
19741978
@@ -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
@@ -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,7 +11584,8 @@ proc create_prefs_page {w} {
1157611584
1157711585proc prefspage_general {notebook} {
1157811586 global NS maxwidth maxgraphpct showneartags showlocalchanges
11579- global tabstop wrapcomment wrapdefault 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]
@@ -11594,14 +11603,22 @@ 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
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+
1160511622 ${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" ]
@@ -12419,6 +12436,7 @@ set maxlinelen 200
1241912436set showlocalchanges 1
1242012437set limitdiffs 1
1242112438set datetimeformat " %Y-%m-%d %H:%M:%S"
12439+ set autocopy 0
1242212440set autoselect 1
1242312441set autosellen 40
1242412442set perfile_attrs 0
@@ -12516,7 +12534,8 @@ config_check_tmp_exists 50
1251612534
1251712535set config_variables {
1251812536 mainfont textfont uifont tabstop findmergefiles maxgraphpct maxwidth
12519- cmitmode wrapcomment wrapdefault autoselect autosellen showneartags maxrefs visiblerefs
12537+ cmitmode wrapcomment wrapdefault autocopy autoselect autosellen
12538+ showneartags maxrefs visiblerefs
1252012539 hideremotes showlocalchanges datetimeformat limitdiffs uicolor want_ttk
1252112540 bgcolor fgcolor uifgcolor uifgdisabledcolor colors diffcolors mergecolors
1252212541 markbgcolor diffcontext selectbgcolor foundbgcolor currentsearchhitbgcolor
0 commit comments