Testing tangled. Original: https://github.com/j6t/gitk

Merge branch 'ah/commit-id-to-clipboard'

* ah/commit-id-to-clipboard:
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"

Signed-off-by: Johannes Sixt <j6t@kdbg.org>

+31 -12
+31 -12
gitk
··· 1969 1969 return $confirm_ok 1970 1970 } 1971 1971 1972 + proc haveselectionclipboard {} { 1973 + return [expr {[tk windowingsystem] eq "x11"}] 1974 + } 1975 + 1972 1976 proc setoptions {} { 1973 1977 global use_ttk 1974 1978 ··· 2223 2227 set sha1entry .tf.bar.sha1 2224 2228 set entries $sha1entry 2225 2229 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 \ 2227 2231 -command gotocommit -width 8 2228 2232 $sha1but conf -disabledforeground [$sha1but cget -foreground] 2229 2233 pack .tf.bar.sha1label -side left ··· 7344 7348 global mergemax numcommits pending_select 7345 7349 global cmitmode showneartags allcommits 7346 7350 global targetrow targetid lastscrollrows 7347 - global autoselect autosellen jump_to_here 7351 + global autocopy autoselect autosellen jump_to_here 7348 7352 global vinlinediff 7349 7353 7350 7354 unset -nocomplain pending_select ··· 7410 7414 7411 7415 $sha1entry delete 0 end 7412 7416 $sha1entry insert 0 $id 7413 - if {$autoselect} { 7417 + if {$autoselect && [haveselectionclipboard]} { 7414 7418 $sha1entry selection range 0 $autosellen 7419 + } 7420 + if {$autocopy} { 7421 + clipboard clear 7422 + clipboard append [string range $id 0 [expr $autosellen - 1]] 7415 7423 } 7416 7424 rhighlight_sel $id 7417 7425 ··· 8756 8764 if {$state == "normal"} { 8757 8765 $sha1but conf -state normal -relief raised -text "[mc "Goto:"] " 8758 8766 } else { 8759 - $sha1but conf -state disabled -relief flat -text "[mc "SHA1 ID:"] " 8767 + $sha1but conf -state disabled -relief flat -text "[mc "Commit ID:"] " 8760 8768 } 8761 8769 } 8762 8770 ··· 8775 8783 set matches [longid $id] 8776 8784 if {$matches ne {}} { 8777 8785 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] 8779 8787 return 8780 8788 } 8781 8789 set id [lindex $matches 0] ··· 8792 8800 return 8793 8801 } 8794 8802 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] 8796 8804 } else { 8797 8805 set msg [mc "Revision %s is not in the current view" $sha1string] 8798 8806 } ··· 11576 11584 11577 11585 proc prefspage_general {notebook} { 11578 11586 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 11580 11589 global hideremotes want_ttk have_ttk maxrefs web_browser 11581 11590 11582 11591 set page [create_prefs_page $notebook.general] ··· 11594 11603 ${NS}::checkbutton $page.showlocal -text [mc "Show local changes"] \ 11595 11604 -variable showlocalchanges 11596 11605 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 11601 11606 ${NS}::checkbutton $page.hideremotes -text [mc "Hide remote refs"] \ 11602 11607 -variable hideremotes 11603 11608 grid x $page.hideremotes -sticky w 11609 + 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 11604 11621 11605 11622 ${NS}::label $page.ddisp -text [mc "Diff display options"] -font mainfontbold 11606 11623 grid $page.ddisp - -sticky w -pady 10 ··· 12419 12436 set showlocalchanges 1 12420 12437 set limitdiffs 1 12421 12438 set datetimeformat "%Y-%m-%d %H:%M:%S" 12439 + set autocopy 0 12422 12440 set autoselect 1 12423 12441 set autosellen 40 12424 12442 set perfile_attrs 0 ··· 12516 12534 12517 12535 set config_variables { 12518 12536 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 12520 12539 hideremotes showlocalchanges datetimeformat limitdiffs uicolor want_ttk 12521 12540 bgcolor fgcolor uifgcolor uifgdisabledcolor colors diffcolors mergecolors 12522 12541 markbgcolor diffcontext selectbgcolor foundbgcolor currentsearchhitbgcolor