Skip to content

Commit d77c3e3

Browse files
committed
gitk: support auto-copy comit ID to primary clipboard
Auto-select ("Copy commit ID to X11 selection") is useful when a selection cliboard exists, but otherwise generally meaningless, for instance on Windows. Add a similar pref and behavior which copies the commit ID to the primary clipboard - for platforms without a selection clipboard, but which can also be useful additionally on platforms with selection. Note that while autoselect is enabled by default, autocopy isn't. That's because the selection clipboard is typically dispensable, while the primary clipboard can be considered a more precious resource, which we don't want to (clear and) overwrite by default. Signed-off-by: Avi Halachmi (:avih) <[email protected]>
1 parent 92d911a commit d77c3e3

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

gitk

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7344,7 +7344,7 @@ proc selectline {l isnew {desired_loc {}} {switch_to_patch 0}} {
73447344
global mergemax numcommits pending_select
73457345
global cmitmode showneartags allcommits
73467346
global targetrow targetid lastscrollrows
7347-
global autoselect autosellen jump_to_here
7347+
global autocopy autoselect autosellen jump_to_here
73487348
global vinlinediff
73497349

73507350
unset -nocomplain pending_select
@@ -7413,6 +7413,10 @@ proc selectline {l isnew {desired_loc {}} {switch_to_patch 0}} {
74137413
if {$autoselect} {
74147414
$sha1entry selection range 0 $autosellen
74157415
}
7416+
if {$autocopy} {
7417+
clipboard clear
7418+
clipboard append [string range $id 0 [expr $autosellen - 1]]
7419+
}
74167420
rhighlight_sel $id
74177421

74187422
$ctext conf -state normal
@@ -11576,7 +11580,7 @@ proc create_prefs_page {w} {
1157611580

1157711581
proc prefspage_general {notebook} {
1157811582
global NS maxwidth maxgraphpct showneartags showlocalchanges
11579-
global tabstop limitdiffs autoselect autosellen extdifftool perfile_attrs
11583+
global tabstop limitdiffs autocopy autoselect autosellen extdifftool perfile_attrs
1158011584
global hideremotes want_ttk have_ttk maxrefs web_browser
1158111585

1158211586
set page [create_prefs_page $notebook.general]
@@ -11598,6 +11602,9 @@ proc prefspage_general {notebook} {
1159811602
-variable hideremotes
1159911603
grid x $page.hideremotes -sticky w
1160011604

11605+
${NS}::checkbutton $page.autocopy -text [mc "Copy commit ID to clipboard"] \
11606+
-variable autocopy
11607+
grid x $page.autocopy -sticky w
1160111608
${NS}::checkbutton $page.autoselect -text [mc "Copy commit ID to X11 selection"] \
1160211609
-variable autoselect
1160311610
grid x $page.autoselect -sticky w
@@ -12403,6 +12410,7 @@ set maxlinelen 200
1240312410
set showlocalchanges 1
1240412411
set limitdiffs 1
1240512412
set datetimeformat "%Y-%m-%d %H:%M:%S"
12413+
set autocopy 0
1240612414
set autoselect 1
1240712415
set autosellen 40
1240812416
set perfile_attrs 0
@@ -12500,7 +12508,7 @@ config_check_tmp_exists 50
1250012508

1250112509
set config_variables {
1250212510
mainfont textfont uifont tabstop findmergefiles maxgraphpct maxwidth
12503-
cmitmode wrapcomment autoselect autosellen showneartags maxrefs visiblerefs
12511+
cmitmode wrapcomment autocopy autoselect autosellen showneartags maxrefs visiblerefs
1250412512
hideremotes showlocalchanges datetimeformat limitdiffs uicolor want_ttk
1250512513
bgcolor fgcolor uifgcolor uifgdisabledcolor colors diffcolors mergecolors
1250612514
markbgcolor diffcontext selectbgcolor foundbgcolor currentsearchhitbgcolor

0 commit comments

Comments
 (0)