git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[Gitk PATCH 1/6] gitk: Add procedure to create accelerated menus

From
Robin Rosenberg <robin.rosenberg@dewire.com>
Date
Oct 7, 2008, 21:56 UTC
Message-ID
<1223416609-18864-2-git-send-email-robin.rosenberg@dewire.com>
In-Reply-To
<1223416609-18864-1-git-send-email-robin.rosenberg@dewire.com>

These are the undescores menu items that can be selected with the Alt+letter, key combination on Windows and Linux or Command+letter on Macs.

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
 gitk |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/gitk b/gitk
index 2eaa2ae..050019c 100755
--- a/gitk
+++ b/gitk
@@ -1750,6 +1750,33 @@ proc setoptions {} {
     option add *Entry.font uifont startupFile
 }
 
+# Menu command wrapper. Intercepts any -label arguments, 
+# removes the & and adds the -underline argument necessary
+# to implement the menu accelerator.
+proc mcw {menubar args} {
+    set ai [lsearch $args "-label"]
+    if { $ai > 0 } {
+	set label [lindex $args [expr {$ai + 1}]]
+	foreach {l u} [::tk::UnderlineAmpersand $label] {
+	    lset args [expr {$ai + 1}] $l
+	}
+	lappend args -underline
+	lappend args $u
+    }
+    set cmd [ list $menubar ]
+    foreach a $args {
+	lappend cmd $a
+    }
+    eval $cmd
+}
+
+# Wrapper for mc to remove ampersands used for accelerators.
+proc mca {label} {
+    set tl8 [mc $label]
+    foreach {l u} [::tk::UnderlineAmpersand $tl8] break
+    return $l
+}
+
 proc makewindow {} {
     global canv canv2 canv3 linespc charspc ctext cflist cscroll
     global tabstop
-- 
1.6.0.2.308.gef4a
Previous: Robin RosenbergNext: Robin Rosenberg
Message 2 of 7 in “Menu accelerators for Gitk”
  1. 0/6 Menu accelerators for GitkRobin Rosenberg, Oct 7, 2008
  2. 1/6 gitk: Add procedure to create accelerated menusRobin Rosenberg, Oct 7, 2008
  3. 2/6 gitk: Change menus to use accelerated designRobin Rosenberg, Oct 7, 2008
  4. 3/6 gitk: regenerated po filesRobin Rosenberg, Oct 7, 2008
  5. 4/6 gitk: Add accelerator hintsRobin Rosenberg, Oct 7, 2008
  6. 5/6 gitk: regenerated po filesRobin Rosenberg, Oct 7, 2008
  7. 6/6 gitk: Add menu accelerators for Swedish translationRobin Rosenberg, Oct 7, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.