@matheusbsbs / matheus-bagliano / commits / ebcaadabcb
Fork 0

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>

Shawn O. Pearce committed May 5, 2007 at 02:28 UTC ebcaadabcb90eaf35a3bd69a50cccce4be4dcc2c
1 file changed +14 -6
lib/merge.tcl
+14 -6
@@ -160,6 +160,7 @@ You can attempt this merge again by merging only one branch at a time." $w
160
161 proc dialog {} {
162 global current_branch
163 + global M1B
164
165 if {![_can_merge]} return
166
@@ -197,20 +198,20 @@ proc dialog {} {
198 toplevel $w
199 wm geometry $w "+[winfo rootx .]+[winfo rooty .]"
200
201 + set _visualize [namespace code [list _visualize $w $to_show]]
202 + set _start [namespace code [list _start $w $to_show]]
203 +
204 label $w.header \
205 -text "Merge Into $current_branch" \
206 -font font_uibold
207 pack $w.header -side top -fill x
208
209 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
211 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
213 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]
215 pack $w.buttons.cancel -side right -padx 5
216 pack $w.buttons -side bottom -fill x -pady 10 -padx 10
217
@@ -237,6 +238,13 @@ proc dialog {} {
238 $subj([lindex $ref 0])]
239 }
240
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
248 bind $w <Visibility> "grab $w; focus $w.source.l"
249 bind $w <Key-Escape> "unlock_index;destroy $w"
250 bind $w <Destroy> unlock_index