Skip to content

Commit ebcaada

Browse files
committed
git-gui: Use vi-like keys in merge dialog
Since we support vi-like keys for scrolling in other UI contexts we can easily do so here too. Tk's handy little `event generate' makes this a lot easier than I thought it would be. We may want to go back and fix some of the other vi-like bindings to redirect to the arrow and pageup/pagedown keys, rather than running the view changes directly. I've bound 'v' to visualize, as this is a somewhat common thing to want to do in the merge dialog. Control (or Command) Return is also bound to start the merge, much as it is bound in the main window to activate the commit. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
1 parent 1fc4ba8 commit ebcaada

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

lib/merge.tcl

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ You can attempt this merge again by merging only one branch at a time." $w
160160

161161
proc dialog {} {
162162
global current_branch
163+
global M1B
163164

164165
if {![_can_merge]} return
165166

@@ -197,20 +198,20 @@ proc dialog {} {
197198
toplevel $w
198199
wm geometry $w "+[winfo rootx .]+[winfo rooty .]"
199200

201+
set _visualize [namespace code [list _visualize $w $to_show]]
202+
set _start [namespace code [list _start $w $to_show]]
203+
200204
label $w.header \
201205
-text "Merge Into $current_branch" \
202206
-font font_uibold
203207
pack $w.header -side top -fill x
204208

205209
frame $w.buttons
206-
button $w.buttons.visualize -text Visualize \
207-
-command [namespace code [list _visualize $w $to_show]]
210+
button $w.buttons.visualize -text Visualize -command $_visualize
208211
pack $w.buttons.visualize -side left
209-
button $w.buttons.create -text Merge \
210-
-command [namespace code [list _start $w $to_show]]
212+
button $w.buttons.create -text Merge -command $_start
211213
pack $w.buttons.create -side right
212-
button $w.buttons.cancel -text {Cancel} \
213-
-command [list destroy $w]
214+
button $w.buttons.cancel -text {Cancel} -command [list destroy $w]
214215
pack $w.buttons.cancel -side right -padx 5
215216
pack $w.buttons -side bottom -fill x -pady 10 -padx 10
216217

@@ -237,6 +238,13 @@ proc dialog {} {
237238
$subj([lindex $ref 0])]
238239
}
239240

241+
bind $w.source.l <Key-k> [list event generate %W <Key-Up>]
242+
bind $w.source.l <Key-j> [list event generate %W <Key-Down>]
243+
bind $w.source.l <Key-h> [list event generate %W <Key-Left>]
244+
bind $w.source.l <Key-l> [list event generate %W <Key-Right>]
245+
bind $w.source.l <Key-v> $_visualize
246+
247+
bind $w <$M1B-Key-Return> $_start
240248
bind $w <Visibility> "grab $w; focus $w.source.l"
241249
bind $w <Key-Escape> "unlock_index;destroy $w"
242250
bind $w <Destroy> unlock_index

0 commit comments

Comments
 (0)