aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvi Halachmi (:avih) <avihpit@yahoo.com>2024-12-11 11:22:03 +0200
committerAvi Halachmi (:avih) <avihpit@yahoo.com>2024-12-13 01:37:08 +0200
commitd77c3e35bbca78a0cee6f0eacecccd9aac957c8b (patch)
tree11d8897d0890a32e998df0d0e06ff1ead6b252e7
parentgitk: prefs dialog: refine Auto-select UI (diff)
downloadgit-d77c3e35bbca78a0cee6f0eacecccd9aac957c8b.tar.gz
git-d77c3e35bbca78a0cee6f0eacecccd9aac957c8b.zip
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) <avihpit@yahoo.com>
-rwxr-xr-xgitk14
1 files changed, 11 insertions, 3 deletions
diff --git a/gitk b/gitk
index 322236d361..38baf20b95 100755
--- a/gitk
+++ b/gitk
@@ -7344,7 +7344,7 @@ proc selectline {l isnew {desired_loc {}} {switch_to_patch 0}} {
global mergemax numcommits pending_select
global cmitmode showneartags allcommits
global targetrow targetid lastscrollrows
- global autoselect autosellen jump_to_here
+ global autocopy autoselect autosellen jump_to_here
global vinlinediff
unset -nocomplain pending_select
@@ -7413,6 +7413,10 @@ proc selectline {l isnew {desired_loc {}} {switch_to_patch 0}} {
if {$autoselect} {
$sha1entry selection range 0 $autosellen
}
+ if {$autocopy} {
+ clipboard clear
+ clipboard append [string range $id 0 [expr $autosellen - 1]]
+ }
rhighlight_sel $id
$ctext conf -state normal
@@ -11576,7 +11580,7 @@ proc create_prefs_page {w} {
proc prefspage_general {notebook} {
global NS maxwidth maxgraphpct showneartags showlocalchanges
- global tabstop limitdiffs autoselect autosellen extdifftool perfile_attrs
+ global tabstop limitdiffs autocopy autoselect autosellen extdifftool perfile_attrs
global hideremotes want_ttk have_ttk maxrefs web_browser
set page [create_prefs_page $notebook.general]
@@ -11598,6 +11602,9 @@ proc prefspage_general {notebook} {
-variable hideremotes
grid x $page.hideremotes -sticky w
+ ${NS}::checkbutton $page.autocopy -text [mc "Copy commit ID to clipboard"] \
+ -variable autocopy
+ grid x $page.autocopy -sticky w
${NS}::checkbutton $page.autoselect -text [mc "Copy commit ID to X11 selection"] \
-variable autoselect
grid x $page.autoselect -sticky w
@@ -12403,6 +12410,7 @@ set maxlinelen 200
set showlocalchanges 1
set limitdiffs 1
set datetimeformat "%Y-%m-%d %H:%M:%S"
+set autocopy 0
set autoselect 1
set autosellen 40
set perfile_attrs 0
@@ -12500,7 +12508,7 @@ config_check_tmp_exists 50
set config_variables {
mainfont textfont uifont tabstop findmergefiles maxgraphpct maxwidth
- cmitmode wrapcomment autoselect autosellen showneartags maxrefs visiblerefs
+ cmitmode wrapcomment autocopy autoselect autosellen showneartags maxrefs visiblerefs
hideremotes showlocalchanges datetimeformat limitdiffs uicolor want_ttk
bgcolor fgcolor uifgcolor uifgdisabledcolor colors diffcolors mergecolors
markbgcolor diffcontext selectbgcolor foundbgcolor currentsearchhitbgcolor