git-gui: Allow vi keys to scroll the diff/blame regions

Users who are used to vi and recent versions of gitk may want
to scroll the diff region using vi style keybindings.  Since
these aren't bound to anything else and that widget does not
accept focus for data input, we can easily support that too.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
maint
Shawn O. Pearce 2007-05-01 15:51:09 -04:00
parent a35d65d9c8
commit 60aa065f69
2 changed files with 23 additions and 0 deletions

View File

@ -2038,6 +2038,12 @@ bind $ui_diff <Key-Up> {catch {%W yview scroll -1 units};break}
bind $ui_diff <Key-Down> {catch {%W yview scroll 1 units};break}
bind $ui_diff <Key-Left> {catch {%W xview scroll -1 units};break}
bind $ui_diff <Key-Right> {catch {%W xview scroll 1 units};break}
bind $ui_diff <Key-k> {catch {%W yview scroll -1 units};break}
bind $ui_diff <Key-j> {catch {%W yview scroll 1 units};break}
bind $ui_diff <Key-h> {catch {%W xview scroll -1 units};break}
bind $ui_diff <Key-l> {catch {%W xview scroll 1 units};break}
bind $ui_diff <Control-Key-b> {catch {%W yview scroll -1 pages};break}
bind $ui_diff <Control-Key-f> {catch {%W yview scroll 1 pages};break}
bind $ui_diff <Button-1> {focus %W}

if {[is_enabled branch]} {

View File

@ -125,6 +125,23 @@ proc show_blame {commit path} {
"
}

foreach i [list \
$w.out.loaded_t \
$w.out.linenumber_t \
$w.out.file_t \
$w.cm.t] {
bind $i <Key-Up> {catch {%W yview scroll -1 units};break}
bind $i <Key-Down> {catch {%W yview scroll 1 units};break}
bind $i <Key-Left> {catch {%W xview scroll -1 units};break}
bind $i <Key-Right> {catch {%W xview scroll 1 units};break}
bind $i <Key-k> {catch {%W yview scroll -1 units};break}
bind $i <Key-j> {catch {%W yview scroll 1 units};break}
bind $i <Key-h> {catch {%W xview scroll -1 units};break}
bind $i <Key-l> {catch {%W xview scroll 1 units};break}
bind $i <Control-Key-b> {catch {%W yview scroll -1 pages};break}
bind $i <Control-Key-f> {catch {%W yview scroll 1 pages};break}
}

bind $w.cm.t <Button-1> "focus $w.cm.t"
bind $tl <Visibility> "focus $tl"
bind $tl <Destroy> "